Repository navigation
fix(esp): give ESP's errors the ESP: prefix and !r values (#2297) - #2366
Merged
Merged
Conversation
No ProtocolError in pcapkit.protocols.internet.esp carried the
"<prefix>: <lowercase description>: ... {value!r}" form #2232 and #2257
gave Ethernet, PCAP-NG and ARP: none had an "ESP:" prefix, some put
"ESP" mid-sentence, and most printed the value bare.
Every message raised by _resolve, CipherSuite.get, IntegritySuite.get,
SecurityAssociation (SPI, destination, AEAD plus integrity, ICV length,
compute_icv, decrypt, encrypt, _split_key), ESPContext.register and
ESP.make now reads "ESP: <description>: ...", with the offending value
in !r form. SecurityAssociation.unavailable gives the same prefixed
reason. The traceback quoted in the module docstring and esp.rst follows.
Test: ESPErrorMessageTests pins each message whole; the HAS_CRYPTO gate
count in test_tier_guard rises by its one gated test.
Owner
Author
|
Review: GOOD TO GO at
|
Owner
Author
|
Ready to merge. Review: GOOD TO GO (Sonnet) at |
Contributor
|
Coverage: 91.60% (unit tier, Python 3.15,
Per-file detail: the |
JarryShaw
added a commit
that referenced
this pull request
Oct 28, 2026
…rotocol (#2411) #2366 (fixing #2297) put the house `ESP: <lowercase description>` prefix on `ESP.make`'s ProtocolError messages and on `SecurityAssociation.unavailable`, but eight sites were outside its checklist. The same condition therefore read two ways depending on the direction it was hit from -- `make` said `ESP: no security association for SPI 0x...`, `read` said `no security association for SPI 0x...`. - esp.py `ESP._read_trailer` (a staticmethod, so the prefix is spelled literally, as every `SecurityAssociation` site does): the plaintext-too-short diagnostic, the pad-length-beyond-the-plaintext one, and the padding-pattern one, which is both returned and warned with. - esp.py `ESP.read` (an instance method, so `{self.alias}:`, as `ESP.make`): the NO_SA, TRUNCATED, separate-integrity AUTH_FAILED and AEAD-tag AUTH_FAILED messages, surfaced as `esp.error`. - esp.py `SecurityAssociation.__init__`: the short-integrity-key warning. `warn` reports the caller's frame rather than the protocol, so the message text is the only thing naming ESP -- it needs the prefix more than the exceptions do, not less. - test_tier_guard.py `DependencyGateFalsifiabilityTests .test_removing_crypto_from_the_test_job_is_caught`: the new module is the second to carry a `HAS_CRYPTO` gate, so it joins that test's expected set of gated modules and its `describe_gap` location assertions. #2324 dropped this test's `len(gap.gates)` pin and kept the set equality as the structural claim, so the fix is to extend the set rather than to loosen it. Two messages were reworded rather than only prefixed, to avoid `ESP: ESP payload ...` and `ESP: decrypted ESP payload ...`, and the three that read as `<thing> for SPI x does/declares y` were turned into the `description: detail` house form. Every substring the existing tests match on is preserved. Test: tests/protocols/internet/test_esp_message_prefix_2411_unit.py (new, 13 tests, every message pinned whole rather than by substring -- matching fragments is why the omission survived #2366). Confirmed 10 failed / 3 passed against unpatched esp.py, each failure a missing prefix; the 3 that passed are the controls that assert the guards did not widen. All but one of the new tests runs without `cryptography`: an ENCR_NULL SA reaches the trailer and separate-integrity paths on hmac and hashlib alone. tests/test_tier_guard.py in full: 135 passed / 2497 subtests / 0 failed. tests/ in full, after `examples/generators/make_samples.py`: 6776 passed / 118 skipped / 101828 subtests / 0 failed. Fixes #2411.
JarryShaw
added a commit
that referenced
this pull request
Oct 28, 2026
…rotocol (#2411) (#2413) #2366 (fixing #2297) put the house `ESP: <lowercase description>` prefix on `ESP.make`'s ProtocolError messages and on `SecurityAssociation.unavailable`, but eight sites were outside its checklist. The same condition therefore read two ways depending on the direction it was hit from -- `make` said `ESP: no security association for SPI 0x...`, `read` said `no security association for SPI 0x...`. - esp.py `ESP._read_trailer` (a staticmethod, so the prefix is spelled literally, as every `SecurityAssociation` site does): the plaintext-too-short diagnostic, the pad-length-beyond-the-plaintext one, and the padding-pattern one, which is both returned and warned with. - esp.py `ESP.read` (an instance method, so `{self.alias}:`, as `ESP.make`): the NO_SA, TRUNCATED, separate-integrity AUTH_FAILED and AEAD-tag AUTH_FAILED messages, surfaced as `esp.error`. - esp.py `SecurityAssociation.__init__`: the short-integrity-key warning. `warn` reports the caller's frame rather than the protocol, so the message text is the only thing naming ESP -- it needs the prefix more than the exceptions do, not less. - test_tier_guard.py `DependencyGateFalsifiabilityTests .test_removing_crypto_from_the_test_job_is_caught`: the new module is the second to carry a `HAS_CRYPTO` gate, so it joins that test's expected set of gated modules and its `describe_gap` location assertions. #2324 dropped this test's `len(gap.gates)` pin and kept the set equality as the structural claim, so the fix is to extend the set rather than to loosen it. Two messages were reworded rather than only prefixed, to avoid `ESP: ESP payload ...` and `ESP: decrypted ESP payload ...`, and the three that read as `<thing> for SPI x does/declares y` were turned into the `description: detail` house form. Every substring the existing tests match on is preserved. Test: tests/protocols/internet/test_esp_message_prefix_2411_unit.py (new, 13 tests, every message pinned whole rather than by substring -- matching fragments is why the omission survived #2366). Confirmed 10 failed / 3 passed against unpatched esp.py, each failure a missing prefix; the 3 that passed are the controls that assert the guards did not widen. All but one of the new tests runs without `cryptography`: an ENCR_NULL SA reaches the trailer and separate-integrity paths on hmac and hashlib alone. tests/test_tier_guard.py in full: 135 passed / 2497 subtests / 0 failed. tests/ in full, after `examples/generators/make_samples.py`: 6776 passed / 118 skipped / 101828 subtests / 0 failed. Fixes #2411.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix — bug fixDescription
Closes #2297.
ESP: <description>: {value!r}— for exampleinvalid SPI: -1becomesESP: invalid SPI: -1— matching the house form used across fix(ethernet,pcapng): reject a non-string MAC or EUI address (#2222) #2232/fix(arp): prefix the hardware-address messages and reject a bool with ProtocolError (#2256) #2257/fix(http): HTTP version, data and start-line messages lack the HTTP: prefix #2298/fix(interface): reassembly, trace and engine-fallback messages break the house form #2303.origin/main. Passing on the rebased head (179 passed across the ESP, docstring-contract and tier-guard tests).len(gap.gates)pin intests/test_tier_guard.py, since test: tests pin counts of registry members, table entries and source occurrences #2324's{gate.module for gate in gap.gates}set-equality check already covers the new HAS_CRYPTO gate without a count.