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

TypeError: Object of type bytes is not JSON serializable #94

Open
winux138 opened this issue Sep 30, 2022 · 1 comment · May be fixed by #96
Open

TypeError: Object of type bytes is not JSON serializable #94

winux138 opened this issue Sep 30, 2022 · 1 comment · May be fixed by #96

Comments

@winux138
Copy link

nccgroup/umap2 is a USB assessment tool, and they are using the kitty engine to fuzz USB host.

The issue I encounter is the following, I can't access any report, they all have the label "trigger timed out", and when I access the detail for a report I get an alert window with "Failed to load report" while in the console running the kitty engine (and the web server I guess) I get the following message :

Exception occurred during processing of request from ('127.0.0.1', 35804)
Traceback (most recent call last):
  File "/usr/lib64/python3.10/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib64/python3.10/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib64/python3.10/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 72, in __init__
    BaseHTTPRequestHandler.__init__(
  File "/usr/lib64/python3.10/socketserver.py", line 747, in __init__
    self.handle()
  File "/usr/lib64/python3.10/http/server.py", line 432, in handle
    self.handle_one_request()
  File "/usr/lib64/python3.10/http/server.py", line 420, in handle_one_request
    method()
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 116, in do_GET
    self._my_handle()
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 261, in _my_handle
    response = endpoints[endpoint]()
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 199, in _handle_api_request
    response = self._get_report()
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 234, in _get_report
    return json.dumps(response)
  File "/usr/lib64/python3.10/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib64/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib64/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable

I think the issue is related to kitty rather than umap2, but I might be wrong, in that case let me know and I will close the issue.

If you need additional information let me know, I will do my best to provide them.

@winux138
Copy link
Author

winux138 commented Oct 7, 2022

After some digging, here are some update

In data/report.py, the method to_dict has a loop to iterate over every item and convert every byte array encountered to a string.
The issue is, it is not recursive. If an item is a list of byte array, it will remain so, causing an issue later on.

I will clean up my implementation and submit a PR later on.

@winux138 winux138 linked a pull request Oct 18, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant