]> source.dussan.org Git - rspamd.git/commitdiff
Add optional status prefix to X-Virus header 2205/head
authorBernhard Frauendienst <rspamd@nospam.obeliks.de>
Mon, 30 Apr 2018 12:34:51 +0000 (14:34 +0200)
committerBernhard Frauendienst <rspamd@nospam.obeliks.de>
Mon, 30 Apr 2018 12:34:51 +0000 (14:34 +0200)
Adds two options to X-Virus milter header routine that prefix the header
value with a configured string when a virus was found (or not). This is
useful for sieve implementations (like pidgeonhole) that require a fixed
value part to match against.

src/plugins/lua/milter_headers.lua

index 0eb92ff274ebaf616857d075682a6dbd45cc9341..5e7fb21ed434c3ae1dac118c64bc3b94caaced87 100644 (file)
@@ -71,6 +71,8 @@ local settings = {
     ['x-virus'] = {
       header = 'X-Virus',
       remove = 1,
+      status_clean = nil,
+      status_infected = nil,
       symbols = {}, -- needs config
     },
     ['x-spamd-bar'] = {
@@ -344,7 +346,13 @@ local function milter_headers(task)
       end
     end
     if #virii > 0 then
-      add_header('x-virus', table.concat(virii, ','))
+      local virusstatus = table.concat(virii, ',')
+      if settings.routines['x-virus'].status_infected then
+        virusstatus = settings.routines['x-virus'].status_infected .. ', ' .. virusstatus
+      end
+      add_header('x-virus', virusstatus)
+    elseif settings.routines['x-virus'].status_clean then
+      add_header('x-virus', settings.routines['x-virus'].status_clean)
     end
   end