Summary
Evaluate whether dedicated fuzzing tests (e.g., cargo-fuzz / libFuzzer) are appropriate for the project, and implement them if so. v0.3.0 introduces features with significantly more complex parsing and evaluation paths that would benefit from coverage-guided fuzzing.
Current State
unsafe_code = "forbid" is enforced project-wide, so memory corruption is not a concern
- Property tests via
proptest (tests/property_tests.rs) generate random inputs for the parser and evaluator, providing a lightweight form of fuzzing
- 94%+ line coverage with 1,000+ tests across unit, integration, property, and doc tests
- Attack surface is currently small: 4 types, 7 operators, absolute/from-end offsets
v0.3.0 Features That Would Benefit
These features introduce complex, data-dependent parsing and evaluation paths where edge cases are hard to enumerate manually:
- Regex type (
regex/N): Pattern compilation from untrusted magic files, binary-safe matching against arbitrary file content. Malformed patterns, catastrophic backtracking, and binary edge cases are classic fuzzing targets.
- 64-bit integer types (
quad, bequad, lequad): Wider value ranges increase the combinatorial space for comparison and bitwise operators.
- Floating-point types (
float, double, befloat, lefloat): NaN, infinity, subnormals, and endianness handling create subtle edge cases.
- Search type: Variable-length pattern matching with offset ranges.
Suggested Fuzz Targets
- Parser fuzzing: Feed random bytes as magic file content to the parser; verify it never panics
- Evaluator fuzzing: Generate random (rule, buffer) pairs; verify evaluation never panics
- End-to-end fuzzing: Random magic file + random target buffer through
MagicDatabase::evaluate_buffer
Evaluation Criteria
- Does
cargo-fuzz find bugs that proptest misses?
- Is the maintenance overhead (fuzz corpus, CI integration) justified?
- Does this contribute to OSSF Best Practices silver/gold badge requirements?
Acceptance Criteria
Summary
Evaluate whether dedicated fuzzing tests (e.g.,
cargo-fuzz/libFuzzer) are appropriate for the project, and implement them if so. v0.3.0 introduces features with significantly more complex parsing and evaluation paths that would benefit from coverage-guided fuzzing.Current State
unsafe_code = "forbid"is enforced project-wide, so memory corruption is not a concernproptest(tests/property_tests.rs) generate random inputs for the parser and evaluator, providing a lightweight form of fuzzingv0.3.0 Features That Would Benefit
These features introduce complex, data-dependent parsing and evaluation paths where edge cases are hard to enumerate manually:
regex/N): Pattern compilation from untrusted magic files, binary-safe matching against arbitrary file content. Malformed patterns, catastrophic backtracking, and binary edge cases are classic fuzzing targets.quad,bequad,lequad): Wider value ranges increase the combinatorial space for comparison and bitwise operators.float,double,befloat,lefloat): NaN, infinity, subnormals, and endianness handling create subtle edge cases.Suggested Fuzz Targets
MagicDatabase::evaluate_bufferEvaluation Criteria
cargo-fuzzfind bugs thatproptestmisses?Acceptance Criteria
fuzz/directory with at least parser and evaluator targetssrc/builtin_rules.magic