aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdamKorcz <44787359+AdamKorcz@users.noreply.github.com>2021-03-15 16:44:11 +0000
committerGitHub <noreply@github.com>2021-03-15 09:44:11 -0700
commit3dfcdfa0b2d17b899a6aa8cf6c653f97f5092e34 (patch)
tree2f1c7ae1628cb88417d08a1beba58b6c41e622a2
parent5ca736fe000557115aeb945063298781494d4d04 (diff)
downloadoss-fuzz-3dfcdfa0b2d17b899a6aa8cf6c653f97f5092e34.tar.gz
[runc] Move fuzzers upstream (#5390)
* [runc] Move fuzzers upstream * Experimental fix * Revert
-rw-r--r--projects/runc/Dockerfile6
-rw-r--r--projects/runc/build.sh9
-rw-r--r--projects/runc/configs_fuzzer.go35
-rw-r--r--projects/runc/id_map_fuzzer.go28
-rw-r--r--projects/runc/user_fuzzer.go58
5 files changed, 2 insertions, 134 deletions
diff --git a/projects/runc/Dockerfile b/projects/runc/Dockerfile
index 63e3017f6..78616e91e 100644
--- a/projects/runc/Dockerfile
+++ b/projects/runc/Dockerfile
@@ -16,9 +16,5 @@
FROM gcr.io/oss-fuzz-base/base-builder
RUN git clone --depth 1 https://github.com/opencontainers/runc
-COPY build.sh \
- id_map_fuzzer.go \
- user_fuzzer.go \
- configs_fuzzer.go \
- $SRC/
+COPY build.sh $SRC/
WORKDIR $SRC/runc
diff --git a/projects/runc/build.sh b/projects/runc/build.sh
index 4c30ab5ac..4f0b084d1 100644
--- a/projects/runc/build.sh
+++ b/projects/runc/build.sh
@@ -15,11 +15,4 @@
#
################################################################################
-mv $SRC/id_map_fuzzer.go $SRC/runc/libcontainer/system/
-compile_go_fuzzer ./libcontainer/system Fuzz id_map_fuzzer linux
-
-mv $SRC/user_fuzzer.go $SRC/runc/libcontainer/user
-compile_go_fuzzer ./libcontainer/user Fuzz user_fuzzer
-
-mv $SRC/configs_fuzzer.go $SRC/runc/libcontainer/configs
-compile_go_fuzzer ./libcontainer/configs Fuzz configs_fuzzer
+$SRC/runc/tests/fuzzing/oss_fuzz_build.sh
diff --git a/projects/runc/configs_fuzzer.go b/projects/runc/configs_fuzzer.go
deleted file mode 100644
index d482ba0fa..000000000
--- a/projects/runc/configs_fuzzer.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2021 Google LLC
-//
-// 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 configs
-
-import(
- "fmt"
-)
-
-
-func Fuzz(data []byte) int {
- hookNameList := []string {"prestart",
- "createRuntime",
- "createContainer",
- "startContainer",
- "poststart"}
-
- for _, hookName := range hookNameList {
- hooks := Hooks{}
- _ = hooks.UnmarshalJSON([]byte(fmt.Sprintf(`{"%s" :[%s]}`, hookName, data)))
- }
- return 1
-}
diff --git a/projects/runc/id_map_fuzzer.go b/projects/runc/id_map_fuzzer.go
deleted file mode 100644
index 4d842a4cb..000000000
--- a/projects/runc/id_map_fuzzer.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2021 Google LLC
-//
-// 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 system
-
-import (
- "strings"
- "github.com/opencontainers/runc/libcontainer/user"
-)
-
-
-func Fuzz(data []byte) int {
- uidmap, _ := user.ParseIDMap(strings.NewReader(string(data)))
- _ = UIDMapInUserNS(uidmap)
- return 1
-}
diff --git a/projects/runc/user_fuzzer.go b/projects/runc/user_fuzzer.go
deleted file mode 100644
index b3a2ca71c..000000000
--- a/projects/runc/user_fuzzer.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2021 Google LLC
-//
-// 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 user
-
-import (
- "strings"
- "io"
-)
-
-
-func IsDivisbleBy(n int, divisibleby int) bool {
- return (n % divisibleby) == 0
-}
-
-func Fuzz(data []byte) int {
- if len(data)==0 {
- return -1
- }
- divisible := IsDivisbleBy(len(data), 5)
- if divisible==false {
- return -1
- }
-
- var divided [][]byte
-
- chunkSize := len(data)/5
-
- for i := 0; i < len(data); i += chunkSize {
- end := i + chunkSize
-
- divided = append(divided, data[i:end])
- }
-
- _, _ = ParsePasswdFilter(strings.NewReader(string(divided[0])), nil)
-
- var passwd, group io.Reader
-
- group = strings.NewReader(string(divided[1]))
- _, _ = GetAdditionalGroups([]string{string(divided[2])}, group)
-
-
- passwd = strings.NewReader(string(divided[3]))
- _, _ = GetExecUser(string(divided[4]), nil, passwd, group)
- return 1
-}