mirror of https://github.com/crytic/slither
commit
aa68cacdce
@ -1,8 +1,13 @@ |
|||||||
|
from typing import Tuple, List, Type |
||||||
|
|
||||||
from slither_my_plugin.detectors.example import Example |
from slither_my_plugin.detectors.example import Example |
||||||
|
|
||||||
|
from slither.detectors.abstract_detector import AbstractDetector |
||||||
|
from slither.printers.abstract_printer import AbstractPrinter |
||||||
|
|
||||||
|
|
||||||
def make_plugin(): |
def make_plugin() -> Tuple[List[Type[AbstractDetector]], List[Type[AbstractPrinter]]]: |
||||||
plugin_detectors = [Example] |
plugin_detectors = [Example] |
||||||
plugin_printers = [] |
plugin_printers: List[Type[AbstractPrinter]] = [] |
||||||
|
|
||||||
return plugin_detectors, plugin_printers |
return plugin_detectors, plugin_printers |
||||||
|
@ -0,0 +1,15 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
### Test path filtering across POSIX and Windows |
||||||
|
|
||||||
|
solc-select use 0.8.0 |
||||||
|
slither "tests/test_path_filtering/test_path_filtering.sol" --config "tests/test_path_filtering/slither.config.json" > "output.txt" 2>&1 |
||||||
|
|
||||||
|
if ! grep -q "0 result(s) found" "output.txt" |
||||||
|
then |
||||||
|
echo "Path filtering across POSIX and Windows failed" |
||||||
|
rm output.txt |
||||||
|
exit 5 |
||||||
|
else |
||||||
|
rm output.txt |
||||||
|
fi |
@ -1,21 +1,23 @@ |
|||||||
|
from typing import List |
||||||
|
|
||||||
from slither.slithir.operations.lvalue import OperationWithLValue |
from slither.slithir.operations.lvalue import OperationWithLValue |
||||||
from slither.core.solidity_types.elementary_type import ElementaryType |
from slither.core.solidity_types.elementary_type import ElementaryType |
||||||
|
|
||||||
|
|
||||||
class TmpNewElementaryType(OperationWithLValue): |
class TmpNewElementaryType(OperationWithLValue): |
||||||
def __init__(self, new_type, lvalue): |
def __init__(self, new_type: ElementaryType, lvalue): |
||||||
assert isinstance(new_type, ElementaryType) |
assert isinstance(new_type, ElementaryType) |
||||||
super().__init__() |
super().__init__() |
||||||
self._type = new_type |
self._type: ElementaryType = new_type |
||||||
self._lvalue = lvalue |
self._lvalue = lvalue |
||||||
|
|
||||||
@property |
@property |
||||||
def read(self): |
def read(self) -> List: |
||||||
return [] |
return [] |
||||||
|
|
||||||
@property |
@property |
||||||
def type(self): |
def type(self) -> ElementaryType: |
||||||
return self._type |
return self._type |
||||||
|
|
||||||
def __str__(self): |
def __str__(self) -> str: |
||||||
return f"{self.lvalue} = new {self._type}" |
return f"{self.lvalue} = new {self._type}" |
||||||
|
@ -1,28 +1,35 @@ |
|||||||
from decimal import Decimal |
from fractions import Fraction |
||||||
from typing import Union |
from typing import Union |
||||||
|
|
||||||
from slither.exceptions import SlitherError |
from slither.exceptions import SlitherError |
||||||
|
|
||||||
|
|
||||||
def convert_string_to_int(val: Union[str, int]) -> int: |
def convert_string_to_fraction(val: Union[str, int]) -> Fraction: |
||||||
if isinstance(val, int): |
if isinstance(val, int): |
||||||
return val |
return Fraction(val) |
||||||
if val.startswith(("0x", "0X")): |
if val.startswith(("0x", "0X")): |
||||||
return int(val, 16) |
return Fraction(int(val, 16)) |
||||||
|
|
||||||
|
# Fractions do not support underscore separators (on Python <3.11) |
||||||
|
val = val.replace("_", "") |
||||||
|
|
||||||
if "e" in val or "E" in val: |
if "e" in val or "E" in val: |
||||||
base, expo = val.split("e") if "e" in val else val.split("E") |
base, expo = val.split("e") if "e" in val else val.split("E") |
||||||
base, expo = Decimal(base), int(expo) |
base, expo = Fraction(base), int(expo) |
||||||
# The resulting number must be < 2**256-1, otherwise solc |
# The resulting number must be < 2**256-1, otherwise solc |
||||||
# Would not be able to compile it |
# Would not be able to compile it |
||||||
# 10**77 is the largest exponent that fits |
# 10**77 is the largest exponent that fits |
||||||
# See https://github.com/ethereum/solidity/blob/9e61f92bd4d19b430cb8cb26f1c7cf79f1dff380/libsolidity/ast/Types.cpp#L1281-L1290 |
# See https://github.com/ethereum/solidity/blob/9e61f92bd4d19b430cb8cb26f1c7cf79f1dff380/libsolidity/ast/Types.cpp#L1281-L1290 |
||||||
if expo > 77: |
if expo > 77: |
||||||
if base != Decimal(0): |
if base != Fraction(0): |
||||||
raise SlitherError( |
raise SlitherError( |
||||||
f"{base}e{expo} is too large to fit in any Solidity integer size" |
f"{base}e{expo} is too large to fit in any Solidity integer size" |
||||||
) |
) |
||||||
return 0 |
return 0 |
||||||
return int(Decimal(base) * Decimal(10 ** expo)) |
return Fraction(base) * Fraction(10**expo) |
||||||
|
|
||||||
|
return Fraction(val) |
||||||
|
|
||||||
return int(Decimal(val)) |
|
||||||
|
def convert_string_to_int(val: Union[str, int]) -> int: |
||||||
|
return int(convert_string_to_fraction(val)) |
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue