[kubernetes] add Kubernetes as a fuzz target (#2949)

This commit is contained in:
Mike Danese 2019-10-15 23:01:56 -07:00 committed by Max Moroz
parent 69a7f1c413
commit 652c83e441
3 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,12 @@
FROM gcr.io/oss-fuzz-base/base-builder
ENV GOPATH /gopath
RUN go get -u -d github.com/dvyukov/go-fuzz/...
RUN go get github.com/ianlancetaylor/demangle
RUN git clone --depth 1 https://github.com/kubernetes/kubernetes.git /gopath/src/k8s.io/kubernetes
WORKDIR /gopath/src/k8s.io/kubernetes
COPY build.sh $SRC/build.sh

37
projects/kubernetes/build.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
# Copyright 2019 Google Inc.
#
# 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.
#
################################################################################
set -o nounset
set -o pipefail
set -o errexit
set -x
# Based on the function from oss-fuzz/projects/golang/build.sh script.
function compile_fuzzer {
local pkg=$1
local function=$2
local fuzzer="${pkg}_${function}"
# Instrument all Go files relevant to this fuzzer
go-fuzz-build -libfuzzer -func "${function}" -o "${fuzzer}.a" "k8s.io/kubernetes/test/fuzz/${pkg}"
# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE "${fuzzer}.a" -lpthread -o "${OUT}/${fuzzer}"
}
compile_fuzzer "yaml" "FuzzSigYaml"
compile_fuzzer "yaml" "FuzzYamlV2"

View File

@ -0,0 +1,6 @@
homepage: "https://kubernetes.io"
primary_contact: "mikedanese@google.com"
fuzzing_engines:
- libfuzzer
sanitizers:
- address