Return nil from spam analyzers when primary headers are missing
Bug: https://github.com/happyDomain/happydeliver/issues/11
This commit is contained in:
parent
26025c96a2
commit
2fcee1b885
2 changed files with 15 additions and 0 deletions
|
|
@ -51,6 +51,13 @@ func (a *RspamdAnalyzer) AnalyzeRspamd(email *EmailMessage) *api.RspamdResult {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Require at least X-Spamd-Result or X-Rspamd-Score to produce a meaningful report
|
||||
_, hasSpamdResult := headers["X-Spamd-Result"]
|
||||
_, hasRspamdScore := headers["X-Rspamd-Score"]
|
||||
if !hasSpamdResult && !hasRspamdScore {
|
||||
return nil
|
||||
}
|
||||
|
||||
result := &api.RspamdResult{
|
||||
Symbols: make(map[string]api.RspamdSymbol),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,14 @@ func (a *SpamAssassinAnalyzer) AnalyzeSpamAssassin(email *EmailMessage) *api.Spa
|
|||
return nil
|
||||
}
|
||||
|
||||
// Require at least X-Spam-Status, X-Spam-Score, or X-Spam-Flag to produce a meaningful report
|
||||
_, hasStatus := headers["X-Spam-Status"]
|
||||
_, hasScore := headers["X-Spam-Score"]
|
||||
_, hasFlag := headers["X-Spam-Flag"]
|
||||
if !hasStatus && !hasScore && !hasFlag {
|
||||
return nil
|
||||
}
|
||||
|
||||
result := &api.SpamAssassinResult{
|
||||
TestDetails: make(map[string]api.SpamTestDetail),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue