make it interprocedural (only 1 call deep)

pull/2340/head
alpharush 9 months ago
parent 69d3c257b4
commit 04ff85fd65
  1. 2
      slither/detectors/all_detectors.py
  2. 17
      slither/detectors/functions/out_of_order_retryable.py
  3. 4
      tests/e2e/detectors/snapshots/detectors__detector_OutOfOrderRetryable_0_8_20_out_of_order_retryable_sol__0.txt
  4. 23
      tests/e2e/detectors/test_data/out-of-order-retryable/0.8.20/out_of_order_retryable.sol
  5. BIN
      tests/e2e/detectors/test_data/out-of-order-retryable/0.8.20/out_of_order_retryable.sol-0.8.20.zip

@ -97,6 +97,4 @@ from .assembly.return_instead_of_leave import ReturnInsteadOfLeave
from .operations.incorrect_exp import IncorrectOperatorExponentiation
from .statements.tautological_compare import TautologicalCompare
from .statements.return_bomb import ReturnBomb
from .functions.out_of_order_retryable import OutOfOrderRetryable

@ -98,12 +98,23 @@ Bob calls `doStuffOnL2` but the first retryable ticket calling `claim_rewards` f
if self.key not in node.context:
node.context[self.key] = fathers_context
# analyze node
for ir in node.irs:
# include ops from internal function calls
internal_ops = []
for internal_call in node.internal_calls:
if isinstance(internal_call, Function):
internal_ops += internal_call.all_slithir_operations()
# analyze node for retryable tickets
for ir in node.irs + internal_ops:
if (
isinstance(ir, HighLevelCall)
and isinstance(ir.function, Function)
and ir.function.name == "createRetryableTicket"
and ir.function.name
in [
"createRetryableTicket",
"outboundTransferCustomRefund",
"unsafeCreateRetryableTicket",
]
):
node.context[self.key].append(node)

@ -6,3 +6,7 @@ Multiple retryable tickets created in the same function:
-Y(msg.sender).createRetryableTicket(address(1),0,0,address(0),address(0),0,0,) (tests/e2e/detectors/test_data/out-of-order-retryable/0.8.20/out_of_order_retryable.sol#40-48)
-Y(msg.sender).createRetryableTicket(address(2),0,0,address(0),address(0),0,0,) (tests/e2e/detectors/test_data/out-of-order-retryable/0.8.20/out_of_order_retryable.sol#50-58)
Multiple retryable tickets created in the same function:
-Y(msg.sender).createRetryableTicket(address(1),0,0,address(0),address(0),0,0,) (tests/e2e/detectors/test_data/out-of-order-retryable/0.8.20/out_of_order_retryable.sol#83-91)
-good2() (tests/e2e/detectors/test_data/out-of-order-retryable/0.8.20/out_of_order_retryable.sol#92)

@ -79,4 +79,27 @@ function bad2() external {
0,
"");
}
function bad3() external {
Y(msg.sender).createRetryableTicket(
address(1),
0,
0,
address(0),
address(0),
0,
0,
"");
good2();
}
function good2() internal {
Y(msg.sender).createRetryableTicket(
address(2),
0,
0,
address(0),
address(0),
0,
0,
"");
}
}
Loading…
Cancel
Save