Skip to content

Commit

Permalink
Fix the version for aderyn.toml + Optimize CI by canceling in-progres…
Browse files Browse the repository at this point in the history
…s tasks running concurrently in a group (#802)
  • Loading branch information
TilakMaddy authored Feb 20, 2025
1 parent 22b609c commit 9f3ae69
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 22 additions & 14 deletions aderyn/templates/aderyn.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
# 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.
# Example:
# 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"]
7 changes: 7 additions & 0 deletions aderyn_driver/src/config_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize>,
pub root: Option<String>,
pub src: Option<String>,
pub exclude: Option<Vec<String>>,
Expand All @@ -27,6 +29,10 @@ fn load_aderyn_config(root: &Path) -> Result<AderynConfig, String> {
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);
Expand Down Expand Up @@ -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()]),
Expand Down
1 change: 1 addition & 0 deletions tests/adhoc-sol-files/aderyn.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version = 1
# src = ""
exclude = ["lib/"]
# remappings = []
Expand Down

0 comments on commit 9f3ae69

Please sign in to comment.