Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add ICAP Content-Type and Filename from TODO List #4595

Merged
merged 3 commits into from Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions lualib/lua_scanners/icap.lua
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/lua/external_services.lua
Expand Up @@ -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

Expand Down