Repository navigation
refactor(vendor,pcapng): generate TLSKeyLabel from the RFC 9850 IANA registry - #890
Conversation
6144606 to
476fe92
Compare
|
GOOD TO GO on The CI failure was one defect across five legs, not five: One judgement call in the fix, flagged rather than waved through. The cost is that The review's blocking find is also fixed: Two disclosure gaps closed in the PR body: the base-class move is a second public-contract effect beyond the import path (type identity flips; One latent crawler bug fixed unprompted: the citation builder matched Determinism, |
|
added inline comment and synced from main branch |
…registry - Add pcapkit/vendor/pcapng/tls_key_label.py, a new crawler fetching the IANA "TLS SSLKEYLOGFILE Labels" CSV (RFC 9850 section 4.2) and generating pcapkit/const/pcapng/tls_key_label.py, matching the shape of its const/pcapng siblings (EnumRegistry + StrEnum, no _missing_, so lookup stays closed and raises exactly as it did before this move). The RFC citation is parsed from each row rather than assumed, and raises loudly on a reference it does not recognise instead of guessing one. - RSA has no row in the registry (NSS-only, removed in NSS 3.34) and is hand-carried by the crawler with its #883 comment preserved verbatim; the other 8 "*_SECRET*" members keep their `# nosec B105` suppression. - pcapkit/protocols/misc/pcapng.py now imports TLSKeyLabel as Enum_TLSKeyLabel, matching the alias every one of its seven pcapkit.const.pcapng siblings already carries in this file, and re-exports it under the original bare name (`TLSKeyLabel = Enum_TLSKeyLabel`) so `from pcapkit.protocols.misc.pcapng import TLSKeyLabel` keeps resolving to the identical object; the three other internal importers are left importing through that re-export, to avoid splitting their existing combined import with WireGuardKeyLabel, which stays put and hand-written (the alias convention is about imports of const enums, not local definitions). Updated the one docstring elsewhere that named TLSKeyLabel's old StrEnum base, which this move changes from compat.StrEnum to aenum.StrEnum. - Register the new crawler/const module in the vendor/const __init__.py index files and docs, and pin the const-enum sweep tests' updated counts in both files that census pcapkit/const's population. - Extend test_pcapng_unit.py to check the re-export identity, pin every member's value, and confirm unknown/lower-case labels still raise. Build/test: ran the crawler twice (byte-identical sha256), plus tests/protocols/misc/test_pcapng_unit.py (94/94) and the affected tests/const + tests/vendor + tests/project sweeps, all green.
ce8931d to
7def2d1
Compare
|
GOOD TO GO on The The rebinding turns out to earn its keep in a way I had not considered. Because pickle's A bare On One pre-existing defect found, not this PR's. Unpublished and unmerged, yours to merge — it closes #886. |
…L_BESPOKE - test_default_still_resolves_when_registered_str called its str-valued case "synthetic, since no shipped aenum.StrEnum registry mixes in the base yet". Measured on main (walking pcapkit.const, filtering for EnumRegistry+str subclasses): ten already do (Command, FEATCode, Method, OptionType, TLSKeyLabel, AppType and its four transport subclasses). Rewrote the docstring to say so instead of the stale claim. - EXCLUDED_STILL_BESPOKE described its members as overriding the base's generic implementation, plus TransportProtocol for never mixing in the base at all. In fact most entries do mix in EnumRegistry -- the set's real, operative meaning is "outside this file's IntEnum-only historical census, anchored at commit 05468a0". Renamed to EXCLUDED_FROM_INTENUM_CENSUS and re-grouped its eleven entries by which of three reasons applies: not an IntEnum, overrides the base, or never mixes in the base (apptype.py carries two of the three, in one file). return_code.py/status_code.py's actual override is a custom __new__ plus _unregistered_member, not get()/register() -- their get/get_all/ register/register_alias all resolve to the base's own implementation; ResponseKind and GroupingInformation, co-resident in return_code.py, override nothing at all. Updated the other four EXCLUDED_STILL_BESPOKE references (one behavioural, three prose) to the new name. - No behaviour change: the set's file-membership, and the 6/11/105/122 counts it feeds, are unchanged (122/11/105 following #890's merge, which added pcapkit/const/pcapng/tls_key_label.py to both). Build/test: tests/const/test_const_registry_protocol.py (run=74, failures=0, errors=0) and tests/const/test_const_enum_builtin_parity.py (run=33, failures=0, errors=0), both via the worktree's own pcapkit.
…L_BESPOKE - test_default_still_resolves_when_registered_str called its str-valued case "synthetic, since no shipped aenum.StrEnum registry mixes in the base yet". Measured on main (walking pcapkit.const, filtering for EnumRegistry+str subclasses): ten already do (Command, FEATCode, Method, OptionType, TLSKeyLabel, AppType and its four transport subclasses). Rewrote the docstring to say so instead of the stale claim. - EXCLUDED_STILL_BESPOKE described its members as overriding the base's generic implementation, plus TransportProtocol for never mixing in the base at all. In fact most entries do mix in EnumRegistry -- the set's real, operative meaning is "outside this file's IntEnum-only historical census, anchored at commit 05468a0". Renamed to EXCLUDED_FROM_INTENUM_CENSUS and re-grouped its eleven entries by which of three reasons applies: not an IntEnum, overrides the base, or never mixes in the base (apptype.py carries two of the three, in one file). return_code.py/status_code.py's actual override is a custom __new__ plus _unregistered_member, not get()/register() -- their get/get_all/ register/register_alias all resolve to the base's own implementation; ResponseKind and GroupingInformation, co-resident in return_code.py, override nothing at all. Updated the other four EXCLUDED_STILL_BESPOKE references (one behavioural, three prose) to the new name. - No behaviour change: the set's file-membership, and the 6/11/105/122 counts it feeds, are unchanged (122/11/105 following #890's merge, which added pcapkit/const/pcapng/tls_key_label.py to both). Build/test: tests/const/test_const_registry_protocol.py (run=74, failures=0, errors=0) and tests/const/test_const_enum_builtin_parity.py (run=33, failures=0, errors=0), both via the worktree's own pcapkit.
…L_BESPOKE (#894) - test_default_still_resolves_when_registered_str called its str-valued case "synthetic, since no shipped aenum.StrEnum registry mixes in the base yet". Measured on main (walking pcapkit.const, filtering for EnumRegistry+str subclasses): ten already do (Command, FEATCode, Method, OptionType, TLSKeyLabel, AppType and its four transport subclasses). Rewrote the docstring to say so instead of the stale claim. - EXCLUDED_STILL_BESPOKE described its members as overriding the base's generic implementation, plus TransportProtocol for never mixing in the base at all. In fact most entries do mix in EnumRegistry -- the set's real, operative meaning is "outside this file's IntEnum-only historical census, anchored at commit 05468a0". Renamed to EXCLUDED_FROM_INTENUM_CENSUS and re-grouped its eleven entries by which of three reasons applies: not an IntEnum, overrides the base, or never mixes in the base (apptype.py carries two of the three, in one file). return_code.py/status_code.py's actual override is a custom __new__ plus _unregistered_member, not get()/register() -- their get/get_all/ register/register_alias all resolve to the base's own implementation; ResponseKind and GroupingInformation, co-resident in return_code.py, override nothing at all. Updated the other four EXCLUDED_STILL_BESPOKE references (one behavioural, three prose) to the new name. - No behaviour change: the set's file-membership, and the 6/11/105/122 counts it feeds, are unchanged (122/11/105 following #890's merge, which added pcapkit/const/pcapng/tls_key_label.py to both). Build/test: tests/const/test_const_registry_protocol.py (run=74, failures=0, errors=0) and tests/const/test_const_enum_builtin_parity.py (run=33, failures=0, errors=0), both via the worktree's own pcapkit.
Summary
Closes #886.
TLSKeyLabelmoves from a hand-written class inpcapkit/protocols/misc/pcapng.pyto a generated one at
pcapkit/const/pcapng/tls_key_label.py, crawled from theIANA "TLS SSLKEYLOGFILE Labels" registry (RFC 9850 section 4.2), matching its
const/pcapngsiblings' shape.RSAhas no registry row (NSS-only, removed inNSS 3.34) and is hand-carried by the crawler with its
#883comment keptverbatim. Matching stays by uppercase value, not name, unchanged.
The canonical import path changes, per the owner's ruling on #886 ("go with
(1)");
pcapkit/protocols/misc/pcapng.pynow re-exports the class under its ownname, so
from pcapkit.protocols.misc.pcapng import TLSKeyLabelkeeps working.Two further public-contract effects
breakingalready covers but are worthnaming explicitly:
Base class: the generated class derives from
aenum.StrEnum(matchingevery other
const/pcapngstring registry) instead ofpcapkit.utilities.compat.StrEnum.isinstance/issubclassagainst thecompatclass now returnsFalse.repr,str,format,%-formatting,json.dumps,== 'ECH_SECRET',hash,isinstance(m, str),.value/.nameare all unaffected — checked directly, not assumed.
New API surface: mixing in
EnumRegistryaddsget/get_all/register/register_alias(es), which the hand-written class never had. No lookup pathmints —
T(...),.get(...),.get_all(...),T[...]on an unknown labelall still raise/miss exactly as before — only the explicit
T.register(...)grows the member set, which is the documented
EnumRegistrycontract.Searched for similar pull requests (fix(pcapng): repoint TLSKeyLabel at RFC 9850, add ECH_SECRET/ECH_CONFIG #883 is the related, already-merged one)
Followed the coding style (
pylint/mypy/isortrun against the changed files; no new findings)make testpasses, and a test case covers the changeAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md-- N/A -- changelog centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
refactor— changes neither behaviour nor performanceTest plan
pcapkit.vendor.__main__entry point; byte-identical (sha2569466eef...58446d) both timestests/protocols/misc/test_pcapng_unit.py— 94/94, extended with re-export identity + per-member value pinstests/const/test_const_enum_builtin_parity.py,test_const_enum_lookup.py,test_const_enum_get.py,test_const_enum_no_mint.py,test_const_registry_protocol.py— all green with updated sweep countstests/vendor/test_vendor_missing_body_unit.py,test_vendor_dest_path_unit.py,tests/project/test_public_api.py,test_isort_clean.py— all green