Repository navigation
Conversation
The byte-level grammar the HTTP codec will be built on, per RFC 9112 and RFC 9110: head scan, request/status line, field lines, list parsing, Transfer-Encoding, Content-Length, §6.3 framing, chunked bodies and trailers, and connection disposition. It raises only when a message cannot be represented (not HTTP/1.x, a hard size limit, decode context misuse, a body boundary lost mid-body, or incomplete at close); every other departure from the RFCs decodes by the defined resolution and is reported as a located, aggregated anomaly, so desync and smuggling signatures are surfaced rather than silently resolved. Every rule is an undecorated module-level function so mutmut reaches it, and the module joins the nightly audit. Nothing is exported; the HTTP Protocol class comes next. Host checks are deferred to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CEQCZGyuvpMyZwUbDucF3G
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This branch has not been deployed
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.
Summary
This adds the byte-level HTTP/1.1 grammar (RFC 9112 framing, RFC 9110 fields) that an upcoming
HTTPcodec class will build on. It decodes one complete, already-reassembled message from a buffer. Stream reassembly is out of scope and remains the caller's job.A passive security decoder should surface ambiguity rather than settle it silently. So the grammar raises only when a message cannot be represented:
closed=True, the message is incomplete.Everything else decodes using the RFC's own resolution and is reported as a located, aggregated anomaly. That covers CL+TE, bare LF, obs-fold, whitespace before the colon, Content-Length lists, TE parameters or odd octets, chunk-extension and chunk-line variants, and misplaced framing fields.
Draft: the nightly survivor gate added in #213 currently fails for this module. See Notes.
What's included
src/netprotocols/layer7/http.py:CONTINUE/CLOSE/TUNNEL).HTTPAnomalyKind,HTTPFramingandHTTPDisposition, plus theHTTPAnomalyrecord.tests/test_http.pyhas one vector per rule, including:tchar,VCHAR,HEXDIG, obs-text and quoted-string tables against the ABNF;pyproject.toml(only_mutateand the test selection),mutation.yml,EXPECTED_FILTERSand CONTRIBUTING all gain'netprotocols.layer7.http.x__*'.Verification
uv run ruff checkanduv run ruff format --checkare cleanuv run mypyis clean (strict)uv run pytestpasses;layer7/http.pyhas 100% line and branch coverageCHANGELOG.mdhas an entry under## [Unreleased]Notes
field/offset/expected/actualvalues on raised errors and anomalies, which the tests don't yet assert. The rest are spread across chunk and trailer parsing, start lines and message ends. Those need killing tests, not allowlist entries, before this leaves draft.HOST_*anomalies) move to theHTTPclass PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01CEQCZGyuvpMyZwUbDucF3G
Generated by Claude Code