Skip to content

fix(protocols): input refusals raised as FieldValueError, FieldError or EnumValueError stay loud under the next-layer fallback (#3238) - #3255

Open
JarryShaw wants to merge 1 commit into
developfrom
fix/3238-input-refusals-as-protocolerror
Open

JarryShaw wants to merge 1 commit into
developfrom
fix/3238-input-refusals-as-protocolerror

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Please follow the guide below

  • Put an x into every box [ ] that applies to your pull request (like this: [x])

  • Use the Preview tab to see how your pull request will look

  • Searched for similar pull requests

  • Followed the coding style (make pylint, make mypy, make isort)

  • make test passes, and a test case covers the change

  • Described the user-visible change below and left its changelog entry to the maintainer, keeping docs/source/changelog/ and CHANGELOG.md out of the diff, if the change is user-visible: N/A — centralised

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect

  • feat — adds a feature

  • perf — changes performance, not behaviour

  • refactor — changes neither behaviour nor performance

  • test — tests only

  • docs — documentation only

  • ci — workflows or build tooling

  • release — bumps the version or rolls up a distribution

  • chore — anything else

  • Also tick if it regenerates constant or registry tables, members keeping their numeric values (the const label)


Description of your pull request and other information

Closes #3238.

Each site is classified against rfc-conformance.rst:

  • Structural, now ProtocolError at its source (quiet under the fallback): TCP's mptcp_data_selector (flagless MP_JOIN, RFC 8684 §3.2) and mptcp_add_address_selector (ADD_ADDR length, §3.4.1); HIP's Length callbacks, locator_value_selector (RFC 8046 §4) and its fixed-width lists; IPv6-Route's Source Route address list (odd Hdr Ext Len, RFC 2460 §4.4). The remainder check these lists and SCTP's share moves to the new pcapkit.corekit.schema.entries.whole_entries.
  • Value rules, through conformance.nonconforming: HOPOPT's and IPv6-Opts' SMF TaggerID TidLen (RFC 6621 §6.1.1), read on as TidLen + 1 octets, with NULL's TidLen now checked and rebuilt; MH's four closed enumerations, kept as an int by MH._read_closed. Both honour PCAPKIT_MIMIC=wireshark (dissect_opt_smf_dpd and packet-mip6.c read them silently), with rows in the mimic-mode table. A cut code is not reported.
  • rfc-conformance.rst names the helper. A FieldError, FieldValueError or EnumValueError from a real bug at these sites stays loud, which each new test pins.

Tests: the five new *_3238_unit.py modules fail on an origin/develop export. Pins moved in the HIP, MH, IPv6-Ext, IPv6 option helper, option-area cut and MPTCP modules. The touched modules, tests/project, tests/protocols/*.py and tests/*.py pass.

@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) review: running A cross-review is in flight against the current head - no verdict yet labels Nov 30, 2026
@github-actions github-actions Bot added this to the PyPCAPKit v1.10 milestone Nov 30, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

@JarryShaw

Copy link
Copy Markdown
Owner Author

Needs changes at e31648064, after a Sonnet cross-review. The design holds up. Two changes are needed, and the fix round is already under way.

  • What the review confirmed:
  • Change 1: SMF TaggerID needs a wireshark mimic row, since dissect_opt_smf_dpd reads a mismatched TidLen silently. rfc-conformance.rst puts a new site's rows in the same change.
  • Change 2: HIP's entries_len, SCTP's whole_entries and IPv6-Route's source_route_len are one remainder check. Under the shared-helper rule it moves to corekit.schema.
  • Nits: a Note in the MH make docstrings, RFC 8200 and 5095 context next to the RFC 2460 citation, and a test name that is now stale.
  • Accepted as is: a direct make() still accepts any value, which matches PPP's precedent and how the constructing contextvar is designed. A refusal goes through from_fields.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Good to go at 5889c40fa. I reviewed the fix round against e31648064 myself (develop unchanged).

  • SMF TaggerID: both _read_opt_smf_dpd readers pass mimic='accept' under wireshark. The mimic table gains the SMF rows. dpkt and scapy are "as unset", which the worker checked against dpkt 1.9.8's raw options and Scapy 2.7.0's HBHOptUnknown. The new wireshark test fails at the old head.
  • Shared helper: a new pcapkit.corekit.schema.entries.whole_entries(length, width, message) replaces SCTP's whole_entries (moved, unreleased, no re-export), HIP's entries_len (now a thin wrapper) and IPv6-Route's source_route_len (removed). It has a docs page and its own unit test.
  • Nits: done. That covers the MH make Notes, the RFC 8200/5095 context on the Source Route citation and the renamed test.
  • Follow-up candidate: SCTP's shipped entries_length and MH's "whole number of N-octet items" checks run the same test. Left out here to keep the SCTP hunks small.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Coverage: 94.99% (unit tier, Python 3.15, 3cff3c3ef, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 116 4 20 2 95.59%
pcapkit/const 22386 224 3186 191 98.28%
pcapkit/corekit 3172 83 1062 40 96.86%
pcapkit/dumpkit 423 3 148 5 98.60%
pcapkit/foundation 4355 24 1368 26 99.13%
pcapkit/interface 112 4 40 3 95.39%
pcapkit/protocols 29118 154 7726 128 99.22%
pcapkit/toolkit 1279 35 474 9 96.69%
pcapkit/utilities 669 7 186 5 98.60%
pcapkit/vendor 6575 2396 1478 258 60.24%

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

@JarryShaw

Copy link
Copy Markdown
Owner Author

Rebase note: develop moved (#3251 merged as 6fcbdca79), so this PR now conflicts in one file, the Mimic Mode table in docs/source/pcapkit/foundation/engines/index.rst. The original worker is rebasing it and keeping both sides' rows. The patch outside that file should be unchanged; I'll check the patch-id and post the result.

…or EnumValueError stay loud under the next-layer fallback (#3238)

Each site is classified against the RFC-conformance convention (#3234).

Structural, now raised as ProtocolError at its source, so a next-layer
fallback keeps the layer raw quietly (#2588):
- TCP: a flagless MP_JOIN (RFC 8684 section 3.2) and an ADD_ADDR of a
  length that gives no address family (section 3.4.1).
- HIP: a Length short of a parameter's fixed fields, one leaving part of
  a list entry, and a locator type and length RFC 8046 section 4 gives
  no layout.
- IPv6-Route: a Source Route of an odd Hdr Ext Len (RFC 2460 section 4.4).
- The remainder check SCTP's lists, HIP's and IPv6-Route's share moves to
  pcapkit.corekit.schema.entries.whole_entries.

Value rules, through pcapkit.utilities.conformance.nonconforming:
- HOPOPT and IPv6-Opts: an SMF TaggerID whose TidLen RFC 6621 section
  6.1.1 rules out is read as TidLen + 1 octets and warned of, and a NULL
  TaggerID's TidLen is checked and rebuilt.
- MH: an unassigned FBack or LRA status, or IPv6 Address/Prefix or LMA
  Address option code, is kept as an int through MH._read_closed.
- Under PCAPKIT_MIMIC=wireshark both are read and built silently, as
  dissect_opt_smf_dpd and packet-mip6.c read them.

The RFC-conformance page names the helper, and the mimic-mode table
gains the MH and SMF rows. A real pcapkit bug at these sites stays loud.
@JarryShaw
JarryShaw force-pushed the fix/3238-input-refusals-as-protocolerror branch from 5889c40 to 3cff3c3 Compare November 30, 2026 18:56
@JarryShaw

Copy link
Copy Markdown
Owner Author

Rebased from 5889c40fa to 3cff3c3ef, on top of develop 707c6e2d7 (after #3251 and #3252). I checked the result myself.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Integration check after #3256: this PR's CI ran against develop 707c6e2d7. #3256 has since landed and also edits sctp/schema.py and ipv6_ext/schema.py, so I checked the two together. A Sonnet agent merged this head (3cff3c3ef) into develop be7737f64 in a scratch tree; the merge was clean. Results there:

  • tests/protocols/transport, tests/protocols/internet and tests/corekit: 2508 passed.
  • tests/protocols/misc with the tests/protocols/*.py sweeps: 1188 passed.
  • tests/foundation with the root tests/*.py: 1311 passed.

There were no failures, so the combination is green.

This branch has not been deployed

No deployments
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) review: good-to-go Cross-review at the current head says ready; CI state is separate

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

fix(protocols): input refusals raised as FieldValueError, FieldError or EnumValueError stay loud under the next-layer fallback

1 participant