Skip to content

Commit

Permalink
add native support
Browse files Browse the repository at this point in the history
  • Loading branch information
olegggatttor committed Apr 16, 2024
1 parent 9028442 commit a96c304
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions slitherin/detectors/price_manipulation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from typing import List
from slither.utils.output import Output
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations import Function
from slither.slithir.operations.event_call import EventCall
from slither.slithir.operations.high_level_call import HighLevelCall
from slither.slithir.operations.internal_call import InternalCall
from slither.slithir.operations.binary import Binary, BinaryType
from slither.slithir.operations.solidity_call import SolidityCall
from slither.slithir.operations.binary import Binary
from slither.analyses.data_dependency.data_dependency import is_dependent


Expand All @@ -30,6 +29,9 @@ def _detect(self) -> List[Output]:
for func in contract.functions:
for n in func.nodes:
for x in n.irs:
if isinstance(x, SolidityCall):
if x.function.name == "balance(address)" or x.function.name == "self.balance" or x.function.name == "this.balance()":
all_balance_vars.append((n, x._lvalue))
if isinstance(x, HighLevelCall):
if str(x.function_name).lower() == "balanceof":
all_balance_vars.append((n, x._lvalue))
Expand Down
4 changes: 4 additions & 0 deletions tests/price_manipulation_test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ contract Test1 {
price = getBalance() + mySupply() + 1;
}

function test_vuln_7() external returns(uint256 price) {
price = address(token).balance / mySupply();
}

function getBalance() public returns(uint256 bal) {
bal = token.balanceOf(msg.sender);
}
Expand Down

0 comments on commit a96c304

Please sign in to comment.