Skip to content

Commit

Permalink
clippy:
Browse files Browse the repository at this point in the history
  • Loading branch information
alexroan committed Jul 28, 2024
1 parent 2f97bee commit 7ca61d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions aderyn_core/src/context/investigator/callgraph_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod callgraph_tests {
context
.function_definitions()
.into_iter()
.find(|&x| x.name == name.to_string())
.find(|&x| x.name == *name)
.unwrap(),
)
}
Expand All @@ -29,7 +29,7 @@ mod callgraph_tests {
context
.modifier_definitions()
.into_iter()
.find(|&x| x.name == name.to_string())
.find(|&x| x.name == *name)
.unwrap(),
)
}
Expand Down
40 changes: 20 additions & 20 deletions aderyn_core/src/detect/high/delegate_call_no_address_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ impl IssueDetector for DelegateCallOnUncheckedAddressDetector {
}
}

struct DelegateCallNoAddressChecksTracker<'a> {
has_address_checks: bool,
has_delegate_call_on_non_state_variable_address: bool,
context: &'a WorkspaceContext,
}

impl<'a> StandardInvestigatorVisitor for DelegateCallNoAddressChecksTracker<'a> {
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;
}
if !self.has_delegate_call_on_non_state_variable_address
&& helpers::has_delegate_calls_on_non_state_variables(node, self.context)
{
self.has_delegate_call_on_non_state_variable_address = true;
}
eyre::Ok(())
}
}

#[cfg(test)]
mod delegate_call_no_address_check_tests {
use crate::detect::{
Expand Down Expand Up @@ -110,23 +130,3 @@ mod delegate_call_no_address_check_tests {
);
}
}

struct DelegateCallNoAddressChecksTracker<'a> {
has_address_checks: bool,
has_delegate_call_on_non_state_variable_address: bool,
context: &'a WorkspaceContext,
}

impl<'a> StandardInvestigatorVisitor for DelegateCallNoAddressChecksTracker<'a> {
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;
}
if !self.has_delegate_call_on_non_state_variable_address
&& helpers::has_delegate_calls_on_non_state_variables(node, self.context)
{
self.has_delegate_call_on_non_state_variable_address = true;
}
eyre::Ok(())
}
}

0 comments on commit 7ca61d5

Please sign in to comment.