diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index 85f270e3d..e1cd41f2d 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -2,6 +2,10 @@ on: [push, pull_request, workflow_dispatch] name: Aderyn +concurrency: + group: ci-${{ github.ref }}-cargo + cancel-in-progress: true + jobs: check: name: Check diff --git a/.github/workflows/reports.yml b/.github/workflows/reports.yml index ffeaa2616..011bed438 100644 --- a/.github/workflows/reports.yml +++ b/.github/workflows/reports.yml @@ -2,6 +2,10 @@ on: [push, pull_request, workflow_dispatch] name: Reports Workflow +concurrency: + group: ci-${{ github.ref }}-reports + cancel-in-progress: true + jobs: reports-setup: name: Check Reports diff --git a/aderyn/templates/aderyn.toml b/aderyn/templates/aderyn.toml index b127482cc..985401a9b 100644 --- a/aderyn/templates/aderyn.toml +++ b/aderyn/templates/aderyn.toml @@ -1,27 +1,33 @@ # Aderyn Configuration File -# This is a sample configuration for Aderyn +# Help Aderyn work with more granular control -# The root directory of smart contracts -# root = "." +# DO NOT CHANGE version below. As of now, only 1 is supported +version = 1 -# By default, aderyn will try to extract the following values based on the framework that is being used. -# However, if you want to be explicit consider mentioning them. +# Read the description carefully and uncomment the examples in each paragraph should you consider using them. -# The source directory containing the Solidity contracts. -# This is often "contracts/" or "src/" +# Base path for resolving remappings and compiling smart contracts, relative to workspace-root (directory in which the editor is open) +# Most of the time, you want to point it to the directory containing foundry.toml or hardhat.config.js/ts. +root = "." + +# Path of source directory containing the contracts, relative to root (above) +# Aderyn traverse all the nested files inside scanning for vulnerabilities +# If not specified, Aderyn will try to extract it from the framework that is being used. (Foundry / Hardhat) +# That would be "contracts/" in case of Hardhat and in case of Foundry, it depends on foundry's config file and +# many other factors like FOUNDRY_PROFILE environment variable, etc. used. +# Please specify explicitly in case it's not Foundry / Hardhat project. +# Example: # src = "src/" -# Contract files to include in the analysis. -# This is a list of strings representing the file paths of the contracts to include. +# Path segments of contract files to include in the analysis. # It can be a partial match like "/interfaces/", which will include all files with "/interfaces/" in the file path. -# Or it can be a full match like "Counter.sol", which will include only the file with the exact file. +# Or it can be a full match like "counters/Counter.sol", which will include only the file with the exact file. # If not specified, all contract files in the source directory will be included. # Example: -# include = ["Counter.sol"] +# include = ["counters/Counter.sol"] # include = [] -# Contract files to exclude from the analysis. -# This is a list of strings representing the file paths of the contracts to exclude. +# Path segments of contract files to exclude in the analysis. # It can be a partial match like "/interfaces/", which will exclude all files with "/interfaces/" in the file path. # Or it can be a full match like "Counter.sol", which will exclude only the file with the exact file. # If not specified, no contract files will be excluded. @@ -29,6 +35,8 @@ # exclude = ["/interfaces/"] # exclude = [] -## Remappings used for compiling the contracts. +# Remappings used for compiling the contracts. +# If not specified, Aderyn will try to derive the values from foundry's config file (if present.) +# That would be the result of calling `foundry remappings` # Example: # remappings = ["@oz/contracts=lib/openzeppelin-contracts/contracts"] diff --git a/aderyn_driver/src/config_helpers.rs b/aderyn_driver/src/config_helpers.rs index 081b042e7..e37f8a6c6 100644 --- a/aderyn_driver/src/config_helpers.rs +++ b/aderyn_driver/src/config_helpers.rs @@ -9,6 +9,8 @@ use serde::Deserialize; /// aderyn.toml structure #[derive(Deserialize, Clone)] pub struct AderynConfig { + /// By default we'll assume it's version 1 + pub version: Option, pub root: Option, pub src: Option, pub exclude: Option>, @@ -27,6 +29,10 @@ fn load_aderyn_config(root: &Path) -> Result { let mut config: AderynConfig = toml::from_str(&content).map_err(|err| format!("Error parsing config file: {}", err))?; + if config.version.is_some_and(|v| v != 1) { + return Err("aderyn.toml version not supported".to_owned()); + } + // Clear empty vectors clear_empty_vectors(&mut config.exclude); clear_empty_vectors(&mut config.remappings); @@ -217,6 +223,7 @@ mod tests { #[test] fn test_interpret_aderyn_config_correctly_appends_and_replaces() { let config = super::AderynConfig { + version: Some(1), root: Some("CONFIG_ROOT".to_string()), src: Some("CONFIG_SRC".to_string()), exclude: Some(vec!["CONFIG_EXCLUDE".to_string()]), diff --git a/tests/adhoc-sol-files/aderyn.toml b/tests/adhoc-sol-files/aderyn.toml index f29dce1a5..a62d87dad 100644 --- a/tests/adhoc-sol-files/aderyn.toml +++ b/tests/adhoc-sol-files/aderyn.toml @@ -1,3 +1,4 @@ +version = 1 # src = "" exclude = ["lib/"] # remappings = []