Skip to content

Commit 05b513d

Browse files
committed
Fix domain validation for subdomains (#19)
Don't run the advisor over scans from the CLI if an error occurred
1 parent 216bdbe commit 05b513d

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

cmd/dss/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var (
2323
Use: "dss",
2424
Short: "Scan a domain's DNS records.",
2525
Long: "Scan a domain's DNS records.\nhttps://github.com/GlobalCyberAlliance/domain-security-scanner",
26-
Version: "2.4.6",
26+
Version: "2.4.7",
2727
PersistentPreRun: func(cmd *cobra.Command, args []string) {
2828
if debug {
2929
log = zerolog.New(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339}).With().Timestamp().Logger().Level(zerolog.DebugLevel)

cmd/dss/scan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var cmdScan = &cobra.Command{
6060
ScanResult: result,
6161
}
6262

63-
if advise {
63+
if result.Error == "" && advise {
6464
resultWithAdvice.Advice = domainAdvisor.CheckAll(result.BIMI, result.DKIM, result.DMARC, result.Domain, result.MX, result.SPF, checkTls)
6565
}
6666

pkg/scanner/scanner.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,13 @@ func (s *Scanner) Scan(domain string) *ScanResult {
272272
// check that the domain name is valid
273273
records, err := s.getDNSAnswers(domain, dns.TypeNS)
274274
if err != nil || len(records) == 0 {
275-
return &ScanResult{
276-
Domain: domain,
277-
Error: "invalid domain name",
275+
// check if TXT records exist, as the nameserver check won't work for subdomains
276+
records, err = s.getDNSAnswers(domain, dns.TypeTXT)
277+
if err != nil || len(records) == 0 {
278+
return &ScanResult{
279+
Domain: domain,
280+
Error: "invalid domain name",
281+
}
278282
}
279283
}
280284

0 commit comments

Comments
 (0)