💻Using the CLI
Fine tuning everything for optimal fuzzing
Fuzz is a command-line tool for smart contract fuzzing. It provides several modes of fuzzing, including smart mode, manual mode, and Foundry tests fuzzing. It is the only way to submit campaign to Diligence Fuzzing.
Installing the CLI
The Diligence Fuzzing CLI runs on Python 3.6+, including 3.8 and pypy3. To install it, simply run:
Subscriptions and API Key
In order to submit campaigns, you need to have an active subscription to Diligence Fuzzing. Pricing plans can be found at https://consensys.net/diligence/fuzzing . To get started you can also use our free trial, which doesn't require a credit card. Subscriptions and Free Trial can be activated at https://fuzzing.diligence.tools/subscription.
Once you have an active subscription, you can go to https://fuzzing.diligence.tools/keys and create a new API key. That key should then be passed to the cli when submitting campaigns.
The best way to configure the API key is by adding it to a .env
file in your project's folder.
Remember to add the .env file to your .gitignore so you don't push your API key to version control.
Alternatively you can also:
Set the API key as an environment variable called
FUZZ_API_KEY;
Add the API key to the .fuzz.yaml configuration file (See CLI Configuration);
Set the API key as a configuration parameter of the campaign start command
fuzz run -k your_api_key_here .
CLI Configuration
The Fuzz
CLI tool allows configuration through 4 sources:
.env
filesEnvironment variables
Command options
YAML config files
.env Files and Environment variables
Virtually all of the CLI's configuration parameters can be set as environment variables. A complete list can be found here. These environment variables can also be configured on a .env file on your project's folder.
Remember to add the .env file to your .gitignore so you don't push your API key to version control.
Configuration File
On all but Foundry projects, a configuration file is required. The CLI can automatically generate a configuration file, by running fuzz config generate
. You will then be guided through a process to get you going.
The fuzz config generate command will do its best to detect the framework you're using, find the sources and build directory and set some up parameters. You can then manually tweak the file to add or change any parameters.
Below, you can find two examples of configuration files. The first section contains a small sample configuration that will likely be enough to get you started. The second section contains some tips and tricks that you can use to improve your fuzzing configuration and super-charge your fuzzing setup.
Don't worry about the configuration too much. The simple configuration will get you some awesome fuzzing results in no time!
First, below is our base configuration, which you'll recognise from Fuzzing 1-2-3:
The following extends the configuration and sets all available configuration options:
Tips and Tricks
Make sure you have the right additional_contracts_addresses
additional_contracts_addresses
If you forget to add a crucial component to your additional_contracts_addresses
then the fuzzer will ignore that contract. Unfortunately, that can result in parts of your system not being explored by the fuzzer. To avoid this, make sure to add the addresses of all relevant components!
Last updated