Skip to content

fix(protocols): refuse or build what the TCP, HIP and MH makers mishandled (#2708) - #2724

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2708-maker-defects
Nov 3, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2708-maker-defects

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect

This fixes small make() defects in TCP, HIP and MH found while reviewing #2692, plus a HIP parse defect found while fixing them.

  • TCP: the raw-bytes option branch now resolves the kind through _make_index, the same call the pair form uses. An unassigned kind such as 255 builds instead of raising EnumValueError. An empty raw item raises ProtocolError rather than IndexError.
  • HIP version: HIP(next=59, parameters=[]) wrote version 6. IPv6_Ext.__post_init__ defaults version to the IP version, and that default reached HIP's make(). HIP.__post_init__ now defaults it to 2, as RFC 7401 §5.1 gives. read() still ignores the enclosing layer's version.
  • HIP ENCRYPTED: an IV given with a cipher that uses none is refused, through both the keyword and the data-model paths.
  • HIP ENCRYPTED on parse: it never found the HIP_CIPHER before it. It warned, read the cipher as 0xFFFF and took the IV as data, because OptionField.unpack hands every parameter one shared dict and never fills options. HIP_CIPHER now records its IDs in that context, and each ENCRYPTED takes the next one.
  • MH _make_opt_cga_param: dict is dropped from the annotation and the refusal is documented, matching what the maker already did.

The new tests fail on main. Every parsed TCP option and every HIP cipher id rebuilds byte-exactly.

Closes #2708

…and ENCRYPTED, MH CGA parameters (#2708)

- TCP: a raw-octets option resolves its kind through _make_index, as a
  (code, arguments) pair does, so kind 255, which Option.get refuses, builds
  instead of raising EnumValueError; empty raw octets raise ProtocolError
  rather than IndexError.
- HIP version: IPv6_Ext.__post_init__ defaults version to 6, the IP version,
  and hands it to make(), which wrote it as the HIP version. HIP.__post_init__
  takes version with make()'s default, so HIP(next=59) writes version 2.
- HIP ENCRYPTED maker: an IV given with a cipher other than AES-128-CBC and
  AES-256-CBC raises ProtocolError, instead of counting in Length while the
  schema drops it.
- HIP ENCRYPTED parse: its schema looked for the cipher in a packet['options']
  no parse sets, so it warned of a missing HIP_CIPHER and read an AES IV as
  data. HIP_CIPHER now records its cipher IDs in the context the area's
  parameters share, and ENCRYPTED reads the Nth of them.
- MH _make_opt_cga_param: the annotation drops dict[str, Any], which the maker
  always refused; the docstring documents the refusal.
- Tests: one module per family that fails on the base; the HIP version pin in
  test_protocol_make_unit and the HIP tests that passed a stray IV or drove the
  old cipher lookup are updated.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 3, 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 3, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 951ce7493, from a Sonnet review of 0106e42e5. The rebase onto main keeps the same patch-id.

  • All 1205 parsed TCP options rebuild through the raw-bytes path. Every HIP cipher id from 0 to 599, plus the enum and the reserved ids, builds and parses back quietly with the right IV state.
  • Three ENCRYPTED parameters behind two HIP_CIPHERs take their ciphers in order. Nothing leaks between packets parsed in sequence.
  • No other IPv6_Ext subclass has a version that would leak into make(). The edited pins keep their intent. 356 modules pass.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 3, 2026
@JarryShaw
JarryShaw merged commit 5e3a621 into main Nov 3, 2026
63 checks passed
@JarryShaw
JarryShaw deleted the fix/2708-maker-defects branch November 3, 2026 03:48
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 3, 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
…s.pickle, FRAD's pad and the TCP and HIP maker fixes into 1.6.0 (#2449)

- Breaking: a fixed-size octet field given any other width raises, where
  1.5.x padded or cut it, and IPv4's Timestamp option refuses a slot count
  past what it holds, where 1.5.x cut it (#2691); folded into the IPv4 to HIP
  makers' range-check entry, with the ZigBee keys into the PCAP-NG entry. Old
  values measured against v1.5.1.
- Added: pcapkit.utilities.pickle, whose ReduceAsProtocol2 lets Info, Schema
  and the reassembly engines pickle under protocols 0 and 1 on GraalPy, and
  numbers._reduce_unregistered_member's removal (#2722).
- Fixed: TCP's raw-octet options, HIP's default version, HIP's ENCRYPTED IV
  and its cipher on parse (#2724).
- Folded into unreleased entries: FRAD's pad field and make(pad=) (#2721).
- No entry for the docstring-only 596dcfa, the test-only 149cced, or
  #2724's MH annotation.
- 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(protocols): small make() defects in TCP raw options, HIP ENCRYPTED and version, and MH CGA parameters

1 participant