Skip to content

fix(misc): rebuild PCAP-NG decryption secrets from their dict as captured (#2698) - #2707

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2698-pcapng-secrets-dict
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2698-pcapng-secrets-dict

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

PCAPNG.from_data(info.to_dict()) did not give back the captured Decryption Secrets Block. The dict path hands the secrets to the maker as keywords, with the captured text or octets under data. The TLS, WireGuard and ZigBee makers read data only from a data model, never as a keyword. So a key log was rewritten under a # generated by PyPCAPKit line, and a ZigBee key came back zero-filled.

_make_secrets_tls and _make_secrets_wireguard now take data and write it verbatim. _make_secrets_zigbee_nwk and _make_secrets_zigbee_aps take data and rebuild it through zigbee_key_held, so a cut still goes through Schema's built-in short read.

Tests cover every registered secrets type and an unregistered one. Each is checked whole, cut at every octet, with octets past the fixed width, and with a Secrets Length past the block. Each case is rebuilt from both info and info.to_dict(), and every test fails on main. Shipped captures parse identically.

Closes #2698

…ured (#2698)

A dict's secrets come back from Info.from_dict as a mapping, which
_make_block_dsb spreads into the secrets maker as keywords. The TLS,
WireGuard and ZigBee makers read the text or octets held under `data`
from a data model only, so from the dict a key log was written from its
entries under a generated comment and a ZigBee key from its zero-filled
fields.

- _make_secrets_tls / _make_secrets_wireguard: take the key log text as
  `data`, written verbatim as the model's text is.
- _make_secrets_zigbee_nwk / _make_secrets_zigbee_aps: take the Secrets
  Data octets as `data`, rebuilt through zigbee_key_held as the model's
  octets are.
- Every secrets type, whole, cut at every octet, past its fixed width and
  past the block, rebuilds the captured octets from `info` and from
  `info.to_dict()`, and both paths report the same.

The new tests fail without the fix; the pcapng, engine, round-trip and
project guard modules pass, and shipped captures parse identically.

Closes #2698
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 2, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at b5a4c11f0, from a Sonnet cross-review.

  • Every secrets type rebuilds exactly from both info and info.to_dict(), with identical warnings. The reviewer's own 424-case sweep found no mismatches.
  • data taking precedence is right: it is the model path's rule, and reversing it would break the byte-exact round trip.
  • Every mutant was killed.

@JarryShaw
JarryShaw merged commit 57a6c36 into main Nov 2, 2026
51 checks passed
@JarryShaw
JarryShaw deleted the fix/2698-pcapng-secrets-dict branch November 2, 2026 23:58
@github-project-automation github-project-automation Bot moved this to Done in PyPCAPKit Nov 2, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 3, 2026
JarryShaw added a commit that referenced this pull request Nov 3, 2026
… helpers, MH options 6 and 27, the cut SCTP and option-area schemas and dict-built secrets into 1.6.0 (#2449)

- Breaking: a make() enumeration field takes a member or an int, its
  X_default/X_namespace/X_reversed keywords removed with no alias, and names,
  wide codes and wide option codes are refused (#2692); the schema helpers
  move to pcapkit.corekit.schema and pcapkit.corekit.fields.byteorder is
  removed (#2704); MobileNetworkPrefixOption gains prefix_length and keeps an
  IPv6Address prefix, and TimestampOption's timestamp is None past 9999
  (#2709). Folded into the MH data-model entry; old values measured against
  v1.5.1.
- Fixed: the SCTP schema cut inside its padding and a header schema cut
  inside an option area pack back as captured (#2682), into the SCTP entry;
  a Decryption Secrets Block rebuilds from its dict as captured (#2707), into
  the DSB entry.
- Folded into unreleased entries: FRAD's Q.922 address refusal and quiet cut
  rebuild (#2719); a from_data rebuild's checksum status (#2712); a failed
  ListField fill's ledger (#2706); pad_length's path (#2704); TLS's enumeration
  fields (#2692); the make() and schema-helper rulings, into the conventions
  entry (#2692, #2704); the GraalPy shards, into the CI-legs entry (#2720).
- 1.5.0's corekit.fields.byteorder role points at corekit.schema.byteorder,
  where #2704 moved it, so the nitpicky build does not warn on it; 1.5.0's
  text unchanged.
- No entry for the test-only 72b2bd8 (#2715), or the docs-and-test-only
  0c07940 (#2718).
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
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)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(misc): PCAP-NG secrets blocks rebuilt from a dict lose their captured octets

1 participant