diff --git a/.gitignore b/.gitignore index e506f20..15964e9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ Cargo.lock *.pdb .DS_Store +.idea/ diff --git a/README.md b/README.md index c8b389d..11b9df5 100644 --- a/README.md +++ b/README.md @@ -31,14 +31,14 @@ Today, `soliris` **is not production-ready** and might report false information. Below is a list of the scanners implementation statuses: -| Name | Goal | Status | -|:-------------------:|----------------------------------------------------------------------------------------------------------------|:--------:| -| Missing Comments | Reports missing comments in your code. | ✅ | -| Unused Imports | Reports unused `import` declarations in your contracts. | ❌ | -| Mutable Functions | Reports functions able to mutate your contract's state. | ✅ | -| Mutable Variables | Reports variables likely to mutate. | ✅ | -| Mutation Grapher | Creates a graph showing the variables likely to mutate connected to the places where they undergo mutations. | ❌ | -| Struct Repacker | Suggests an alternative way to define a struct such that it takes less storage slots. | ❌ | +| Name | Goal | Status | +|:-----------------: |-------------------------------------------------------------------------------------------------------------- |:------: | +| Missing Comments | Reports missing comments in your code. | ✅ | +| Unused Imports | Reports unused `import` declarations in your contracts. | ❌ | +| Mutable Functions | Reports functions able to mutate your contract's state. | ✅ | +| Mutable Variables | Reports variables likely to mutate. | ✅ | +| Mutation Grapher | Creates a graph showing the variables likely to mutate connected to the places where they undergo mutations. | ❌ | +| Struct Repacker | Suggests an alternative way to define a struct such that it takes less storage slots. | ❌ | ## Getting Started diff --git a/src/scanners/implementations/mod.rs b/src/scanners/implementations/mod.rs index f5ca1ec..5d5f123 100644 --- a/src/scanners/implementations/mod.rs +++ b/src/scanners/implementations/mod.rs @@ -1,5 +1,6 @@ pub mod missing_comments; pub mod mutable_functions; pub mod mutable_variables; +pub mod mutation_grapher; pub mod struct_repacker; pub mod unused_imports; diff --git a/src/scanners/implementations/mutation_grapher.rs b/src/scanners/implementations/mutation_grapher.rs new file mode 100644 index 0000000..b6a52bd --- /dev/null +++ b/src/scanners/implementations/mutation_grapher.rs @@ -0,0 +1,14 @@ +use syn_solidity::{Item, ItemContract, ItemFunction}; + +use crate::scanners::{memory::Metadata, Scanner}; + +#[derive(Default)] +pub struct MutationGrapher {} + +impl MutationGrapher {} + +impl Scanner for MutationGrapher { + fn execute(&self, _ast: &[Item], _metadata: &Metadata) { + println!("todo!") + } +} diff --git a/src/scanners/mod.rs b/src/scanners/mod.rs index 3b38d4f..680359e 100644 --- a/src/scanners/mod.rs +++ b/src/scanners/mod.rs @@ -3,8 +3,8 @@ pub mod memory; use self::implementations::{ missing_comments::MissingComments, mutable_functions::MutableFunctions, - mutable_variables::MutableVariables, struct_repacker::StructRepacker, - unused_imports::UnusedImports, + mutable_variables::MutableVariables, mutation_grapher::MutationGrapher, + struct_repacker::StructRepacker, unused_imports::UnusedImports, }; use crate::scanners::memory::Metadata; use syn_solidity::Item; @@ -37,6 +37,7 @@ impl Default for Registry { Box::::default(), Box::::default(), Box::::default(), + Box::::default(), ], } } @@ -60,7 +61,7 @@ mod tests { fn it_creates_default_scanners_registry() { let scanners_registry = Registry::default(); - assert_eq!(scanners_registry.get_scanners().len(), 5) + assert_eq!(scanners_registry.get_scanners().len(), 6) } #[test] @@ -69,6 +70,6 @@ mod tests { scanners_registry.register_scanner(Box::new(MockScanner::default())); - assert_eq!(scanners_registry.get_scanners().len(), 6) + assert_eq!(scanners_registry.get_scanners().len(), 7) } } diff --git a/tests/contracts/MutableContract.sol b/tests/contracts/MutableContract.sol new file mode 100644 index 0000000..2ccb76e --- /dev/null +++ b/tests/contracts/MutableContract.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: UNLICENSED + +pragma solidity ^0.8.15; + +function IsAmethystBeautiful() public returns (bool) { + return true; +} + +contract MutableContract { + +}