Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PR#2034 #2384

Merged
merged 5 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions slither/solc_parsing/declarations/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,19 +849,26 @@ def _parse_variable_definition(self, statement: Dict, node: NodeSolc, scope: Sco
new_node = self._parse_variable_definition_init_tuple(
new_statement, i, new_node, scope
)
else:
variables.append(None)
i = i + 1

var_identifiers = []
# craft of the expression doing the assignement
for v in variables:
identifier = {
"nodeType": "Identifier",
"src": v["src"],
"name": v["name"],
"referencedDeclaration": v["id"],
"typeDescriptions": {"typeString": v["typeDescriptions"]["typeString"]},
}
var_identifiers.append(identifier)
if v is not None:
identifier = {
"nodeType": "Identifier",
"src": v["src"],
"name": v["name"],
"referencedDeclaration": v["id"],
"typeDescriptions": {
"typeString": v["typeDescriptions"]["typeString"]
},
}
var_identifiers.append(identifier)
else:
var_identifiers.append(None)

tuple_expression = {
"nodeType": "TupleExpression",
Expand Down
6 changes: 0 additions & 6 deletions slither/visitors/slithir/expression_to_slithir.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,6 @@
for idx, _ in enumerate(left):
if not left[idx] is None:
index = idx
# The following test is probably always true?
if (
isinstance(left[idx], LocalVariableInitFromTuple)
and left[idx].tuple_index is not None
):
index = left[idx].tuple_index
operation = Unpack(left[idx], right, index)
operation.set_expression(expression)
self._result.append(operation)
Expand Down Expand Up @@ -436,7 +430,7 @@
set_val(expression, val)

def _post_conditional_expression(self, expression: ConditionalExpression) -> None:
raise Exception(f"Ternary operator are not convertible to SlithIR {expression}")

Check warning on line 433 in slither/visitors/slithir/expression_to_slithir.py

View workflow job for this annotation

GitHub Actions / Lint Code Base

W0719: Raising too general exception: Exception (broad-exception-raised)

def _post_elementary_type_name_expression(
self,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Reentrancy in ReentrancyBenign.bad0() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#16-22):
External calls:
- (success,None) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#17)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#21)

Reentrancy in ReentrancyBenign.bad3(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#41-45):
External calls:
- externalCaller(target) (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#42)
Expand All @@ -6,11 +12,11 @@ Reentrancy in ReentrancyBenign.bad3(address) (tests/e2e/detectors/test_data/reen
- varChanger() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#43)
- anotherVariableToChange ++ (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#69)

Reentrancy in ReentrancyBenign.bad0() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#16-22):
Reentrancy in ReentrancyBenign.bad1(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#24-28):
External calls:
- (success) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#17)
- (success,None) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#25)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#21)
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#27)

Reentrancy in ReentrancyBenign.bad5(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#54-58):
External calls:
Expand All @@ -33,15 +39,9 @@ Reentrancy in ReentrancyBenign.bad4(address) (tests/e2e/detectors/test_data/reen
- varChanger() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#50)
- anotherVariableToChange ++ (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#69)

Reentrancy in ReentrancyBenign.bad1(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#24-28):
External calls:
- (success) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#25)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#27)

Reentrancy in ReentrancyBenign.bad2(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#30-39):
External calls:
- (success) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#31)
- (success,None) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#31)
- address(target).call.value(1000)() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#33)
External calls sending eth:
- address(target).call.value(1000)() (tests/e2e/detectors/test_data/reentrancy-benign/0.5.16/reentrancy-benign.sol#33)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Reentrancy in ReentrancyBenign.bad2(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#30-39):
External calls:
- (success,None) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#31)
- address(target).call.value(1000)() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#33)
External calls sending eth:
- address(target).call.value(1000)() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#33)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#34)

Reentrancy in ReentrancyBenign.bad4(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#47-52):
External calls:
- externalCaller(target) (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#48)
Expand All @@ -19,21 +28,6 @@ Reentrancy in ReentrancyBenign.bad3(address) (tests/e2e/detectors/test_data/reen
- varChanger() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#43)
- anotherVariableToChange ++ (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#69)

Reentrancy in ReentrancyBenign.bad2(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#30-39):
External calls:
- (success) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#31)
- address(target).call.value(1000)() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#33)
External calls sending eth:
- address(target).call.value(1000)() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#33)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#34)

Reentrancy in ReentrancyBenign.bad1(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#24-28):
External calls:
- (success) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#25)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#27)

Reentrancy in ReentrancyBenign.bad5(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#54-58):
External calls:
- ethSender(address(0)) (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#55)
Expand All @@ -44,7 +38,13 @@ Reentrancy in ReentrancyBenign.bad5(address) (tests/e2e/detectors/test_data/reen

Reentrancy in ReentrancyBenign.bad0() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#16-22):
External calls:
- (success) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#17)
- (success,None) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#17)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#21)

Reentrancy in ReentrancyBenign.bad1(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#24-28):
External calls:
- (success,None) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#25)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.6.11/reentrancy-benign.sol#27)

Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
Reentrancy in ReentrancyBenign.bad3(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#41-45):
Reentrancy in ReentrancyBenign.bad0() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#16-22):
External calls:
- externalCaller(target) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#42)
- address(target).call() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#61)
- (success,None) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#17)
State variables written after the call(s):
- varChanger() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#43)
- anotherVariableToChange ++ (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#69)
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#21)

Reentrancy in ReentrancyBenign.bad2(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#30-39):
External calls:
- (success) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#31)
- (success,None) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#31)
- address(target).call{value: 1000}() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#33)
External calls sending eth:
- address(target).call{value: 1000}() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#33)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#34)

Reentrancy in ReentrancyBenign.bad3(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#41-45):
External calls:
- externalCaller(target) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#42)
- address(target).call() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#61)
State variables written after the call(s):
- varChanger() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#43)
- anotherVariableToChange ++ (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#69)

Reentrancy in ReentrancyBenign.bad5(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#54-58):
External calls:
- ethSender(address(0)) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#55)
Expand All @@ -23,6 +29,12 @@ Reentrancy in ReentrancyBenign.bad5(address) (tests/e2e/detectors/test_data/reen
- varChanger() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#56)
- anotherVariableToChange ++ (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#69)

Reentrancy in ReentrancyBenign.bad1(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#24-28):
External calls:
- (success,None) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#25)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#27)

Reentrancy in ReentrancyBenign.bad4(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#47-52):
External calls:
- externalCaller(target) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#48)
Expand All @@ -36,15 +48,3 @@ Reentrancy in ReentrancyBenign.bad4(address) (tests/e2e/detectors/test_data/reen
- varChanger() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#50)
- anotherVariableToChange ++ (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#69)

Reentrancy in ReentrancyBenign.bad1(address) (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#24-28):
External calls:
- (success) = target.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#25)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#27)

Reentrancy in ReentrancyBenign.bad0() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#16-22):
External calls:
- (success) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#17)
State variables written after the call(s):
- counter += 1 (tests/e2e/detectors/test_data/reentrancy-benign/0.7.6/reentrancy-benign.sol#21)

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Reentrancy in ReentrancyWrite.bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#16-23):
External calls:
- (success) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#18)
- (success,None) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#18)
State variables written after the call(s):
- notCalled = false (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#22)
ReentrancyWrite.notCalled (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#4) can be used in cross function reentrancies:
Expand All @@ -11,9 +11,9 @@ Reentrancy in ReentrancyWrite.bad0() (tests/e2e/detectors/test_data/reentrancy-n

Reentrancy in ReentrancyWrite.bad1(address) (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#25-30):
External calls:
- (success) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#27)
- (success,None) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#27)
- bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#29)
- (success) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#18)
- (success,None) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#18)
State variables written after the call(s):
- bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#29)
- notCalled = false (tests/e2e/detectors/test_data/reentrancy-no-eth/0.5.16/reentrancy-write.sol#22)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
Reentrancy in ReentrancyWrite.bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#16-23):
Reentrancy in ReentrancyWrite.bad1(address) (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#25-30):
External calls:
- (success) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#18)
- (success,None) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#27)
- bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#29)
- (success,None) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#18)
State variables written after the call(s):
- notCalled = false (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#22)
- bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#29)
- notCalled = false (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#22)
ReentrancyWrite.notCalled (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#4) can be used in cross function reentrancies:
- ReentrancyWrite.bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#16-23)
- ReentrancyWrite.bad1(address) (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#25-30)
- ReentrancyWrite.constructor(address) (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#7-14)
- ReentrancyWrite.good() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#32-39)

Reentrancy in ReentrancyWrite.bad1(address) (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#25-30):
Reentrancy in ReentrancyWrite.bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#16-23):
External calls:
- (success) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#27)
- bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#29)
- (success) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#18)
- (success,None) = msg.sender.call() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#18)
State variables written after the call(s):
- bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#29)
- notCalled = false (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#22)
- notCalled = false (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#22)
ReentrancyWrite.notCalled (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#4) can be used in cross function reentrancies:
- ReentrancyWrite.bad0() (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#16-23)
- ReentrancyWrite.bad1(address) (tests/e2e/detectors/test_data/reentrancy-no-eth/0.6.11/reentrancy-write.sol#25-30)
Expand Down
Loading
Loading