Nightly Fuzzing #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nightly Fuzzing | |
| on: | |
| schedule: | |
| # Run at 2 AM UTC every day | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| fuzz-deep: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| contract: [oracle_aggregator, zk_verifier] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: nightly | |
| override: true | |
| - name: Install cargo-fuzz | |
| run: cargo install cargo-fuzz | |
| - name: Cache fuzz corpus | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| contracts/${{ matrix.contract }}/fuzz/corpus | |
| key: fuzz-corpus-${{ matrix.contract }}-${{ github.sha }} | |
| restore-keys: | | |
| fuzz-corpus-${{ matrix.contract }}- | |
| - name: Deep fuzz ${{ matrix.contract }} (30 min per target) | |
| run: | | |
| cd contracts/${{ matrix.contract }} | |
| targets=$(ls fuzz/fuzz_targets/*.rs | xargs -n1 basename | sed 's/\.rs$//') | |
| for target in $targets; do | |
| echo "====================" | |
| echo "Deep fuzzing $target for 30 minutes..." | |
| echo "====================" | |
| # 30 minutes = 1800 seconds | |
| cargo +nightly fuzz run $target -- \ | |
| -max_total_time=1800 \ | |
| -max_len=4096 \ | |
| -rss_limit_mb=4096 \ | |
| -timeout=30 \ | |
| -print_final_stats=1 || exit 1 | |
| done | |
| - name: Upload crash artifacts | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: fuzz-crash-artifacts-${{ matrix.contract }}-${{ github.run_id }} | |
| path: | | |
| contracts/${{ matrix.contract }}/fuzz/artifacts | |
| retention-days: 90 | |
| - name: Report coverage statistics | |
| if: always() | |
| run: | | |
| cd contracts/${{ matrix.contract }} | |
| echo "Fuzz corpus statistics:" | |
| find fuzz/corpus -type f | wc -l | |
| du -sh fuzz/corpus |