Skip to content

Commit fe5e36e

Browse files
committed
- Adding some safety checks to DNS implementation to avoid OOI errors
1 parent 8196662 commit fe5e36e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

helpers/helpers.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,14 @@ func DoDNSEnrichment(ipaddress string) (string, string) {
496496
for i, v := range dnsRecords {
497497
dnsRecords[i] = strings.TrimSuffix(strings.TrimSpace(v), ".")
498498
}
499-
_, m, td := tldparser.ParseDomain(dnsRecords[0])
500-
domain = fmt.Sprintf("%s.%s", m, td)
499+
if len(dnsRecords) == 0 {
500+
dnsRecords = append(dnsRecords, "none")
501+
}
502+
domain := ""
503+
if dnsRecords[0] != "none" {
504+
_, m, td := tldparser.ParseDomain(dnsRecords[0])
505+
domain = fmt.Sprintf("%s.%s", m, td)
506+
}
501507
recordsJoined := strings.Join(dnsRecords, "|")
502508
vars.Dnsfastcache.Set([]byte(ipaddress), []byte(recordsJoined))
503509
return recordsJoined, domain

0 commit comments

Comments
 (0)