Skip to content

Commit 73230e2

Browse files
authored
[codex] add clusterfuzzlite fuzzing lane (#18)
* ci: add clusterfuzzlite fuzzing lanes * fix: wire clusterfuzzlite build entrypoint
1 parent 424df31 commit 73230e2

6 files changed

Lines changed: 134 additions & 0 deletions

File tree

.clusterfuzzlite/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM gcr.io/oss-fuzz-base/base-builder-python
2+
3+
WORKDIR $SRC/fileyard
4+
COPY . $SRC/fileyard
5+
COPY .clusterfuzzlite/build.sh $SRC/build.sh
6+
7+
RUN python3 -m pip install --disable-pip-version-check --upgrade pip==26.0.1 \
8+
&& python3 -m pip install --disable-pip-version-check atheris \
9+
&& python3 -m pip install --disable-pip-version-check .

.clusterfuzzlite/build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
cd "$SRC/fileyard"
5+
6+
python3 -m pip install --disable-pip-version-check atheris
7+
python3 -m pip install --disable-pip-version-check .
8+
9+
compile_python_fuzzer tests/fuzz/fuzz_safe_join.py

.clusterfuzzlite/project.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
homepage: https://github.com/xiaojiou176-open/fileyard
2+
language: python
3+
primary_contact: 125581657+xiaojiou176@users.noreply.github.com
4+
main_repo: https://github.com/xiaojiou176-open/fileyard

.github/workflows/cflite_batch.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: cflite-batch
2+
3+
on:
4+
schedule:
5+
- cron: "20 4 * * 1"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: cflite-batch-${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
run-fuzzers:
17+
timeout-minutes: 30
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
security-events: write
22+
steps:
23+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
24+
with:
25+
clean: true
26+
persist-credentials: false
27+
- name: Build fuzzers
28+
uses: google/clusterfuzzlite/actions/build_fuzzers@82652fb49e77bc29c35da1167bb286e93c6bcc05 # v1
29+
with:
30+
language: python
31+
sanitizer: address
32+
- name: Run batch fuzzing
33+
uses: google/clusterfuzzlite/actions/run_fuzzers@82652fb49e77bc29c35da1167bb286e93c6bcc05 # v1
34+
with:
35+
language: python
36+
sanitizer: address
37+
mode: batch
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
fuzz-seconds: 600

.github/workflows/cflite_pr.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: cflite-pr
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: cflite-pr-${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
run-fuzzers:
17+
timeout-minutes: 20
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
security-events: write
22+
steps:
23+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
24+
with:
25+
clean: true
26+
persist-credentials: false
27+
- name: Build fuzzers
28+
uses: google/clusterfuzzlite/actions/build_fuzzers@82652fb49e77bc29c35da1167bb286e93c6bcc05 # v1
29+
with:
30+
language: python
31+
sanitizer: address
32+
- name: Run PR fuzzing
33+
uses: google/clusterfuzzlite/actions/run_fuzzers@82652fb49e77bc29c35da1167bb286e93c6bcc05 # v1
34+
with:
35+
language: python
36+
sanitizer: address
37+
mode: code-change
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
fuzz-seconds: 300

tests/fuzz/fuzz_safe_join.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
from pathlib import Path
5+
6+
import atheris
7+
8+
with atheris.instrument_imports():
9+
from packages.domain.normalization import safe_join
10+
11+
12+
ROOT = Path("/tmp/fileyard-fuzz-root")
13+
14+
15+
def TestOneInput(data: bytes) -> None:
16+
provider = atheris.FuzzedDataProvider(data)
17+
part_count = provider.ConsumeIntInRange(0, 4)
18+
parts = [provider.ConsumeUnicodeNoSurrogates(32) for _ in range(part_count)]
19+
try:
20+
joined = safe_join(ROOT, *parts)
21+
except ValueError:
22+
return
23+
24+
resolved_root = ROOT.resolve()
25+
assert joined == resolved_root or resolved_root in joined.parents
26+
27+
28+
def main() -> None:
29+
atheris.Setup(sys.argv, TestOneInput)
30+
atheris.Fuzz()
31+
32+
33+
if __name__ == "__main__":
34+
main()

0 commit comments

Comments
 (0)