Skip to content

fix(pcapng): build a Decryption Secrets Block from bytes secrets_data (#2273) - #2346

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2273-pcapng-dsb-bytes-secrets
Oct 27, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2273-pcapng-dsb-bytes-secrets

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — bug fix

Description

Closes #2273.

  • Fix: _make_block_dsb read a bytes secrets_data straight through, but every _read_secrets_* expects a parsed schema. It now runs the bytes through dsb_secrets_selector, the same schema the parser picks, so it packs back byte-exact.
  • Fail-without-fix: 18 failed on origin/main. Passing on the rebased head.

…#2273)

_make_block_dsb stored a bytes secrets_data, its b'' default included, in
the block schema as given, and every _read_secrets_* expects a parsed
secrets schema, so no DSB could be made from bytes for any secrets type.
PCAPNG overrides unpack, so the #1312 raw-item reparse never applies.

Read the bytes through dsb_secrets_selector, the schema the parse side
selects, which packs back to the octets given.

Test: TLS, WireGuard, ZigBee NWK/APS (short and long keys), unknown type
and empty bytes all make, parse, and rebuild byte-exactly, with the made
info equal to the parsed info.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 27, 2026
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) 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 27, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 27, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: GOOD TO GO at 23206d128 (Sonnet).

  • Fix: _make_block_dsb's bytes branch now runs secrets_data through dsb_secrets_selector, the same selector the parse side uses, for all four secrets types plus unknown/custom types and empty bytes.
  • Verified independently: 369 hand-packed constructions (TLS, WireGuard, ZigBee NWK/APS at every length, malformed/cut/non-ASCII logs, options combined) all round-trip byte-exact, parse-equal and from_data-exact.
  • Fail-without-fix: 18 failed on origin/main (AttributeError, matching the issue). On the head, the new test gives 4 passed, and 448 passed across the pcapng/docstring/tier selection.
  • Non-blocking follow-ups the reviewer found, present on main too, not caused by this PR: a raw bytes option in an IDB/DSB's options= list raises AttributeError: no attribute '_byte'; PCAPNG.make(block=<bytes>) for a DSB raises AttributeError: 'bytes' object has no attribute 'length'.

@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 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.58% (unit tier, Python 3.15, 23206d128, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19599 881 2618 867 92.11%
pcapkit/corekit 2596 74 818 37 96.51%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 3029 23 1050 25 98.82%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17443 218 4586 185 98.15%
pcapkit/toolkit 914 36 334 10 95.51%
pcapkit/utilities 502 7 144 5 98.14%
pcapkit/vendor 4432 1988 1018 167 51.87%

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

@JarryShaw

Copy link
Copy Markdown
Owner Author

Ready to merge at 23206d128. Closes #2273.

  • Review: GOOD TO GO (Sonnet).
  • CI: Required checks passed SUCCESS, 0 failures, KTLO clean.
  • Ordering leg: protocols gave 1965 tests with 0 failures, run with the PR merged into current main.
  • Merge state: mergeable.

@JarryShaw
JarryShaw merged commit 1711055 into main Oct 27, 2026
68 checks passed
@JarryShaw
JarryShaw deleted the fix/2273-pcapng-dsb-bytes-secrets branch October 27, 2026 14:51
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 27, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issues reporting a defect (set by the bug report template; a default, not an assessment) fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(pcapng): a Decryption Secrets Block with bytes secrets_data cannot be constructed

1 participant