domainaware / checkdmarc

A parser for SPF and DMARC DNS records
https://domainaware.github.io/checkdmarc
Apache License 2.0
246 stars 76 forks source link

exception thrown when an A record does not exist #5

Closed kjellchr closed 6 years ago

kjellchr commented 6 years ago
$ checkdmarc sogne.folkebibl.no
Traceback (most recent call last):
  File "/usr/local/bin/checkdmarc", line 11, in <module>
    sys.exit(_main())
  File "/usr/local/lib/python3.4/dist-packages/checkdmarc.py", line 659, in _main
    nameservers=args.nameserver)
  File "/usr/local/lib/python3.4/dist-packages/checkdmarc.py", line 614, in check_domains
    nameservers=nameservers)
  File "/usr/local/lib/python3.4/dist-packages/checkdmarc.py", line 497, in parse_spf_record
    a_records = _get_a_records(domain, nameservers=nameservers)
  File "/usr/local/lib/python3.4/dist-packages/checkdmarc.py", line 426, in _get_a_records
    return records
UnboundLocalError: local variable 'records' referenced before assignment

record:

$ dig +short sogne.folkebibl.no TXT
"v=spf1 include:_spf.bibsyst.no a mx ~all"

however the A record of sogne.folkebibl.no does not exist

kjellchr commented 6 years ago

similar case - _spf.spire.as note: this is a good example where the one included TXT record also does not exist (smtp.spireweb.no)

kjellchr commented 6 years ago

checking checkware.com show that included records that does not exist seems to be handled correctly

kjellchr commented 6 years ago

note - remember to check for AAAA as well :-) (if not already done)

kjellchr commented 6 years ago

a weird one:

$ checkdmarc selje.kommune.no
{
  "dmarc": {
    "record": null,
    "valid": false,
    "error": "A TXT record does not exist at _dmarc.selje.kommune.no"
  },
  "spf": {
    "warnings": [],
    "record": "v=spf1 a:SXO-K-IMSC01.nordfjordnett.no a:SXO-K-IMSC02.nordfjordnett.no a:mail.nordfjordnett.no a:mail.vagsoy.kommune.no a:smtp.onevoice.no a:msg-out.onevoice.no -all",
    "valid": true,
    "results": {
      "exp": null,
      "all": "fail",
      "redirect": null,
      "neutral": [],
      "include": {},
      "softfail": [],
      "pass": [],
      "fail": []
    }
  },
  "domain": "selje.kommune.no"
}

smtp.onevoice.no does not exist. not sure why it is not failing and not giving an alert

seanthegeek commented 6 years ago

@kjellchr It already checks for AAAA :)