Visitar URL original
馃敡 chore(test): add opt-in Atheris fuzz harness by gaborbernat 路 Pull Request #3246 路 pypa/virtualenv 路 GitHub
Skip to content

馃敡 chore(test): add opt-in Atheris fuzz harness - #3246

Merged
gaborbernat merged 1 commit into
mainfrom
fuzz-quote-harness
Sep 17, 2026
Merged

gaborbernat merged 1 commit into
mainfrom
fuzz-quote-harness

Conversation

@gaborbernat

Copy link
Copy Markdown
Contributor

OpenSSF Scorecard's Fuzzing check scores 0 for this repo. Its detection only checks for import atheris (or a ClusterFuzzLite/OSS-Fuzz setup) anywhere in the tree, so this adds a real target rather than a token import that would move the number without doing anything.

NushellActivator.quote and PowerShellActivator.quote are hand-rolled escaping schemes over arbitrary strings pulled from paths and prompts: Nushell counts the longest run of # and wraps in one more than that, PowerShell doubles single quotes. Both take untrusted-shaped input, and a broken escape is a correctness bug worth catching, not just a lint target. Each harness in tasks/fuzz_*.py recomputes the expected output from the escaping rule on its own and asserts equality against the real function, so it fails on any scheme violation, not only on a crash. I ran both assertions against 200k+ randomized adversarial strings (embedded quotes, # runs, control characters, Unicode) against the real functions before wiring them into Atheris.

Atheris only ships prebuilt wheels for Linux + CPython 3.12-3.14 - it doesn't build on this machine at all, since Apple Clang doesn't ship libFuzzer. It lives in its own fuzz dependency group with a marker matching that exact combination, so nothing else ever tries to install it or falls into a doomed source build. tox -e fuzz is opt-in and outside env_list, so no existing environment or CI job changes.

@gaborbernat
gaborbernat enabled auto-merge (squash) September 17, 2026 15:30
OpenSSF Scorecard's Fuzzing check scores 0 with no signal in the repo
that any fuzzing happens. Rather than add a token import just to move
the number, this fuzzes two real hand-rolled escaping implementations:
NushellActivator.quote (a `#`-run-counting raw-string scheme) and
PowerShellActivator.quote (single-quote doubling). Both take arbitrary
strings from paths and prompts, and a broken escape is a real
correctness bug, not just a lint target.

Each harness recomputes the expected output from the escaping rule
independently and asserts equality, so it catches actual scheme
violations, not just crashes. Verified the assertions against both
targets with 200k+ randomized adversarial strings before wiring them
into atheris, since atheris itself can't build here (Apple Clang ships
without libFuzzer).

Atheris only ships Linux wheels for CPython 3.12-3.14, so it lives in
its own "fuzz" dependency group, installed nowhere else, with a marker
that skips it entirely outside that combination instead of triggering
a doomed source build. tox -e fuzz is opt-in and not part of env_list,
so nothing changes for any other environment or CI job.
@gaborbernat
gaborbernat merged commit 787d1c9 into main Sep 17, 2026
64 checks passed
@gaborbernat
gaborbernat deleted the fuzz-quote-harness branch September 17, 2026 16:28
@gaborbernat gaborbernat added the security Fixes a vulnerability or hardens the supply chain, CI or release label Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement security Fixes a vulnerability or hardens the supply chain, CI or release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant