2023-10-08 15:34:37 +00:00
|
|
|
name: Fuzzing
|
|
|
|
|
|
|
|
# spell-checker:ignore fuzzer
|
|
|
|
|
|
|
|
on: [push, pull_request]
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
|
|
|
|
# End the current execution if there is a new changeset in the PR.
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
|
|
|
|
jobs:
|
2023-10-31 08:08:40 +00:00
|
|
|
fuzz-build:
|
|
|
|
name: Build the fuzzers
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: dtolnay/rust-toolchain@nightly
|
|
|
|
- name: Install `cargo-fuzz`
|
|
|
|
run: cargo install cargo-fuzz
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
with:
|
|
|
|
shared-key: "cargo-fuzz-cache-key"
|
|
|
|
cache-directories: "fuzz/target"
|
|
|
|
- name: Run `cargo-fuzz build`
|
|
|
|
run: cargo +nightly fuzz build
|
|
|
|
|
|
|
|
fuzz-run:
|
|
|
|
needs: fuzz-build
|
2023-10-08 15:34:37 +00:00
|
|
|
name: Run the fuzzers
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
RUN_FOR: 60
|
2023-10-31 08:08:40 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
test-target:
|
2023-11-20 21:17:57 +00:00
|
|
|
- { name: fuzz_test, should_pass: true }
|
|
|
|
# https://github.com/uutils/coreutils/issues/5311
|
|
|
|
- { name: fuzz_date, should_pass: false }
|
|
|
|
- { name: fuzz_expr, should_pass: true }
|
2023-11-21 11:38:12 +00:00
|
|
|
- { name: fuzz_printf, should_pass: false }
|
2023-11-29 13:11:43 +00:00
|
|
|
- { name: fuzz_echo, should_pass: false }
|
2023-11-20 21:17:57 +00:00
|
|
|
- { name: fuzz_parse_glob, should_pass: true }
|
|
|
|
- { name: fuzz_parse_size, should_pass: true }
|
|
|
|
- { name: fuzz_parse_time, should_pass: true }
|
2023-10-08 15:34:37 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: dtolnay/rust-toolchain@nightly
|
|
|
|
- name: Install `cargo-fuzz`
|
|
|
|
run: cargo install cargo-fuzz
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
2023-10-31 08:08:40 +00:00
|
|
|
with:
|
|
|
|
shared-key: "cargo-fuzz-cache-key"
|
|
|
|
cache-directories: "fuzz/target"
|
2023-10-14 05:33:43 +00:00
|
|
|
- name: Restore Cached Corpus
|
|
|
|
uses: actions/cache/restore@v3
|
|
|
|
with:
|
2023-11-20 21:17:57 +00:00
|
|
|
key: corpus-cache-${{ matrix.test-target.name }}
|
2023-10-14 05:33:43 +00:00
|
|
|
path: |
|
2023-11-20 21:17:57 +00:00
|
|
|
fuzz/corpus/${{ matrix.test-target.name }}
|
|
|
|
- name: Run ${{ matrix.test-target.name }} for XX seconds
|
2023-10-08 15:34:37 +00:00
|
|
|
shell: bash
|
2023-11-20 21:17:57 +00:00
|
|
|
continue-on-error: ${{ !matrix.test-target.name.should_pass }}
|
2023-10-08 15:34:37 +00:00
|
|
|
run: |
|
2023-11-20 21:17:57 +00:00
|
|
|
cargo +nightly fuzz run ${{ matrix.test-target.name }} -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0
|
2023-10-14 05:33:43 +00:00
|
|
|
- name: Save Corpus Cache
|
|
|
|
uses: actions/cache/save@v3
|
|
|
|
with:
|
2023-11-20 21:17:57 +00:00
|
|
|
key: corpus-cache-${{ matrix.test-target.name }}
|
2023-10-14 05:33:43 +00:00
|
|
|
path: |
|
2023-11-20 21:17:57 +00:00
|
|
|
fuzz/corpus/${{ matrix.test-target.name }}
|