Fix bytes rendering and improve NBI data handling in HTML reports #215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix HTML byte display issue and improve NBI handling (Closes #181)
This PR fixes issue #181, where byte data was displayed in HTML reports as Python byte literals (b'...').
It also includes improvements to Network-Based Indicators (NBI) processing, display formatting, and shared listener utilities.
Summary of Changes
1. Improved HTTP POST body handling
Detects whether POST data is printable text or binary.
Printable data is now decoded and displayed as text.
Binary data is shown as a truncated hexdump (first 16 lines, consistent with RawListener).
2. Consolidated shared utilities
ListenerBase.pywas not a true base listener but contained only utility functions.Renamed
listeners/ListenerBase.py→listeners/utils.pyto better reflect its purpose.Moved
hexdump_table()fromRawListener.pytoutils.pyso it can be shared across listeners.Updated all listener modules (__init__.py, HTTP, Raw, FTP, SMTP, POP, TFTP) to import from
utils.py.Removed an unused ListenerBase import from
ssl_utils/__init__.py.3. HTML report fixes and improvements
Enabled hexdump display for both Data Hexdump (from RawListener) and Request Body (Hexdump) (from HTTPListener).
Rewrote the JavaScript function
copyNbiData(), which previously failed when special character \n was present.Screenshots
New behavior:
If raw bytes are present, a hexdump is shown.
Otherwise, the content is displayed as a decoded string.
Previous behavior:
Raw bytes caused a Python Traceback because an invalid UTF-8 decoding was attempted.
Feedback
I am open to comments or suggestions!
Let me know if you would prefer these changes split into separate PRs or adjusted in any way.
Resolves
Closes #181