Add fuzz testing with CI and fix snapshot ID panic#1165
Add fuzz testing with CI and fix snapshot ID panic#1165
Conversation
|
@Kidswiss mind giving this a review? I think it's OK, but I need another eye. What I'm also unsure of is if the commit history is fine in this PR, because it mixes adding fuzzy testing and a fix found in one commit. It might be fine, but I want to have another opinion on that. |
2687880 to
9e17f48
Compare
Add Go native fuzz tests for: - filterAndConvert: snapshot ID processing - BackupOutputParser.out: restic JSON output parsing - JsonArgsArray.UnmarshalJSON: custom JSON unmarshaling The fuzzer immediately found a panic in filterAndConvert() where snapshot.ID[:8] crashes on IDs shorter than 8 characters. Fixed by checking length before slicing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Aarno Aukia <aarno.aukia@vshn.ch>
Run each fuzz target for 60 seconds on PRs and pushes to master. Uses a matrix strategy so targets run in parallel. Short fuzz runs in CI catch regressions; longer runs can be done locally or via oss-fuzz. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Aarno Aukia <aarno.aukia@vshn.ch>
Kidswiss
left a comment
There was a problem hiding this comment.
We're introducing a completely new testing paradigm here. I'm not convinced if the additional complexity outweighs the benefits.
As for the found issue: Restic's ID's are well defined SHA-256 hashes. So if Restic ever returns something shorter than 8 characters, something is really, really wrong. IMHO I'd rather have the runner pod crash and burn instead of silently discarding it. At least then it should pop up in the backup monitoring.
Summary
snapshot.ID[:8]crashes on IDs shorter than 8 charsBug found and fixed
filterAndConvert()inrestic/kubernetes/snapshots.go:103usedsnapshot.ID[:8]without checking length. If restic ever returns a snapshot with an ID shorter than 8 characters, the operator panics. Fixed by checking length before slicing.Fuzz targets
FuzzFilterAndConvertFuzzBackupOutputParserFuzzJsonArgsArrayUnmarshalJSONCI integration
Each fuzz target runs for 60 seconds in parallel via matrix strategy. Short runs catch regressions; longer runs can be done locally (
go test -fuzz=... -fuzztime=5m) or via oss-fuzz.Running locally
Test plan
🤖 Generated with Claude Code