forked from TrueCloudLab/distribution
Fuzzing: Add 3 fuzzers
Signed-off-by: AdamKorcz <adam@adalogics.com>
This commit is contained in:
parent
01f589cf87
commit
d0ca0c3303
4 changed files with 49 additions and 0 deletions
16
configuration/fuzz.go
Normal file
16
configuration/fuzz.go
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// +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
|
||||||
|
}
|
12
reference/fuzz.go
Normal file
12
reference/fuzz.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// +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
|
||||||
|
}
|
12
registry/api/v2/fuzz.go
Normal file
12
registry/api/v2/fuzz.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// +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
|
||||||
|
}
|
9
script/oss_fuzz_build.sh
Executable file
9
script/oss_fuzz_build.sh
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash -eu
|
||||||
|
|
||||||
|
sed 's/parserFuzzer/ParserFuzzer/g' -i ./configuration/fuzz.go
|
||||||
|
sed 's/fuzzParseNormalizedNamed/FuzzParseNormalizedNamed/g' -i ./reference/fuzz.go
|
||||||
|
sed 's/fuzzParseForwardedHeader/FuzzParseForwardedHeader/g' -i ./registry/api/v2/fuzz.go
|
||||||
|
|
||||||
|
compile_go_fuzzer github.com/distribution/distribution/v3/configuration ParserFuzzer parser_fuzzer
|
||||||
|
compile_go_fuzzer github.com/distribution/distribution/v3/reference FuzzParseNormalizedNamed fuzz_parsed_normalized_named
|
||||||
|
compile_go_fuzzer github.com/distribution/distribution/v3/registry/api/v2 FuzzParseForwardedHeader fuzz_parse_forwarded_header
|
Loading…
Reference in a new issue