Skip to content

feat: packet payload hex+ASCII viewer (#46)#69

Merged
NotYuSheng merged 2 commits intomainfrom
feature/packet-payload-hex-viewer
Mar 28, 2026
Merged

feat: packet payload hex+ASCII viewer (#46)#69
NotYuSheng merged 2 commits intomainfrom
feature/packet-payload-hex-viewer

Conversation

@NotYuSheng
Copy link
Copy Markdown
Owner

Summary

  • Extracts raw packet bytes during PCAP parsing and stores the first 1024 bytes as a lowercase hex string per packet
  • Conversation detail panel now opens as a full modal-xl with prev/next navigation and keyboard shortcuts
  • Clicking a packet row in the stream expands an inline hex+ASCII dump (Wireshark-style); rows with significant cleartext are flagged with an ASCII badge

Changes

Backend

  • V12__add_payload_to_packets.sql — new migration
  • PcapParserServiceextractPayloadHex() helper converts raw frame bytes to hex (capped at 1024 bytes); threaded through processIpPacketbuildPacketInfo; tshark fallback leaves payload null
  • PacketEntity, PacketResponse, AnalysisService — payload field propagated end-to-end

Frontend

  • HexViewer.tsx — new component rendering offset / hex (8+8 split) / ASCII columns in a dark monospace panel with a truncation notice
  • ConversationDetail — clickable packet rows expand HexViewer; yellow ASCII badge on rows where >30% of bytes are printable ASCII; hint text in card header
  • ConversationPage — split-panel replaced with modal-xl; ←/→ arrow keys navigate prev/next; ESC or backdrop click closes; X/N counter in header; hint text on conversations card

Test plan

  • Upload ftp.pcap — verify packet rows show ASCII badge and hex dump displays readable FTP commands/responses on click
  • Verify encrypted traffic (TLS) shows unreadable bytes with no ASCII badge
  • Test ESC, ←/→ arrow keys, backdrop click, and Prev/Next buttons in the modal
  • Confirm DB migration V12 runs cleanly
  • Verify packets parsed via tshark fallback still load (payload will be empty)

Closes #46

🤖 Generated with Claude Code

- DB migration V12: add payload TEXT column to packets
- PcapParserService: extract raw frame bytes as lowercase hex (first 1024 bytes) in pcap4j path via extractPayloadHex(); tshark fallback leaves payload null
- PacketEntity, PacketResponse, AnalysisService: propagate payload end-to-end
- HexViewer component: renders offset / hex (split 8+8) / ASCII columns in a dark monospace panel with truncation notice
- ConversationDetail: clickable packet rows expand inline HexViewer; ASCII badge shown on rows where >30% of bytes are printable ASCII
- ConversationPage: detail view converted from split-panel to modal-xl; prev/next navigation with ←/→ arrow keys; ESC closes modal; backdrop click closes modal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to view packet payloads in a hex viewer within the conversation detail view. Changes include backend updates to store and serve the first 1024 bytes of packet data, a new database migration, and a frontend refactor that moves conversation details into a modal with keyboard navigation. Feedback focuses on improving performance in hex string conversion, fixing potential stale state issues in React hooks, addressing magic numbers and hardcoded styles, and ensuring proper error logging and UI alignment.

Comment thread frontend/src/pages/Conversation/ConversationPage.tsx Outdated
Comment thread backend/src/main/java/com/tracepcap/analysis/service/PcapParserService.java Outdated
Comment thread frontend/src/components/conversation/HexViewer/HexViewer.tsx Outdated
Comment thread frontend/src/components/conversation/HexViewer/HexViewer.tsx Outdated
Comment thread frontend/src/pages/Conversation/ConversationPage.tsx Outdated
- PcapParserService: replace String.format hex loop with char[] lookup array for performance
- ConversationPage: wrap handlePrev/handleNext in useCallback; remove eslint-disable; log error in catch block
- ConversationDetail: extract 0.3 threshold into PRINTABLE_ASCII_THRESHOLD constant
- HexViewer: move inline styles to HexViewer.css; fix hex column padding (48 not 49 chars)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NotYuSheng NotYuSheng merged commit c437595 into main Mar 28, 2026
@NotYuSheng NotYuSheng deleted the feature/packet-payload-hex-viewer branch March 28, 2026 05:11
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 this pull request may close these issues.

feat: packet payload hex+ASCII viewer

1 participant