NameError: name 'strict' is not defined

Asked by George

I've upgrade to version 2.0.2 and am getting the following error occassionally: "NameError: name 'strict' is not defined"

Oct 5 10:38:48 mokaru policyd-spf[382]: Traceback (most recent call last):
Oct 5 10:38:48 mokaru policyd-spf[382]: File "/usr/bin/policyd-spf", line 809, in <module>
Oct 5 10:38:48 mokaru policyd-spf[382]: instance_dict, configData, peruser, peruserconfigData)
Oct 5 10:38:48 mokaru policyd-spf[382]: File "/usr/bin/policyd-spf", line 623, in _spfcheck
Oct 5 10:38:48 mokaru policyd-spf[382]: mres = mfromquery.check()
Oct 5 10:38:48 mokaru policyd-spf[382]: File "/usr/lib/python3.6/dist-packages/spf.py", line 591, in check
Oct 5 10:38:48 mokaru policyd-spf[382]: spf = self.dns_spf(self.d)
Oct 5 10:38:48 mokaru policyd-spf[382]: File "/usr/lib/python3.6/dist-packages/spf.py", line 1160, in dns_spf
Oct 5 10:38:48 mokaru policyd-spf[382]: a = [t for t in self.dns_txt(domain) if RE_SPF.match(t)]
Oct 5 10:38:48 mokaru policyd-spf[382]: File "/usr/lib/python3.6/dist-packages/spf.py", line 1210, in dns_txt
Oct 5 10:38:48 mokaru policyd-spf[382]: dns_list = self.dns(domainname, rr,ignore_void=ignore_void)
Oct 5 10:38:48 mokaru policyd-spf[382]: File "/usr/lib/python3.6/dist-packages/spf.py", line 1354, in dns
Oct 5 10:38:48 mokaru policyd-spf[382]: for k, v in DNSLookup(name, qtype, self.strict, timeout):
Oct 5 10:38:48 mokaru policyd-spf[382]: File "/usr/lib/python3.6/dist-packages/spf.py", line 106, in DNSLookup_pydns
Oct 5 10:38:48 mokaru policyd-spf[382]: if strict > 1:
Oct 5 10:38:48 mokaru policyd-spf[382]: NameError: name 'strict' is not defined

Is this due to misconfiguration? or is there really a bug in pyspf?

I built with the following packages installed:
ipaddr 2.2.0
py3dns 3.2.1
pyspf 2.0.13

Or improvements from line 622:
                mfromquery = spf.query(i=ip, s=sender, h=helo, querytime=configData.get('Lookup_Time'))
                mfromquery.strict = True ##Add this set to true or false.
                mres = mfromquery.check()

Question information

Language:
English Edit question
Status:
Solved
For:
pypolicyd-spf Edit question
Assignee:
No assignee Edit question
Solved by:
Scott Kitterman
Solved:
Last query:
Last reply:
Revision history for this message
Best Scott Kitterman (kitterman) said :
#1

It's a bug in pyspf. I already provided a fix upstream:

https://github.com/sdgathman/pyspf/commit/4744deeec4a2c10987aae72989d7137156ed4151

It'll be fixed in the next release. You can apply that patch, use the git version (be sure to grab the pyspf-2_0-branch), or downgrade to the previous version.

Unrelated to this issue, FYI: Because there is now a milter interface as well as the policy server, this project was renamed and moved to https://launchpad.net/spf-engine - there is a newer version available there.

Revision history for this message
George (gquerymax) said :
#2

Thank you. Patch worked great.

Revision history for this message
David W (dmwhite823) said :
#3

This issue is also described here: https://github.com/sdgathman/pyspf/issues/17
I applied the fix in https://github.com/sdgathman/pyspf/issues/17#issuecomment-544478766 before I found this bug report on launchpad.

Thanks for your work, Scott.

I can confirm that corrected the issue in my case:

Installed Packages
Name : pypolicyd-spf
Version : 2.0.2
Release : 7.el8
Architecture : noarch
Size : 121 k
Source : pypolicyd-spf-2.0.2-7.el8.src.rpm