Skip to content

fix(foundation): number pcapng blocks across the whole file, not per section (#1256) - #1426

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1256-pcapng-unique-block-names
Oct 8, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1256-pcapng-unique-block-names

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

Closes #1256. foundation/engines/pcapng.py numbered IDB, NRB, ISB, DSB, systemd Journal Export, Custom and Unknown blocks by the current section's list length, which restarts at every SHB, so test.pcapng dumped Interface Description 1 twice (14 blocks, 13 unique keys, 13 files). Each kind now takes a file-wide counter (_block_name); Section Header and Frame were already file-wide.

  • test.pcapng: section 2's IDB is now Interface Description 3; 14 keys, 14 files.
  • Single-section files: key lists identical before/after for dhcp, dhcp_big_endian, dhcp_little_endian, many_interfaces, profile. Only multi-section files change, and only for keys that previously collided, so not marked breaking.
  • New tests/foundation/test_pcapng_unique_block_names_unit.py builds a two-section capture with every named kind in both sections; it fails on main (Interface Description 1 where 2 is expected) and passes here.

…section (#1256)

- The engine named IDB, NRB, ISB, DSB, systemd Journal Export, Custom
  and Unknown blocks by the length of the current section's context list,
  which restarts at every SHB. A second section's first IDB was named
  "Interface Description 1" again, so JSON/plist kept one of the two
  blocks and files=True overwrote a file. Each kind now takes its number
  from a file-wide counter; a single-section file is named as before.
- tests/foundation/test_pcapng_unique_block_names_unit.py extracts a
  two-section capture holding every named kind in both sections.
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 8, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 2724abfc8 (Sonnet cross-review; the author ran on Opus).

  • Re-derived by me (JSON extraction, main a8cc02594 vs this PR):
    • test.pcapng (two sections): 13 keys → 14. On main, section 2's IDB overwrote Interface Description 1; here it becomes Interface Description 3.
    • Single-section files are identical: dhcp 6 keys, many_interfaces 88 keys. The reviewer also found dhcp_big_endian, dhcp_little_endian and profile identical.
  • Coverage: all seven per-section kinds (IDB, NRB, Journal Export, DSB, ISB, Custom, Unknown) now use the file-wide _block_name. Section Header and Frame were already file-wide, and no other per-section counter exists in pcapkit/.
  • Lookup unaffected: _get_interface still reads the per-section self._ctx.interfaces. In a two-section probe (section 2: raw-IP IDB, then Ethernet IDB), EPB interface_id 0 decodes as RAW and 1 as Ethernet/IPv4/UDP, the same as main.
  • files=True: 8 files, where main gives 7 because one is overwritten. TraceFlow only uses Frame N. No docs or changelog page documents the IDB/NRB/ISB key format.
  • Tests:
    • The new test fails with only the engine reverted.
    • Neighbours pass: test_pcapng_engine.py 14, test_extraction.py 22, test_pcapng_end_to_end.py 6 + 1 skipped, test_files_output_naming.py 4.
    • The file compiles under Python 3.10.
  • Not breaking: only multi-section key collisions change, so the label stays fix.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Coverage: 89.45% (unit tier, Python 3.14, 2724abfc8, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18791 968 2352 869 90.90%
pcapkit/corekit 2038 89 634 25 94.76%
pcapkit/dumpkit 234 2 84 2 98.74%
pcapkit/foundation 2642 98 928 48 94.79%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 16615 221 4474 185 98.04%
pcapkit/toolkit 539 74 168 3 84.58%
pcapkit/utilities 429 4 122 4 98.55%
pcapkit/vendor 4409 2342 1006 157 43.25%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit ef90d41 into main Oct 8, 2026
41 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 8, 2026
@JarryShaw
JarryShaw deleted the fix/1256-pcapng-unique-block-names branch October 8, 2026 22:22
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 8, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(foundation): pcapng engine reuses 'Interface Description 1' across sections, so json/plist lose a block and files=True drops a file

1 participant