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

Remove false positive on array length detector #813

Merged
merged 3 commits into from
Mar 28, 2021
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
2 changes: 1 addition & 1 deletion scripts/ci_test_etherlime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ npm i -g etherlime
etherlime init
slither .

if [ $? -eq 8 ]
if [ $? -eq 7 ]
then
exit 0
fi
Expand Down
18 changes: 7 additions & 11 deletions slither/detectors/attributes/incorrect_solc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ class IncorrectSolc(AbstractDetector):
We also recommend avoiding complex `pragma` statement."""
WIKI_RECOMMENDATION = """
Deploy with any of the following Solidity versions:
- 0.5.11 - 0.5.13,
- 0.5.15 - 0.5.17,
- 0.6.8,
- 0.6.10 - 0.6.11.
- 0.5.16 - 0.5.17
- 0.6.11 - 0.6.12
- 0.7.5 - 0.7.6
Use a simple pragma version that allows any of these versions.
Consider using the latest version of Solidity for testing."""

Expand All @@ -47,23 +46,20 @@ class IncorrectSolc(AbstractDetector):
LESS_THAN_TXT = "uses lesser than"

TOO_RECENT_VERSION_TXT = (
"necessitates a version too recent to be trusted. Consider deploying with 0.6.11"
"necessitates a version too recent to be trusted. Consider deploying with 0.6.12/0.7.6"
)
BUGGY_VERSION_TXT = (
"is known to contain severe issues (https://solidity.readthedocs.io/en/latest/bugs.html)"
)

# Indicates the allowed versions. Must be formatted in increasing order.
ALLOWED_VERSIONS = [
"0.5.11",
"0.5.12",
"0.5.13",
"0.5.15",
"0.5.16",
"0.5.17",
"0.6.8",
"0.6.10",
"0.6.11",
"0.6.12",
"0.7.5",
"0.7.6",
]

# Indicates the versions that should not be used.
Expand Down
3 changes: 3 additions & 0 deletions slither/detectors/statements/array_length_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def _detect(self):
Detect array length assignments
"""
results = []
# Starting from 0.6 .length is read only
if self.slither.solc_version >= "0.6.":
return results
for contract in self.contracts:
array_length_assignments = detect_array_length_assignment(contract)
if array_length_assignments:
Expand Down