Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.3.4 Staging #783

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aderyn_core/src/context/browser/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<'a> ExtractReferencedDeclarationsConditionally<'a> {
}
}

impl<'a> ASTConstVisitor for ExtractReferencedDeclarationsConditionally<'a> {
impl ASTConstVisitor for ExtractReferencedDeclarationsConditionally<'_> {
fn visit_member_access(&mut self, node: &MemberAccess) -> Result<bool> {
if !self.condition.as_ref()(node.id, self.context) {
return Ok(true);
Expand Down
4 changes: 2 additions & 2 deletions aderyn_core/src/context/browser/storage_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'a> Add<ApproximateStorageChangeFinder<'_>> for ApproximateStorageChangeFin
}
}

impl<'a> Debug for ApproximateStorageChangeFinder<'a> {
impl Debug for ApproximateStorageChangeFinder<'_> {
// Do not print context. Hence, debug is custom derived for this struct
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "Manipulated directly: {:?}", self.directly_manipulated_state_variables)?;
Expand Down Expand Up @@ -213,7 +213,7 @@ impl<'a> ApproximateStorageChangeFinder<'a> {
}
}

impl<'a> ASTConstVisitor for ApproximateStorageChangeFinder<'a> {
impl ASTConstVisitor for ApproximateStorageChangeFinder<'_> {
fn visit_unary_operation(&mut self, node: &UnaryOperation) -> Result<bool> {
// WRITE HEURISTICS
// Catch unary operations that manipulate variables
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/context/graph/callgraph_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ mod callgraph_test_functions {
outward_side_effects_modifier_definitions_names: Vec<String>,
}

impl<'a> Tracker<'a> {
impl Tracker<'_> {
fn new(context: &WorkspaceContext) -> Tracker {
Tracker {
context,
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/detect/high/const_func_change_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct StateVariableChangeTracker<'a> {
context: &'a WorkspaceContext,
}

impl<'a> CallGraphVisitor for StateVariableChangeTracker<'a> {
impl CallGraphVisitor for StateVariableChangeTracker<'_> {
fn visit_any(&mut self, node: &crate::ast::ASTNode) -> eyre::Result<()> {
if self.state_var_has_changed {
return Ok(());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct DelegateCallNoAddressChecksTracker<'a> {
context: &'a WorkspaceContext,
}

impl<'a> CallGraphVisitor for DelegateCallNoAddressChecksTracker<'a> {
impl CallGraphVisitor for DelegateCallNoAddressChecksTracker<'_> {
fn visit_any(&mut self, node: &crate::context::workspace_context::ASTNode) -> eyre::Result<()> {
if !self.has_address_checks && helpers::has_binary_checks_on_some_address(node) {
self.has_address_checks = true;
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/detect/high/incorrect_erc20_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ mod erc_matching_function_signature_helper {
}

// Helps with checking if a function definition satisifed a signature matcher
impl<'a> SignatureMatcher<'a> {
impl SignatureMatcher<'_> {
fn satisfies(&self, func: &FunctionDefinition) -> Option<bool> {
if func.name != self.name {
return Some(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mod erc721_matching_function_signature_helper {
}

// Helps with checking if a function definition satisifed a signature matcher
impl<'a> SignatureMatcher<'a> {
impl SignatureMatcher<'_> {
fn satisfies(&self, func: &FunctionDefinition) -> bool {
if func.name != self.name {
return false;
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/detect/high/nested_struct_in_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn version_req_allows_below_0_5_0(version_req: &VersionReq) -> bool {
}

let comparator = &version_req.comparators[0];
comparator.major == 0 && comparator.minor.map_or(false, |m| m < 5)
comparator.major == 0 && comparator.minor.is_some_and(|m| m < 5)
}

impl IssueDetector for NestedStructInMappingDetector {
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/detect/high/state_variable_shadowing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn allows_below_0_6_0(version_req: &VersionReq) -> bool {
}

let comparator = &version_req.comparators[0];
comparator.major == 0 && comparator.minor.map_or(false, |m| m < 6)
comparator.major == 0 && comparator.minor.is_some_and(|m| m < 6)
}

impl IssueDetector for StateVariableShadowingDetector {
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/detect/low/assert_state_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mod assert_state_change_tracker {
context: &'a WorkspaceContext,
}

impl<'a> CallGraphVisitor for StateVariableChangeTracker<'a> {
impl CallGraphVisitor for StateVariableChangeTracker<'_> {
fn visit_any(&mut self, node: &crate::ast::ASTNode) -> eyre::Result<()> {
if self.has_some_state_variable_changed {
return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/detect/low/cache_array_length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ mod loop_investigation_helper {
changes: Option<ApproximateStorageChangeFinder<'a>>,
}

impl<'a> CallGraphVisitor for StateVariableChangeTracker<'a> {
impl CallGraphVisitor for StateVariableChangeTracker<'_> {
fn visit_any(&mut self, node: &ASTNode) -> eyre::Result<()> {
let changes = ApproximateStorageChangeFinder::from(self.context, node);
if self.changes.is_none() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct StateVariableChangeTracker<'a> {
context: &'a WorkspaceContext,
}

impl<'a> CallGraphVisitor for StateVariableChangeTracker<'a> {
impl CallGraphVisitor for StateVariableChangeTracker<'_> {
fn visit_any(&mut self, node: &crate::ast::ASTNode) -> eyre::Result<()> {
if self.state_var_has_changed {
return Ok(());
Expand Down
4 changes: 2 additions & 2 deletions aderyn_core/src/detect/low/deprecated_oz_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl IssueDetector for DeprecatedOZFunctionsDetector {
directive
.absolute_path
.as_ref()
.map_or(false, |path| path.contains("openzeppelin"))
.is_some_and(|path| path.contains("openzeppelin"))
}) && identifier.name == "_setupRole"
{
capture!(self, context, identifier);
Expand All @@ -51,7 +51,7 @@ impl IssueDetector for DeprecatedOZFunctionsDetector {
directive
.absolute_path
.as_ref()
.map_or(false, |path| path.contains("openzeppelin"))
.is_some_and(|path| path.contains("openzeppelin"))
}) && member_access.member_name == "safeApprove"
{
capture!(self, context, member_access);
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/detect/low/function_init_state_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<'a> NonConstantStateVariableReferenceDeclarationTracker<'a> {
}
}

impl<'a> CallGraphVisitor for NonConstantStateVariableReferenceDeclarationTracker<'a> {
impl CallGraphVisitor for NonConstantStateVariableReferenceDeclarationTracker<'_> {
fn visit_any(&mut self, node: &ASTNode) -> eyre::Result<()> {
// We already know the condition is satisifed
if self.makes_a_reference {
Expand Down
4 changes: 2 additions & 2 deletions aderyn_core/src/detect/low/missing_inheritance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl IssueDetector for MissingInheritanceDetector {
continue;
}
if let Some(ASTNode::ContractDefinition(c)) = context.nodes.get(contract_id) {
if c.kind != ContractKind::Contract || c.is_abstract.map_or(false, identity) {
if c.kind != ContractKind::Contract || c.is_abstract.is_some_and(identity) {
continue;
}
}
Expand All @@ -100,7 +100,7 @@ impl IssueDetector for MissingInheritanceDetector {
if let Some(ASTNode::ContractDefinition(c)) =
context.nodes.get(potentially_missing_inheritance)
{
if c.kind == ContractKind::Interface || c.is_abstract.map_or(false, identity) {
if c.kind == ContractKind::Interface || c.is_abstract.is_some_and(identity) {
// Check that the contract is compatible with the missing inheritance
if missing_function_selectors.iter().all(|s| contract_selectors.contains(s))
{
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/detect/low/return_bomb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct CallNoAddressChecksTracker<'a> {
context: &'a WorkspaceContext,
}

impl<'a> CallGraphVisitor for CallNoAddressChecksTracker<'a> {
impl CallGraphVisitor for CallNoAddressChecksTracker<'_> {
fn visit_any(&mut self, node: &crate::context::workspace_context::ASTNode) -> eyre::Result<()> {
if !self.has_address_checks && helpers::has_binary_checks_on_some_address(node) {
self.has_address_checks = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ mod function_state_changes_finder_helper {
changes: Option<ApproximateStorageChangeFinder<'a>>,
}

impl<'a> CallGraphVisitor for StateVariableChangeTracker<'a> {
impl CallGraphVisitor for StateVariableChangeTracker<'_> {
fn visit_any(&mut self, node: &ASTNode) -> eyre::Result<()> {
let changes = ApproximateStorageChangeFinder::from(self.context, node);
if self.changes.is_none() {
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/detect/low/unsafe_oz_erc721_mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl IssueDetector for UnsafeERC721MintDetector {
directive
.absolute_path
.as_ref()
.map_or(false, |path| path.contains("openzeppelin"))
.is_some_and(|path| path.contains("openzeppelin"))
}) && identifier.name == "_mint"
{
let this_contract_definition = identifier
Expand Down
6 changes: 1 addition & 5 deletions aderyn_core/src/fscloc/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ impl FromStr for CodeIterator {
type Err = usize;

fn from_str(code: &str) -> Result<Self, <Self as FromStr>::Err> {
return Ok(CodeIterator {
content: code.chars().collect::<Vec<_>>(),
curr_pos: 0,
line_no: 1,
});
Ok(CodeIterator { content: code.chars().collect::<Vec<_>>(), curr_pos: 0, line_no: 1 })
}
}
11 changes: 0 additions & 11 deletions aderyn_core/src/report/json_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ pub struct JsonContent {

pub struct JsonPrinter;

/**
* JSON should mimick MD
{
"files_summary": {...},
"files_details": {...},
"issue_summary": {...},
"high_issues": {...},
...
}
*/

impl ReportPrinter<()> for JsonPrinter {
fn print_report<W: Write>(
&self,
Expand Down
Loading