Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(enrichment): keep WHOIS and DNS records from every source in mergeResults (#1178)

OTILabs180594a39948
diff --git a/services/enrichment/internal/enricher/enricher.go b/services/enrichment/internal/enricher/enricher.go
index 619f03397..1cf4f96bb 100644
--- a/services/enrichment/internal/enricher/enricher.go
+++ b/services/enrichment/internal/enricher/enricher.go
@@ -257,6 +257,8 @@ func (e *Enricher) enrichURL(ctx context.Context, rawURL string) (*EnrichmentRes
// - RiskScore = max of all sources (worst-case wins)
// - Confidence scales with number of corroborating sources
// - Geo/Whois/community fields take the highest-risk source's data
+// - Whois falls back to the first source that has one when the highest-risk
+// source has none; DNS records are union-merged
// - Tags / classifications / sources / vulns / dark-web are union-merged
// - Brand-risk takes the highest-scoring brand signal
func mergeResults(iocType IOCType, value string, results []*EnrichmentResult) *EnrichmentResult {
@@ -285,6 +287,7 @@ func mergeResults(iocType IOCType, value string, results []*EnrichmentResult) *E
malwareSet := map[string]bool{}
campaignSet := map[string]bool{}
cveSet := map[string]bool{}
+ dnsSet := map[string]bool{}
for _, r := range results {
if r.RiskScore > maxRisk {
@@ -296,6 +299,15 @@ func mergeResults(iocType IOCType, value string, results []*EnrichmentResult) *E
merged.Whois = r.Whois
}
}
+ if len(merged.Whois) == 0 && len(r.Whois) > 0 {
+ merged.Whois = r.Whois
+ }
+ for _, record := range r.DNSRecords {
+ if !dnsSet[record] {
+ dnsSet[record] = true
+ merged.DNSRecords = append(merged.DNSRecords, record)
+ }
+ }
if r.MaliciousVotes > merged.MaliciousVotes {
merged.MaliciousVotes = r.MaliciousVotes
merged.HarmlessVotes = r.HarmlessVotes
diff --git a/services/enrichment/internal/enricher/merge_test.go b/services/enrichment/internal/enricher/merge_test.go
new file mode 100644
index 000000000..4e7f951fc
--- /dev/null
+++ b/services/enrichment/internal/enricher/merge_test.go
@@ -0,0 +1,49 @@
+package enricher
+
+import (
+ "slices"
+ "testing"
+)
+
+func TestMergeKeepsWhoisFromSourceWithoutRisk(t *testing.T) {
+ scored := &EnrichmentResult{RiskScore: 40, Tags: []string{"vendor:phishing"}}
+ facts := &EnrichmentResult{
+ Whois: map[string]string{"registrar": "Example Registrar, Inc."},
+ DNSRecords: []string{"A 192.0.2.10", "NS ns1.example.net."},
+ }
+
+ merged := mergeResults(IOCTypeDomain, "example.com", []*EnrichmentResult{scored, facts})
+
+ if merged.RiskScore != 40 {
+ t.Errorf("RiskScore = %v, want 40", merged.RiskScore)
+ }
+ if merged.Whois["registrar"] != "Example Registrar, Inc." {
+ t.Errorf("Whois = %v, want the registrar from the source that had one", merged.Whois)
+ }
+ if !slices.Equal(merged.DNSRecords, facts.DNSRecords) {
+ t.Errorf("DNSRecords = %q", merged.DNSRecords)
+ }
+}
+
+func TestMergePrefersWhoisOfHighestRiskSource(t *testing.T) {
+ facts := &EnrichmentResult{Whois: map[string]string{"registrar": "from-facts"}}
+ scored := &EnrichmentResult{RiskScore: 70, Whois: map[string]string{"registrar": "from-scored"}}
+
+ merged := mergeResults(IOCTypeDomain, "example.com", []*EnrichmentResult{facts, scored})
+
+ if merged.Whois["registrar"] != "from-scored" {
+ t.Errorf("Whois = %v, want the highest-risk source's", merged.Whois)
+ }
+}
+
+func TestMergeDeduplicatesDNSRecords(t *testing.T) {
+ a := &EnrichmentResult{DNSRecords: []string{"A 192.0.2.10", "MX 10 mail.example.com."}}
+ b := &EnrichmentResult{DNSRecords: []string{"A 192.0.2.10", "A 192.0.2.11"}}
+
+ merged := mergeResults(IOCTypeDomain, "example.com", []*EnrichmentResult{a, b})
+
+ want := []string{"A 192.0.2.10", "MX 10 mail.example.com.", "A 192.0.2.11"}
+ if !slices.Equal(merged.DNSRecords, want) {
+ t.Errorf("DNSRecords = %q, want %q", merged.DNSRecords, want)
+ }
+}