Skip to content

feat(demo/reveng): add real pcap examples, fetch workflow, and automated tshark tests - #52

Merged
cherninkiy merged 7 commits into
mainfrom
copilot/create-demo-reveng-folder
Apr 19, 2026
Merged

feat(demo/reveng): add real pcap examples, fetch workflow, and automated tshark tests#52
cherninkiy merged 7 commits into
mainfrom
copilot/create-demo-reveng-folder

Conversation

Copilot AI commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Extends demo/reveng with a real-traffic download workflow, a reproducible synthetic sample generator, and a full automated tshark test suite validating all four Lua dissectors.

What

Real pcap download workflow (tools/fetch_samples.sh)

  • Downloads ipv4frags.pcap (Wireshark SampleCaptures) → ip_scoped/real_sample.pcap + session_id/real_sample.pcap
  • Downloads imap-ssl.pcapng (Lekensteyn/wireshark-notes) → tls_weak_cipher/real_sample.pcapng + tls_sni_analysis/real_sample.pcapng
  • Falls back gracefully with manual curl hints if URLs are unreachable; real samples never committed (*.pcapng, real_sample.* added to .gitignore)

Synthetic sample regeneration (tools/make_samples.py)

  • stdlib-only Python script reproducing all committed sample.pcap files byte-for-byte from spec; idempotent via make make-samples

Automated tshark tests (tools/test_dissectors.sh)

  • Skips cleanly (exit 0) when tshark is absent — CI-safe
  • Auto-generates results/*.lua via generate_all.sh if missing
  • Per-case assertions:
Case Assertions
ip_scoped src_scope/dst_scope values per frame; 8 display-filter counts; src_lan/dst_lan bool filters
session_id session_with_service values per frame; 2 filter counts; A↔B and C↔D symmetry checks
tls_weak_cipher has_weak_cipher filter counts (1 weak / 1 safe); is_client_hello count
tls_sni_analysis sni_category values per frame; category filter counts; is_anomaly bool filter

Makefile targets added: fetch-samples, make-samples, test: generate

Minor fixes: 0x00FF label corrected to TLS_FALLBACK_SCSV in tls_weak_cipher/expected.txt; SNI packet #3 sni_length corrected to 39 in tls_sni_analysis/expected.txt

Why

  • Demo previously had no way to test dissector correctness automatically — expected.txt described expected behaviour but required manual Wireshark inspection
  • No script existed to reproduce committed sample.pcap files from scratch
  • Real-world captures were unavailable without manual downloading

Validation

  • make_samples.py produces byte-identical output to the committed sample.pcap files (verified via git diff — zero binary changes)
  • All shell scripts pass bash -n syntax check
  • test_dissectors.sh skips safely when tshark is absent

Checks

  • CI impact
  • Breaking changes

Notes

  • set -e is intentionally absent from test_dissectors.sh: tshark exits non-zero when a display filter matches 0 frames, which would abort mid-suite; failures are accumulated via _fail() instead
  • Real sample files use a different name (real_sample.*) so they cannot accidentally shadow the committed synthetic sample.pcap

Copilot AI and others added 6 commits April 18, 2026 04:01
…y, updated Makefile and README

Agent-Logs-Url: https://github.com/protocollab-co/protocollab/sessions/d207c835-b2b6-48b9-af96-6ef77cce9905

Co-authored-by: cherninkiy <2933630+cherninkiy@users.noreply.github.com>
Base automatically changed from dev to main April 19, 2026 21:57
@cherninkiy
cherninkiy marked this pull request as ready for review April 19, 2026 22:00

@cherninkiy cherninkiy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review

Overall the PR is well-structured and covers an important gap: there was no way to validate dissector correctness without running Wireshark manually. The CI-safe skip, stdlib-only make_samples.py, and the --force flag on fetch_samples.sh are all good design choices.

Found a few items to address before merging:


Bugs / correctness

1. Docstring mismatch in make_tls_sni_analysis (make_samples.py)

The function docstring says packet #3 has sni_length=32, but the code uses long_sni_claimed_length = 39, which matches expected.txt and test_dissectors.sh. The docstring is wrong and will mislead anyone trying to regenerate the file manually:

# docstring says:
#   #3  sni_length=32  ...
# code does:
long_sni_claimed_length = 39

Fix: update the docstring to sni_length=39.


Reliability / portability

2. Stale download URL in fetch_samples.sh

The primary URL for ipv4frags.pcap points to the old MoinMoin Wireshark wiki (wiki.wireshark.org/SampleCaptures?action=AttachFile...), which was retired when Wireshark migrated to GitLab. The first attempt will always fail silently and fall through to the GitHub mirror. Consider swapping the order (use the GitHub mirror as primary) or removing the dead URL.

3. wc -l whitespace trimming in assert_count (test_dissectors.sh)

count=$(tshark ... | wc -l | tr -d ' ')

On macOS, wc -l pads with leading spaces; tr -d ' ' works but removes all spaces. More portable:

count=$(tshark ... | wc -l)
count=${count// /}

Nits

4. session_key instance is never asserted

session_id.yaml defines both session_key (raw XOR) and session_with_service. Only the latter is tested. A single assert_values for session_key would confirm symmetry independently of port masking.

5. Binary pcap blobs

Downstream reviewers should run make make-samples && git diff --stat to verify blobs are unchanged rather than inspecting the binary diff directly. Worth a note in CONTRIBUTING or the README.

@cherninkiy

Copy link
Copy Markdown
Collaborator

Review

Overall the PR is well-structured and covers an important gap: there was no way to validate dissector correctness without running Wireshark manually. The CI-safe tshark skip, stdlib-only make_samples.py, and the --force flag on fetch_samples.sh are all good design choices.

A few items to address before merging:


Bug

1. Docstring mismatch in make_tls_sni_analysis (make_samples.py)

The docstring says packet #3 has sni_length=32, but the code uses long_sni_claimed_length = 39, which correctly matches expected.txt and test_dissectors.sh. The docstring is wrong:

# docstring (wrong):
#   #3  sni_length=32  sni_name=<random 32-char>    → Long/Anomaly (>20)

# code (correct):
long_sni_claimed_length = 39

Fix: change the docstring line to sni_length=39.


Reliability

2. Stale primary URL in fetch_samples.sh

"https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=ipv4frags.pcap"

The old MoinMoin Wireshark wiki was retired when the project moved to GitLab. This URL always fails silently and wastes a 30 s timeout before falling through to the GitHub mirror. Recommend swapping the two URLs so the GitHub mirror is primary.

3. wc -l | tr -d ' ' in assert_count is non-portable

On macOS, wc -l pads output with leading spaces. tr -d ' ' removes them but also drops any accidental mid-string spaces. Simpler portable alternative:

count=$(tshark ... | wc -l)
count=${count// /}   # bash parameter expansion, no extra subprocess

Nit

4. session_key instance is defined but never tested

session_id.yaml defines session_key (raw src_ip ^ dst_ip) alongside session_with_service. Only the latter is asserted in test_dissectors.sh. Adding a single assert_values call for session_key would independently confirm the symmetry property and make the YAML field testable.

5. Binary pcap blobs in the diff

The committed sample.pcap files produce unreadable diffs. Worth a one-liner in the README: reviewers should run make make-samples && git diff --stat to verify the blobs are bit-identical rather than eyeballing the binary diff.

- fix tls_sni_analysis docstring to match claimed SNI length (39)
- use GitHub mirror as primary ipv4frags download URL
- normalize wc output via bash expansion in test_dissectors.sh
- add explicit session_key assertions in session_id tests
- update README URLs and add binary pcap review guidance
@cherninkiy
cherninkiy merged commit 73256b7 into main Apr 19, 2026
6 checks passed
@cherninkiy
cherninkiy deleted the copilot/create-demo-reveng-folder branch April 19, 2026 22:44
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.

2 participants