| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## master #1829 +/- ##
==========================================
+ Coverage 99.81% 99.86% +0.05%
==========================================
Files 33 33
Lines 3839 3839
Branches 553 553
==========================================
+ Hits 3832 3834 +2
+ Misses 5 3 -2
Partials 2 2 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
Merging this PR will not alter performance✅ 24 untouched benchmarks Comparing fuzz_incoming (2f17ae8) with master (77f8cf0)1 Footnotes |
Sorry, something went wrong.
|
Previous review — superseded by a newer review below. |
Sorry, something went wrong.
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Sorry, something went wrong.
There was a problem hiding this comment.
Adds reproducible Hypothesis fuzz coverage for DNSIncoming packet parsing.
Changes:
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
Show a summary per file| File | Description |
|---|---|
| tests/test_fuzz_incoming.py | Adds parser fuzz tests and valid-packet controls. |
| tests/conftest.py | Configures Hypothesis profiles and optional collection. |
| pyproject.toml | Adds the Hypothesis development dependency. |
| poetry.lock | Locks Hypothesis and its dependency. |
| .gitignore | Ignores Hypothesis state. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
PR Review — test: add fuzzing coverage for incoming packet parsingAll six findings from the previous round are addressed; what remains are two nits. Merge-ready. The follow-up commit is a clean response rather than a minimal one: the Hypothesis profile registration moved into tests/conftest.py so it is session-wide config instead of a single module's import side effect; the availability guard is now importlib.util.find_spec("hypothesis"), which covers both PyPy and a non-dev install with one condition, and the accompanying comment's stated "why" now matches reality (I verified .github/workflows/ci.yml:60 pins pypy-3.10 and the lock ships only pp311 wheels). MAX_PACKET_SIZE is derived from const._MAX_MSG_ABSOLUTE with the slack explained, _parse now reprs and hashes every returned record, and test_corpus_parses_cleanly gives the suite the positive control it was missing — without it, a regression that made the parser reject everything would have left all six tests green. The poetry.lock version churn flagged last time is gone (lock-version stays at 2.1), and exceptiongroup already carries a python_version == "3.10" marker wide enough for Hypothesis's backport requirement, so the 3.10 matrix entry resolves. I re-verified the two properties the suite leans on: DNSRecord.__eq__ compares wire fields only (_dns.py:283-292, 575-594) and excludes created, so the determinism assertion at line 70 is stable; and _seen_logs is capped by _mark_seen (_logger.py:62), while tests/test_logger.py and tests/test_protocol.py both .clear() it up front, so the fuzz run cannot leak state into them.
✅ Resolved since last review (6)Previously-flagged issues verified fixed
🟢 Suggestions1. `_parse` misses `repr(incoming)` and the production constructor shapetests/test_fuzz_incoming.py:42-55 The helper now touches the returned records (good — that closes the earlier gap), but two surfaces the parser exposes in production are still untouched.
Both are cheap to add: def _parse(data: bytes, scope_id: int | None = None) -> list[DNSRecord]:
incoming = DNSIncoming(data, ("127.0.0.1", 5353), scope_id)
...
repr(incoming)
return answersNote repr(incoming) calls answers() internally, so order it after the existing loop to keep the record-level asserts first. answers = incoming.answers()
assert isinstance(answers, list)
for record in answers:
repr(record)
hash(record)
return answers
tests/test_fuzz_incoming.py:103-105 start = pos % (len(data) - 1) is only safe because every current CORPUS entry is a full multi-record packet. A 1-byte entry gives pos % 0 → ZeroDivisionError; an empty one gives pos % -1 → 0, and then data[1] = ... raises IndexError. Why it matters: the corpus is a shared, growable module global (CORPUS = [*generate_packets(), _nsec_packet()]). The next person adding a deliberately tiny packet — exactly the kind of thing you'd want in a fuzz corpus — gets a crash inside the strategy body rather than a fuzz finding, and the failure will read as a Hypothesis bug rather than a corpus one. Either clamp (start = pos % max(len(data) - 1, 1)) or assert the precondition once next to CORPUS (assert all(len(p) >= 2 for p in CORPUS)). data = bytearray(packet)
start = pos % (len(data) - 1)
data[start] = 0xC0 | (target >> 8)
data[start + 1] = target & 0xFF
Checklist
Automated review by Kōan (Claude) HEAD=2f17ae8 4 min 41s |
Sorry, something went wrong.
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Adds hypothesis based fuzzing for DNSIncoming ahead of planned parser performance work; the constructor contract is that any byte sequence parses or fails quietly with valid = False, never raising.
Details
Test plan