fix: add HTTP parse error counter and surface in summary (#17)#27
Merged
fix: add HTTP parse error counter and surface in summary (#17)#27
Conversation
Covers return type change, aggregate counter, summarize() output, TooManyHeaders finding (T1499.002), and test plan.
4 tasks: return type change, error handling + finding, summarize output, comprehensive test suite (6 new tests).
- Add no-finding assertions to Token error tests (request + response) - Add TooManyHeaders test for response path (validates evidence string) - Add multi-error accumulation test (verifies counter > 1)
There was a problem hiding this comment.
Pull request overview
This PR enhances the HTTP stream analyzer to preserve httparse::Error variants, track an aggregate parse-error counter, and surface that counter in summarize(), with a specific security Finding emitted for TooManyHeaders (DoS/header-flood signal).
Changes:
- Change
parse_one_request/parse_one_responseto returnResult<_, httparse::Error>instead of collapsing errors to(). - Add
parse_errors: u64toHttpAnalyzer, expose it viaparse_error_count(), and include it insummarize()detail output. - Generate an
Anomalyfinding forhttparse::Error::TooManyHeaders; add tests covering counter behavior and the finding.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/analyzer/http.rs |
Preserve httparse::Error, increment/emit parse-error signals, and surface parse_errors in summary output. |
tests/http_analyzer_tests.rs |
Add targeted tests for parse-error counting, summary surfacing, TooManyHeaders finding, and recovery behavior. |
docs/superpowers/specs/2026-04-06-http-parse-error-design.md |
Spec describing the intended behavior and rationale for parse error handling. |
docs/superpowers/plans/2026-04-06-http-parse-error.md |
Implementation plan/checklist for the change set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
After a successful header parse, remaining body bytes would be re-parsed as HTTP and inflate parse_errors on normal traffic. Add had_success flag to suppress counting errors that follow a successful parse in the same call (body-byte-induced). Update spec with design decision.
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
parse_one_request/parse_one_responsereturn type fromResult<_, ()>toResult<_, httparse::Error>to preserve error variant informationparse_errors: u64counter toHttpAnalyzer, surfaced insummarize()outputFindingforhttparse::Error::TooManyHeaders(Anomaly, Inconclusive, Medium confidence, MITRE T1499.002 — Service Exhaustion Flood)Closes #17
Test plan
test_parse_error_increments_counter— malformed request increments counter, no finding generatedtest_parse_error_in_summarize— counter appears in summarize() detail maptest_too_many_headers_generates_finding— 97-header request triggers finding with correct fieldstest_too_many_headers_in_response_generates_finding— response path finding with "response" evidencetest_parse_error_in_response— malformed response increments counter, no findingtest_parse_error_clears_buffer_and_continues— buffer cleared on error, subsequent valid request parsestest_multiple_parse_errors_accumulate— counter correctly accumulates across multiple errorstest_normal_request_no_parse_errors— valid request: zero errors, no findings