Skip to content

Commit

Permalink
Merge branch 'dev' into add-detectors-to-include-override-exclude-args
Browse files Browse the repository at this point in the history
  • Loading branch information
nsiregar authored Apr 25, 2024
2 parents 03487e8 + ded705d commit 1b5210f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 7 deletions.
25 changes: 25 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: "en"
early_access: false
knowledge_base:
learnings:
scope: auto
issues:
scope: global
reviews:
profile: "chill"
request_changes_workflow: false
high_level_summary: true
poem: false
review_status: true
collapse_walkthrough: true
auto_review:
enabled: true
ignore_title_keywords:
- "WIP"
- "DO NOT MERGE"
drafts: false
base_branches:
- dev
chat:
auto_reply: true
10 changes: 8 additions & 2 deletions slither/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Type, Union


from crytic_compile import cryticparser, CryticCompile
from crytic_compile import cryticparser, CryticCompile, InvalidCompilation
from crytic_compile.platform.standard import generate_standard_export
from crytic_compile.platform.etherscan import SUPPORTED_NETWORK
from crytic_compile import compile_all, is_supported
Expand Down Expand Up @@ -93,7 +93,13 @@ def process_all(
detector_classes: List[Type[AbstractDetector]],
printer_classes: List[Type[AbstractPrinter]],
) -> Tuple[List[Slither], List[Dict], List[Output], int]:
compilations = compile_all(target, **vars(args))

try:
compilations = compile_all(target, **vars(args))
except InvalidCompilation:
logger.error("Unable to compile all targets.")
sys.exit(2)

slither_instances = []
results_detectors = []
results_printers = []
Expand Down
2 changes: 1 addition & 1 deletion slither/detectors/compiler_bugs/reused_base_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ReusedBaseConstructor(AbstractDetector):
ARGUMENT = "reused-constructor"
HELP = "Reused base constructor"
IMPACT = DetectorClassification.MEDIUM
# The confidence is medium, because prior Solidity 0.4.22, we cant differentiate
# The confidence is medium, because prior Solidity 0.4.22, we can't differentiate
# contract C is A() {
# to
# contract C is A {
Expand Down
2 changes: 1 addition & 1 deletion slither/solc_parsing/declarations/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def _analyze_params_elements( # pylint: disable=too-many-arguments,too-many-loc
def analyze_constant_state_variables(self) -> None:
for var_parser in self._variables_parser:
if var_parser.underlying_variable.is_constant:
# cant parse constant expression based on function calls
# can't parse constant expression based on function calls
try:
var_parser.analyze(self)
except (VariableNotFound, KeyError) as e:
Expand Down
20 changes: 20 additions & 0 deletions tests/e2e/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys
import tempfile
import pytest

from slither.__main__ import main_impl


def test_cli_exit_on_invalid_compilation_file(caplog):

with tempfile.NamedTemporaryFile("w") as f:
f.write("pragma solidity ^0.10000.0;")

sys.argv = ["slither", f.name]
with pytest.raises(SystemExit) as pytest_wrapped_e:
main_impl([], [])

assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 2

assert caplog.record_tuples[0] == ("Slither", 40, "Unable to compile all targets.")
2 changes: 1 addition & 1 deletion tests/unit/core/test_source_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_source_mapping_inheritance(solc_binary_path, solc_version):
assert {(x.start, x.end) for x in slither.offset_to_implementations(file, 203)} == {(193, 230)}

# Offset 93 is the call to f() in A.test()
# This can lead to three differents functions, depending on the current contract's context
# This can lead to three different functions, depending on the current contract's context
functions = slither.offset_to_objects(file, 93)
print(functions)
assert len(functions) == 3
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/slithir/test_data/ternary_expressions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contract C {
// TODO
// 1) support variable declarations
//uint min = 1 > 0 ? 1 : 2;
// 2) suppory ternary index range access
// 2) support ternary index range access
// function e(bool cond, bytes calldata x) external {
// bytes memory a = x[cond ? 1 : 2 :];
// }
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/slithir/test_ssa_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def test_storage_refers_to(slither_from_solidity_source):
entryphi = [x for x in phinodes if x.lvalue in sphi.lvalue.refers_to]
assert len(entryphi) == 2

# The remaining two phis are the ones recording that write through ReferenceVariable occured
# The remaining two phis are the ones recording that write through ReferenceVariable occurred
for ephi in entryphi:
phinodes.remove(ephi)
phinodes.remove(sphi)
Expand Down

0 comments on commit 1b5210f

Please sign in to comment.