aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-09-13 11:17:45 +0100
committerGitHub <noreply@github.com>2023-09-13 11:17:45 +0100
commit054e08b328de81529b88ce1dde4f16aad7f2501f (patch)
tree1c0ef246d8dd5a2f52a7c9cbea99e0ef89199032
parent7ff64cd1359375974155e560c7d3200f03a4e500 (diff)
parent7846b2f3203c1fefce8560fb89ef198e2323d939 (diff)
downloadrspamd-054e08b328de81529b88ce1dde4f16aad7f2501f.tar.gz
rspamd-054e08b328de81529b88ce1dde4f16aad7f2501f.zip
Merge pull request #4595 from lbahtarliev/master
[Feature] Add ICAP Content-Type and Filename from TODO List
-rw-r--r--lualib/lua_scanners/icap.lua10
-rw-r--r--src/plugins/lua/external_services.lua4
2 files changed, 10 insertions, 4 deletions
diff --git a/lualib/lua_scanners/icap.lua b/lualib/lua_scanners/icap.lua
index 16459b06e..59d2caa4a 100644
--- a/lualib/lua_scanners/icap.lua
+++ b/lualib/lua_scanners/icap.lua
@@ -240,10 +240,16 @@ local function icap_check(task, content, digest, rule, maybe_part)
local function get_req_headers()
+ local in_client_ip = task:get_from_ip()
local req_hlen = 2
- table.insert(req_headers, string.format('GET %s HTTP/1.0\r\n', rule.req_fake_url))
table.insert(req_headers, string.format('Date: %s\r\n', rspamd_util.time_to_string(rspamd_util.get_time())))
- --table.insert(http_headers, string.format('Content-Type: %s\r\n', 'text/html'))
+ if maybe_part then
+ table.insert(req_headers, string.format('GET http://%s/%s HTTP/1.0\r\n', in_client_ip, maybe_part:get_filename()))
+ table.insert(http_headers, string.format('Content-Type: %s/%s\r\n', maybe_part:get_detected_type()))
+ else
+ table.insert(req_headers, string.format('GET %s HTTP/1.0\r\n', rule.req_fake_url))
+ table.insert(http_headers, string.format('Content-Type: application/octet-stream\r\n'))
+ end
if rule.user_agent ~= "none" then
table.insert(req_headers, string.format("User-Agent: %s\r\n", rule.user_agent))
end
diff --git a/src/plugins/lua/external_services.lua b/src/plugins/lua/external_services.lua
index a68517c08..e299d9faa 100644
--- a/src/plugins/lua/external_services.lua
+++ b/src/plugins/lua/external_services.lua
@@ -181,12 +181,12 @@ local function add_scanner_rule(sym, opts)
fun.each(function(p)
local content = p:get_content()
if content and #content > 0 then
- cfg.check(task, content, p:get_digest(), rule)
+ cfg.check(task, content, p:get_digest(), rule, p)
end
end, common.check_parts_match(task, rule))
else
- cfg.check(task, task:get_content(), task:get_digest(), rule)
+ cfg.check(task, task:get_content(), task:get_digest(), rule, nil)
end
end