Using the config file - aderyn.toml
Customize Aderyn with aderyn.toml configuration
Using the config file - aderyn.toml
Aderyn works seamlessly on commonly recognized project structures, i.e., when a foundry.toml or hardhat.config.js is found in the workspace's root. By default all detectors are run and all files in the project source are included.
Initialization
To customize this behavior of Aderyn, initialize aderyn.toml config file in the project root by doing either of the following:
-
Run
aderyn initwhen using command line version of Aderyn -
Pick the action
Aderyn: Initialize Config Filein VS Code command palette by pressing Ctrl/Cmd + Shift + P when using the VS Code extension
Guide to understand customization keys
Version
version = 1
- Description: Specifies the version of the configuration file format.
- Note: As of now, only version
1is supported. Do not change this value.
Root
root = "."
- Description: Defines the base path for resolving remappings and compiling smart contracts. This path is relative to the workspace root (the directory where the editor is open).
- Default:
.(current directory). - Recommendation: Typically, this should point to the directory containing
foundry.tomlorhardhat.config.js/ts.
Source Directory (src)
src = "src/"
- Description: Specifies the path to the directory containing your smart contracts, relative to the
rootdirectory. Aderyn will traverse all nested files within this directory to scan for vulnerabilities. - Default: If not specified, Aderyn will attempt to extract this value from the framework being used (e.g., Foundry or Hardhat).
- For Hardhat, the default is
contracts/. - For Foundry, the default depends on
foundry.tomland other factors like theFOUNDRY_PROFILEenvironment variable.
- For Hardhat, the default is
- Override: If specified, Aderyn will use this value instead of the framework-derived path.
Include Files (include)
include = ["src/counters/Counter.sol", "src/others/"]
include = ["/interfaces/"]
- Description: Specifies the path segments of contract files to include in the analysis.
- Behavior:
- You can use partial matches (e.g.,
/interfaces/) to include all files containing that segment in their path. - You can use full matches (e.g.,
src/counters/Counter.sol) to include only the exact file.
- You can use partial matches (e.g.,
- Default: If not specified, all contract files in the source directory will be included.
Exclude Files (exclude)
exclude = ["src/counters/Counter.sol", "src/others/"]
exclude = ["/interfaces/"]
- Description: Specifies the path segments of contract files to exclude from the analysis.
- Behavior:
- You can use partial matches (e.g.,
/interfaces/) to exclude all files containing that segment in their path. - You can use full matches (e.g.,
src/counters/Counter.sol) to exclude only the exact file.
- You can use partial matches (e.g.,
- Default: If not specified, no contract files will be excluded.
Remappings
- Description: Aderyn uses remappings to resolve dependencies in your project.
- Behavior:
- Remappings can be specified in a
remappings.txtfile within the root folder of the project. - If not specified, Aderyn will attempt to derive remappings from
foundry.toml(if present).
- Remappings can be specified in a
Environment Variables (env)
[env]
FOUNDRY_PROFILE = "default"
- Description: Specifies environment variables that Aderyn should use during analysis.
- Use Case: Useful for advanced configurations, such as when different profiles in
foundry.tomlhave differentsrcdeclarations. For example, settingFOUNDRY_PROFILEcan dictate the correctsrcvalue. - Default: If not specified, Aderyn will use the system's environment variables.
Include Or Exclude Detectors
Description: To include or exclude to specific detectors, find out the names of the detectors either by hovering over the underlined issue if you are using the VS Code extension or by simply running aderyn registry if you are using Command Line version of Aderyn.
Default: All detectors are run.
Behavior: Use the following syntax to include or exclude specific detectors
Examples:
[detectors]
include = ["unspecific-solidity-pragma", "unused-state-variable"]
[detectors]
exclude = ["unspecific-solidity-pragma", "unused-state-variable"]
Example Configuration
Here's an example of a complete aderyn.toml file:
version = 1
root = "."
include = ["src/counters/Counter.sol", "/interfaces/"]
exclude = ["src/others/", "/test/"]
[env]
FOUNDRY_PROFILE = "ccip"