Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ post:
- func: "upload coverage"
- func: "upload mo artifacts"
- func: "upload test results"
- func: "upload fuzz artifacts"
- func: "cleanup"

tasks:
Expand Down
26 changes: 26 additions & 0 deletions .evergreen/generated_configs/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,32 @@ functions:
optional: "true"
type: setup

# Upload fuzz artifacts
upload fuzz artifacts:
- command: ec2.assume_role
params:
role_arn: ${assume_role_arn}
type: setup
- command: archive.targz_pack
params:
target: fuzz-native-artifacts.tgz
source_dir: ./
include:
- ./src/fuzz-scratch/**
- command: s3.put
params:
remote_file: ${build_variant}/${revision}/${version_id}/${build_id}/fuzz/${task_id}-${execution}-fuzz-native-artifacts.tar.gz
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
bucket: ${bucket_name}
local_file: fuzz-native-artifacts.tgz
permissions: public-read
content_type: ${content_type|application/x-gzip}
display_name: Fuzz Artifacts - Execution
optional: "true"
type: setup

# Upload mo artifacts
upload mo artifacts:
- command: ec2.assume_role
Expand Down
106 changes: 92 additions & 14 deletions .evergreen/generated_configs/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,27 +208,105 @@ tasks:
# Fuzz tests
- name: fuzz-regression
commands:
- func: run tests
vars:
TEST_NAME: fuzz
SUB_TEST_NAME: regression
UV_PYTHON: "3.13"
- command: subprocess.exec
params:
binary: bash
args:
- .evergreen/scripts/install-dependencies.sh
working_dir: src
type: test
- command: subprocess.exec
params:
binary: uv
args:
- run
- --extra
- test
- python
- -m
- pytest
- test/test_fuzz_shared.py
- -m
- default
working_dir: src
type: test
- command: subprocess.exec
params:
binary: bash
args:
- fuzz/build_native.sh
working_dir: src
type: test
- command: subprocess.exec
params:
binary: bash
args:
- fuzz/run_native.sh
working_dir: src
env:
FUZZ_MAX_TIME: "0"
type: test
tags: [fuzz, fuzz-regression, pr]
- name: fuzz
- name: fuzz-python-full
commands:
- func: run tests
vars:
TEST_NAME: fuzz
SUB_TEST_NAME: fuzz
UV_PYTHON: "3.13"
tags: [fuzz, fuzz-nightly]
- name: fuzz-capture
tags: [fuzz, fuzz-python]
- name: fuzz-native-full
commands:
- func: run tests
vars:
TEST_NAME: fuzz
SUB_TEST_NAME: fuzz
UV_PYTHON: "3.13"
- command: subprocess.exec
params:
binary: bash
args:
- .evergreen/scripts/install-dependencies.sh
working_dir: src
type: test
- command: subprocess.exec
params:
binary: bash
args:
- fuzz/build_native.sh
working_dir: src
type: test
- command: subprocess.exec
params:
binary: bash
args:
- fuzz/run_native.sh
working_dir: src
include_expansions_in_env:
- FUZZ_MAX_TIME
type: test
tags: [fuzz, fuzz-native]
- name: fuzz-corpus-capture
commands:
- command: subprocess.exec
params:
binary: bash
args:
- .evergreen/scripts/install-dependencies.sh
working_dir: src
type: test
- command: subprocess.exec
params:
binary: bash
args:
- fuzz/build_native.sh
working_dir: src
type: test
- command: subprocess.exec
params:
binary: bash
args:
- fuzz/run_native.sh
- fuzz-scratch/corpus
working_dir: src
include_expansions_in_env:
- FUZZ_MAX_TIME
type: test
- command: subprocess.exec
params:
binary: bash
Expand All @@ -242,7 +320,7 @@ tasks:
- AWS_SECRET_ACCESS_KEY
- AWS_SESSION_TOKEN
type: test
tags: [fuzz, fuzz-weekly]
tags: [fuzz, fuzz-corpus-capture]

# Getdata tests
- name: getdata
Expand Down
26 changes: 8 additions & 18 deletions .evergreen/generated_configs/variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,27 +201,17 @@ buildvariants:
AUTH: auth

# Fuzz tests
- name: fuzz-regression-rhel8
- name: fuzzing-rhel8
tasks:
- name: .fuzz-regression
display_name: Fuzz Regression RHEL8
- name: fuzz-regression
- name: fuzz-python-full
- name: fuzz-native-full
- name: fuzz-corpus-capture
batchtime: 10080
display_name: Fuzzing RHEL8
run_on:
- rhel8.10-small
tags: [pr]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm is losing the pr tag intentional?

- name: fuzz-rhel8
tasks:
- name: .fuzz-nightly
display_name: Fuzz RHEL8
run_on:
- rhel8.10-small
- rhel8.7-large
batchtime: 1440
- name: fuzz-capture-rhel8
tasks:
- name: .fuzz-weekly
display_name: Fuzz Capture RHEL8
run_on:
- rhel8.10-small
batchtime: 10080

# Green framework tests
- name: green-gevent-rhel8
Expand Down
25 changes: 15 additions & 10 deletions .evergreen/scripts/capture-fuzz-corpus.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
#!/bin/bash
# PYTHON-6178: capture coverage-increasing inputs from a fuzz run and open
# an automated PR growing fuzz/corpus/. Runs as the last command of the
# weekly "fuzz-capture" task, while the scratch corpus exists; manual
# `evergreen patch --variant fuzz-capture-rhel8 --task fuzz-capture` runs
# capture too.
# weekly fuzz-corpus-capture task, whose fuzzing run is native
# (PYTHON-6169). Manual `evergreen patch --variant fuzzing-capture-rhel8
# --task fuzz-corpus-capture` runs capture too.
set -eu

# Same environment as just.sh: venv on PATH for a modern Python.
. "$(dirname "${BASH_SOURCE:-$0}")/setup-dev-env.sh"

# No new units means no PR, and the github secrets flow is never touched.
uv run --no-sync python fuzz/capture_corpus.py
# The venv python directly: `uv run` re-syncs, which would clobber the
# instrumented extensions the replay validates against. capture_corpus.py
# is stdlib-only, so the venv needs nothing extra.
.venv/bin/python fuzz/capture_corpus.py
if [ -z "$(ls -A fuzz-scratch/capture 2>/dev/null || true)" ]; then
echo "No new fuzz corpus units; nothing to do."
exit 0
fi

# The replay runs the atheris targets, so it must request the fuzz group.
# Replay the captured units natively: each unit as a file argument, so
# libFuzzer runs each exactly once under ASan. Same environment as
# run_native.sh.
ATHERIS_RUNTIME=$(.venv/bin/python -c 'import atheris; print(atheris.path())')/asan_with_fuzzer.so
replay=(fuzz-scratch/capture/*)
for target in fuzz_decode fuzz_decode_all fuzz_is_valid; do
echo "Replaying captured units against ${target}..."
if ! uv run --group fuzz python "fuzz/${target}.py" "${replay[@]}" \
-artifact_prefix="$PWD/fuzz-scratch/" -atheris_runs="${#replay[@]}"
if ! FUZZ_NATIVE=1 PYTHONMALLOC=malloc ASAN_OPTIONS="detect_leaks=0" \
LD_PRELOAD="$ATHERIS_RUNTIME" \
.venv/bin/python "fuzz/${target}.py" "${replay[@]}" \
-artifact_prefix="$PWD/fuzz-scratch/"
then
echo "Captured unit fails ${target}; no corpus PR." >&2
exit 1
Expand Down
Loading
Loading