Skip to content

Commit af0226b

Browse files
authored
Merge pull request #577 from pjbgf/fix-fuzz
2 parents 3fc70ff + 03c56e7 commit af0226b

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
hack/libgit2/
1+
build/libgit2/

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARG GO_VERSION=1.17
33
ARG XX_VERSION=1.1.0
44

55
ARG LIBGIT2_IMG=ghcr.io/fluxcd/golang-with-libgit2
6-
ARG LIBGIT2_TAG=libgit2-1.1.1-6
6+
ARG LIBGIT2_TAG=libgit2-1.1.1-7
77

88
FROM ${LIBGIT2_IMG}:${LIBGIT2_TAG} AS libgit2-libs
99

Makefile

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TAG ?= latest
44

55
# Base image used to build the Go binary
66
LIBGIT2_IMG ?= ghcr.io/fluxcd/golang-with-libgit2
7-
LIBGIT2_TAG ?= libgit2-1.1.1-6
7+
LIBGIT2_TAG ?= libgit2-1.1.1-7
88

99
# Allows for defining additional Docker buildx arguments,
1010
# e.g. '--push'.
@@ -234,13 +234,11 @@ fuzz-build: $(LIBGIT2)
234234
rm -rf $(shell pwd)/build/fuzz/
235235
mkdir -p $(shell pwd)/build/fuzz/out/
236236

237-
# TODO: remove mapping of current libgit2 dir and pull binaries from release or build dependency chain on demand.
238237
docker build . --tag local-fuzzing:latest -f tests/fuzz/Dockerfile.builder
239238
docker run --rm \
240239
-e FUZZING_LANGUAGE=go -e SANITIZER=address \
241240
-e CIFUZZ_DEBUG='True' -e OSS_FUZZ_PROJECT_NAME=fluxcd \
242241
-v "$(shell pwd)/build/fuzz/out":/out \
243-
-v "$(shell pwd)/build/libgit2":"/root/go/src/github.com/fluxcd/source-controller/build/libgit2" \
244242
local-fuzzing:latest
245243

246244
fuzz-smoketest: fuzz-build

tests/fuzz/oss_fuzz_build.sh

100644100755
+24-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
set -euxo pipefail
1818

19-
LIBGIT2_TAG="${LIBGIT2_TAG:-libgit2-1.1.1-6}"
19+
LIBGIT2_TAG="${LIBGIT2_TAG:-libgit2-1.1.1-7}"
2020
GOPATH="${GOPATH:-/root/go}"
2121
GO_SRC="${GOPATH}/src"
2222
PROJECT_PATH="github.com/fluxcd/source-controller"
@@ -25,9 +25,31 @@ cd "${GO_SRC}"
2525

2626
pushd "${PROJECT_PATH}"
2727

28+
export TARGET_DIR="$(/bin/pwd)/build/libgit2/${LIBGIT2_TAG}"
29+
30+
# For most cases, libgit2 will already be present.
31+
# The exception being at the oss-fuzz integration.
32+
if [ ! -d "${TARGET_DIR}" ]; then
33+
curl -o output.tar.gz -LO "https://github.com/fluxcd/golang-with-libgit2/releases/download/${LIBGIT2_TAG}/linux-$(uname -m)-libs.tar.gz"
34+
35+
DIR=libgit2-linux
36+
NEW_DIR="$(/bin/pwd)/build/libgit2/${LIBGIT2_TAG}"
37+
INSTALLED_DIR="/home/runner/work/golang-with-libgit2/golang-with-libgit2/build/${DIR}"
38+
39+
mkdir -p ./build/libgit2
40+
41+
tar -xf output.tar.gz
42+
rm output.tar.gz
43+
mv "${DIR}" "${LIBGIT2_TAG}"
44+
mv "${LIBGIT2_TAG}/" "./build/libgit2"
45+
46+
# Update the prefix paths included in the .pc files.
47+
# This will make it easier to update to the location in which they will be used.
48+
find "${NEW_DIR}" -type f -name "*.pc" | xargs -I {} sed -i "s;${INSTALLED_DIR};${NEW_DIR};g" {}
49+
fi
50+
2851
apt-get update && apt-get install -y pkg-config
2952

30-
export TARGET_DIR="$(/bin/pwd)/build/libgit2/${LIBGIT2_TAG}"
3153
export CGO_ENABLED=1
3254
export LIBRARY_PATH="${TARGET_DIR}/lib:${TARGET_DIR}/lib64"
3355
export PKG_CONFIG_PATH="${TARGET_DIR}/lib/pkgconfig:${TARGET_DIR}/lib64/pkgconfig"

0 commit comments

Comments
 (0)