Skip to content

fix(internet): build an MH CGA parameter from its data model or a schema without public_key_test (#2725) - #2732

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2725-mh-cga-build
Nov 3, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2725-mh-cga-build

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect

Two MH CGA parameter build defects, both present on main:

  • A raw extension inside a data model raised AttributeError in _read_cga_extensions. ProtocolBase._passes_raw never looked inside a data model, which is a Mapping but not a dict, so the made header was never re-parsed. It now looks inside one, and reads every value of a multi-mapping, so a raw item in a later CGA option is found too. Across the option captures, every other layer's _make_raw is unchanged, and from_data takes no longer.
  • A schema without public_key_test raised KeyError. hasattr found the unset field's class attribute, so the maker never set the key test. The maker now checks 'public_key_test' not in data and builds the key test on a copy, leaving the caller's schema untouched.

The new tests fail on main, and so does the updated test_mh_unit case.

Closes #2725

…ema without public_key_test (#2725)

Two defects in building the MH CGA Parameters option, both on main.

- _passes_raw, which gates the re-parse of a made header that holds raw
  items, did not look inside a data model. A CGA parameter's data model with
  a raw extension, given directly or carried by from_data, left the octets in
  the made header, and _read_cga_extensions raised AttributeError. It looks
  into a data model as into a dict, and into a multi-mapping through every
  value of each key, so a raw item in a later option is found too.
- _make_opt_cga_param set public_key_test only when hasattr() said it was
  missing, which it never did: a schema does not store an unset field, so
  hasattr() found the class's field object and packing raised KeyError. It
  tests the schema's keys, and sets the key test on a copy, leaving the
  caller's schema as given.
- test_mh_unit reaches that branch without deleting the class attribute, and
  checks the made key test and the caller's untouched schema.

The new module and the test_mh_unit case fail on 468f9c2 without the
pcapkit/ change; the internet modules and the project guards pass.
@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 7b96fb51f, from a Sonnet review of aeaceb67a. The review asked for two changes, both now made: copy the caller's schema rather than mutate it, and drop a timed word from a test docstring. The commit is rebased onto ab7be2fb0.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Coverage: 94.45% (unit tier, Python 3.15, 7b96fb51f, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 21062 175 2914 156 98.58%
pcapkit/corekit 2861 76 916 37 96.80%
pcapkit/dumpkit 282 3 100 3 98.43%
pcapkit/foundation 3496 26 1214 32 98.77%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 22618 150 5864 123 99.03%
pcapkit/toolkit 961 26 342 8 96.62%
pcapkit/utilities 533 7 144 5 98.23%
pcapkit/vendor 5590 2286 1280 214 55.75%

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

@JarryShaw
JarryShaw merged commit af69a79 into main Nov 3, 2026
65 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 3, 2026
@JarryShaw
JarryShaw deleted the fix/2725-mh-cga-build branch November 3, 2026 16:25
@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
- Breaking: FrameRecord is an Info and TLSKeyLog.entries a TLSKeyLogEntries
  data model, not dicts (#2734); a new entry with 1.5.1's behaviour, and
  pickles checked loading both ways.
- Fixed: MH's CGA Parameters maker builds a data model's raw extension and a
  schema without public_key_test (#2732), into the makers' Fixed entry.
- Fixed: a capture cut inside or in front of an option area reads as a short
  read in MH, HOPOPT and IPv6-Opts, and an odd item list raises ProtocolError
  (#2731, ab7be2f, which the merge of 07ceaf7 also brings in); the
  short-read ruling into the conventions entry.
- Old values measured against v1.5.1.
- 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(internet): an MH CGA parameter with a raw extension in its data model, or no public_key_test, fails to build

1 participant