pull/1107/head
Boyan-MILANOV 3 years ago
parent 2fb4587302
commit 43fa42a120
  1. 6
      slither/core/solidity_types/elementary_type.py
  2. 7
      slither/detectors/naming_convention/naming_convention.py
  3. 2
      slither/detectors/statements/type_based_tautology.py
  4. 4
      slither/slithir/convert.py
  5. 2
      slither/utils/integer_conversion.py
  6. 2
      slither/visitors/expression/constants_folding.py

@ -43,8 +43,8 @@ Int = [
"int256",
]
Max_Int = {k: 2 ** (8 * i - 1) - 1 if i > 0 else 2**255 - 1 for i, k in enumerate(Int)}
Min_Int = {k: -(2 ** (8 * i - 1)) if i > 0 else -(2**255) for i, k in enumerate(Int)}
Max_Int = {k: 2 ** (8 * i - 1) - 1 if i > 0 else 2 ** 255 - 1 for i, k in enumerate(Int)}
Min_Int = {k: -(2 ** (8 * i - 1)) if i > 0 else -(2 ** 255) for i, k in enumerate(Int)}
Uint = [
"uint",
@ -82,7 +82,7 @@ Uint = [
"uint256",
]
Max_Uint = {k: 2 ** (8 * i) - 1 if i > 0 else 2**256 - 1 for i, k in enumerate(Uint)}
Max_Uint = {k: 2 ** (8 * i) - 1 if i > 0 else 2 ** 256 - 1 for i, k in enumerate(Uint)}
Min_Uint = {k: 0 for k in Uint}

@ -89,10 +89,13 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2
if func.is_constructor:
continue
if not self.is_mixed_case(func.name):
if func.visibility in [
if (
func.visibility
in [
"internal",
"private",
] and self.is_mixed_case_with_underscore(func.name):
] and self.is_mixed_case_with_underscore(func.name)
):
continue
if func.name.startswith("echidna_") or func.name.startswith("crytic_"):
continue

@ -11,7 +11,7 @@ from slither.core.solidity_types.elementary_type import Int, Uint
def typeRange(t):
bits = int(t.split("int")[1])
if t in Uint:
return 0, (2**bits) - 1
return 0, (2 ** bits) - 1
if t in Int:
v = (2 ** (bits - 1)) - 1
return -v, v

@ -170,10 +170,10 @@ def _fits_under_integer(val: int, can_be_int: bool, can_be_uint) -> List[str]:
assert can_be_int | can_be_uint
while n <= 256:
if can_be_uint:
if val <= 2**n - 1:
if val <= 2 ** n - 1:
ret.append(f"uint{n}")
if can_be_int:
if val <= (2**n) / 2 - 1:
if val <= (2 ** n) / 2 - 1:
ret.append(f"int{n}")
n = n + 8
return ret

@ -23,6 +23,6 @@ def convert_string_to_int(val: Union[str, int]) -> int:
f"{base}e{expo} is too large to fit in any Solidity integer size"
)
return 0
return int(Decimal(base) * Decimal(10**expo))
return int(Decimal(base) * Decimal(10 ** expo))
return int(Decimal(val))

@ -43,7 +43,7 @@ class ConstantFolding(ExpressionVisitor):
left = get_val(expression.expression_left)
right = get_val(expression.expression_right)
if expression.type == BinaryOperationType.POWER:
set_val(expression, left**right)
set_val(expression, left ** right)
elif expression.type == BinaryOperationType.MULTIPLICATION:
set_val(expression, left * right)
elif expression.type == BinaryOperationType.DIVISION:

Loading…
Cancel
Save