[Pymilter] pyspf SPF checking raises TypeError exception when checking erroneous record

Kazuhiro Ogura kazuhiro.ogura at hde.co.jp
Wed Mar 13 00:58:06 EDT 2013


Hi,

I'm using pyspf-2.0.7, and I've found that spf.query.check() raises
TypeError exception when doing SPF check against particular DNS
entries like:

        example.com  IN  TXT     "v=spf1 mx:mx1.example.com"
    mx1.example.com  IN  CNAME   .

or entries like:

        example.com  IN  TXT     "v=spf1 a:mx2.example.com"
    mx2.example.com  IN  CNAME   .

(It is apparently wrong, but it do exists in real world)


The traceback for the former is like:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "spf.py", line 543, in check
    rc = self.check1(spf, self.d, 0)
  File "spf.py", line 582, in check1
    return self.check0(spf, recursion)
  File "spf.py", line 876, in check0
    if self.cidrmatch(self.dns_mx(arg), cidrlength):
  File "spf.py", line 1163, in dns_mx
    return [a for mx in mxnames[:max] for a in self.dns_a(mx[1],self.A)]
TypeError: 'NoneType' object is unsubscriptable


And for the latter is like:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "spf.py", line 543, in check
    rc = self.check1(spf, self.d, 0)
  File "spf.py", line 582, in check1
    return self.check0(spf, recursion)
  File "spf.py", line 871, in check0
    if self.cidrmatch(self.dns_a(arg,self.A), cidrlength):
  File "spf.py", line 1295, in cidrmatch
    for ip in [bin(ip) for ip in ipaddrs]:
TypeError: 'NoneType' object is not iterable


I did some debugging and it looks like DNSLookup() call inside
spf.query.dns() returns '' instead of '.', and that is not what is
expected in the following code.

Is this pydns-side problem? Or should it be fixed in pyspf?

-- 
Kazuhiro Ogura <kazuhiro.ogura at hde.co.jp>
Representative Director, Chief Executive Officer
HDE, Inc.
http://www.hde.co.jp/
GPG Key Id: 0xFA80C875
We support Karesansui Project: http://karesansui-project.info



More information about the Pymilter mailing list