-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
808 additions
and
258 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Debug | ||
|
||
To debug your program with values from a crash file: | ||
|
||
```bash | ||
# fuzzer will run the <TARGET_NAME> with the specified <CRASH_FILE_PATH> | ||
trident fuzz run-debug <TARGET_NAME> <CRASH_FILE_PATH> | ||
# for example: | ||
trident fuzz run-debug fuzz_0 trident-tests/fuzz_tests/fuzzing/fuzz_0/cr1.fuzz | ||
``` | ||
|
||
|
||
## Debug Output | ||
|
||
!!! important | ||
|
||
The debug output is at current development stage really verbose and contains lldb parts. We are working on improving this experience. In the picture below you can see an example of provided debug output. | ||
|
||
1. Series of Transaction Logs | ||
2. Structures of data send within the Instructions | ||
3. **Panic** or **Crash**, based on if the Fuzzing paniced within the Solana Program or Invariant Check failed. | ||
|
||
|
||
|
||
![alt text](../../images/run-debug.png) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Fuzzing statistics | ||
|
||
!!! important | ||
|
||
In order to show statistics of fuzzing session (statistics are displayed after the fuzzing session ended), set `fuzzing_with_stats` within the Trident.toml to `true`. | ||
|
||
```toml | ||
[fuzz] | ||
# ... | ||
fuzzing_with_stats = true | ||
# ... | ||
``` | ||
|
||
|
||
Currently exported statistics from the Fuzzing Session | ||
|
||
#### Simple | ||
|
||
- Number of invocations of each instruction during the fuzzing session. | ||
- Number of successful invocations of each instruction during the fuzzing session. | ||
- Number of failed invariants checks for each instruction during the fuzzing session. | ||
|
||
??? note | ||
|
||
Keep in mind that the number of fuzz iterations does not directly correspond to the total number of invocations. In one fuzz iteration, the fuzzer might be unable to deserialize fuzz data into instructions, causing the entire iteration to be skipped. | ||
|
||
On the other hand this is expected behavior as the underlying data are randomly (with coverage feedback) generated, so the Honggfuzz will not necessarily find appropriate data each iteration. |
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
hide: | ||
- toc | ||
--- | ||
|
||
# Trident by Examples | ||
|
||
<div class="grid cards" markdown> | ||
|
||
- :material-hand-wave:{ .lg .middle } __Hello World!__ | ||
|
||
--- | ||
|
||
Hello World example with Trident. | ||
|
||
[Hello World!](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/hello_world) | ||
|
||
- :octicons-bug-16:{ .lg .middle } __Possible vulnerabilities and bugs__ | ||
|
||
--- | ||
|
||
Check the possible attack vectors and bugs that can be detected using Trident. | ||
|
||
[Unchecked Arithmetic](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/unchecked-arithmetic-0) | ||
|
||
[Incorrect Instruction Sequence](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/incorrect-ix-sequence-1) | ||
|
||
[Unauthorized Access](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/unauthorized-access-2) | ||
|
||
[Incorrect Integer Arithmetic](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/incorrect-integer-arithmetic-3) | ||
|
||
- :octicons-tools-24:{ .lg .middle } __Customize with Arbitrary__ | ||
|
||
--- | ||
|
||
You can use Arbitrary crate to your advantage and limit or customize the data that are sent to the instructions. | ||
|
||
[Custom Data Types](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/arbitrary-custom-types-4) | ||
|
||
|
||
[Limiting Instructions Inputs](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/arbitrary-limit-inputs-5) | ||
|
||
- :material-call-made:{ .lg .middle } __Cross-Program Invocation__ | ||
|
||
--- | ||
|
||
Trident supports Cross-Program Invocation, you can fuzz your programs and create NFTs at the same time. | ||
|
||
[Simple CPI](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/simple-cpi-6) | ||
|
||
[CPI with Metaplex Metadata Program](https://github.com/Ackee-Blockchain/trident/tree/master/examples/fuzz-tests/cpi-metaplex-7) | ||
|
||
</div> |
File renamed without changes.
This file contains 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
32 changes: 32 additions & 0 deletions
32
documentation/docs/fuzzing/first-steps/writing-fuzz-test.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Writing Fuzz Test | ||
|
||
!!! important | ||
|
||
At the current development stage, there are some manual steps required to start the Fuzzing Session. In principle: | ||
|
||
**Prerequisites:** | ||
|
||
- Add dependencies specific to your program to `trident-tests/fuzz_tests/Cargo.toml` (such as anchor-spl etc.). | ||
- Add necessary `use` statements into `trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/accounts_snapshots.rs` to import missing types. | ||
|
||
**Writing Fuzz Tests** | ||
|
||
1. Include desired Programs [Include Programs](../writing-fuzz-test/programs.md). | ||
2. Specify pseudo-random accounts to re-use [Accounts to re-use](../writing-fuzz-test/accounts.md). | ||
3. Specify instruction data [Instruction Data](../writing-fuzz-test/instruction-data.md). | ||
4. Specify instruction accounts [Instruction Accounts](../writing-fuzz-test/instruction-accounts.md). | ||
|
||
**Run and Debug** | ||
|
||
1. Execute desired fuzz test [Run](../execute/run.md) | ||
2. See the found crash with more details [Debug](../execute/debug.md) | ||
|
||
!!! note | ||
|
||
For better fuzzing results and experience you can also manually adjust the following: | ||
|
||
1. Define Invariants checks [Invariants Checks](../writing-fuzz-test-extra/invariants-checks.md). | ||
2. Specify instruction sequences[Instruction sequences](../writing-fuzz-test-extra/instruction-sequences.md). | ||
3. Specify custom data types[Custom Data types](../writing-fuzz-test-extra/custom-data-types.md). | ||
4. Well structured data[Arbitrary](../writing-fuzz-test-extra/arbitrary.md). | ||
4. AccountsSnapshots macro[AccountsSnapshots](../writing-fuzz-test-extra/accounts-snapshots.md). |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
documentation/docs/fuzzing/initialization/fuzzing-initialization-all.md
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
documentation/docs/fuzzing/initialization/fuzzing-initialization-fuzz-add.md
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.