Repository navigation
#383 — test: first fuzz target on the --pr-diff patch parser - #385
Conversation
Wire cute-dbt's first fuzz target (the Q4 bring-into-shape move) over the
highest-risk untrusted-input surface: the `--pr-diff` unified-diff parser
(`cli::pr_diff::parse_unified_diff`). In CI/PR-review mode arbitrary diff
text is fed in, so this is the realistic adversarial surface.
Harness: bolero on STABLE Rust (MSRV 1.88) — its DefaultEngine mimics
libtest and runs under plain `cargo test`/`cargo nextest`, replaying the
committed corpus AND generating fresh random inputs, with no nightly, no
libFuzzer, and no `cargo-bolero` binary required. Chosen over cargo-fuzz
for exactly that lowest-friction property.
The target asserts the fail-closed contract ("cute-dbt never panics on a
bad diff"): for any byte sequence the parser never panics/hangs, returns
Ok(PrDiff) or Err only, emits a structurally well-formed POD on success
(no embedded newlines in parsed paths/bodies), and is deterministic. A
bounded in-session run of 1,000,000 random iterations + the 14-input seed
corpus surfaced zero crashes — the parser was already fail-closed, so no
parser fix was needed.
- Expose `parse_unified_diff` as `pub(crate)` + a `#[doc(hidden)]`
`cli::fuzz_parse_unified_diff` seam (the pure parser, no `@file` I/O on
the fuzzed path). Not public API; same internal-reach motive as `bdd`.
- Seed corpus committed (regression-files-committed rule) under
tests/fuzz_pr_diff_parser/corpus/ — valid + adversarial shapes (orphan
hunk header, `+++` body line, pure rename, CRLF, malformed/huge ranges,
prose, empty/whitespace).
- All 15 new transitive crates are MIT / MIT-OR-Apache-2.0 (already in
deny.toml's allowlist) — `cargo deny check` stays green, no license
change. multiple-versions stays "warn" per the v0.x policy.
- Non-blocking CI: a separate `fuzz.yml` (workflow_dispatch + weekly cron),
NOT a merge gate and not in branch protection; reuses only actions
already in ci.yml. The cheap corpus replay rides the normal Test job.
- testing.md: Fuzz rung aspirational -> in-progress; Q4 WEAK -> improving;
remaining candidates noted (manifest JSON reader, RFC-4180 CSV parser).
The quality-manifest mirror in ops is a follow-up.
Closes #383
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (20)
📝 WalkthroughWalkthroughA Bolero-based fuzz harness is wired for the Changes--pr-diff fuzz pilot
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Ready to review this PR? Stage has broken it down into 7 individual chapters for you: Chapters generated by Stage for commit e5ac304 on Jun 14, 2026 1:09am UTC. |
📄 Rendered report previewAll golden examples regenerated cleanly. 🟡 Golden examplesCommitted to
🐶 Live dogfood previewThis PR doesn't touch 🧭 Explore previewThe two-page 🟡 Golden exploreThe committed
🐶 Live exploreThis PR doesn't touch ▶ Open ↗ opens the report or explorer in your browser in one The Pages preview may take ~1 min to update after this comment Alternative: GitHub CLI# gh CLI >= 2.63 extracts into ./report-preview-playground/.
gh run download 27484340693 -R breezy-bays-labs/cute-dbt -n report-preview-playground
open report-preview-playground/playground-report.htmlPosted by |
Summary
Wires cute-dbt's first fuzz target (the org's named "single most valuable Q4 move") over the highest-risk untrusted-input surface: the
--pr-diffunified-diff parser (cli::pr_diff::parse_unified_diff). In CI/PR-review mode arbitrary diff text is fed in, so this is the realistic adversarial surface.Closes #383
Toolchain — bolero on STABLE Rust (no nightly, no libFuzzer)
bolerois chosen overcargo-fuzzbecause itsDefaultEnginemimics libtest and runs under plaincargo test/cargo nexteston the crate's MSRV 1.88 — it replays the committedcorpus/and generates fresh random inputs, with no nightly, no libFuzzer, and nocargo-bolerobinary required to exercise the corpus. That lowest-friction property is exactly the AC.What lands
tests/fuzz_pr_diff_parser/main.rs(harness = false, likebdd) drivingbolero::check!().for_each(|bytes: &[u8]| …). It asserts the fail-closed contract ("cute-dbt never panics on a bad diff"): for any byte sequence the parser never panics/hangs, returnsOk(PrDiff)/Erronly, emits a structurally well-formed POD on success (no embedded newlines in parsed paths/bodies), and is deterministic.parse_unified_diff→pub(crate)+ a#[doc(hidden)]cli::fuzz_parse_unified_diffre-export (the pure parser — no@filefilesystem I/O on the fuzzed path). Not public API; same internal-reach motive as thebddtarget. Does not tripnon-mirror-guard(that grepssrc/lib.rsforpub use crate::…::…; this seam lives insrc/cli/mod.rs).tests/fuzz_pr_diff_parser/corpus/per the regression-files-committed rule — valid + adversarial shapes (orphan hunk header,+++body line, pure rename, CRLF, malformed/huge ranges, prose, empty/whitespace)..github/workflows/fuzz.yml(workflow_dispatch+ weekly cron), NOT a merge gate and not in branch protection. Reuses only actions already inci.yml(no new org-allowlist entry). The cheap corpus replay rides the normalTestjob (cargo testbuilds the target; the corpus replays there).aspirational —→ in-progress; Q4WEAK→improving; remaining candidates noted (manifest JSON reader, RFC-4180 CSV parser). The quality-manifest mirror in ops is a follow-up.Bounded-run result
BOLERO_RANDOM_ITERATIONS=1000000+ the 14-input corpus → zero crashes (~277k iters/s, ~3.6s), nocrashes/orhangs/produced. The parser was already fail-closed, so no parser fix was needed (including the@@ … +1,99999999999999999999 @@usize-overflow path, which correctly returnsErr, never panics).Deps + gates
deny.toml's allowlist.cargo deny check: advisories ok, bans ok, licenses ok, sources ok (no license change).multiple-versionsstayswarnper the v0.x policy.cargo fmt --check,cargo clippy --all-targets --locked -- -D warnings,cargo nextest run(2052 passed),RUSTDOCFLAGS=-D warnings cargo doc --no-deps --locked— all green.git status examples/empty). No.featurechange → feature-count mirror untouched.test:prefix → no version bump.🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
--pr-diffpatch parser with validation of edge cases and malformed inputs.Documentation