Skip to content

impossible for milter_headers to add a custom header #51

@dlatchx

Description

@dlatchx

rspamd has a module to insert custom headers : https://rspamd.com/doc/modules/milter_headers.html

But this filter only support a few hardcoded headers.

I think the problem is here :

/**
* Prefix auth headers to incoming mail in proper order.
*/
if len(authHeaders) > 0 {
hdrs := []string{
"ARC-Seal",
"ARC-Message-Signature",
"ARC-Authentication-Results",
"Authentication-Results"}
for _, h := range hdrs {
if authHeaders[h] != "" {
writeHeader(s, token, h, authHeaders[h])
}
}
}

Only the headers in hdrs will be inserted by the filter.

Here is an example of the headers that rspamd can return:

curl -s -X POST http://localhost:11333/checkv2 | jq .milter.add_headers
{
  "X-Spamd-Bar": {
    "value": "+++++++++++++++",
    "order": -1
  },
  "X-Spamd-Result": {
    "value": "default: True [15.00 / 15.00];\r\n\tCOMPLETELY_EMPTY(15.00)[]",
    "order": -1
  },
  "X-Rspamd-Action": {
    "value": "reject",
    "order": -1
  },
  "X-Spam-Status": {
    "value": "Yes, score=15.00",
    "order": -1
  },
  "Authentication-Results": {
    "value": "localhost;\r\n\tnone",
    "order": 1
  },
  "X-Rspamd-Server": {
    "value": "localhost",
    "order": -1
  },
  "X-Spam-Level": {
    "value": "***************",
    "order": -1
  }
}

I can rewrite this, but I'd like to know what is the rationale for this code:

How does the order matter ?
Does this matter for other headers (such as those given above) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions