Skip to content

Commit

Permalink
Update dos_detector.py
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayarawat19 committed Apr 9, 2024
1 parent 6298cdc commit e3c1971
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions slither/detectors/functions/dos_detector.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from typing import List, Optional
from enum import Enum
from slither.core.cfg.node import NodeType, Node
from slither.detectors.detector import AbstractDetector, DetectorClassification
from slither.core.solidity_types import ElementaryType
from slither.slithir.variables import Constant
from slither.core.declarations import Contract
from slither.utils.output import Output
from slither.slithir.operations import Condition

def detect_infinite_loop_calls(contract: Contract) -> List[Node]:
ret: List[Node] = []
Expand Down Expand Up @@ -34,9 +30,7 @@ def detect_infinite_calls(node: Optional[Node], visited: List[Node], ret: List[N
def has_exit_condition(node: Node) -> bool:
if node.type == NodeType.STARTLOOP:
for son in node.sons:
# Check if the son node represents a condition
if son.type == NodeType.IFLOOP:
# if son.type == NodeType.WHILELOOP:
return True # Exit condition found
return False # No condition found within the loop
else:
Expand Down Expand Up @@ -65,8 +59,7 @@ def _detect(self) -> List[Output]:
values = detect_infinite_loop_calls(c)
for node in values:
func = node.function

info: DETECTOR_INFO = [func, " contains a loop without proper exit condition: ", node, "\n",]
info = [func, " contains a loop without proper exit condition: ", node, "\n",]
res = self.generate_result(info)
results.append(res)
return results
Expand Down

0 comments on commit e3c1971

Please sign in to comment.