-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Summary
Add a thin Atheris wrapper using the polyglot pattern to satisfy the OSSF Scorecard Fuzzing check. The Scorecard check only recognizes import atheris for Python fuzzing — Hypothesis alone scores 0/10 despite providing genuine property-based testing value. This issue creates a bridge between the Hypothesis test infrastructure (Phase 1) and Scorecard's detection requirements.
Context
This is Phase 3 of the Python Security Testing & Fuzzing Initiative.
OSSF Scorecard Fuzzing Detection Pipeline
Scorecard uses a three-phase detection pipeline with binary scoring (any fuzz detection = 10/10):
.clusterfuzzlite/Dockerfilewith non-comment contentgoogle/oss-fuzzproject registration- Language-specific import patterns — for Python: only
import atheris
Hypothesis is recognized for Haskell (QuickCheck), JavaScript (fast-check), C# (FsCheck), Erlang (eqc), and others — but not for Python. This is a known gap in Scorecard's detection.
Prominent Language Filter
Scorecard only scans "prominent" languages (LoC >= 25% of average). Python may or may not meet the threshold in this predominantly Markdown/PowerShell/YAML repository.
Implementation
Polyglot Pattern
Create a single Python file that works both as a pytest property test AND as an Atheris fuzz target:
"""Polyglot fuzz harness: runs as Hypothesis property test in CI, Atheris fuzz target for Scorecard."""
import sys
try:
import atheris
FUZZING = True
except ImportError:
FUZZING = False
from hypothesis import given, settings
import hypothesis.strategies as st
yaml_values = st.recursive(
st.none() | st.booleans() | st.integers() | st.floats(allow_nan=False) | st.text(),
lambda children: st.lists(children) | st.dictionaries(st.text(), children),
max_leaves=50,
)
@given(data=yaml_values)
@settings(max_examples=500)
def test_parse_yaml_input(data):
"""Polyglot: runs as Hypothesis property test or Atheris fuzz target."""
# Property test logic here — reuses strategies from Phase 1
...
if FUZZING:
atheris.Setup(sys.argv, atheris.instrument_func(test_parse_yaml_input))
atheris.Fuzz()File Location
.github/skills/experimental/powerpoint/tests/fuzz_harness.py — placed in the test directory to be discovered by Scorecard's file scanning.
Dependency
atheris should be an optional dependency (not required for CI):
[dependency-groups]
fuzz = [
"atheris>=2.3.0",
]Dependencies
- Depends on: Hypothesis property tests (Phase 1) — reuses strategies and property definitions
- Related: Contribute Hypothesis detection to ossf/scorecard (upstream alternative)
RPI Framework
task-researcher
- Confirm Scorecard's file scanning scope for this repository (does it scan
.github/skills/subtrees?) - Verify the prominent language filter threshold for Python in this repo
- Test whether
import atherisin a try/except block satisfies Scorecard's regex detection - Check Atheris compatibility with Python >=3.11 and the project's test infrastructure
task-planner
- Design the polyglot harness to maximize reuse of Phase 1 Hypothesis strategies
- Determine file placement that satisfies Scorecard scanning
- Plan Atheris as an optional dependency (not required for CI)
- Evaluate if Phase 1 completion is a hard prerequisite or if a minimal harness can be created independently
task-implementor
- Create the polyglot fuzz harness file
- Add
atheris>=2.3.0as an optional dependency group - Verify the harness works as a standalone pytest test (Hypothesis mode)
- Verify Scorecard detection by checking the
import atherispattern match - Document the polyglot pattern and its purpose
Acceptance Criteria
- A Python file containing
import atherisexists in a location scanned by Scorecard - The file works as a valid pytest test when Atheris is not installed (Hypothesis-only mode)
- The file works as an Atheris fuzz target when Atheris is installed
- Atheris is an optional dependency, not required for standard CI
- The polyglot harness reuses Hypothesis strategies from Phase 1 property tests
- OSSF Scorecard Fuzzing check detects the Atheris import (verified via local Scorecard run or manual regex check)
- The harness is documented with its dual-mode purpose