Skip to content

Commit 6921117

Browse files
author
Paulo Gomes
committed
libgit2: Remove libgit2 from fuzzers
Signed-off-by: Paulo Gomes <[email protected]>
1 parent 5ffa6a5 commit 6921117

File tree

6 files changed

+5
-231
lines changed

6 files changed

+5
-231
lines changed

tests/fuzz/Dockerfile.builder

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
FROM gcr.io/oss-fuzz-base/base-builder-go
22

3-
RUN apt-get update && apt-get install -y cmake pkg-config
3+
ENV SRC=$GOPATH/src/github.com/fluxcd/source-controller
4+
ENV FLUX_CI=true
45

5-
COPY ./ $GOPATH/src/github.com/fluxcd/source-controller/
6-
COPY ./tests/fuzz/oss_fuzz_build.sh $SRC/build.sh
7-
COPY tests/fuzz/compile_native_go_fuzzer /usr/local/bin/
6+
COPY ./ $SRC
7+
RUN wget https://raw.githubusercontent.com/google/oss-fuzz/master/projects/fluxcd/build.sh -O $SRC/build.sh
88

99
WORKDIR $SRC

tests/fuzz/compile_native_go_fuzzer

Lines changed: 0 additions & 62 deletions
This file was deleted.

tests/fuzz/oss_fuzz_build.sh

Lines changed: 0 additions & 80 deletions
This file was deleted.

tests/fuzz/oss_fuzz_postbuild.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/fuzz/oss_fuzz_prebuild.sh

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,3 @@ set -euxo pipefail
2323
# for traversing into ascending dirs, therefore we copy those contents here:
2424
mkdir -p controllers/testdata/crd
2525
cp config/crd/bases/*.yaml controllers/testdata/crd/
26-
27-
# libgit2, cmake and pkg-config are requirements to support libgit2.
28-
LIBGIT2_TAG="${LIBGIT2_TAG:-v0.4.0}"
29-
30-
# Avoid updating apt get and installing dependencies, if they are already in place.
31-
if (! command -v cmake &> /dev/null) || (! command -v pkg-config &> /dev/null) then
32-
apt-get update && apt-get install -y cmake pkg-config
33-
fi
34-
35-
export TARGET_DIR="$(/bin/pwd)/build/libgit2/${LIBGIT2_TAG}"
36-
37-
# For most cases, libgit2 will already be present.
38-
# The exception being at the oss-fuzz integration.
39-
if [ ! -d "${TARGET_DIR}" ]; then
40-
curl --connect-timeout 2 --retry 3 --retry-delay 1 --retry-max-time 30 \
41-
-o output.tar.gz -LO "https://github.com/fluxcd/golang-with-libgit2/releases/download/${LIBGIT2_TAG}/linux-$(uname -m)-libgit2-only.tar.gz"
42-
43-
DIR=linux-libgit2-only
44-
NEW_DIR="$(/bin/pwd)/build/libgit2/${LIBGIT2_TAG}"
45-
INSTALLED_DIR="/home/runner/work/golang-with-libgit2/golang-with-libgit2/build/${DIR}"
46-
47-
mkdir -p ./build/libgit2
48-
49-
tar -xf output.tar.gz
50-
rm output.tar.gz
51-
mv "${DIR}" "${LIBGIT2_TAG}"
52-
mv "${LIBGIT2_TAG}/" "./build/libgit2"
53-
54-
# Update the prefix paths included in the .pc files.
55-
# This will make it easier to update to the location in which they will be used.
56-
find "${NEW_DIR}" -type f -name "*.pc" | xargs -I {} sed -i "s;${INSTALLED_DIR};${NEW_DIR};g" {}
57-
fi
58-
59-
export CGO_ENABLED=1
60-
export LIBRARY_PATH="${TARGET_DIR}/lib"
61-
export PKG_CONFIG_PATH="${TARGET_DIR}/lib/pkgconfig"
62-
export CGO_CFLAGS="-I${TARGET_DIR}/include"
63-
export CGO_LDFLAGS="$(pkg-config --libs --static --cflags libgit2)"
64-
65-
# Temporary hack whilst libgit2 is still in use.
66-
# Enables the fuzzing compilation to link libgit2.
67-
#
68-
# After building the fuzzers, the value of
69-
# LIB_FUZZING_ENGINE is reset to what it was before
70-
# it to avoid side effects onto other repositories.
71-
#
72-
# For context refer to:
73-
# https://github.com/google/oss-fuzz/pull/9063
74-
export PRE_LIB_FUZZING_ENGINE="${LIB_FUZZING_ENGINE}"
75-
76-
export LIB_FUZZING_ENGINE="${LIB_FUZZING_ENGINE} -Wl,--start-group ${TARGET_DIR}/lib/libgit2.a"

tests/fuzz/oss_fuzz_run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
set -euxo pipefail
1818

1919
# run each fuzzer once to ensure they are working properly
20-
find /out -type f -name "fuzz*" -exec echo {} -runs=1 \; | bash -e
20+
find /out -type f -iname "fuzz*" -exec echo {} -runs=1 \; | bash -e

0 commit comments

Comments
 (0)