Skip to content

fix(esp): give ESP's errors the ESP: prefix and !r values (#2297) - #2366

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2297-esp-message-prefix
Oct 27, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2297-esp-message-prefix

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — bug fix

Description

Closes #2297.

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.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 27, 2026
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) fix Pull requests that fix a defect (fix: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 27, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 27, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: GOOD TO GO at e26ee2352 (Sonnet).

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 27, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Ready to merge.

Review: GOOD TO GO (Sonnet) at e26ee2352.
CI: Required checks passed, 0 failures (only Sync Status and the non-blocking experimental GraalPy leg still pending).
Ordering leg: protocols clean — 1973 test(s), 0 failure(s), 0 error(s).
Mergeable, 0 unresolved review threads.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.60% (unit tier, Python 3.15, e26ee2352, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19601 881 2620 867 92.12%
pcapkit/corekit 2596 74 818 37 96.51%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 3029 23 1050 25 98.82%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17455 210 4598 178 98.22%
pcapkit/toolkit 914 36 334 10 95.51%
pcapkit/utilities 502 7 144 5 98.14%
pcapkit/vendor 4432 1988 1018 167 51.87%

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

@JarryShaw
JarryShaw merged commit 36def54 into main Oct 27, 2026
68 checks passed
@JarryShaw
JarryShaw deleted the fix/2297-esp-message-prefix branch October 27, 2026 15:00
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 27, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 27, 2026
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.
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) fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(esp): ESP error messages lack the ESP: prefix and mostly print values without !r

1 participant