test: add fuzzing coverage for incoming packet parsing by bdraco · Pull Request #1829 · python-zeroconf/python-zeroconf · GitHub
Skip to content

test: add fuzzing coverage for incoming packet parsing - #1829

Merged
bdraco merged 3 commits into
masterfrom
fuzz_incoming
Aug 28, 2026
Merged

bdraco merged 3 commits into
masterfrom
fuzz_incoming

Conversation

@bdraco

@bdraco bdraco commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

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

  • new tests/test_fuzz_incoming.py covers raw garbage, mutated and truncated valid packets, spliced compression pointers, adversarial name sections built from label and pointer tokens, and NSEC bitmap mutations; every parsed record is also touched via repr and hash, and a positive control pins that the corpus itself parses fully
  • the CI profile is derandomized with bounded examples so runs stay fast and reproducible, making CI a fixed regression suite; the actual exploration happens through HYPOTHESIS_PROFILE=long deep runs, which are manual for now
  • hypothesis joins the dev dependency group; .hypothesis/ is gitignored
  • verified on both the compiled extension and the pure python fallback; a 300k example deep run passed clean

Test plan

  • poetry run pytest tests passes, 490 passed
  • fuzz file passes against the pure python path with the extensions removed
  • HYPOTHESIS_PROFILE=long run, 50k examples per test, no failures

@codecov

codecov Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

@codspeed

codspeed Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing fuzz_incoming (2f17ae8) with master (77f8cf0)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (228902a) during the generation of this report, so 77f8cf0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@bdraco
bdraco marked this pull request as ready for review August 28, 2026 20:56
@bluetoothbot

bluetoothbot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Previous review — superseded by a newer review below.

@bluetoothbot bluetoothbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

@bdraco bdraco mentioned this pull request Aug 28, 2026
5 tasks done

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds reproducible Hypothesis fuzz coverage for DNSIncoming packet parsing.

Changes:

  • Tests malformed, mutated, truncated, compressed-name, and NSEC inputs.
  • Configures bounded CI and extended local fuzzing profiles.
  • Adds Hypothesis and ignores its generated state.

Reviewed 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.

@bluetoothbot

Copy link
Copy Markdown
Contributor

@bluetoothbot bluetoothbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

@bdraco
bdraco merged commit 868391c into master Aug 28, 2026
39 checks passed
@bdraco
bdraco deleted the fuzz_incoming branch August 28, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants