Skip to content

Commit eb7fdb3

Browse files
committed
Merge branch 'dev' of github.com:crytic/slither into dev
2 parents 5b1f549 + df1ff42 commit eb7fdb3

File tree

9 files changed

+1885
-1855
lines changed

9 files changed

+1885
-1855
lines changed

scripts/ci_test_printers.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,24 @@
22

33
### Test printer
44

5-
# Needed for evm printer
6-
pip install evm-cfg-builder
5+
cd tests/ast-parsing/compile || exit
76

8-
if ! slither "tests/*.json" --print all --json -; then
9-
echo "Printer tests failed"
7+
# Do not test the evm printer,as it needs a refactoring
8+
ALL_PRINTERS="cfg,constructor-calls,contract-summary,data-dependency,echidna,function-id,function-summary,modifiers,call-graph,human-summary,inheritance,inheritance-graph,slithir,slithir-ssa,vars-and-auth,require,variable-order"
9+
10+
# Only test 0.5.17 to limit test time
11+
for file in *0.5.17-compact.zip; do
12+
if ! slither "$file" --print "$ALL_PRINTERS" > /dev/null 2>&1 ; then
13+
echo "Printer failed"
14+
echo "$file"
1015
exit 1
11-
fi
16+
fi
17+
done
1218

19+
cd ../../.. || exit
20+
# Needed for evm printer
21+
pip install evm-cfg-builder
1322
solc-select use "0.5.1"
14-
15-
slither examples/scripts/test_evm_api.sol --print evm
23+
if ! slither examples/scripts/test_evm_api.sol --print evm; then
24+
echo "EVM printer failed"
25+
fi

slither/core/declarations/function.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,11 @@ def is_protected(self) -> bool:
14051405
"""
14061406
Determine if the function is protected using a check on msg.sender
14071407
1408-
Only detects if msg.sender is directly used in a condition
1408+
Consider onlyOwner as a safe modifier.
1409+
If the owner functionality is incorrectly implemented, this will lead to incorrectly
1410+
classify the function as protected
1411+
1412+
Otherwise only detects if msg.sender is directly used in a condition
14091413
For example, it wont work for:
14101414
address a = msg.sender
14111415
require(a == owner)
@@ -1417,6 +1421,9 @@ def is_protected(self) -> bool:
14171421
if self.is_constructor:
14181422
self._is_protected = True
14191423
return True
1424+
if "onlyOwner" in [m.name for m in self.modifiers]:
1425+
self._is_protected = True
1426+
return True
14201427
conditional_vars = self.all_conditional_solidity_variables_read(include_loop=False)
14211428
args_vars = self.all_solidity_variables_used_as_args()
14221429
self._is_protected = (

slither/detectors/compiler_bugs/storage_ABIEncoderV2_array.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"0.5.7",
4444
"0.5.8",
4545
"0.5.9",
46-
"0.5.10",
4746
]
4847

4948

@@ -61,7 +60,7 @@ class ABIEncoderV2Array(AbstractDetector):
6160
"https://github.com/crytic/slither/wiki/Detector-Documentation#storage-abiencoderv2-array"
6261
)
6362
WIKI_TITLE = "Storage ABIEncoderV2 Array"
64-
WIKI_DESCRIPTION = """`solc` versions `0.4.7`-`0.5.10` contain a [compiler bug](https://blog.ethereum.org/2019/06/25/solidity-storage-array-bugs.) leading to incorrect ABI encoder usage."""
63+
WIKI_DESCRIPTION = """`solc` versions `0.4.7`-`0.5.9` contain a [compiler bug](https://blog.ethereum.org/2019/06/25/solidity-storage-array-bugs) leading to incorrect ABI encoder usage."""
6564
WIKI_EXPLOIT_SCENARIO = """
6665
```solidity
6766
contract A {

slither/printers/summary/variable_order.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def output(self, _filename):
2929
table = MyPrettyTable(["Name", "Type", "Slot", "Offset"])
3030
for variable in contract.state_variables_ordered:
3131
if not variable.is_constant:
32-
slot, offset = self.slither.storage_layout_of(contract, variable)
32+
slot, offset = contract.compilation_unit.storage_layout_of(contract, variable)
3333
table.add_row([variable.canonical_name, str(variable.type), slot, offset])
3434

3535
all_tables.append((contract.name, table))

slither/tools/upgradeability/checks/initialization.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22

3+
from slither.core.declarations import Function
34
from slither.slithir.operations import InternalCall
45
from slither.tools.upgradeability.checks.abstract_checks import (
56
AbstractCheck,
@@ -14,8 +15,18 @@ class MultipleInitTarget(Exception):
1415
pass
1516

1617

18+
def _has_initiliaze_modifier(function: Function):
19+
if not function.modifiers:
20+
return False
21+
return any((m.name == "initializer") for m in function.modifiers)
22+
23+
1724
def _get_initialize_functions(contract):
18-
return [f for f in contract.functions if f.name == "initialize" and f.is_implemented]
25+
return [
26+
f
27+
for f in contract.functions
28+
if (f.name == "initialize" or _has_initiliaze_modifier(f)) and f.is_implemented
29+
]
1930

2031

2132
def _get_all_internal_calls(function):

0 commit comments

Comments
 (0)