Repository navigation
feat(mcpx): testsupport/gen core (ChaCha8 streams) + FuzzStripJSONC proof target (#1956) - #2636
Conversation
…roof target (#1956) Approach C core, stdlib only (go.mod untouched): internal/testsupport/gen with the Source interface, ChaCha8 streams keyed by stream(test, name@version) under SHA-256 derivation v1 from #1949, a BytesSource fuzz adapter (big-endian draws, zeros past the end), Lemire Intn, and a size-growing runner (the shrinking substitute). Golden test pins the bytes@1 stream output for a fixed test-vector seed, so a generator-output change can only land as a new version. Proof target: FuzzStripJSONC in internal/config drives StripJSONC through BytesSource, with f.Add seeds plus a seed corpus under testdata/fuzz/ that runs under plain go test; a 15s local -fuzz run (1.33M execs) found no crash. Follow-on work left named on #1956: fuzz targets for codegen.TypeFor, launcher.Expand, settings.ParseBytes, the #1958 registry, and the -fuzz soak job.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ba9a559ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| size := gen.Intn(src, 4096) | ||
| input := gen.Bytes(src, size) |
There was a problem hiding this comment.
Preserve the intended corpus inputs when selecting the size
For the checked-in corpus and f.Add seeds, Intn consumes the first eight payload bytes as a length, so StripJSONC never receives the intended examples. For example, // only a comment becomes a comment followed by NUL padding, the block-comment seed loses its opening /*, and the seven-byte binary seed becomes empty input. This undermines the targeted comment/string edge-case coverage during ordinary go test runs. Derive the size from len(data) without consuming the source, or encode a separate length prefix in every seed so the intended payload reaches the stripper intact.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 65cf3e9: the size is no longer drawn from the source. input := gen.Bytes(src, len(data)) — Bytes over a BytesSource round-trips (pinned by TestBytesSourceReadsZerosPastTheEnd), so every seed/corpus payload now reaches StripJSONC byte-for-byte intact, including // only a comment, the block-comment seed, and the 7-byte binary seed.
Derive the input size from len(data) instead of drawing it from the BytesSource: gen.Intn consumed the first eight payload bytes as a length, so seed-corpus examples never reached StripJSONC intact (Codex P2 finding on PR #2636). Bytes over a BytesSource round-trips, so the full payload now reaches the stripper unchanged.
Implements #1956 Approach C core — queue task 3251. Stdlib only;
go.mod/go.sumuntouched, rapid NOT adopted.internal/testsupport/gen— the generator core:Sourceinterface (Uint64() uint64) — the only draw generators make.root = SHA-256("mcpx-test-seed/v1\0" || seedID),stream(t, g@v) = SHA-256(root || 0 || "g@v" || 0 || t)as the ChaCha8 key. Adding/removing tests never shifts another test's inputs; a generator version bump never shifts another generator.BytesSourcefuzz adapter: big-endian Uint64 draws from a[]byte, zeros past the end, never panics.Intn), per mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test #1949's stability rule — nothing depends onmath/rand/v2Rand-method stability, only on ChaCha8's specified stream.Sizes/Run): sizes double small-to-large, the shrinking substitute — a failure is within 2× of the smallest failing size.Golden stability test pins the exact first draws of the
bytes@1stream for a fixed test-vector seed: if generation output ever changes, the test fails and the change must land as a new generator version, never silently.Proof target —
FuzzStripJSONCininternal/config: fuzz bytes become aBytesSource, the generator draws the input, andStripJSONCmust never panic, never grow its input, and be deterministic.f.Addseeds plus a corpus undertestdata/fuzz/FuzzStripJSONC/run as ordinary tests under plaingo test ./....Verified before pushing (laptop):
go testgreen fortestsupport/genand the fullinternal/configpackage; a 15s-fuzzrun completed 1.33M execs with no crash. Fullgo test ./...runs in CI on this PR.Left as named follow-on work on #1956 (per the packet): fuzz targets for
codegen.TypeFor,launcher.Expand,settings.ParseBytes; the generator registry (#1958); the scheduled-fuzzsoak job (#1985 family).Need help on this PR? Tag
@codesmith-botwith what you need.