#12: implement Antispam & Antivirus scanning pipeline (Rspamd & ClamAV)
This commit is contained in:
1 parent
4c2e0b9563
commit
54d1ea5810
15 files changed
+825
-5
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package valueobject
|
||||
|
||||
type ScanVerdict string
|
||||
|
||||
const (
|
||||
ScanVerdictClean ScanVerdict = "CLEAN"
|
||||
ScanVerdictSpamJunk ScanVerdict = "SPAM_JUNK"
|
||||
ScanVerdictSpamReject ScanVerdict = "SPAM_REJECT"
|
||||
ScanVerdictGreylist ScanVerdict = "GREYLIST"
|
||||
ScanVerdictVirusReject ScanVerdict = "VIRUS_REJECT"
|
||||
)
|
||||
|
||||
type ScanResult struct {
|
||||
Verdict ScanVerdict
|
||||
Score float64
|
||||
RequiredScore float64
|
||||
Action string
|
||||
VirusName string
|
||||
Symbols map[string]float64
|
||||
HeadersToAdd map[string]string
|
||||
}
|
||||
|
||||
func NewCleanScanResult() *ScanResult {
|
||||
return &ScanResult{
|
||||
Verdict: ScanVerdictClean,
|
||||
Symbols: make(map[string]float64),
|
||||
HeadersToAdd: make(map[string]string),
|
||||
}
|
||||
}
|
||||
|
||||
func NewVirusScanResult(virusName string) *ScanResult {
|
||||
return &ScanResult{
|
||||
Verdict: ScanVerdictVirusReject,
|
||||
VirusName: virusName,
|
||||
Symbols: make(map[string]float64),
|
||||
HeadersToAdd: make(map[string]string),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package valueobject
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewCleanScanResult(t *testing.T) {
|
||||
res := NewCleanScanResult()
|
||||
if res.Verdict != ScanVerdictClean {
|
||||
t.Errorf("verdict = %s, want CLEAN", res.Verdict)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewVirusScanResult(t *testing.T) {
|
||||
res := NewVirusScanResult("EICAR-Test-Signature")
|
||||
if res.Verdict != ScanVerdictVirusReject || res.VirusName != "EICAR-Test-Signature" {
|
||||
t.Errorf("unexpected virus scan result: %+v", res)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user