commit 5bb1ce5: [Feature] Add ICAP Content-Type and Filename from TODO List
Lyuben Bahtarliev
Wed Sep 13 10:21:03 UTC 2023
Author: Lyuben Bahtarliev
Date: 2023-09-11 08:17:08 +0300
URL: https://github.com/rspamd/rspamd/commit/5bb1ce5ee2cb9ef383e6bdc82adfaafd058e925b
[Feature] Add ICAP Content-Type and Filename from TODO List
---
lualib/lua_scanners/icap.lua | 8 ++++++--
src/plugins/lua/external_services.lua | 11 +++++++++--
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/lualib/lua_scanners/icap.lua b/lualib/lua_scanners/icap.lua
index 16459b06e..042ce1e98 100644
--- a/lualib/lua_scanners/icap.lua
+++ b/lualib/lua_scanners/icap.lua
@@ -240,10 +240,14 @@ local function icap_check(task, content, digest, rule, maybe_part)
local function get_req_headers()
+ local in_client_ip = task:get_from_ip()
+ lua_util.debugm(rule.name, task, 'URL: http://%s/%s | Content-Type: %s/%s',
+ in_client_ip, maybe_part[1], maybe_part[2], maybe_part[3])
+
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('GET http://%s/%s HTTP/1.0\r\n', in_client_ip, maybe_part[1]))
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'))
+ table.insert(http_headers, string.format('Content-Type: %s/%s\r\n', maybe_part[2], maybe_part[3]))
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..98a0a6d93 100644
--- a/src/plugins/lua/external_services.lua
+++ b/src/plugins/lua/external_services.lua
@@ -181,12 +181,19 @@ 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)
+ local in_fname = p:get_filename()
+ local in_type, in_stype = p:get_detected_type()
+ local part_info = {in_fname,in_type,in_stype}
+ cfg.check(task, content, p:get_digest(), rule, part_info)
end
end, common.check_parts_match(task, rule))
else
- cfg.check(task, task:get_content(), task:get_digest(), rule)
+ local in_fname = "mail"
+ local in_type = "application"
+ local in_stype = "octet-stream"
+ local part_info = {in_fname,in_type,in_stype}
+ cfg.check(task, task:get_content(), task:get_digest(), rule, part_info)
end
end
More information about the Commits
mailing list