mirror of
https://github.com/distribution/distribution
synced 2024-11-06 19:35:52 +01:00
Fuzzing: Rewrite existing fuzzers to native go fuzzers
Signed-off-by: AdamKorcz <adam@adalogics.com>
This commit is contained in:
parent
3b8fbf9752
commit
9337b8df66
@ -1,17 +0,0 @@
|
||||
//go:build gofuzz
|
||||
// +build gofuzz
|
||||
|
||||
package configuration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
)
|
||||
|
||||
// ParserFuzzer implements a fuzzer that targets Parser()
|
||||
// Export before building
|
||||
// nolint:deadcode
|
||||
func parserFuzzer(data []byte) int {
|
||||
rd := bytes.NewReader(data)
|
||||
_, _ = Parse(rd)
|
||||
return 1
|
||||
}
|
15
configuration/fuzz_test.go
Normal file
15
configuration/fuzz_test.go
Normal file
@ -0,0 +1,15 @@
|
||||
package configuration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// ParserFuzzer implements a fuzzer that targets Parser()
|
||||
// nolint:deadcode
|
||||
func FuzzConfigurationParse(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
rd := bytes.NewReader(data)
|
||||
_, _ = Parse(rd)
|
||||
})
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
//go:build gofuzz
|
||||
// +build gofuzz
|
||||
|
||||
package reference
|
||||
|
||||
// fuzzParseNormalizedNamed implements a fuzzer
|
||||
// that targets ParseNormalizedNamed
|
||||
// Export before building the fuzzer.
|
||||
// nolint:deadcode
|
||||
func fuzzParseNormalizedNamed(data []byte) int {
|
||||
_, _ = ParseNormalizedNamed(string(data))
|
||||
return 1
|
||||
}
|
14
reference/fuzz_test.go
Normal file
14
reference/fuzz_test.go
Normal file
@ -0,0 +1,14 @@
|
||||
package reference
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// fuzzParseNormalizedNamed implements a fuzzer
|
||||
// that targets ParseNormalizedNamed
|
||||
// nolint:deadcode
|
||||
func FuzzParseNormalizedNamed(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data string) {
|
||||
_, _ = ParseNormalizedNamed(data)
|
||||
})
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
//go:build gofuzz
|
||||
// +build gofuzz
|
||||
|
||||
package v2
|
||||
|
||||
// FuzzParseForwardedHeader implements a fuzzer
|
||||
// that targets parseForwardedHeader
|
||||
// Export before building
|
||||
// nolint:deadcode
|
||||
func fuzzParseForwardedHeader(data []byte) int {
|
||||
_, _, _ = parseForwardedHeader(string(data))
|
||||
return 1
|
||||
}
|
13
registry/api/v2/fuzz_test.go
Normal file
13
registry/api/v2/fuzz_test.go
Normal file
@ -0,0 +1,13 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// FuzzParseForwardedHeader implements a fuzzer
|
||||
// that targets parseForwardedHeader
|
||||
func FuzzParseForwardedHeader(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data string) {
|
||||
_, _, _ = parseForwardedHeader(data)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user