fix: nil guard in Check/Validate + extend fuzz coverage (4 new targets)#295
Open
canolgun-commits wants to merge 1 commit into
Open
fix: nil guard in Check/Validate + extend fuzz coverage (4 new targets)#295canolgun-commits wants to merge 1 commit into
canolgun-commits wants to merge 1 commit into
Conversation
fix: nil guard in Check/Validate + extend fuzz coverage - Add nil pointer check to Constraints.Check() and Constraints.Validate() to prevent panic on nil *Version (CWE-476, severity HIGH). - Add 4 new native fuzz targets for extended coverage: FuzzVersionCompare — comparison invariants, antisymmetry, nil safety FuzzVersionRoundTrip — Parse→String→Parse→Equal cycle FuzzIncOverflow — MaxUint64 overflow, recovery, increment invariants FuzzConstraintVersionCheck — constraint + version integration, nil safety - Enrich existing FuzzNewVersion/FuzzStrictNewVersion with edge case seeds (overflow values, leading zeros, long strings, round-trip validation). All existing tests pass. No breaking changes. @
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.
Summary
Constraints.Check()andConstraints.Validate()to prevent panic on nil*Version(CWE-476, severity HIGH).FuzzNewVersionandFuzzStrictNewVersionwith edge case seeds.Changes
Fix: Nil guard (constraints.go)
Both
Check(v *Version)andValidate(v *Version)now safely returnfalsewhenvis nil instead of panicking with a nil pointer dereference.New fuzz targets (fuzz_extended_test.go)
FuzzVersionCompareFuzzVersionRoundTripFuzzIncOverflowFuzzConstraintVersionCheckEnriched existing fuzz (version_test.go)
Extended
FuzzNewVersionseed corpus with overflow values, round-trip validation, MustParse recovery. ExtendedFuzzStrictNewVersionwith additional edge cases.Verification
go vet ./... → PASS
go test ./... → PASS
go test -fuzz=FuzzVersionCompare -fuzztime=10s → 164K execs, 0 crashes
No breaking changes. All existing tests pass.