-
Notifications
You must be signed in to change notification settings - Fork 979
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test case added, API output asserted, output format slightly changed
- Loading branch information
1 parent
fcb0aed
commit 4710753
Showing
3 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
pragma solidity ^0.8.19; | ||
|
||
interface IERC20 { | ||
function transferFrom(address from, address to, uint amount) external returns (bool); | ||
} | ||
|
||
/** | ||
* @title MissingReturnBug | ||
* @author IllIllI | ||
*/ | ||
|
||
// test case of the missing return bug described here: | ||
// https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca | ||
contract Unsafe { | ||
IERC20 erc20; | ||
function good2(address to, uint256 am) public { | ||
address from_msgsender = msg.sender; | ||
int_transferFrom(from_msgsender, to, am); // from is constant | ||
} | ||
|
||
// This is not detected | ||
function bad2(address from, address to, uint256 am) public { | ||
int_transferFrom(from, to, amount); // from is not a constant | ||
} | ||
|
||
function int_transferFrom(address from, address to, uint256 amount) internal { | ||
erc20.transferFrom(from, to, amount); // not a constant = not a constant U constant | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from pathlib import Path | ||
from slither import Slither | ||
from slither.analyses.data_dependency.data_dependency import ( | ||
get_must_depends_on | ||
) | ||
|
||
TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data" | ||
|
||
def test_must_depend_on_returns(solc_binary_path): | ||
solc_path = solc_binary_path("0.8.19") | ||
file = Path(TEST_DATA_DIR, "must_depend_on.sol").as_posix() | ||
slither_obj = Slither(file, solc=solc_path) | ||
result = get_must_depends_on(slither_obj.contracts[1].functions[2].parameters[0]) | ||
assert isinstance(result, list) and len(result) <= 1 | ||