Skip to content
Snippets Groups Projects
Commit 5a39cecd authored by ale's avatar ale
Browse files

Add ASN field to DMARC events

parent 7785289f
No related branches found
No related tags found
No related merge requests found
...@@ -153,6 +153,9 @@ func (h *DMARCHandler) eventFromRecord(report *dmarcReport, rec *dmarcRecord) Ev ...@@ -153,6 +153,9 @@ func (h *DMARCHandler) eventFromRecord(report *dmarcReport, rec *dmarcRecord) Ev
e.Set("report_id", report.Metadata.ReportID) e.Set("report_id", report.Metadata.ReportID)
e.Set("report_organization", report.Metadata.Organization) e.Set("report_organization", report.Metadata.Organization)
if asn, ok := lookupASN(rec.Row.SourceIP); ok {
e.Set("asn", asn)
}
e.Set("policy_evaluated_disposition", rec.Row.PolicyEvaluated.Disposition) e.Set("policy_evaluated_disposition", rec.Row.PolicyEvaluated.Disposition)
e.Set("policy_evaluated_dkim", rec.Row.PolicyEvaluated.DKIM) e.Set("policy_evaluated_dkim", rec.Row.PolicyEvaluated.DKIM)
e.Set("policy_evaluated_spf", rec.Row.PolicyEvaluated.SPF) e.Set("policy_evaluated_spf", rec.Row.PolicyEvaluated.SPF)
......
...@@ -34,7 +34,11 @@ func lookupASN(addr string) (string, bool) { ...@@ -34,7 +34,11 @@ func lookupASN(addr string) (string, bool) {
geodbInit.Do(initGeoIP) geodbInit.Do(initGeoIP)
if geodb != nil { if geodb != nil {
asn, err := geodb.ASN(net.ParseIP(addr)) ip := net.ParseIP(addr)
if ip == nil {
return "", false
}
asn, err := geodb.ASN(ip)
if err == nil { if err == nil {
return fmt.Sprintf("AS%d", asn.AutonomousSystemNumber), true return fmt.Sprintf("AS%d", asn.AutonomousSystemNumber), true
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment