Skip to content

Commit 5c2a23e

Browse files
authored
Merge branch 'isc-projects:master' into master
2 parents 92ab16a + 6022284 commit 5c2a23e

File tree

1,919 files changed

+265883
-42134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,919 files changed

+265883
-42134
lines changed

.clusterfuzzlite/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM registry.gitlab.isc.org/isc-projects/kea:fuzz-latest
2+
3+
# Copy repo and link build.sh so that it runs from a location relative to the Kea repo.
4+
WORKDIR "${SRC}"
5+
COPY . "${SRC}/kea"
6+
RUN ln -s "${SRC}/kea/.clusterfuzzlite/build.sh" "${SRC}/build.sh"

.clusterfuzzlite/build.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash -eu
2+
3+
# https://reports.kea.isc.org/new-fuzzer.html
4+
5+
script_path="$(dirname "$(readlink -f "${0}")")"
6+
cd "${script_path}/.."
7+
8+
# Use a wrapper function to allow "return 1" instead of "exit 1" which may have
9+
# unforeseen consequences in case this script is sourced.
10+
install_kea() {
11+
# ccache
12+
export CCACHE_DIR=/cache
13+
export PATH="/usr/lib/ccache:$PATH"
14+
export KEA_BUILD_DIR="${KEA_BUILD_DIR-/builds/isc-projects/kea}"
15+
16+
cxxflags=
17+
autoreconf -i
18+
if test "${SANITIZER}" = 'none'; then
19+
cxxflags="${cxxflags} -fno-sanitize=all"
20+
enable_fuzzing='--enable-fuzzing'
21+
else
22+
cxxflags="${cxxflags} -fsanitize=${SANITIZER}"
23+
enable_fuzzing='--enable-fuzzing=ci'
24+
fi
25+
export CXXFLAGS="${cxxflags}"
26+
export LDFLAGS='-L/usr/lib/gcc/x86_64-linux-gnu/9 -lstdc++fs'
27+
if ! ./configure --enable-boost-headers-only --prefix='/opt/kea' "${enable_fuzzing}" --with-gtest=/usr/src/googletest/googletest; then
28+
printf './configure failed. Here is config.log:\n'
29+
cat config.log
30+
return 1
31+
fi
32+
make -j "$(nproc)"
33+
make install
34+
35+
# Copy internal libraries.
36+
# SC2156 (warning): Injecting filenames is fragile and insecure. Use parameters.
37+
# shellcheck disable=SC2156
38+
find "/opt/kea/lib" -mindepth 1 -maxdepth 1 -not -type d -exec sh -c "cp {} ${KEA_BUILD_DIR}" ';'
39+
40+
# Copy the binaries.
41+
for fuzzer in fuzz_config_kea_dhcp4 fuzz_http_endpoint_kea_dhcp4 fuzz_packets_kea_dhcp4 fuzz_unix_socket_kea_dhcp4 \
42+
fuzz_config_kea_dhcp6 fuzz_http_endpoint_kea_dhcp6 fuzz_packets_kea_dhcp6 fuzz_unix_socket_kea_dhcp6 \
43+
; do
44+
cp "/opt/kea/sbin/${fuzzer}" "${OUT}/${fuzzer}"
45+
# copy all required libraries
46+
echo "ldd ${OUT}/${fuzzer}: "
47+
ldd "${OUT}/${fuzzer}"
48+
EXTENDED_PATH=$(readelf -d "${OUT}/${fuzzer}" | grep 'R.*PATH' | cut -d '[' -f 2 | cut -d ']' -f 1)
49+
patchelf --set-rpath "/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu:${EXTENDED_PATH}" "${OUT}/${fuzzer}"
50+
readelf -d "${OUT}/${fuzzer}" | grep 'R.*PATH' || true
51+
for i in $(ldd "${OUT}/${fuzzer}" | cut -f 2 | cut -d ' ' -f 3); do
52+
cp "${i}" "${KEA_BUILD_DIR}"
53+
done
54+
done
55+
}
56+
57+
install_kea

.clusterfuzzlite/project.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
language: c++

.clusterfuzzlite/run-locally.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
3+
# Change to parent directory, so that the script can be called from anywhere.
4+
parent_path=$(cd "$(dirname "${0}")" && pwd)
5+
cd "${parent_path}" || exit 1
6+
7+
mkdir -p build/out
8+
mkdir -p build/work
9+
10+
cd .. || exit 2
11+
12+
docker build -t kea-fuzzing -f .clusterfuzzlite/Dockerfile .
13+
14+
docker_run() {
15+
docker run \
16+
--interactive \
17+
--privileged \
18+
--platform linux/amd64 \
19+
--rm \
20+
--shm-size=2g \
21+
-e ARCHITECTURE=x86_64 \
22+
-e CIFUZZ=true \
23+
-e FUZZING_ARGS='-rss_limit_mb=8192' \
24+
-e FUZZING_ENGINE=libfuzzer \
25+
-e FUZZING_LANGUAGE=c++ \
26+
-e KEA_BUILD_DIR=/src \
27+
-e SANITIZER=address \
28+
-v "${parent_path}/build/out:/out" \
29+
-v "${parent_path}/build/work:/work" \
30+
kea-fuzzing \
31+
"${@}"
32+
}
33+
34+
docker_run
35+
36+
docker_run compile

.github/workflows/codeql.yml

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: "CodeQL"
22

33
on:
44
push:
5-
branches: [ "master", "ci" ]
5+
branches: [ "master", "ci", "v*_*" ]
66
pull_request:
77
# The branches below must be a subset of the branches above
8-
branches: [ "master", "ci" ]
8+
branches: [ "master", "ci", "v*_*" ]
99
schedule:
1010
- cron: '41 12 * * 0'
1111

@@ -25,51 +25,23 @@ jobs:
2525

2626
steps:
2727
- name: Checkout repository
28-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
2929

30-
# Initializes the CodeQL tools for scanning.
3130
- name: Initialize CodeQL
32-
uses: github/codeql-action/init@v2
31+
uses: github/codeql-action/init@v3
3332
with:
3433
languages: ${{ matrix.language }}
35-
# If you wish to specify custom queries, you can do so here or in a config file.
36-
# By default, queries listed here will override any specified in a config file.
37-
# Prefix the list here with "+" to use these queries and those in the config file.
3834

39-
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
40-
# queries: security-extended,security-and-quality
41-
42-
43-
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
44-
# If this step fails, then you should remove it and run the build manually (see below)
4535
- name: Install dependencies
4636
run: |
47-
./hammer.py prepare-system -p local -w docs,netconf,perfdhcp,shell,tls,unittest
48-
49-
- name: Inspect system CPU
50-
run: cat /proc/cpuinfo
51-
52-
# We want to enable shell, so python files are generated. And CodeQL can
53-
# check them.
37+
./hammer.py prepare-system -p local -w all
5438
55-
# Flags skipped: --with-gssapi --with-freeradius
5639
- name: Build Kea
5740
run: |
58-
autoreconf -i
59-
./configure --enable-shell --enable-debug --enable-generate-docs --enable-generate-messages --enable-generate-parser --enable-logger-checks --enable-perfdhcp --enable-shell --with-libyang --with-libyang-cpp --with-openssl --with-sysrepo --with-sysrepo-cpp
60-
make -j2
61-
62-
# ℹ️ Command-line programs to run using the OS shell.
63-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
64-
65-
# If the Autobuild fails above, remove it and uncomment the following three lines.
66-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
67-
68-
# - run: |
69-
# echo "Run, Build Application using script"
70-
# ./location_of_script_within_repo/buildscript.sh
41+
meson setup build --auto-features enabled -D fuzz=enabled -D tests=enabled -D cpp_std=c++20
42+
meson compile -C build
7143
7244
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@v2
45+
uses: github/codeql-action/analyze@v3
7446
with:
7547
category: "/language:${{matrix.language}}"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ config.h.in~
4646
/logger_lockfile
4747
/report.info
4848
/hammer
49+
50+
/build

0 commit comments

Comments
 (0)