]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Add ICAP Content-Type and Filename from TODO List. Simplify changes. Remove...
authorLyuben Bahtarliev <>
Mon, 11 Sep 2023 21:26:59 +0000 (00:26 +0300)
committerLyuben Bahtarliev <>
Tue, 12 Sep 2023 20:36:40 +0000 (23:36 +0300)
lualib/lua_scanners/icap.lua
src/plugins/lua/external_services.lua

index 042ce1e980169df1135123e8715dcf57d6fd157d..59d2caa4a1e48f55bc8f92eaafcd74542c983d64 100644 (file)
@@ -241,13 +241,15 @@ 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 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/%s\r\n', maybe_part[2], maybe_part[3]))
+        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
index 98a0a6d930f68c05e0b22e4f4b7ee77453c32850..e299d9faa3b179ba32d89ea089ef65bc1e1950f1 100644 (file)
@@ -181,19 +181,12 @@ local function add_scanner_rule(sym, opts)
       fun.each(function(p)
         local content = p:get_content()
         if content and #content > 0 then
-          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)
+          cfg.check(task, content, p:get_digest(), rule, p)
         end
       end, common.check_parts_match(task, rule))
 
     else
-      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)
+      cfg.check(task, task:get_content(), task:get_digest(), rule, nil)
     end
   end