Skip to content

fix: nil guard in Check/Validate + extend fuzz coverage (4 new targets)#295

Open
canolgun-commits wants to merge 1 commit into
Masterminds:masterfrom
canolgun-commits:fix-nil-guard-fuzz-coverage
Open

fix: nil guard in Check/Validate + extend fuzz coverage (4 new targets)#295
canolgun-commits wants to merge 1 commit into
Masterminds:masterfrom
canolgun-commits:fix-nil-guard-fuzz-coverage

Conversation

@canolgun-commits

Copy link
Copy Markdown

Summary

  • Add nil pointer guard to Constraints.Check() and Constraints.Validate() to prevent panic on nil *Version (CWE-476, severity HIGH).
  • Add 4 new Go native fuzz targets with comprehensive invariant checks.
  • Enrich existing FuzzNewVersion and FuzzStrictNewVersion with edge case seeds.

Changes

Fix: Nil guard (constraints.go)

Both Check(v *Version) and Validate(v *Version) now safely return false when v is nil instead of panicking with a nil pointer dereference.

New fuzz targets (fuzz_extended_test.go)

Target Coverage
FuzzVersionCompare Comparison invariants, antisymmetry, nil safety, LessThan/GreaterThan/Equal consistency
FuzzVersionRoundTrip Parse → String → Parse → Equal cycle
FuzzIncOverflow MaxUint64 overflow, panic recovery, increment invariants (patch reset, +1)
FuzzConstraintVersionCheck Constraint × Version integration, nil Check/Validate on invalid inputs

Enriched existing fuzz (version_test.go)

Extended FuzzNewVersion seed corpus with overflow values, round-trip validation, MustParse recovery. Extended FuzzStrictNewVersion with 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.

@
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.
@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant