diff --git a/.github/actions/setup-honggfuzz/action.yml b/.github/actions/setup-honggfuzz/action.yml new file mode 100644 index 000000000..7f05fb667 --- /dev/null +++ b/.github/actions/setup-honggfuzz/action.yml @@ -0,0 +1,23 @@ +name: "Setup Honggfuzz" +description: "Setup Honggfuzz" + +runs: + using: "composite" + steps: + - uses: actions/cache@v3 + name: Cache Honggfuzz + id: cache-honggfuzz + with: + path: | + ~/.cache/honggfuzz/ + ~/.local/share/honggfuzz/ + key: honggfuzz-${{ runner.os }}-v0000-${{ env.HONGGFUZZ_VERSION }} + - name: Install honggfuzz + run: cargo install honggfuzz --version ${{ env.HONGGFUZZ_VERSION }} + shell: bash + - name: Install binutils-dev + run: sudo apt-get install binutils-dev + shell: bash + - name: Install libunwind-dev + run: sudo apt-get install libunwind-dev + shell: bash diff --git a/.github/workflows/run_fuzz_example.yml b/.github/workflows/run_fuzz_example.yml new file mode 100644 index 000000000..e8d07b8b4 --- /dev/null +++ b/.github/workflows/run_fuzz_example.yml @@ -0,0 +1,25 @@ +name: Test Fuzz Tests + +on: + workflow_dispatch: + pull_request: + +env: + SOLANA_CLI_VERSION: 1.18.12 + ANCHOR_VERSION: 0.29.0 + HONGGFUZZ_VERSION: 0.5.55 + +jobs: + run_fuzz_example: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-rust/ + - uses: ./.github/actions/setup-solana/ + - uses: ./.github/actions/setup-honggfuzz/ + id: rust-setup + - uses: Swatinem/rust-cache@v2 + name: Cache Rust and it's packages + - name: Test Fuzz + working-directory: examples/fuzz-tests/unchecked-arithmetic-0 + run: cargo run --manifest-path ../../../Cargo.toml fuzz run fuzz_0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2adc50cfc..d525ceb52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 incremented upon a breaking change and the patch version will be incremented for features. ## [dev] - Unreleased -- del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171)) +- fix/in case of fuzzing failure throw error instead of only printing message([#167](https://github.com/Ackee-Blockchain/trident/pull/167)) +- del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171)) - fix/snapshot's zeroed account as optional ([#170](https://github.com/Ackee-Blockchain/trident/pull/170)) - feat/fuzzer-stats-logging, an optional statistics output for fuzzing session ([#144](https://github.com/Ackee-Blockchain/trident/pull/144)) diff --git a/crates/client/src/commander.rs b/crates/client/src/commander.rs index b5a3c9233..dd8d24187 100644 --- a/crates/client/src/commander.rs +++ b/crates/client/src/commander.rs @@ -223,7 +223,7 @@ impl Commander { "The crash directory {} contains new fuzz test crashes. Exiting!", crash_dir.to_string_lossy() ); - process::exit(1); + process::exit(99); } } } @@ -292,7 +292,7 @@ impl Commander { res = child.wait() => match res { Ok(status) => if !status.success() { - println!("Honggfuzz exited with an error!"); + throw!(Error::FuzzingFailed); }, Err(_) => throw!(Error::FuzzingFailed), }, @@ -358,7 +358,7 @@ impl Commander { match res { Ok(status) => { if !status.success() { - println!("Honggfuzz exited with an error!"); + throw!(Error::FuzzingFailed); } }, Err(_) => throw!(Error::FuzzingFailed), @@ -367,7 +367,6 @@ impl Commander { _ = signal::ctrl_c() => { fuzz_end.store(true, std::sync::atomic::Ordering::SeqCst); tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; - }, } let stats_result = stats_handle diff --git a/examples/fuzz-tests/unchecked-arithmetic-0/Trident.toml b/examples/fuzz-tests/unchecked-arithmetic-0/Trident.toml index a398402c4..d0247eb7c 100644 --- a/examples/fuzz-tests/unchecked-arithmetic-0/Trident.toml +++ b/examples/fuzz-tests/unchecked-arithmetic-0/Trident.toml @@ -6,7 +6,7 @@ validator_startup_timeout = 15000 # Timeout in seconds (default: 10) timeout = 10 # Number of fuzzing iterations (default: 0 [no limit]) -iterations = 0 +iterations = 100 # Number of concurrent fuzzing threads (default: 0 [number of CPUs / 2]) threads = 0 # Don't close children's stdin, stdout, stderr; can be noisy (default: false) @@ -14,7 +14,7 @@ keep_output = false # Disable ANSI console; use simple log output (default: false) verbose = false # Exit upon seeing the first crash (default: false) -exit_upon_crash = false +exit_upon_crash = true # Maximal number of mutations per one run (default: 6) mutations_per_run = 6 # Target compilation directory, (default: "" ["trident-tests/fuzz_tests/fuzzing/hfuzz_target"]). @@ -38,4 +38,4 @@ save_all = false allow_duplicate_txs = false # Trident will show statistics after the fuzzing session. This option forces use of honggfuzz parameter # `keep_output` as true in order to be able to catch fuzzer stdout. (default: false) -fuzzing_with_stats = false +fuzzing_with_stats = true