Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 type issue #19

Open
jwahsnakupaku opened this issue Feb 20, 2023 · 1 comment
Open

Python3 type issue #19

jwahsnakupaku opened this issue Feb 20, 2023 · 1 comment

Comments

@jwahsnakupaku
Copy link
Contributor

When trying to use pywdns to read an existing .nmsg file I run into the following error on Python3.
If I set it all up on Python2, it works fine.

Using the following;
CentOS Stream
Python 3.9
Latest pywdns commit from this repo.
Latest releases for mtbl, wdns, etc.

Stack trace

$ cat nmsg_test/*.nmsg | python ~/simple_py3_test.py 
Traceback (most recent call last):
  File "/home/jwah/simple_py3_test.py", line 23, in <module>
    test_parse_nmsg(sys.stdin)
  File "/home/jwah/simple_py3_test.py", line 16, in test_parse_nmsg
    base_dnsqr_response = wdns.parse_message(base_dnsqr['response'])
  File "wdns.pyx", line 593, in wdns.parse_message
  File "wdns.pyx", line 858, in wdns.edns.__init__
TypeError: Expected str, got bytes

Sample Script

import sys
import nmsg
import wdns

def test_parse_nmsg(input):
    dnsqr = nmsg.input.open_file(input)
    dnsqr.set_filter_msgtype('base', 'dnsqr')
    more = True
    while more:
        base_dnsqr = dnsqr.read()
        if not base_dnsqr:
            more = False
        elif (base_dnsqr['type'] == 'UDP_QUERY_RESPONSE' and 'response' in
             base_dnsqr):
            try:
                base_dnsqr_response = wdns.parse_message(base_dnsqr['response'])
            except wdns.MessageParseException:
                pass

if __name__ == '__main__':
    test_parse_nmsg(sys.stdin)
jwahsnakupaku added a commit to jwahsnakupaku/pywdns that referenced this issue Feb 20, 2023
Fix for the following stack trace;
  File "wdns.pyx", line 593, in wdns.parse_message
  File "wdns.pyx", line 858, in wdns.edns.__init__
TypeError: Expected str, got bytes
farsightsec#19
@cmikk
Copy link
Contributor

cmikk commented Jan 9, 2024

Merged fix, thank you!

Will close issue when this is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants