Skip to content

Commit

Permalink
Name graph -> callgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
alexroan committed Aug 14, 2024
1 parent 71b69f6 commit 500daa2
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 7 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion aderyn_core/src/context/investigator/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
ast::{NodeID, NodeType},
context::{
browser::{ExtractReferencedDeclarations, GetClosestAncestorOfTypeX},
graph::WorkspaceCallGraph,
callgraph::WorkspaceCallGraph,
workspace_context::{ASTNode, WorkspaceContext},
},
};
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/context/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod browser;
pub mod callgraph;
pub mod capturable;
pub mod graph;
pub mod investigator;
pub mod macros;
pub mod meta_workspace;
Expand Down
2 changes: 1 addition & 1 deletion aderyn_core/src/context/workspace_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::cmp::Ordering;
use std::collections::HashMap;

use super::browser::GetImmediateParent;
use super::callgraph::WorkspaceCallGraph;
use super::capturable::Capturable;
use super::graph::WorkspaceCallGraph;
pub use crate::ast::ASTNode;

#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
Expand Down
4 changes: 2 additions & 2 deletions aderyn_core/src/detect/test_utils/load_source_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::{

use crate::{
ast::SourceUnit,
context::{graph::traits::Transpose, workspace_context::WorkspaceContext},
context::{callgraph::traits::Transpose, workspace_context::WorkspaceContext},
};
use crate::{context::graph::WorkspaceCallGraph, visitor::ast_visitor::Node};
use crate::{context::callgraph::WorkspaceCallGraph, visitor::ast_visitor::Node};

use super::ensure_valid_solidity_file;

Expand Down
4 changes: 2 additions & 2 deletions aderyn_driver/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::{
config_helpers::{append_from_foundry_toml, derive_from_aderyn_toml},
ensure_valid_root_path, process_auto,
};
use aderyn_core::context::graph::traits::Transpose;
use aderyn_core::context::callgraph::traits::Transpose;
use aderyn_core::{
context::{graph::WorkspaceCallGraph, workspace_context::WorkspaceContext},
context::{callgraph::WorkspaceCallGraph, workspace_context::WorkspaceContext},
detect::detector::{get_all_issue_detectors, IssueDetector, IssueSeverity},
fscloc,
report::{
Expand Down
48 changes: 48 additions & 0 deletions tests/contract-playground/src/CallsInsideLoop.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.19;

contract HighLevelCallsInLoop {
address payable[] destinations;

function bad() external {
// BAD for loop (the fallback may revert causing DoS)
for (uint i = 0; i < destinations.length; i++) {
destinations[i].transfer(i);
}
}

function bad2() external {
// BAD for loop (the fallback may revert causing DoS)
for (uint i = 0; i < destinations.length; i++) {
facilitateTransfer(i, i * 2);
}
}

function facilitateTransfer(uint256 index, uint256 money) internal {
destinations[index].transfer(money);
}

function bad3() external view {
// BAD for loop
for (uint i = 0; i < destinations.length; i++) {
SimplyRevert(destinations[i]).sayHello();
}
}

function goodButTreatedAsBad() external view {
// BAD for loop
for (uint i = 0; i < destinations.length; i++) {
SimplyRevert(destinations[i]).innocent();
}
}
}

contract SimplyRevert {
error HellNo(string);

function sayHello() external pure {
revert();
}

function innocent() external pure {}
}

0 comments on commit 500daa2

Please sign in to comment.