Q: Headers insertion

44 views
Skip to first unread message

Toxa

unread,
Jul 28, 2017, 9:54:10 AM7/28/17
to rspamd
Hello,

I'm completely new to rspamd, so sorry for the noob questions (actually migrating from SA, under Exim).

What I want to do is to inject the "Authentication-Results" header into the received messages.

So far I wrote in /etc/rspamd/rspamd.local.lua :

rspamd_config.XX_TEST = {
    callback = function(task)
      local ar = require "auth_results"
      local cur_auth_results = ar.gen_auth_results(task)
      local logger = require "rspamd_logger"
      logger.infox(task, "AUTH_RESULTS: %1", cur_auth_results)
      return true
    end,
    score = 0
}

rspamd_config:register_dependency('XX_TEST', 'R_DKIM_ALLOW')
rspamd_config:register_dependency('XX_TEST', 'R_SPF_ALLOW')
rspamd_config:register_dependency('XX_TEST', 'DMARC_POLICY_ALLOW')



this writes the right string to the log. But:

1) I'm not sure that it's the right approach (to define the new symbol).

2) The dependency is clearly wrong (should not depend on "ALLOW", but on any R_DKIM_* etc.).

3) How to inject the header into the message instead of logging it? Can't find.

P.S. I saw the 'authentication-results' function in milter-headers, but not sure if I can use it.

Thanks for any help!

Andrew Lewis

unread,
Jul 28, 2017, 10:04:35 AM7/28/17
to rsp...@googlegroups.com

Hi,

> P.S. I saw the 'authentication-results' function in milter-headers, but not
> sure if I can use it.

That is the way to add the authentication-results header in general;
however since you use Exim which uses a legacy protocol there is
currently no possibility to add headers via Rspamd.

Your options may include:

* Adopting something like Postfix or Haraka instead
* Using Exim's own support for adding this header (if Exim is compiled
with DMARC support)

Best,
-AL.

Toxa

unread,
Jul 28, 2017, 10:21:15 AM7/28/17
to rspamd
Andrew, thanks for your reply!

Yes, I'm actually doing it at Exim level, but would prefer to get the info from Rspamd... That would avoid the excessive DNS queries, etc.

Just curious: may be it could be possible to add the auth-result string to spam_report (The same way as 'Message: (SPF)' and 'Message-Id')? And then parse it out in Exim...

Toxa

unread,
Jul 28, 2017, 2:48:33 PM7/28/17
to rspamd
For the record. This adds the "Authentication-Results:" header in Exim.

I finished with something like this:

In /etc/rspamd/rspamd.local.lua :

rspamd_config.XX_AUTH_RESULTS = {

    callback = function(task)
      local ar = require "auth_results"
      local cur_auth_results = ar.gen_auth_results(task)
      if string.find(cur_auth_results, ";") then
        task:append_message('AuthResults: ' .. cur_auth_results)
      end

      return true
    end,
    score = 0
}

rspamd_config:register_dependency('XX_AUTH_RESULTS', 'R_SPF_ALLOW')
rspamd_config:register_dependency('XX_AUTH_RESULTS', 'R_DKIM_ALLOW')
rspamd_config:register_dependency('XX_AUTH_RESULTS', 'DMARC_POLICY_ALLOW')



Not sure about dependencies. The 'dmarc' one probably already includes 'spf' and 'dkim'.

In exim4.conf:

  warn
        spam = nobody:true

  warn
        condition = ${if match{$spam_report}{Message: AuthResults:} {yes}{no}}
        add_header = :at_start:Authentication-Results: ${sg{$spam_report}{\N(?s)^.*Message: AuthResults:\s+([^\n]+).*$\N}{\$1}}



Reply all
Reply to author
Forward
0 new messages