sdgathman / pyspf

Other
49 stars 26 forks source link

Passing lowercase qtype to DNSLookup_dnspython() always results in empty list #32

Closed hrkokw closed 2 years ago

hrkokw commented 2 years ago

Hi,

When DNSLookup_dnspython() is called with qtype option including lowercase letter, empty list is always returned as if there's no record, regardless of the actual server response.

dnspython accepts both upper/lowercase rdtype and internally normalizes to uppercase. I suppose letting DNSLookup_dnspython() behave alike would be the best fix.

This one-line patch works well in my environment:

--- a/spf.py
+++ b/spf.py
@@ -120,6 +120,7 @@ def DNSLookup_pydns(name, qtype, strict=True, timeout=20):
 def DNSLookup_dnspython(name, qtype, tcpfallback=True, timeout=30):
     retVal = []
     try:
+        qtype = qtype.upper()
         # FIXME: how to disable TCP fallback in dnspython if not tcpfallback?
         dns_version = dns.version.MAJOR+dns.version.MINOR/100
         if dns_version<1.16:

Thanks.

sdgathman commented 2 years ago

You are calling the DNSLookup api to allow your app to work with any of several libraries (like pyspf does)? In that case, maybe I should split off "anydns" to provide just that unified/simplified API, and require that in pyspf.

hrkokw commented 2 years ago

Ah, no, I've just found this issue when debugging spf-engine, which doesn't work correctly in dnspython-enabled environment because of the way it calls DNSLookup:

rDNSResults = spf.DNSLookup (_get_rdns_lookup(ip), 'ptr', timeout=configData.get('Whitelist_Lookup_Time'))
# => empty, always

I wondered to which report this issue but finally I came here.

Thanks.

sdgathman commented 2 years ago

https://github.com/sdgathman/pyspf/commit/0858adb6cf529e696a42318b7938e0b9e8a86c1c