Skip to content

feat(application): under PCAPKIT_MIMIC=wireshark, TLS extensions are gated by handshake message as Wireshark gates them (#3228) - #3252

Merged
JarryShaw merged 1 commit into
developfrom
feat/3228-tls-extension-gating-mimic
Nov 30, 2026
Merged

JarryShaw merged 1 commit into
developfrom
feat/3228-tls-extension-gating-mimic

Conversation

@JarryShaw

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 #3228.

With PCAPKIT_MIMIC=wireshark, each TLS/DTLS extension decodes, and builds from keyword arguments, as its case in Wireshark's ssl_dissect_hnd_extension (epan/dissectors/packet-tls-utils.c at 0235e7b9e) reads it, in the messages that function reads extensions in: CH, SH, HRR, NST, EE, CT, CR. Unset, dpkt and scapy keep #2853's RFC gating.

  • supported_groups, ec_point_formats, signature_algorithms, ALPN, padding, record_size_limit, session_ticket, cookie, psk_key_exchange_modes, renegotiation_info: in each of those messages.
  • The other types: their structure where the case reads one, Empty where it reads nothing (ssl_end_vector flags any octet left, which stays raw). connection_id keeps feat(utilities): a PCAPKIT_WIRESHARK flag that makes pcapkit follow Wireshark where it follows an RFC instead (#3224) #3226's hellos-only reading. Kept raw for want of a schema: status_request in a TLS 1.3 Certificate, early_data in a NewSessionTicket.
  • One table per schema (__structure__) feeds both the data selector and the constructor, so read and make agree. Each schema's data doc names its Wireshark case; the engines page's Mimic Mode table gains the site.

Tests: test_tls_extension_wireshark_gating_3228_unit.py fails on a git archive origin/develop export (unittest: 105 failures, 102 errors). Coverage of ssl/ rises (99.16% to 99.21%, branch). No pins moved. tests/protocols/application, tests/utilities, tests/project, tests/protocols/*.py, tests/*.py, the Sphinx-gated modules and a docs build pass, but test_conda_dev_release_gate_2458, which fails the same on the export.

@JarryShaw JarryShaw changed the title feat(application): under PCAPKIT_WIRESHARK, TLS extensions are gated by handshake message as Wireshark gates them (#3228) feat(application): under PCAPKIT_MIMIC=wireshark, TLS extensions are gated by handshake message as Wireshark gates them (#3228) Nov 30, 2026
@JarryShaw JarryShaw added feat Pull requests that add a new capability (feat: subject prefix) 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
@JarryShaw JarryShaw moved this to In review in PyPCAPKit 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 fc435f6de. The cross-review (Sonnet) found the design sound, and the fixes are small. A fix round is under way.

  • Confirmed: across 22 schemas and 7 messages, every gating cell matches ssl_dissect_hnd_extension (0235e7b9e67b). Unset, dpkt and scapy give byte-identical results to develop over 1100 cells. A zero-length body decoding as Empty, not raw, matches ssl_end_vector, so it reads Wireshark more closely than the issue's "raw" did.
  • To fix:
    • the engines table's wireshark cell is garbled ("…in, and but for…");
    • it cites the path without its epan/ prefix;
    • _make_ext_connection_id still gates ad hoc rather than through __structure__, so read and make could drift;
    • the commit subject still says PCAPKIT_WIRESHARK.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Decision needed: should each TLS extension schema's new class-level __structure__ table (message type → structure, RFC and Wireshark columns) be a registry with register_<kind> APIs?

I recommend (A), and I'm proceeding with it. The table encodes RFC and engine gating, which #3234 routes through PCAPKIT_MIMIC alone, and a register API would let callers override RFC gating. New extension types still register through the existing extension-type registry.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment needs: decision Waiting on the maintainer to decide — not blocked by other work and removed review: running A cross-review is in flight against the current head - no verdict yet labels Nov 30, 2026
@JarryShaw JarryShaw moved this from In review to Needs decision in PyPCAPKit Nov 30, 2026
@JarryShaw
JarryShaw force-pushed the feat/3228-tls-extension-gating-mimic branch from fc435f6 to 00d883c Compare November 30, 2026 15:26
@JarryShaw

Copy link
Copy Markdown
Owner Author

Good to go at 00d883cce. I checked the fix round against fc435f6de myself; develop hasn't moved since. The diff touches only the three intended files.

  • Docs: the engines-table wireshark cell now reads as plain sentences and cites epan/dissectors/packet-tls-utils.c in full.
  • connection_id: _make_ext_connection_id now gates through _layout(…, Schema_ConnectionIdExtension, msg_type), which reads the same __structure__ the read side does. The ad hoc MIMIC and CH/SH checks and the unused config import are gone.
  • Test: the new ReadMakeAgreementTests covers every type, every message, both record layers and all four mimic values. The worker reintroduced the old maker in a scratch copy, and the test failed on 2 subtests.
  • Commit subject: it now reads PCAPKIT_MIMIC=wireshark.

The __structure__ registry question above still stands. I'm going ahead with (A).

@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
@JarryShaw

Copy link
Copy Markdown
Owner Author

Correction to my earlier review of #3252. I asked for epan/dissectors/packet-tls-utils.c in full, but that was wrong. The engines page states its convention above the table: Wireshark's files are named within the epan/ tree. Every other row follows it (dissectors/packet-ipv6.c, -sctp.c, -pop.c). The worker is reverting that one path, and I'll re-check the delta once it's pushed.

@JarryShaw JarryShaw added review: pending No verdict for the current head - never reviewed, or the head moved since the last one and removed review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 30, 2026
…gated by handshake message as Wireshark gates them (#3228)

With PCAPKIT_MIMIC=wireshark, each TLS and DTLS extension decodes, and builds
from keyword arguments, as its case in Wireshark's ssl_dissect_hnd_extension
(epan/dissectors/packet-tls-utils.c) reads it, in the messages that function
reads extensions in. Unset, #2853's RFC gating stays.

- supported_groups, ec_point_formats, signature_algorithms, ALPN, padding,
  record_size_limit, session_ticket, cookie, psk_key_exchange_modes and
  renegotiation_info decode in each of those messages.
- The other types decode their structure where their case reads one, and
  are empty where it reads nothing, as ssl_end_vector flags any octet left;
  connection_id keeps its hellos-only reading.
- Each extension schema holds its structures by message, for the RFC and for
  Wireshark, in a class-level __structure__ that its data selector and its
  constructor both read.
- The engines page's Mimic Mode table gains the site.
@JarryShaw
JarryShaw force-pushed the feat/3228-tls-extension-gating-mimic branch from 00d883c to 235142b Compare November 30, 2026 15:46
@JarryShaw

Copy link
Copy Markdown
Owner Author

Good to go at 235142b0f. I checked it myself: the only change from 00d883cce is the one-line path revert, dissectors/packet-tls-utils.c, which follows the page's naming rule. The only epan/ left on the page is in that rule's own sentence. The __structure__ registry question above is still open, and I'm going ahead with (A).

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Nov 30, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Take recommendations.

And I think extension on schema's registry is actually done by subclassing the base schema class. Right?

@JarryShaw

Copy link
Copy Markdown
Owner Author

Recorded: (A). __structure__ stays a fixed per-schema table with no register API, which is what this PR already does, so no code change follows.

Yes, extension goes through subclassing. I checked this against the code:

  • Extension is an EnumSchema. A subclass declared with code=… registers itself in Extension.__enum__ through __init_subclass__, and Extension.register(code, schema) does the same. Both warn with RegistryWarning on an overwrite.
  • register_tls_extension(code, …, schema=…) takes that Extension subclass together with the parser and constructor.
  • Gating travels with the class. A new subclass declares its own __structure__ and data = SwitchField(selector=__structure__).
  • The shipped extension schemas are @schema_final, so replacing one means subclassing Extension under the same code, which warns. You can't subclass the shipped class itself.

@JarryShaw JarryShaw removed the needs: decision Waiting on the maintainer to decide — not blocked by other work label Nov 30, 2026
@JarryShaw JarryShaw moved this from Needs decision to In review in PyPCAPKit Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 94.99% (unit tier, Python 3.15, 235142b0f, 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 3162 83 1060 40 96.85%
pcapkit/dumpkit 423 3 148 5 98.60%
pcapkit/foundation 4350 24 1364 26 99.12%
pcapkit/interface 112 4 40 3 95.39%
pcapkit/protocols 29085 153 7712 128 99.23%
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Pull requests that add a new capability (feat: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat(application): under PCAPKIT_MIMIC=wireshark, TLS extensions are gated by handshake message as Wireshark gates them

1 participant