Skip to content

Commit 576a858

Browse files
committed
Updates to support easily running OSS-Fuzz using local repo sources
- Updates the fuzzing documentation to include steps for working with locally modified versions of the gitpython repository. - Updates the build.sh script to make the fuzz target search path more specific, reducing the risk of local OSS-Fuzz builds picking up files located outside of where we expect them (for example, in a .venv directory.) - add artifacts produced by local OSS-Fuzz runs to gitignore
1 parent 1bc9a1a commit 576a858

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ output.txt
4747

4848
# Finder metadata
4949
.DS_Store
50+
51+
# Files created by OSS-Fuzz when running locally
52+
fuzz_*.pkg.spec

Diff for: fuzzing/README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ containers.
134134
Set environment variables to simplify command usage:
135135

136136
```shell
137-
export SANITIZER=address # Can be either 'address' or 'undefined'.
138-
export FUZZ_TARGET=fuzz_config # specify the fuzz target without the .py extension.
137+
# $SANITIZER can be either 'address' or 'undefined':
138+
export SANITIZER=address
139+
# specify the fuzz target without the .py extension:
140+
export FUZZ_TARGET=fuzz_config
139141
```
140142

141143
#### Build and Run
@@ -149,6 +151,19 @@ python infra/helper.py build_image gitpython
149151
python infra/helper.py build_fuzzers --sanitizer $SANITIZER gitpython
150152
```
151153

154+
> [!TIP]
155+
> The `build_fuzzers` command above accepts a local file path pointing to your gitpython repository clone as the last
156+
> argument.
157+
> This makes it easy to build fuzz targets you are developing locally in this repository without changing anything in
158+
> the OSS-Fuzz repo!
159+
> For example, if you have cloned this repository (or a fork of it) into: `~/code/GitPython`
160+
> Then running this command would build new or modified fuzz targets using the `~/code/GitPython/fuzzing/fuzz-targets`
161+
> directory:
162+
> ```shell
163+
> python infra/helper.py build_fuzzers --sanitizer $SANITIZER gitpython ~/code/GitPython
164+
> ```
165+
166+
152167
Verify the build of your fuzzers with the optional `check_build` command:
153168
154169
```shell

Diff for: fuzzing/oss-fuzz-scripts/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ find "$SEED_DATA_DIR" \( -name '*_seed_corpus.zip' -o -name '*.options' -o -name
1313
-exec cp {} "$OUT" \;
1414

1515
# Build fuzzers in $OUT.
16-
find "$SRC" -name 'fuzz_*.py' -print0 | while IFS= read -r -d $'\0' fuzz_harness; do
16+
find "$SRC/gitpython/fuzzing" -name 'fuzz_*.py' -print0 | while IFS= read -r -d $'\0' fuzz_harness; do
1717
compile_python_fuzzer "$fuzz_harness"
1818

1919
common_base_dictionary_filename="$SEED_DATA_DIR/__base.dict"

0 commit comments

Comments
 (0)