diff --git a/contrib/fuzz/oss_fuzz_build.sh b/contrib/fuzz/oss_fuzz_build.sh index 6ab1f4269..8010b132c 100755 --- a/contrib/fuzz/oss_fuzz_build.sh +++ b/contrib/fuzz/oss_fuzz_build.sh @@ -70,10 +70,10 @@ mv $SRC/containerd/filters/filter_test.go $SRC/containerd/filters/filter_test_fu go get github.com/AdamKorcz/go-118-fuzz-build/utils compile_native_go_fuzzer github.com/containerd/containerd/filters FuzzFiltersParse fuzz_filters_parse compile_native_go_fuzzer github.com/containerd/containerd/pkg/cap FuzzParseProcPIDStatus fuzz_parse_proc_pid_status +compile_native_go_fuzzer github.com/containerd/containerd/platforms FuzzPlatformsParse fuzz_platforms_parse compile_go_fuzzer github.com/containerd/containerd/remotes/docker FuzzFetcher fuzz_fetcher compile_go_fuzzer github.com/containerd/containerd/remotes/docker FuzzParseDockerRef fuzz_parse_docker_ref -compile_go_fuzzer github.com/containerd/containerd/contrib/fuzz FuzzPlatformsParse fuzz_platforms_parse compile_go_fuzzer github.com/containerd/containerd/contrib/fuzz FuzzApply fuzz_apply compile_go_fuzzer github.com/containerd/containerd/contrib/fuzz FuzzImportIndex fuzz_import_index compile_go_fuzzer github.com/containerd/containerd/contrib/fuzz FuzzCSWalk fuzz_cs_walk diff --git a/contrib/fuzz/platforms_fuzzers.go b/contrib/fuzz/platforms_fuzzers.go deleted file mode 100644 index cf418a976..000000000 --- a/contrib/fuzz/platforms_fuzzers.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build gofuzz -// +build gofuzz - -/* - Copyright The containerd Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package fuzz - -import ( - "github.com/containerd/containerd/platforms" -) - -func FuzzPlatformsParse(data []byte) int { - _, err := platforms.Parse(string(data)) - if err != nil { - return 0 - } - return 1 -} diff --git a/platforms/platforms_test.go b/platforms/platforms_test.go index c070ddae1..c2af02178 100644 --- a/platforms/platforms_test.go +++ b/platforms/platforms_test.go @@ -364,3 +364,13 @@ func TestParseSelectorInvalid(t *testing.T) { }) } } + +func FuzzPlatformsParse(f *testing.F) { + f.Add("linux/amd64") + f.Fuzz(func(t *testing.T, s string) { + pf, err := Parse(s) + if err != nil && (pf.OS != "" || pf.Architecture != "") { + t.Errorf("either %+v or %+v must be nil", err, pf) + } + }) +}