Note: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features.
Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output.
Custom imports in the .program_client. User is able to import custom types and structures into program client. The import part of the code would not be re-generated.
Trident is now configurable. This requires Trident.toml file to exist in the project's root directory - without this file the execution will fail. To solve this re-run trident init or just create an empty Trident.toml file in the project's root directory.
Note: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features.
Custom Solana RPC error reporter. If the Solana RPC error is thrown, the error code, message and data (logs) are reported to the output.
Custom imports in the .program_client. User is able to import custom types and structures into program client. The import part of the code would not be re-generated.
Trident is now configurable. This requires Trident.toml file to exist in the project's root directory - without this file the execution will fail. To solve this re-run trident init or just create an empty Trident.toml file in the project's root directory.
Fuzzing is a software testing technique that involves providing invalid, unexpected, or random data as inputs to a computer program. The aim is to uncover bugs and vulnerabilities that might not be detected with conventional testing strategies.
The Trident testing framework equips developers with tools to efficiently develop fuzz tests for Anchor-based programs. It streamlines the fuzz testing process through automation and comprehensive support:
Automatically parses Anchor-based programs to generate necessary implementations for deserializing instruction accounts.
Generates templates for developers to customize according to the specific needs of their fuzz test scenarios.
Includes a bank client and helper functions for simplified account management during testing.
Provides a Command-Line Interface (CLI) for executing and debugging fuzz tests with ease.
Trident is built for customization, enabling developers to tailor their fuzz tests by adjusting:
Execution Order of Instructions: Test different sequences and their effects on the program to uncover sequence-related vulnerabilities.
Instruction Parameters: Identify how variations in inputs influence program behavior, testing for robustness against a wide range of data.
Instruction Accounts: Explore the impact of different account states on the software's functionality, ensuring comprehensive account testing.
Comprehensive Testing: Conduct thorough and effective fuzz testing by combining any of the above aspects.
This framework supports a detailed and methodical approach to fuzz testing, facilitating the identification and remediation of potential vulnerabilities in software applications.
\ No newline at end of file
+ Introduction - Trident
Fuzzing is a software testing technique that involves providing invalid, unexpected, or random data as inputs to a computer program. The aim is to uncover bugs and vulnerabilities that might not be detected with conventional testing strategies.
The Trident testing framework equips developers with tools to efficiently develop fuzz tests for Anchor-based programs. It streamlines the fuzz testing process through automation and comprehensive support:
Automatically parses Anchor-based programs to generate necessary implementations for deserializing instruction accounts.
Generates templates for developers to customize according to the specific needs of their fuzz test scenarios.
Includes a bank client and helper functions for simplified account management during testing.
Provides a Command-Line Interface (CLI) for executing and debugging fuzz tests with ease.
Trident is built for customization, enabling developers to tailor their fuzz tests by adjusting:
Execution Order of Instructions: Test different sequences and their effects on the program to uncover sequence-related vulnerabilities.
Instruction Parameters: Identify how variations in inputs influence program behavior, testing for robustness against a wide range of data.
Instruction Accounts: Explore the impact of different account states on the software's functionality, ensuring comprehensive account testing.
Comprehensive Testing: Conduct thorough and effective fuzz testing by combining any of the above aspects.
This framework supports a detailed and methodical approach to fuzz testing, facilitating the identification and remediation of potential vulnerabilities in software applications.
\ No newline at end of file
diff --git a/dev/fuzzing/fuzzing-lifecycle/index.html b/dev/fuzzing/fuzzing-lifecycle/index.html
index d6303dfe..9481a129 100644
--- a/dev/fuzzing/fuzzing-lifecycle/index.html
+++ b/dev/fuzzing/fuzzing-lifecycle/index.html
@@ -1 +1 @@
- Fuzz Test Lifecycle - Trident
The maximal number of iterations is reached (if specified).
A crash was detected and the exit_upon_crash parameter was set.
User interrupted the test manually (for example by hitting CTRL+C).
In each iteration, the fuzzer generates a sequence of random instructions to execute.
User can optionally customize how the instructions are generated and can specify the instructions that should be executed at the beginning (pre_ixs), in the middle (ixs) and at the end (post_ixs) of each iteration. This can be useful for example if your program needs an initialization or you want to fuzz some specific program state.
For each instruction:
User defined mandatory method get_accounts() is called to collect necessary instruction accounts.
User defined mandatory method get_data() is called to collect instruction data.
A snapshot of all instruction accounts before the instruction execution is saved.
The instruction is executed.
A snapshot of all instruction accounts after the instruction execution is saved.
User defined optional method check() is called to check accounts data and evaluate invariants.
\ No newline at end of file
+ Fuzz Test Lifecycle - Trident
The maximal number of iterations is reached (if specified).
A crash was detected and the exit_upon_crash parameter was set.
User interrupted the test manually (for example by hitting CTRL+C).
In each iteration, the fuzzer generates a sequence of random instructions to execute.
User can optionally customize how the instructions are generated and can specify the instructions that should be executed at the beginning (pre_ixs), in the middle (ixs) and at the end (post_ixs) of each iteration. This can be useful for example if your program needs an initialization or you want to fuzz some specific program state.
For each instruction:
User defined mandatory method get_accounts() is called to collect necessary instruction accounts.
User defined mandatory method get_data() is called to collect instruction data.
A snapshot of all instruction accounts before the instruction execution is saved.
The instruction is executed.
A snapshot of all instruction accounts after the instruction execution is saved.
User defined optional method check() is called to check accounts data and evaluate invariants.
\ No newline at end of file
diff --git a/dev/fuzzing/fuzzing-run-debug/index.html b/dev/fuzzing/fuzzing-run-debug/index.html
index bacedb56..360aae9f 100644
--- a/dev/fuzzing/fuzzing-run-debug/index.html
+++ b/dev/fuzzing/fuzzing-run-debug/index.html
@@ -1,4 +1,4 @@
- Run and Debug - Trident
# Content of Trident.toml
@@ -48,4 +48,4 @@
tridentfuzzrun-debug<TARGET_NAME><CRASH_FILE_PATH>
# for example:tridentfuzzrun-debugfuzz_0trident-tests/fuzz_tests/fuzzing/fuzz_0/cr1.fuzz
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/dev/fuzzing/howto/fuzzing-howto-p0/index.html b/dev/fuzzing/howto/fuzzing-howto-p0/index.html
index 3dc3f13c..b43b3d95 100644
--- a/dev/fuzzing/howto/fuzzing-howto-p0/index.html
+++ b/dev/fuzzing/howto/fuzzing-howto-p0/index.html
@@ -1 +1 @@
- First Steps - Trident
At the current development stage, there are some manual steps required to make your fuzz test compile:
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.
\ No newline at end of file
diff --git a/dev/fuzzing/howto/fuzzing-howto-p1/index.html b/dev/fuzzing/howto/fuzzing-howto-p1/index.html
index a36e2e2b..de4da027 100644
--- a/dev/fuzzing/howto/fuzzing-howto-p1/index.html
+++ b/dev/fuzzing/howto/fuzzing-howto-p1/index.html
@@ -1,7 +1,7 @@
- Specify accounts to reuse - Trident
Trident fuzzer helps you to generate only a limited amount of pseudo-random accounts and reuse them in the instructions.
Always generating only random accounts would in most cases lead to a situation where the fuzzer would be stuck because the accounts would be almost every time rejected by your Anchor program. Therefore it is necessary to specify, what accounts should be used and also limit the number of newly created accounts to reduce the space complexity.
Go to the trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/fuzz_instructions.rs file and complete the pre-generated FuzzAccounts structure. It contains all accounts used in your program. You have to determine if the account is a:
Signer
PDA
Token Account
Program account
Then use the corresponding AccountsStorage types such as:
pubstructFuzzAccounts{
+ Specify accounts to reuse - Trident
Trident fuzzer helps you to generate only a limited amount of pseudo-random accounts and reuse them in the instructions.
Always generating only random accounts would in most cases lead to a situation where the fuzzer would be stuck because the accounts would be almost every time rejected by your Anchor program. Therefore it is necessary to specify, what accounts should be used and also limit the number of newly created accounts to reduce the space complexity.
Go to the trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/fuzz_instructions.rs file and complete the pre-generated FuzzAccounts structure. It contains all accounts used in your program. You have to determine if the account is a:
Signer
PDA
Token Account
Program account
Then use the corresponding AccountsStorage types such as:
\ No newline at end of file
diff --git a/dev/fuzzing/howto/fuzzing-howto-p2/index.html b/dev/fuzzing/howto/fuzzing-howto-p2/index.html
index 2c1b6550..365e8045 100644
--- a/dev/fuzzing/howto/fuzzing-howto-p2/index.html
+++ b/dev/fuzzing/howto/fuzzing-howto-p2/index.html
@@ -1,4 +1,4 @@
- Specify instruction data - Trident
Trident fuzzer generates random instruction data for you.
Currently, it is however required, that you manually assign the random fuzzer data to the instruction data. It is done using the IxOps trait and its method get_data.
Go to the trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/fuzz_instructions.rs file and complete the pre-generated get_data methods for each instruction such as:
Trident fuzzer generates random instruction data for you.
Currently, it is however required, that you manually assign the random fuzzer data to the instruction data. It is done using the IxOps trait and its method get_data.
Go to the trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/fuzz_instructions.rs file and complete the pre-generated get_data methods for each instruction such as:
Trident fuzzer generates random indexes of accounts to use in each instruction. Each created account is saved in the global FuzzAccounts structure which helps you to reuse already existing accounts across all instructions.
You are required to define, how these accounts should be created and which accounts should be passed to an instruction. It is done using the IxOps trait and its method get_accounts.
Go to the trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/fuzz_instructions.rs file and complete the pre-generated get_accounts methods for each instruction such as:
Trident fuzzer generates random indexes of accounts to use in each instruction. Each created account is saved in the global FuzzAccounts structure which helps you to reuse already existing accounts across all instructions.
You are required to define, how these accounts should be created and which accounts should be passed to an instruction. It is done using the IxOps trait and its method get_accounts.
Go to the trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/fuzz_instructions.rs file and complete the pre-generated get_accounts methods for each instruction such as:
It is possible to customize how the instructions are generated and which instructions will be executed at the beginning (pre_ixs), in the middle (ixs) and at the end (post_ixs) of each fuzz iteration. This can be useful for example if your program needs an initialization or you want to fuzz some specific program state.
Go to the trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/test_fuzz.rs and implement the corresponding optional method of the FuzzDataBuilder<FuzzInstruction> trait. For example, in order to always call the initialize instruction, modify the trait's implementation as follows:
It is possible to customize how the instructions are generated and which instructions will be executed at the beginning (pre_ixs), in the middle (ixs) and at the end (post_ixs) of each fuzz iteration. This can be useful for example if your program needs an initialization or you want to fuzz some specific program state.
Go to the trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/test_fuzz.rs and implement the corresponding optional method of the FuzzDataBuilder<FuzzInstruction> trait. For example, in order to always call the initialize instruction, modify the trait's implementation as follows:
\ No newline at end of file
diff --git a/dev/fuzzing/howto/fuzzing-howto-p6/index.html b/dev/fuzzing/howto/fuzzing-howto-p6/index.html
index 92817125..1d0db05f 100644
--- a/dev/fuzzing/howto/fuzzing-howto-p6/index.html
+++ b/dev/fuzzing/howto/fuzzing-howto-p6/index.html
@@ -1,4 +1,4 @@
- How to use Custom Data Types - Trident
For a practical example, please refer to the Examples section.
\ No newline at end of file
diff --git a/dev/fuzzing/howto/fuzzing-howto-p7/index.html b/dev/fuzzing/howto/fuzzing-howto-p7/index.html
index 21ab3450..5c9cfbdd 100644
--- a/dev/fuzzing/howto/fuzzing-howto-p7/index.html
+++ b/dev/fuzzing/howto/fuzzing-howto-p7/index.html
@@ -1,4 +1,4 @@
- How to use Arbitrary crate - Trident
The Arbitrary crate in Rust is used for generating well-typed, structured instances of data from raw byte buffers, making it useful for fuzzing by producing random but structured data for tests.
By implementing the Arbitrary trait for Instruction Data structures, you can guide the fuzzing tool to generate meaningful instances of these structures, thus ensuring a more effective and targeted fuzzing process.
Let`s say your Solana program contains instruction, with a similar logic as the example below:
The Arbitrary crate in Rust is used for generating well-typed, structured instances of data from raw byte buffers, making it useful for fuzzing by producing random but structured data for tests.
By implementing the Arbitrary trait for Instruction Data structures, you can guide the fuzzing tool to generate meaningful instances of these structures, thus ensuring a more effective and targeted fuzzing process.
Let`s say your Solana program contains instruction, with a similar logic as the example below:
\ No newline at end of file
diff --git a/dev/fuzzing/initialization/fuzzing-initialization-fuzz-add/index.html b/dev/fuzzing/initialization/fuzzing-initialization-fuzz-add/index.html
index f7990fd6..66dd5afd 100644
--- a/dev/fuzzing/initialization/fuzzing-initialization-fuzz-add/index.html
+++ b/dev/fuzzing/initialization/fuzzing-initialization-fuzz-add/index.html
@@ -1,4 +1,4 @@
- Add new Fuzz Test - Trident
Automated Test Generation: Simplifies the testing process by automatically creating templates for fuzz and integration tests for programs written using the Anchor Framework.
Dynamic Data Generation: Increases test coverage with random instruction data and pseudo-random accounts for unpredictable fuzz test scenarios.
Custom Instruction Sequences: Provides the flexibility to design specific sequences of instructions to meet particular testing needs or to focus on particular aspects of program behavior during fuzz testing. Invariant Checks: Allows for custom invariants checks to spot vulnerabilities and unwanted behaviors.
Automated Test Generation: Simplifies the testing process by automatically creating templates for fuzz and integration tests for programs written using the Anchor Framework.
Dynamic Data Generation: Increases test coverage with random instruction data and pseudo-random accounts for unpredictable fuzz test scenarios.
Custom Instruction Sequences: Provides the flexibility to design specific sequences of instructions to meet particular testing needs or to focus on particular aspects of program behavior during fuzz testing. Invariant Checks: Allows for custom invariants checks to spot vulnerabilities and unwanted behaviors.
\ No newline at end of file
diff --git a/dev/integration-tests/howto/poc-howto-p0/index.html b/dev/integration-tests/howto/poc-howto-p0/index.html
index 0a3be267..bdba3fcb 100644
--- a/dev/integration-tests/howto/poc-howto-p0/index.html
+++ b/dev/integration-tests/howto/poc-howto-p0/index.html
@@ -1,4 +1,4 @@
- Init Fixture - Trident
// <my_project>/trident-tests/poc_tests/tests/test.rs// TODO: do not forget to add all necessary dependencies to the generated `trident-tests/poc_tests/Cargo.toml`useprogram_client::my_instruction;usetrident_client::*;
@@ -41,4 +41,4 @@
letstate=fixture.get_state().await?;assert_eq!(state.something_changed,"yes");}
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/dev/integration-tests/howto/poc-howto-p1/index.html b/dev/integration-tests/howto/poc-howto-p1/index.html
index 9189f1ec..9073441a 100644
--- a/dev/integration-tests/howto/poc-howto-p1/index.html
+++ b/dev/integration-tests/howto/poc-howto-p1/index.html
@@ -1,4 +1,4 @@
- Testing programs with associated token accounts - Trident
\ No newline at end of file
diff --git a/dev/integration-tests/initialization/poc-initialization-program-client/index.html b/dev/integration-tests/initialization/poc-initialization-program-client/index.html
index 088dc04c..23cb23fa 100644
--- a/dev/integration-tests/initialization/poc-initialization-program-client/index.html
+++ b/dev/integration-tests/initialization/poc-initialization-program-client/index.html
@@ -1,2 +1,2 @@
- Program Client - Trident