]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
implemented subject privacy in the webUI
authorKlaus Umbach <klaus-github@uxix.de>
Mon, 19 Mar 2018 18:25:27 +0000 (19:25 +0100)
committerKlaus Umbach <klaus-github@uxix.de>
Mon, 19 Mar 2018 18:27:39 +0000 (19:27 +0100)
src/plugins/lua/history_redis.lua

index c8f2b6ee64fad627eb2f4b8240e99aaabf186fe1..af0511b9164cd54f317b8414268519be94ef4d03 100644 (file)
@@ -19,11 +19,14 @@ if confighelp then
 end
 
 local redis_params
+local hash = require 'rspamd_cryptobox_hash'
 
 local settings = {
   key_prefix = 'rs_history', -- default key name
   nrows = 200, -- default rows limit
   compress = true, -- use zstd compression when storing data in redis
+  subject_privacy = false, -- subject privacy is off
+  subject_privacy_alg = 'md5', -- default hash-algorithm to obfuscate subject
 }
 
 local rspamd_logger = require "rspamd_logger"
@@ -195,6 +198,10 @@ local function handle_history_request(task, conn, from, to, reset)
         fun.each(function(e)
           if e.subject and not rspamd_util.is_valid_utf8(e.subject) then
             e.subject = '???'
+          elseif settings.subject_privacy then
+            local hash_alg = settings.subject_privacy_alg
+            local subject_hash = hash.create_specific(hash_alg, e.subject)
+            e.subject = hash_alg..':'..subject_hash:hex()
           end
         end, data)
         reply.rows = data