Skip to content

test: add config and priority fuzz tests#2107

Open
YooLCD wants to merge 1 commit intospf13:masterfrom
YooLCD:feat-fuzzing-integration
Open

test: add config and priority fuzz tests#2107
YooLCD wants to merge 1 commit intospf13:masterfrom
YooLCD:feat-fuzzing-integration

Conversation

@YooLCD
Copy link

@YooLCD YooLCD commented Mar 11, 2026

Summary

Adds native Go fuzz targets (Go 1.18+) to improve robustness
and support future OSS-Fuzz integration.

This PR contains the upstream fuzz targets.
The OSS-Fuzz integration PR will follow after this is merged.

Targets

  • FuzzConfigYAML / FuzzConfigJSON / FuzzConfigTOML:
    Parser robustness against arbitrary and malformed input
  • FuzzConfigPriority:
    Verifies Env > Config > Default priority correctness
    under arbitrary inputs

Results

All four fuzzers pass with zero crashes or panics.
Parallel-safe (uses t.Setenv), memory-bounded (1MB limit).

How to run

go test -fuzz=FuzzConfigYAML     -fuzztime=30s
go test -fuzz=FuzzConfigJSON     -fuzztime=30s
go test -fuzz=FuzzConfigTOML     -fuzztime=30s
go test -fuzz=FuzzConfigPriority -fuzztime=30s

Test output

ok  github.com/spf13/viper
ok  github.com/spf13/viper/internal/encoding/dotenv
ok  github.com/spf13/viper/internal/encoding/json
ok  github.com/spf13/viper/internal/encoding/toml
ok  github.com/spf13/viper/internal/encoding/yaml

@CLAassistant
Copy link

CLAassistant commented Mar 11, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants