Skip to content

Commit

Permalink
fix lints and add missing artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
0xalpharush committed Apr 21, 2022
1 parent 1d81829 commit 2e7f1f1
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 10 deletions.
12 changes: 6 additions & 6 deletions slither/detectors/erc/erc20/arbitrary_send_erc20.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def _detect_arbitrary_from(self, contract: Contract):
"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)"
in all_high_level_calls
):
self._arbitrary_from(f.nodes, self._permit_results)
ArbitrarySendErc20._arbitrary_from(f.nodes, self._permit_results)
else:
self._arbitrary_from(f.nodes, self._no_permit_results)
ArbitrarySendErc20._arbitrary_from(f.nodes, self._no_permit_results)

@classmethod
def _arbitrary_from(self, nodes: List[Node], results: List[Node]):
@staticmethod
def _arbitrary_from(nodes: List[Node], results: List[Node]):
"""Finds instances of (safe)transferFrom that do not use msg.sender or address(this) as from parameter."""
for node in nodes:
for ir in node.irs:
Expand Down Expand Up @@ -89,7 +89,7 @@ def _arbitrary_from(self, nodes: List[Node], results: List[Node]):
):
results.append(ir.node)

def _detect(self):
""""""
def detect(self):
"""Detect transfers that use arbitrary `from` parameter."""
for c in self.compilation_unit.contracts_derived:
self._detect_arbitrary_from(c)
4 changes: 2 additions & 2 deletions slither/detectors/erc/erc20/arbitrary_send_erc20_no_permit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List
from .arbitrary_send_erc20 import ArbitrarySendErc20
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.utils.output import Output
from .arbitrary_send_erc20 import ArbitrarySendErc20


class ArbitrarySendErc20NoPermit(AbstractDetector):
Expand Down Expand Up @@ -35,7 +35,7 @@ def _detect(self) -> List[Output]:
results: List[Output] = []

arbitrary_sends = ArbitrarySendErc20(self.compilation_unit)
arbitrary_sends._detect()
arbitrary_sends.detect()
for node in arbitrary_sends.no_permit_results:
func = node.function
info = [func, " uses arbitrary from in transferFrom: ", node, "\n"]
Expand Down
4 changes: 2 additions & 2 deletions slither/detectors/erc/erc20/arbitrary_send_erc20_permit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List
from .arbitrary_send_erc20 import ArbitrarySendErc20
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.utils.output import Output
from .arbitrary_send_erc20 import ArbitrarySendErc20


class ArbitrarySendErc20Permit(AbstractDetector):
Expand Down Expand Up @@ -38,7 +38,7 @@ def _detect(self) -> List[Output]:
results: List[Output] = []

arbitrary_sends = ArbitrarySendErc20(self.compilation_unit)
arbitrary_sends._detect()
arbitrary_sends.detect()
for node in arbitrary_sends.permit_results:
func = node.function
info = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
[
[
{
"elements": [
{
"type": "function",
"name": "bad",
"source_mapping": {
"start": 196,
"length": 88,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"is_dependency": false,
"lines": [
11,
12,
13
],
"starting_column": 2,
"ending_column": 3
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "T",
"source_mapping": {
"start": 138,
"length": 149,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"is_dependency": false,
"lines": [
7,
8,
9,
10,
11,
12,
13,
14
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad(address)"
}
},
{
"type": "node",
"name": "erc20.safeTransferFrom(from,address(0x1),90)",
"source_mapping": {
"start": 234,
"length": 46,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"is_dependency": false,
"lines": [
12
],
"starting_column": 3,
"ending_column": 49
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad",
"source_mapping": {
"start": 196,
"length": 88,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"is_dependency": false,
"lines": [
11,
12,
13
],
"starting_column": 2,
"ending_column": 3
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "T",
"source_mapping": {
"start": 138,
"length": 149,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol",
"is_dependency": false,
"lines": [
7,
8,
9,
10,
11,
12,
13,
14
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad(address)"
}
}
}
}
],
"description": "T.bad(address) (tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol#11-13) uses arbitrary from in transferFrom: erc20.safeTransferFrom(from,address(0x1),90) (tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol#12)\n",
"markdown": "[T.bad(address)](tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol#L11-L13) uses arbitrary from in transferFrom: [erc20.safeTransferFrom(from,address(0x1),90)](tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol#L12)\n",
"first_markdown_element": "tests/detectors/arbitrary-send-erc20/0.8.0/arbitrary_send_erc20_inheritance.sol#L11-L13",
"id": "51845f69be45c4d9b97ff3e01cbc5bf55d1c1cddcc4776f39e22dd803a241e46",
"check": "arbitrary-send-erc20",
"impact": "High",
"confidence": "High"
}
]
]

0 comments on commit 2e7f1f1

Please sign in to comment.