Repository navigation
Conversation
Port the oracle-first approach from markcopy's fuzzing strategy. tests/fuzz_oracle.py holds the checks every parser target applies: only documented exceptions, a time and memory ceiling per input, and no NaN or infinity in the result. tests/test_fuzz_parsers.py adds targets for iXML, RIFF chunk walking, the ASC MHL reader and timeline file: URLs, plus a differential verify target: manifests are written by the test, hashes are taken by the test, and a pass must be backed by a hash taken now. Fixes found by the new targets: - A damaged encoding declaration in a previous ASC MHL manifest raised LookupError (or ValueError for a multi-byte encoding) out of the reader, failing the next ASC MHL report instead of starting a new generation. verify now reports such a manifest as a ParseError. - An iXML frame rate of inf was accepted and reached the sound report. Per-test max_examples now scale with the loaded profile, so --fuzz goes deeper on the PDF, report and flat-mode properties instead of staying at 20 to 40 examples. .hypothesis/ is ignored.
tests/fuzz_surfaces.json classifies every module under src/offloader and src/offloader/reports as a surface that reads or renders outside input, with the Hypothesis tests that fuzz it, or as not a surface, with a reason. A surface with nothing fuzzed, or only part of it, records the gap instead of implying coverage: companions, config, history, installation, longpath, thumbs and volumes have no target yet, and the OTIO documents, ffprobe JSON, control files and copy/verify/cancel sequences are listed as gaps on the modules that own them. tests/test_fuzz_surfaces.py reads files only and fails on an unclassified module, a listed path that is gone, a surface with neither a target nor a gap, a target that is not a @given test, a @given test no surface claims, or a fuzz file missing from the CI soak job's pytest line. Ported from markcopy's fuzz coverage manifest.
tests/test_fuzz_state.py covers the files kept between runs, each against an independent reading of what the bytes mean: read_json returns the value or the default, History keeps every record with a fingerprint, a control file moves the job only on a whole control word, a cancel stays final, and claim never overwrites a file that is not a control word. Fixes found by the new targets: - Deeply nested JSON raised RecursionError out of read_json, so a damaged history.json stopped History from being built. - A file_count of 1e400 raised OverflowError in HistoryEntry.from_dict, dropping the record and the duplicate-card warning its fingerprint gives. config.py and history.py move from gaps to fuzzed surfaces, and the control-file targets are listed under engine.py.
Byte-level fuzz targets move to tests/fuzz_targets.py as bytes -> None functions (braw, riff, ixml, ascmhl, state-json, history, control), so the Hypothesis tests and a replay share one statement of each property. tests/fuzz_corpus/<target>/ holds 32 small seeds generated from the unit-test builders by tests/make_fuzz_seeds.py, including the input behind every bug the fuzzers have found. tests/test_fuzz_corpus.py replays each seed through its target in the ordinary suite, and checks that every corpus folder is a target and every target has seeds. Every fix found so far is also an @example on the target that found it. With the fixes reverted, all regression seeds and examples fail. The corpus is marked binary in .gitattributes, so line-ending normalisation cannot rewrite a seed such as "pause\r\n".
tests/test_fuzz_engine.py runs engine.run end to end on a random card, against destinations that may already hold a good copy, a stale one, a truncated one or a same-size impostor, in each verification mode, with skip and replace on or off. A fault plan fails source reads, destination writes, fsync or promotion, transiently or for good, once or from then on; corrupts a staged copy before its full reread; or cancels the job at an arbitrary progress event. The oracle checks the bytes on disk, not the job's account of them: run raises nothing and finishes within a watchdog, the source is unchanged, no partial survives and nothing else appears, every final-named file is the old one or exactly the source, a different existing file survives unless replace_existing, Verified and Copied destinations hold the source, and a "Verified" job had every destination verified, was not cancelled, saw no fault that kept failing and omitted no file. 1200 offloads at --fuzz depth found no violation. Planting a skipped checksum comparison or a no-op _discard in the engine fails the target at the quick budget. Hypothesis events report which faults fired and which verdicts resulted, so a harness that stops reaching the engine shows up in --hypothesis-show-statistics.
The soak took about 7 minutes on every pull request and ran on Linux only. .github/workflows/fuzz.yml now runs the whole suite under --fuzz nightly and on demand (with an example count input), on ubuntu-latest and windows-latest, with a 60-minute timeout. Hypothesis's example database is carried between runs through actions/cache, so a failure found one night is replayed first the next. Permissions are split: the soak job holds a read-only token, and a separate report job with issues: write opens or comments on a "Fuzz failure: <os>" issue carrying the run link and the falsifying examples with their @reproduce_failure lines. A placeholder log and a !success() upload mean a setup failure or a timeout still reaches an issue. The fuzz profile now prints those blobs and reads its depth from OFFLOADER_FUZZ_EXAMPLES. Pull requests keep every property at 100 examples and the seed corpus replay; the soak job is removed from ci.yml. test_fuzz_surfaces now checks that fuzz.yml is scheduled and runs every fuzz module. The release plan's candidate qualification adds a dispatched soak run and no open "Fuzz failure:" issue.
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.
Brings offloader's fuzzing up to the practices in markcopy's fuzzing strategy, adapted to Hypothesis.
What changes
tests/fuzz_oracle.py): only documented exceptions, a time and memory ceiling per input, no NaN or infinity in a result. Per-test example caps now scale under--fuzzinstead of pinning the soak at 20 to 40.tests/test_fuzz_parsers.py): iXML, RIFF chunk walking, the ASC MHL reader, timelinefile:URLs, and a differentialverifytarget. Manifests and hashes are produced by the test, and a pass must match the files' current bytes.tests/test_fuzz_state.py):read_json, history, and the CLI control file. Covers no guessed cancel, a cancel staying final, andclaimnever overwriting a non-control file.tests/test_fuzz_engine.py): random cards and pre-existing copies. Faults fail reads, writes, fsync or promotion, corrupt a staged copy before its reread, or cancel mid-job. The checks run against the bytes on disk. 1200 offloads at--fuzzdepth: no violation. A planted skipped checksum comparison or a no-op_discardfails the target at the quick budget.tests/fuzz_surfaces.jsonandtests/test_fuzz_surfaces.py): every module is mapped to its fuzz targets or to a stated gap. The test fails on an unclassified module or an unclaimed fuzz test.tests/fuzz_corpus/,tests/fuzz_targets.py,tests/make_fuzz_seeds.py): 32 generated seeds, replayed on every test run. Every fix below is also an@exampleand aregress-*seed..github/workflows/fuzz.yml): runs on Linux and Windows, carries the Hypothesis example database between runs, and opens or updates aFuzz failure: <os>issue from a separate job that holds the only write token. The soak job is removed fromci.yml.Fixes found by the new targets
LookupErrororValueErrorout of the reader, which failed the next ASC MHL report.verifynow reports such a manifest as aParseError.infwas accepted and reached the sound report.RecursionErrorout ofread_json, so a damaged history file stoppedHistoryfrom loading.file_countof1e400dropped the whole record and its duplicate-card warning.Each fix has a regression test that fails without it.
Verification
gh.fuzz.ymlhas not run on GitHub yet. GitHub runs both its schedule and its manualworkflow_dispatchtrigger only once the file is on the default branch, so the first real run happens after this reachesmain. Trigger it by hand then, rather than waiting for the night.Known gaps
These are listed in
tests/fuzz_surfaces.json: companions, installation, longpath, thumbs, volumes, timeline documents, whole ffprobe JSON, source scanning, and pause, paranoid rereads and concurrent instances in the engine fault plan.