Fix pylint/black

pull/1640/head
Feist Josselin 2 years ago
parent f16d0989ef
commit 38a46fa0b4
  1. 1
      slither/core/cfg/node.py
  2. 3
      slither/core/declarations/function.py
  3. 2
      slither/core/source_mapping/source_mapping.py
  4. 10
      slither/detectors/abstract_detector.py
  5. 2
      slither/detectors/assembly/shift_parameter_mixup.py
  6. 2
      slither/detectors/attributes/const_functions_asm.py
  7. 2
      slither/detectors/attributes/const_functions_state.py
  8. 3
      slither/detectors/attributes/constant_pragma.py
  9. 3
      slither/detectors/attributes/incorrect_solc.py
  10. 3
      slither/detectors/attributes/locked_ether.py
  11. 7
      slither/detectors/attributes/unimplemented_interface.py
  12. 13
      slither/detectors/compiler_bugs/array_by_reference.py
  13. 2
      slither/detectors/compiler_bugs/multiple_constructor_schemes.py
  14. 3
      slither/detectors/compiler_bugs/public_mapping_nested.py
  15. 12
      slither/detectors/compiler_bugs/reused_base_constructor.py
  16. 7
      slither/detectors/compiler_bugs/storage_ABIEncoderV2_array.py
  17. 7
      slither/detectors/compiler_bugs/uninitialized_function_ptr_in_constructor.py
  18. 8
      slither/detectors/erc/erc20/arbitrary_send_erc20.py
  19. 6
      slither/detectors/erc/erc20/incorrect_erc20_interface.py
  20. 6
      slither/detectors/erc/incorrect_erc721_interface.py
  21. 6
      slither/detectors/erc/unindexed_event_parameters.py
  22. 2
      slither/detectors/examples/backdoor.py
  23. 11
      slither/detectors/functions/arbitrary_send_eth.py
  24. 3
      slither/detectors/functions/modifier.py
  25. 4
      slither/detectors/functions/protected_variable.py
  26. 2
      slither/detectors/functions/suicidal.py
  27. 4
      slither/detectors/functions/unimplemented.py
  28. 7
      slither/detectors/naming_convention/naming_convention.py
  29. 2
      slither/detectors/operations/block_timestamp.py
  30. 7
      slither/detectors/operations/low_level_calls.py
  31. 7
      slither/detectors/operations/missing_events_access_control.py
  32. 13
      slither/detectors/operations/missing_events_arithmetic.py
  33. 15
      slither/detectors/operations/missing_zero_address_validation.py
  34. 7
      slither/detectors/operations/unused_return_values.py
  35. 2
      slither/detectors/operations/void_constructor.py
  36. 2
      slither/detectors/reentrancy/reentrancy_benign.py
  37. 6
      slither/detectors/reentrancy/reentrancy_events.py
  38. 6
      slither/detectors/reentrancy/reentrancy_no_gas.py
  39. 7
      slither/detectors/shadowing/builtin_symbols.py
  40. 16
      slither/detectors/shadowing/local.py
  41. 8
      slither/detectors/shadowing/state.py
  42. 8
      slither/detectors/slither/name_reused.py
  43. 3
      slither/detectors/source/rtlo.py
  44. 3
      slither/detectors/statements/array_length_assignment.py
  45. 7
      slither/detectors/statements/assembly.py
  46. 6
      slither/detectors/statements/assert_state_change.py
  47. 7
      slither/detectors/statements/boolean_constant_equality.py
  48. 8
      slither/detectors/statements/boolean_constant_misuse.py
  49. 2
      slither/detectors/statements/controlled_delegatecall.py
  50. 21
      slither/detectors/statements/deprecated_calls.py
  51. 17
      slither/detectors/statements/divide_before_multiply.py
  52. 29
      slither/detectors/statements/incorrect_strict_equality.py
  53. 7
      slither/detectors/statements/mapping_deletion.py
  54. 3
      slither/detectors/statements/redundant_statements.py
  55. 3
      slither/detectors/statements/too_many_digits.py
  56. 7
      slither/detectors/statements/tx_origin.py
  57. 10
      slither/detectors/statements/type_based_tautology.py
  58. 3
      slither/detectors/statements/unary.py
  59. 1
      slither/detectors/statements/unprotected_upgradeable.py
  60. 1
      slither/detectors/statements/write_after_write.py
  61. 3
      slither/detectors/variables/function_init_state_variables.py
  62. 15
      slither/detectors/variables/predeclaration_usage_local.py
  63. 3
      slither/detectors/variables/similar_variables.py
  64. 6
      slither/detectors/variables/uninitialized_local_variables.py
  65. 7
      slither/detectors/variables/uninitialized_state_variables.py
  66. 7
      slither/detectors/variables/uninitialized_storage_variables.py
  67. 2
      slither/detectors/variables/unused_state_variables.py
  68. 2
      slither/detectors/variables/var_read_using_this.py
  69. 1
      slither/slither.py
  70. 8
      slither/slithir/operations/codesize.py
  71. 2
      slither/slithir/operations/high_level_call.py
  72. 2
      slither/slithir/operations/library_call.py
  73. 2
      slither/slithir/operations/low_level_call.py
  74. 2
      slither/slithir/operations/lvalue.py
  75. 2
      slither/slithir/operations/new_contract.py
  76. 9
      slither/slithir/operations/nop.py
  77. 3
      slither/slithir/operations/operation.py
  78. 10
      slither/slithir/operations/unpack.py
  79. 2
      slither/slithir/variables/reference_ssa.py
  80. 4
      slither/solc_parsing/variables/local_variable_init_from_tuple.py
  81. 46
      slither/utils/output.py
  82. 3
      slither/visitors/expression/export_values.py

@ -41,7 +41,6 @@ from slither.slithir.variables import (
TemporaryVariable, TemporaryVariable,
TupleVariable, TupleVariable,
) )
import slither.slithir.operations.operation
if TYPE_CHECKING: if TYPE_CHECKING:
from slither.slithir.variables.variable import SlithIRVariable from slither.slithir.variables.variable import SlithIRVariable

@ -28,7 +28,6 @@ from slither.utils.type import convert_type_for_solidity_signature_to_string
from slither.utils.utils import unroll from slither.utils.utils import unroll
# pylint: disable=import-outside-toplevel,too-many-instance-attributes,too-many-statements,too-many-lines # pylint: disable=import-outside-toplevel,too-many-instance-attributes,too-many-statements,too-many-lines
if TYPE_CHECKING: if TYPE_CHECKING:
@ -299,7 +298,7 @@ class Function(SourceMapping, metaclass=ABCMeta): # pylint: disable=too-many-pu
def contains_assembly(self, c: bool): def contains_assembly(self, c: bool):
self._contains_assembly = c self._contains_assembly = c
def can_reenter(self, callstack: Optional[List["FunctionContract"]]=None) -> bool: def can_reenter(self, callstack: Optional[List["FunctionContract"]] = None) -> bool:
""" """
Check if the function can re-enter Check if the function can re-enter
Follow internal calls. Follow internal calls.

@ -56,7 +56,7 @@ class Source:
filename_short: str = self.filename.short if self.filename.short else "" filename_short: str = self.filename.short if self.filename.short else ""
return f"{filename_short}{lines} ({self.starting_column} - {self.ending_column})" return f"{filename_short}{lines} ({self.starting_column} - {self.ending_column})"
def _get_lines_str(self, line_descr: str="") -> str: def _get_lines_str(self, line_descr: str = "") -> str:
# If the compilation unit was not initialized, it means that the set_offset was never called # If the compilation unit was not initialized, it means that the set_offset was never called
# on the corresponding object, which should not happen # on the corresponding object, which should not happen

@ -5,19 +5,11 @@ from typing import Optional, List, TYPE_CHECKING, Dict, Union, Callable
from slither.core.compilation_unit import SlitherCompilationUnit from slither.core.compilation_unit import SlitherCompilationUnit
from slither.core.declarations import Contract from slither.core.declarations import Contract
from slither.utils.colors import green, yellow, red
from slither.formatters.exceptions import FormatImpossible from slither.formatters.exceptions import FormatImpossible
from slither.formatters.utils.patches import apply_patch, create_diff from slither.formatters.utils.patches import apply_patch, create_diff
from slither.utils.colors import green, yellow, red
from slither.utils.comparable_enum import ComparableEnum from slither.utils.comparable_enum import ComparableEnum
from slither.utils.output import Output, SupportedOutput from slither.utils.output import Output, SupportedOutput
import slither.core.declarations.contract
from slither.core.cfg.node import Node
from slither.core.declarations.enum import Enum
from slither.core.declarations.event import Event
from slither.core.declarations.function import Function
from slither.core.declarations.pragma_directive import Pragma
from slither.core.declarations.structure import Structure
from slither.core.variables.variable import Variable
if TYPE_CHECKING: if TYPE_CHECKING:
from slither import Slither from slither import Slither

@ -1,9 +1,9 @@
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import Binary, BinaryType from slither.slithir.operations import Binary, BinaryType
from slither.slithir.variables import Constant from slither.slithir.variables import Constant
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class ShiftParameterMixup(AbstractDetector): class ShiftParameterMixup(AbstractDetector):

@ -2,6 +2,7 @@
Module detecting constant functions Module detecting constant functions
Recursively check the called functions Recursively check the called functions
""" """
from typing import List
from slither.detectors.abstract_detector import ( from slither.detectors.abstract_detector import (
AbstractDetector, AbstractDetector,
DetectorClassification, DetectorClassification,
@ -9,7 +10,6 @@ from slither.detectors.abstract_detector import (
) )
from slither.formatters.attributes.const_functions import custom_format from slither.formatters.attributes.const_functions import custom_format
from slither.utils.output import Output from slither.utils.output import Output
from typing import List
class ConstantFunctionsAsm(AbstractDetector): class ConstantFunctionsAsm(AbstractDetector):

@ -2,6 +2,7 @@
Module detecting constant functions Module detecting constant functions
Recursively check the called functions Recursively check the called functions
""" """
from typing import List
from slither.detectors.abstract_detector import ( from slither.detectors.abstract_detector import (
AbstractDetector, AbstractDetector,
DetectorClassification, DetectorClassification,
@ -9,7 +10,6 @@ from slither.detectors.abstract_detector import (
) )
from slither.formatters.attributes.const_functions import custom_format from slither.formatters.attributes.const_functions import custom_format
from slither.utils.output import Output from slither.utils.output import Output
from typing import List
class ConstantFunctionsState(AbstractDetector): class ConstantFunctionsState(AbstractDetector):

@ -1,11 +1,10 @@
""" """
Check that the same pragma is used in all the files Check that the same pragma is used in all the files
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.formatters.attributes.constant_pragma import custom_format from slither.formatters.attributes.constant_pragma import custom_format
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class ConstantPragma(AbstractDetector): class ConstantPragma(AbstractDetector):

@ -3,10 +3,11 @@
""" """
import re import re
from typing import Any, List, Optional, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.formatters.attributes.incorrect_solc import custom_format from slither.formatters.attributes.incorrect_solc import custom_format
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Optional, Tuple, Union
# group: # group:
# 0: ^ > >= < <= (optional) # 0: ^ > >= < <= (optional)

@ -1,7 +1,7 @@
""" """
Check if ethers are locked in the contract Check if ethers are locked in the contract
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import ( from slither.slithir.operations import (
HighLevelCall, HighLevelCall,
@ -14,7 +14,6 @@ from slither.slithir.operations import (
) )
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class LockedEther(AbstractDetector): # pylint: disable=too-many-nested-blocks class LockedEther(AbstractDetector): # pylint: disable=too-many-nested-blocks

@ -4,11 +4,10 @@ Module detecting unimplemented interfaces
Collect all the interfaces Collect all the interfaces
Check for contracts which implement all interface functions but do not explicitly derive from those interfaces. Check for contracts which implement all interface functions but do not explicitly derive from those interfaces.
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class MissingInheritance(AbstractDetector): class MissingInheritance(AbstractDetector):
@ -45,7 +44,9 @@ contract Something {
WIKI_RECOMMENDATION = "Inherit from the missing interface or contract." WIKI_RECOMMENDATION = "Inherit from the missing interface or contract."
@staticmethod @staticmethod
def detect_unimplemented_interface(contract: Contract, interfaces: List[Union[Any, Contract]]) -> List[Union[Any, Contract]]: def detect_unimplemented_interface(
contract: Contract, interfaces: List[Union[Any, Contract]]
) -> List[Union[Any, Contract]]:
""" """
Detects if contract intends to implement one of the interfaces but does not explicitly do so by deriving from it Detects if contract intends to implement one of the interfaces but does not explicitly do so by deriving from it
:param contract: The contract to check :param contract: The contract to check

@ -1,7 +1,7 @@
""" """
Detects the passing of arrays located in memory to functions which expect to modify arrays via storage reference. Detects the passing of arrays located in memory to functions which expect to modify arrays via storage reference.
""" """
from typing import Any, List, Set, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.solidity_types.array_type import ArrayType from slither.core.solidity_types.array_type import ArrayType
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
@ -12,7 +12,6 @@ from slither.core.cfg.node import Node
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Set, Tuple, Union
class ArrayByReference(AbstractDetector): class ArrayByReference(AbstractDetector):
@ -88,7 +87,15 @@ As a result, Bob's usage of the contract is incorrect."""
return results return results
@staticmethod @staticmethod
def detect_calls_passing_ref_to_function(contracts: List[Contract], array_modifying_funcs: Set[FunctionContract]) -> List[Union[Tuple[Node, StateVariable, FunctionContract], Tuple[Node, LocalVariable, FunctionContract], Any]]: def detect_calls_passing_ref_to_function(
contracts: List[Contract], array_modifying_funcs: Set[FunctionContract]
) -> List[
Union[
Tuple[Node, StateVariable, FunctionContract],
Tuple[Node, LocalVariable, FunctionContract],
Any,
]
]:
""" """
Obtains all calls passing storage arrays by value to a function which cannot write to them successfully. Obtains all calls passing storage arrays by value to a function which cannot write to them successfully.
:param contracts: The collection of contracts to check for problematic calls in. :param contracts: The collection of contracts to check for problematic calls in.

@ -1,6 +1,6 @@
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class MultipleConstructorSchemes(AbstractDetector): class MultipleConstructorSchemes(AbstractDetector):

@ -1,7 +1,7 @@
""" """
Module detecting public mappings with nested variables (returns incorrect values prior to 0.5.x) Module detecting public mappings with nested variables (returns incorrect values prior to 0.5.x)
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import ( from slither.detectors.abstract_detector import (
AbstractDetector, AbstractDetector,
DetectorClassification, DetectorClassification,
@ -13,7 +13,6 @@ from slither.core.declarations.structure import Structure
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
def detect_public_nested_mappings(contract: Contract) -> List[Union[StateVariable, Any]]: def detect_public_nested_mappings(contract: Contract) -> List[Union[StateVariable, Any]]:

@ -1,7 +1,7 @@
""" """
Module detecting re-used base constructors in inheritance hierarchy. Module detecting re-used base constructors in inheritance hierarchy.
""" """
from typing import Any, Dict, List, Tuple, Union
from slither.detectors.abstract_detector import ( from slither.detectors.abstract_detector import (
AbstractDetector, AbstractDetector,
DetectorClassification, DetectorClassification,
@ -10,12 +10,14 @@ from slither.detectors.abstract_detector import (
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, Dict, List, Tuple, Union
# Helper: adds explicitly called constructors with arguments to the results lookup. # Helper: adds explicitly called constructors with arguments to the results lookup.
def _add_constructors_with_args( def _add_constructors_with_args(
base_constructors: List[Union[Any, FunctionContract]], called_by_constructor: bool, current_contract: Contract, results: Dict[FunctionContract, List[Tuple[Contract, bool]]] base_constructors: List[Union[Any, FunctionContract]],
called_by_constructor: bool,
current_contract: Contract,
results: Dict[FunctionContract, List[Tuple[Contract, bool]]],
) -> None: ) -> None:
for explicit_base_constructor in base_constructors: for explicit_base_constructor in base_constructors:
if len(explicit_base_constructor.parameters) > 0: if len(explicit_base_constructor.parameters) > 0:
@ -81,7 +83,9 @@ The constructor of `A` is called multiple times in `D` and `E`:
VULNERABLE_SOLC_VERSIONS = ALL_SOLC_VERSIONS_04 VULNERABLE_SOLC_VERSIONS = ALL_SOLC_VERSIONS_04
def _detect_explicitly_called_base_constructors(self, contract: Contract) -> Dict[FunctionContract, List[Tuple[Contract, bool]]]: def _detect_explicitly_called_base_constructors(
self, contract: Contract
) -> Dict[FunctionContract, List[Tuple[Contract, bool]]]:
""" """
Detects explicitly calls to base constructors with arguments in the inheritance hierarchy. Detects explicitly calls to base constructors with arguments in the inheritance hierarchy.
:param contract: The contract to detect explicit calls to a base constructor with arguments to. :param contract: The contract to detect explicit calls to a base constructor with arguments to.

@ -1,7 +1,7 @@
""" """
Module detecting ABIEncoderV2 array bug Module detecting ABIEncoderV2 array bug
""" """
from typing import List, Set, Tuple
from slither.detectors.abstract_detector import ( from slither.detectors.abstract_detector import (
AbstractDetector, AbstractDetector,
DetectorClassification, DetectorClassification,
@ -20,7 +20,6 @@ from slither.core.cfg.node import Node
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import List, Set, Tuple
class ABIEncoderV2Array(AbstractDetector): class ABIEncoderV2Array(AbstractDetector):
@ -60,7 +59,9 @@ contract A {
VULNERABLE_SOLC_VERSIONS = make_solc_versions(4, 7, 25) + make_solc_versions(5, 0, 9) VULNERABLE_SOLC_VERSIONS = make_solc_versions(4, 7, 25) + make_solc_versions(5, 0, 9)
@staticmethod @staticmethod
def _detect_storage_abiencoderv2_arrays(contract: Contract) -> Set[Tuple[FunctionContract, Node]]: def _detect_storage_abiencoderv2_arrays(
contract: Contract,
) -> Set[Tuple[FunctionContract, Node]]:
""" """
Detects and returns all nodes with storage-allocated abiencoderv2 arrays of arrays/structs in abi.encode, events or external calls Detects and returns all nodes with storage-allocated abiencoderv2 arrays of arrays/structs in abi.encode, events or external calls
:param contract: Contract to detect within :param contract: Contract to detect within

@ -1,7 +1,7 @@
""" """
Module detecting uninitialized function pointer calls in constructors Module detecting uninitialized function pointer calls in constructors
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import ( from slither.detectors.abstract_detector import (
AbstractDetector, AbstractDetector,
DetectorClassification, DetectorClassification,
@ -15,7 +15,6 @@ from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.slithir.variables.state_variable import StateIRVariable from slither.slithir.variables.state_variable import StateIRVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
def _get_variables_entrance(function: FunctionContract) -> List[Union[Any, StateIRVariable]]: def _get_variables_entrance(function: FunctionContract) -> List[Union[Any, StateIRVariable]]:
@ -90,7 +89,9 @@ The call to `a(10)` will lead to unexpected behavior because function pointer `a
VULNERABLE_SOLC_VERSIONS = make_solc_versions(4, 5, 25) + make_solc_versions(5, 0, 8) VULNERABLE_SOLC_VERSIONS = make_solc_versions(4, 5, 25) + make_solc_versions(5, 0, 8)
@staticmethod @staticmethod
def _detect_uninitialized_function_ptr_in_constructor(contract: Contract) -> List[Union[Any, Node]]: def _detect_uninitialized_function_ptr_in_constructor(
contract: Contract,
) -> List[Union[Any, Node]]:
""" """
Detect uninitialized function pointer calls in constructors Detect uninitialized function pointer calls in constructors
:param contract: The contract of interest for detection :param contract: The contract of interest for detection

@ -1,11 +1,11 @@
from typing import List from typing import List
from slither.analyses.data_dependency.data_dependency import is_dependent
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.compilation_unit import SlitherCompilationUnit
from slither.core.declarations import Contract, Function, SolidityVariableComposed
from slither.core.declarations.solidity_variables import SolidityVariable from slither.core.declarations.solidity_variables import SolidityVariable
from slither.slithir.operations import HighLevelCall, LibraryCall from slither.slithir.operations import HighLevelCall, LibraryCall
from slither.core.declarations import Contract, Function, SolidityVariableComposed
from slither.analyses.data_dependency.data_dependency import is_dependent
from slither.core.compilation_unit import SlitherCompilationUnit
import slither.core.declarations.contract
class ArbitrarySendErc20: class ArbitrarySendErc20:

@ -2,11 +2,11 @@
Detect incorrect erc20 interface. Detect incorrect erc20 interface.
Some contracts do not return a bool on transfer/transferFrom/approve, which may lead to preventing the contract to be used with contracts compiled with recent solc (>0.4.22) Some contracts do not return a bool on transfer/transferFrom/approve, which may lead to preventing the contract to be used with contracts compiled with recent solc (>0.4.22)
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class IncorrectERC20InterfaceDetection(AbstractDetector): class IncorrectERC20InterfaceDetection(AbstractDetector):
@ -40,7 +40,9 @@ contract Token{
) )
@staticmethod @staticmethod
def incorrect_erc20_interface(signature: Union[Tuple[str, List[str], List[Any]], Tuple[str, List[Any], List[Any]]]) -> bool: def incorrect_erc20_interface(
signature: Union[Tuple[str, List[str], List[Any]], Tuple[str, List[Any], List[Any]]]
) -> bool:
(name, parameters, returnVars) = signature (name, parameters, returnVars) = signature
if name == "transfer" and parameters == ["address", "uint256"] and returnVars != ["bool"]: if name == "transfer" and parameters == ["address", "uint256"] and returnVars != ["bool"]:

@ -1,11 +1,11 @@
""" """
Detect incorrect erc721 interface. Detect incorrect erc721 interface.
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class IncorrectERC721InterfaceDetection(AbstractDetector): class IncorrectERC721InterfaceDetection(AbstractDetector):
@ -41,7 +41,9 @@ contract Token{
) )
@staticmethod @staticmethod
def incorrect_erc721_interface(signature: Union[Tuple[str, List[str], List[str]], Tuple[str, List[str], List[Any]]]) -> bool: def incorrect_erc721_interface(
signature: Union[Tuple[str, List[str], List[str]], Tuple[str, List[str], List[Any]]]
) -> bool:
(name, parameters, returnVars) = signature (name, parameters, returnVars) = signature
# ERC721 # ERC721

@ -1,12 +1,12 @@
""" """
Detect mistakenly un-indexed ERC20 event parameters Detect mistakenly un-indexed ERC20 event parameters
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.event import Event from slither.core.declarations.event import Event
from slither.core.variables.event_variable import EventVariable from slither.core.variables.event_variable import EventVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class UnindexedERC20EventParameters(AbstractDetector): class UnindexedERC20EventParameters(AbstractDetector):
@ -44,7 +44,9 @@ Failure to include these keywords will exclude the parameter data in the transac
STANDARD_JSON = False STANDARD_JSON = False
@staticmethod @staticmethod
def detect_erc20_unindexed_event_params(contract: Contract) -> List[Union[Tuple[Event, EventVariable], Any]]: def detect_erc20_unindexed_event_params(
contract: Contract,
) -> List[Union[Tuple[Event, EventVariable], Any]]:
""" """
Detect un-indexed ERC20 event parameters in a given contract. Detect un-indexed ERC20 event parameters in a given contract.
:param contract: The contract to check ERC20 events for un-indexed parameters in. :param contract: The contract to check ERC20 events for un-indexed parameters in.

@ -1,6 +1,6 @@
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class Backdoor(AbstractDetector): class Backdoor(AbstractDetector):

@ -11,9 +11,10 @@
""" """
from typing import Any, Tuple, Union, List from typing import Any, Tuple, Union, List
from slither.analyses.data_dependency.data_dependency import is_tainted, is_dependent
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations import Function, Contract from slither.core.declarations import Function, Contract
from slither.analyses.data_dependency.data_dependency import is_tainted, is_dependent from slither.core.declarations.function_contract import FunctionContract
from slither.core.declarations.solidity_variables import ( from slither.core.declarations.solidity_variables import (
SolidityFunction, SolidityFunction,
SolidityVariableComposed, SolidityVariableComposed,
@ -28,12 +29,8 @@ from slither.slithir.operations import (
Transfer, Transfer,
) )
# pylint: disable=too-many-nested-blocks,too-many-branches # pylint: disable=too-many-nested-blocks,too-many-branches
from slither.utils.output import Output from slither.utils.output import Output
import slither.core.declarations.contract
import slither.core.declarations.function
from slither.core.declarations.function_contract import FunctionContract
def arbitrary_send(func: Function) -> Union[bool, List[Node]]: def arbitrary_send(func: Function) -> Union[bool, List[Node]]:
@ -77,7 +74,9 @@ def arbitrary_send(func: Function) -> Union[bool, List[Node]]:
return ret return ret
def detect_arbitrary_send(contract: Contract) -> List[Union[Tuple[FunctionContract, List[Node]], Any]]: def detect_arbitrary_send(
contract: Contract,
) -> List[Union[Tuple[FunctionContract, List[Node]], Any]]:
""" """
Detect arbitrary send Detect arbitrary send
Args: Args:

@ -5,11 +5,10 @@ Note that require()/assert() are not considered here. Even if they
are in the outermost scope, they do not guarantee a revert, so a are in the outermost scope, they do not guarantee a revert, so a
default value can still be returned. default value can still be returned.
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.cfg.node import Node, NodeType from slither.core.cfg.node import Node, NodeType
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
def is_revert(node: Node) -> bool: def is_revert(node: Node) -> bool:

@ -5,11 +5,9 @@ A suicidal contract is an unprotected function that calls selfdestruct
""" """
from typing import Any, Union, List from typing import Any, Union, List
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations import Function, Contract from slither.core.declarations import Function, Contract
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.utils.output import Output from slither.utils.output import Output
import slither.core.declarations.contract
import slither.core.declarations.function
class ProtectedVariables(AbstractDetector): class ProtectedVariables(AbstractDetector):

@ -3,12 +3,12 @@ Module detecting suicidal contract
A suicidal contract is an unprotected function that calls selfdestruct A suicidal contract is an unprotected function that calls selfdestruct
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class Suicidal(AbstractDetector): class Suicidal(AbstractDetector):

@ -7,12 +7,12 @@ Check for unimplemented functions that are never implemented
Consider public state variables as implemented functions Consider public state variables as implemented functions
Do not consider fallback function or constructor Do not consider fallback function or constructor
""" """
from typing import Any, List, Set, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Set, Union
# Since 0.5.1, Solidity allows creating state variable matching a function signature. # Since 0.5.1, Solidity allows creating state variable matching a function signature.
older_solc_versions = ["0.5.0"] + ["0.4." + str(x) for x in range(0, 27)] older_solc_versions = ["0.5.0"] + ["0.4." + str(x) for x in range(0, 27)]

@ -1,8 +1,8 @@
import re import re
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.formatters.naming_convention.naming_convention import custom_format from slither.formatters.naming_convention.naming_convention import custom_format
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class NamingConvention(AbstractDetector): class NamingConvention(AbstractDetector):
@ -59,7 +59,10 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2
def should_avoid_name(name: str) -> bool: def should_avoid_name(name: str) -> bool:
return re.search("^[lOI]$", name) is not None return re.search("^[lOI]$", name) is not None
def _detect(self) -> List[Union[Any, Output]]: # pylint: disable=too-many-branches,too-many-statements # pylint: disable=too-many-branches,too-many-statements
def _detect(
self,
) -> List[Union[Any, Output]]:
results = [] results = []
for contract in self.contracts: for contract in self.contracts:

@ -13,8 +13,6 @@ from slither.core.declarations.solidity_variables import (
) )
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import Binary, BinaryType from slither.slithir.operations import Binary, BinaryType
import slither.core.declarations.contract
import slither.core.declarations.function
from slither.utils.output import Output from slither.utils.output import Output

@ -1,14 +1,13 @@
""" """
Module detecting usage of low level calls Module detecting usage of low level calls
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import LowLevelCall from slither.slithir.operations import LowLevelCall
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class LowLevelCalls(AbstractDetector): class LowLevelCalls(AbstractDetector):
@ -36,7 +35,9 @@ class LowLevelCalls(AbstractDetector):
""" """
return any(isinstance(ir, LowLevelCall) for ir in node.irs) return any(isinstance(ir, LowLevelCall) for ir in node.irs)
def detect_low_level_calls(self, contract: Contract) -> List[Union[Any, Tuple[FunctionContract, List[Node]]]]: def detect_low_level_calls(
self, contract: Contract
) -> List[Union[Any, Tuple[FunctionContract, List[Node]]]]:
ret = [] ret = []
for f in [f for f in contract.functions if contract == f.contract_declarer]: for f in [f for f in contract.functions if contract == f.contract_declarer]:
nodes = f.nodes nodes = f.nodes

@ -2,7 +2,7 @@
Module detecting missing events for critical contract parameters set by owners and used in access control Module detecting missing events for critical contract parameters set by owners and used in access control
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.analyses.data_dependency.data_dependency import is_tainted from slither.analyses.data_dependency.data_dependency import is_tainted
from slither.slithir.operations.event_call import EventCall from slither.slithir.operations.event_call import EventCall
@ -13,7 +13,6 @@ from slither.core.declarations.function_contract import FunctionContract
from slither.core.declarations.modifier import Modifier from slither.core.declarations.modifier import Modifier
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class MissingEventsAccessControl(AbstractDetector): class MissingEventsAccessControl(AbstractDetector):
@ -52,7 +51,9 @@ contract C {
WIKI_RECOMMENDATION = "Emit an event for critical parameter changes." WIKI_RECOMMENDATION = "Emit an event for critical parameter changes."
@staticmethod @staticmethod
def _detect_missing_events(contract: Contract) -> List[Union[Any, Tuple[FunctionContract, List[Tuple[Node, StateVariable, Modifier]]]]]: def _detect_missing_events(
contract: Contract,
) -> List[Union[Any, Tuple[FunctionContract, List[Tuple[Node, StateVariable, Modifier]]]]]:
""" """
Detects if critical contract parameters set by owners and used in access control are missing events Detects if critical contract parameters set by owners and used in access control are missing events
:param contract: The contract to check :param contract: The contract to check

@ -2,7 +2,7 @@
Module detecting missing events for critical contract parameters set by owners and used in arithmetic Module detecting missing events for critical contract parameters set by owners and used in arithmetic
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.analyses.data_dependency.data_dependency import is_tainted from slither.analyses.data_dependency.data_dependency import is_tainted
from slither.slithir.operations.event_call import EventCall from slither.slithir.operations.event_call import EventCall
@ -12,7 +12,6 @@ from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class MissingEventsArithmetic(AbstractDetector): class MissingEventsArithmetic(AbstractDetector):
@ -55,7 +54,9 @@ contract C {
WIKI_RECOMMENDATION = "Emit an event for critical parameter changes." WIKI_RECOMMENDATION = "Emit an event for critical parameter changes."
@staticmethod @staticmethod
def _detect_unprotected_use(contract: Contract, sv: StateVariable) -> List[Union[Tuple[Node, FunctionContract], Any]]: def _detect_unprotected_use(
contract: Contract, sv: StateVariable
) -> List[Union[Tuple[Node, FunctionContract], Any]]:
unprotected_functions = [ unprotected_functions = [
function for function in contract.functions_declared if not function.is_protected() function for function in contract.functions_declared if not function.is_protected()
] ]
@ -66,7 +67,11 @@ contract C {
if sv in node.state_variables_read if sv in node.state_variables_read
] ]
def _detect_missing_events(self, contract: Contract) -> List[Union[Tuple[FunctionContract, List[Tuple[Node, List[Tuple[Node, FunctionContract]]]]], Any]]: def _detect_missing_events(
self, contract: Contract
) -> List[
Union[Tuple[FunctionContract, List[Tuple[Node, List[Tuple[Node, FunctionContract]]]]], Any]
]:
""" """
Detects if critical contract parameters set by owners and used in arithmetic are missing events Detects if critical contract parameters set by owners and used in arithmetic are missing events
:param contract: The contract to check :param contract: The contract to check

@ -3,7 +3,7 @@ Module detecting missing zero address validation
""" """
from collections import defaultdict from collections import defaultdict
from typing import Any, DefaultDict, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.analyses.data_dependency.data_dependency import is_tainted from slither.analyses.data_dependency.data_dependency import is_tainted
from slither.core.solidity_types.elementary_type import ElementaryType from slither.core.solidity_types.elementary_type import ElementaryType
@ -15,7 +15,6 @@ from slither.core.declarations.function import ModifierStatements
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.core.variables.local_variable import LocalVariable from slither.core.variables.local_variable import LocalVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, DefaultDict, List, Tuple, Union
class MissingZeroAddressValidation(AbstractDetector): class MissingZeroAddressValidation(AbstractDetector):
@ -53,7 +52,9 @@ Bob calls `updateOwner` without specifying the `newOwner`, so Bob loses ownershi
WIKI_RECOMMENDATION = "Check that the address is not zero." WIKI_RECOMMENDATION = "Check that the address is not zero."
def _zero_address_validation_in_modifier(self, var: LocalVariable, modifier_exprs: List[Union[ModifierStatements, Any]]) -> bool: def _zero_address_validation_in_modifier(
self, var: LocalVariable, modifier_exprs: List[Union[ModifierStatements, Any]]
) -> bool:
for mod in modifier_exprs: for mod in modifier_exprs:
for node in mod.nodes: for node in mod.nodes:
# Skip validation if the modifier's parameters contains more than one variable # Skip validation if the modifier's parameters contains more than one variable
@ -69,7 +70,9 @@ Bob calls `updateOwner` without specifying the `newOwner`, so Bob loses ownershi
return True return True
return False return False
def _zero_address_validation(self, var: LocalVariable, node: Node, explored: List[Union[Any, Node]]) -> bool: def _zero_address_validation(
self, var: LocalVariable, node: Node, explored: List[Union[Any, Node]]
) -> bool:
""" """
Detects (recursively) if var is (zero address) checked in the function node Detects (recursively) if var is (zero address) checked in the function node
""" """
@ -90,7 +93,9 @@ Bob calls `updateOwner` without specifying the `newOwner`, so Bob loses ownershi
return True return True
return False return False
def _detect_missing_zero_address_validation(self, contract: Contract) -> List[Union[Tuple[FunctionContract, DefaultDict[LocalVariable, List[Node]]], Any]]: def _detect_missing_zero_address_validation(
self, contract: Contract
) -> List[Union[Tuple[FunctionContract, DefaultDict[LocalVariable, List[Node]]], Any]]:
""" """
Detects if addresses are zero address validated before use. Detects if addresses are zero address validated before use.
:param contract: The contract to check :param contract: The contract to check

@ -1,7 +1,7 @@
""" """
Module detecting unused return values from external calls Module detecting unused return values from external calls
""" """
from typing import Any, List, Union
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import HighLevelCall from slither.slithir.operations import HighLevelCall
@ -10,7 +10,6 @@ from slither.core.cfg.node import Node
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.slithir.operations.operation import Operation from slither.slithir.operations.operation import Operation
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class UnusedReturnValues(AbstractDetector): class UnusedReturnValues(AbstractDetector):
@ -55,7 +54,9 @@ contract MyConc{
or not isinstance(ir.function, Function) or not isinstance(ir.function, Function)
) )
def detect_unused_return_values(self, f: FunctionContract) -> List[Union[Node, Any]]: # pylint: disable=no-self-use def detect_unused_return_values(
self, f: FunctionContract
) -> List[Union[Node, Any]]: # pylint: disable=no-self-use
""" """
Return the nodes where the return value of a call is unused Return the nodes where the return value of a call is unused
Args: Args:

@ -1,7 +1,7 @@
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import Nop from slither.slithir.operations import Nop
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class VoidConstructor(AbstractDetector): class VoidConstructor(AbstractDetector):

@ -8,7 +8,7 @@ from collections import namedtuple, defaultdict
from typing import Any, DefaultDict, Set, Union, List from typing import Any, DefaultDict, Set, Union, List
from slither.detectors.abstract_detector import DetectorClassification from slither.detectors.abstract_detector import DetectorClassification
from .reentrancy import Reentrancy, to_hashable from slither.detectors.reentrancy.reentrancy import Reentrancy, to_hashable
from slither.utils.output import Output from slither.utils.output import Output
FindingKey = namedtuple("FindingKey", ["function", "calls", "send_eth"]) FindingKey = namedtuple("FindingKey", ["function", "calls", "send_eth"])

@ -5,11 +5,11 @@
Iterate over all the nodes of the graph until reaching a fixpoint Iterate over all the nodes of the graph until reaching a fixpoint
""" """
from collections import namedtuple, defaultdict from collections import namedtuple, defaultdict
from typing import Any, DefaultDict, List, Set, Union
from slither.detectors.abstract_detector import DetectorClassification from slither.detectors.abstract_detector import DetectorClassification
from .reentrancy import Reentrancy, to_hashable from slither.detectors.reentrancy.reentrancy import Reentrancy, to_hashable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, DefaultDict, List, Set, Union
FindingKey = namedtuple("FindingKey", ["function", "calls", "send_eth"]) FindingKey = namedtuple("FindingKey", ["function", "calls", "send_eth"])
FindingValue = namedtuple("FindingValue", ["variable", "node", "nodes"]) FindingValue = namedtuple("FindingValue", ["variable", "node", "nodes"])

@ -5,15 +5,15 @@
Iterate over all the nodes of the graph until reaching a fixpoint Iterate over all the nodes of the graph until reaching a fixpoint
""" """
from collections import namedtuple, defaultdict from collections import namedtuple, defaultdict
from typing import Any, DefaultDict, List, Union
from slither.core.variables.variable import Variable from slither.core.variables.variable import Variable
from slither.detectors.abstract_detector import DetectorClassification from slither.detectors.abstract_detector import DetectorClassification
from slither.slithir.operations import Send, Transfer, EventCall from slither.slithir.operations import Send, Transfer, EventCall
from .reentrancy import Reentrancy, to_hashable from slither.detectors.reentrancy.reentrancy import Reentrancy, to_hashable
from slither.slithir.operations.high_level_call import HighLevelCall from slither.slithir.operations.high_level_call import HighLevelCall
from slither.slithir.operations.member import Member from slither.slithir.operations.member import Member
from slither.slithir.operations.return_operation import Return from slither.slithir.operations.return_operation import Return
from typing import Any, DefaultDict, List, Union
FindingKey = namedtuple("FindingKey", ["function", "calls", "send_eth"]) FindingKey = namedtuple("FindingKey", ["function", "calls", "send_eth"])
FindingValue = namedtuple("FindingValue", ["variable", "node", "nodes"]) FindingValue = namedtuple("FindingValue", ["variable", "node", "nodes"])

@ -1,14 +1,13 @@
""" """
Module detecting reserved keyword shadowing Module detecting reserved keyword shadowing
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.core.declarations.modifier import Modifier from slither.core.declarations.modifier import Modifier
from slither.core.variables.local_variable import LocalVariable from slither.core.variables.local_variable import LocalVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class BuiltinSymbolShadowing(AbstractDetector): class BuiltinSymbolShadowing(AbstractDetector):
@ -128,7 +127,9 @@ contract Bug {
return word in self.BUILTIN_SYMBOLS or word in self.RESERVED_KEYWORDS return word in self.BUILTIN_SYMBOLS or word in self.RESERVED_KEYWORDS
def detect_builtin_shadowing_locals(self, function_or_modifier: Union[Modifier, FunctionContract]) -> List[Union[Any, Tuple[str, LocalVariable]]]: def detect_builtin_shadowing_locals(
self, function_or_modifier: Union[Modifier, FunctionContract]
) -> List[Union[Any, Tuple[str, LocalVariable]]]:
"""Detects if local variables in a given function/modifier are named after built-in symbols. """Detects if local variables in a given function/modifier are named after built-in symbols.
Any such items are returned in a list. Any such items are returned in a list.

@ -1,7 +1,7 @@
""" """
Module detecting local variable shadowing Module detecting local variable shadowing
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.event import Event from slither.core.declarations.event import Event
@ -10,7 +10,6 @@ from slither.core.declarations.modifier import Modifier
from slither.core.variables.local_variable import LocalVariable from slither.core.variables.local_variable import LocalVariable
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class LocalShadowing(AbstractDetector): class LocalShadowing(AbstractDetector):
@ -58,7 +57,18 @@ contract Bug {
OVERSHADOWED_STATE_VARIABLE = "state variable" OVERSHADOWED_STATE_VARIABLE = "state variable"
OVERSHADOWED_EVENT = "event" OVERSHADOWED_EVENT = "event"
def detect_shadowing_definitions(self, contract: Contract) -> List[Union[Any, Tuple[LocalVariable, List[Tuple[str, StateVariable]]], Tuple[LocalVariable, List[Tuple[str, FunctionContract]]], Tuple[LocalVariable, List[Tuple[str, Modifier]]], Tuple[LocalVariable, List[Tuple[str, Event]]]]]: # pylint: disable=too-many-branches # pylint: disable=too-many-branches
def detect_shadowing_definitions(
self, contract: Contract
) -> List[
Union[
Any,
Tuple[LocalVariable, List[Tuple[str, StateVariable]]],
Tuple[LocalVariable, List[Tuple[str, FunctionContract]]],
Tuple[LocalVariable, List[Tuple[str, Modifier]]],
Tuple[LocalVariable, List[Tuple[str, Event]]],
]
]:
"""Detects if functions, access modifiers, events, state variables, and local variables are named after """Detects if functions, access modifiers, events, state variables, and local variables are named after
reserved keywords. Any such definitions are returned in a list. reserved keywords. Any such definitions are returned in a list.

@ -2,13 +2,13 @@
Module detecting shadowing of state variables Module detecting shadowing of state variables
""" """
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from typing import Any, List, Union
from slither.core.declarations import Contract from slither.core.declarations import Contract
from .common import is_upgradable_gap_variable
import slither.core.declarations.contract
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union from slither.detectors.shadowing.common import is_upgradable_gap_variable
def detect_shadowing(contract: Contract) -> List[Union[List[StateVariable], Any]]: def detect_shadowing(contract: Contract) -> List[Union[List[StateVariable], Any]]:

@ -1,9 +1,8 @@
from collections import defaultdict from collections import defaultdict
from typing import Any, List, Union
from slither.core.compilation_unit import SlitherCompilationUnit from slither.core.compilation_unit import SlitherCompilationUnit
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
def _find_missing_inheritance(compilation_unit: SlitherCompilationUnit) -> List[Any]: def _find_missing_inheritance(compilation_unit: SlitherCompilationUnit) -> List[Any]:
@ -52,7 +51,10 @@ As a result, the second contract cannot be analyzed.
WIKI_RECOMMENDATION = "Rename the contract." WIKI_RECOMMENDATION = "Rename the contract."
def _detect(self) -> List[Union[Any, Output]]: # pylint: disable=too-many-locals,too-many-branches # pylint: disable=too-many-locals,too-many-branches
def _detect(
self,
) -> List[Union[Any, Output]]:
results = [] results = []
compilation_unit = self.compilation_unit compilation_unit = self.compilation_unit

@ -1,7 +1,8 @@
import re import re
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
# pylint: disable=bidirectional-unicode # pylint: disable=bidirectional-unicode
class RightToLeftOverride(AbstractDetector): class RightToLeftOverride(AbstractDetector):

@ -1,7 +1,7 @@
""" """
Module detecting assignment of array length Module detecting assignment of array length
""" """
from typing import List, Set
from slither.detectors.abstract_detector import ( from slither.detectors.abstract_detector import (
AbstractDetector, AbstractDetector,
DetectorClassification, DetectorClassification,
@ -15,7 +15,6 @@ from slither.slithir.operations.binary import Binary
from slither.analyses.data_dependency.data_dependency import is_tainted from slither.analyses.data_dependency.data_dependency import is_tainted
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.utils.output import Output from slither.utils.output import Output
from typing import List, Set
def detect_array_length_assignment(contract: Contract) -> Set[Node]: def detect_array_length_assignment(contract: Contract) -> Set[Node]:

@ -1,13 +1,12 @@
""" """
Module detecting usage of inline assembly Module detecting usage of inline assembly
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.cfg.node import Node, NodeType from slither.core.cfg.node import Node, NodeType
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class Assembly(AbstractDetector): class Assembly(AbstractDetector):
@ -35,7 +34,9 @@ class Assembly(AbstractDetector):
""" """
return node.type == NodeType.ASSEMBLY return node.type == NodeType.ASSEMBLY
def detect_assembly(self, contract: Contract) -> List[Union[Any, Tuple[FunctionContract, List[Node]]]]: def detect_assembly(
self, contract: Contract
) -> List[Union[Any, Tuple[FunctionContract, List[Node]]]]:
ret = [] ret = []
for f in contract.functions: for f in contract.functions:
if f.contract_declarer != contract: if f.contract_declarer != contract:

@ -1,16 +1,18 @@
""" """
Module detecting state changes in assert calls Module detecting state changes in assert calls
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations.internal_call import InternalCall from slither.slithir.operations.internal_call import InternalCall
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
def detect_assert_state_change(contract: Contract) -> List[Union[Tuple[FunctionContract, Node], Any]]: def detect_assert_state_change(
contract: Contract,
) -> List[Union[Tuple[FunctionContract, Node], Any]]:
""" """
Detects and returns all nodes with assert calls that change contract state from within the invariant Detects and returns all nodes with assert calls that change contract state from within the invariant
:param contract: Contract to detect :param contract: Contract to detect

@ -1,7 +1,7 @@
""" """
Module detecting misuse of Boolean constants Module detecting misuse of Boolean constants
""" """
from typing import Any, List, Set, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import ( from slither.slithir.operations import (
Binary, Binary,
@ -12,7 +12,6 @@ from slither.core.cfg.node import Node
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Set, Tuple, Union
class BooleanEquality(AbstractDetector): class BooleanEquality(AbstractDetector):
@ -49,7 +48,9 @@ Boolean constants can be used directly and do not need to be compare to `true` o
WIKI_RECOMMENDATION = """Remove the equality to the boolean constant.""" WIKI_RECOMMENDATION = """Remove the equality to the boolean constant."""
@staticmethod @staticmethod
def _detect_boolean_equality(contract: Contract) -> List[Union[Tuple[FunctionContract, Set[Any]], Tuple[FunctionContract, Set[Node]], Any]]: def _detect_boolean_equality(
contract: Contract,
) -> List[Union[Tuple[FunctionContract, Set[Any]], Tuple[FunctionContract, Set[Node]], Any]]:
# Create our result set. # Create our result set.
results = [] results = []

@ -1,6 +1,7 @@
""" """
Module detecting misuse of Boolean constants Module detecting misuse of Boolean constants
""" """
from typing import Any, List, Set, Tuple, Union
from slither.core.cfg.node import Node, NodeType from slither.core.cfg.node import Node, NodeType
from slither.core.solidity_types import ElementaryType from slither.core.solidity_types import ElementaryType
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
@ -17,7 +18,6 @@ from slither.slithir.variables import Constant
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Set, Tuple, Union
class BooleanConstantMisuse(AbstractDetector): class BooleanConstantMisuse(AbstractDetector):
@ -63,7 +63,11 @@ Other uses (in complex expressions, as conditionals) indicate either an error or
WIKI_RECOMMENDATION = """Verify and simplify the condition.""" WIKI_RECOMMENDATION = """Verify and simplify the condition."""
@staticmethod @staticmethod
def _detect_boolean_constant_misuses(contract: Contract) -> List[Union[Tuple[FunctionContract, Set[Any]], Tuple[FunctionContract, Set[Node]], Any]]: # pylint: disable=too-many-branches def _detect_boolean_constant_misuses(
contract: Contract,
) -> List[
Union[Tuple[FunctionContract, Set[Any]], Tuple[FunctionContract, Set[Node]], Any]
]: # pylint: disable=too-many-branches
""" """
Detects and returns all nodes which misuse a Boolean constant. Detects and returns all nodes which misuse a Boolean constant.
:param contract: Contract to detect assignment within. :param contract: Contract to detect assignment within.

@ -1,10 +1,10 @@
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import LowLevelCall from slither.slithir.operations import LowLevelCall
from slither.analyses.data_dependency.data_dependency import is_tainted from slither.analyses.data_dependency.data_dependency import is_tainted
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
def controlled_delegatecall(function: FunctionContract) -> List[Union[Node, Any]]: def controlled_delegatecall(function: FunctionContract) -> List[Union[Node, Any]]:

@ -1,7 +1,7 @@
""" """
Module detecting deprecated standards. Module detecting deprecated standards.
""" """
from typing import Any, List, Tuple, Union
from slither.core.cfg.node import Node, NodeType from slither.core.cfg.node import Node, NodeType
from slither.core.declarations.solidity_variables import ( from slither.core.declarations.solidity_variables import (
SolidityVariableComposed, SolidityVariableComposed,
@ -15,7 +15,6 @@ from slither.core.expressions.binary_operation import BinaryOperation
from slither.core.expressions.call_expression import CallExpression from slither.core.expressions.call_expression import CallExpression
from slither.core.expressions.member_access import MemberAccess from slither.core.expressions.member_access import MemberAccess
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
# Reference: https://smartcontractsecurity.github.io/SWC-registry/docs/SWC-111 # Reference: https://smartcontractsecurity.github.io/SWC-registry/docs/SWC-111
@ -79,7 +78,9 @@ contract ContractWithDeprecatedReferences {
DEPRECATED_NODE_TYPES = [(NodeType.THROW, "throw", "revert()")] DEPRECATED_NODE_TYPES = [(NodeType.THROW, "throw", "revert()")]
DEPRECATED_LOW_LEVEL_CALLS = [("callcode", "callcode", "delegatecall")] DEPRECATED_LOW_LEVEL_CALLS = [("callcode", "callcode", "delegatecall")]
def detect_deprecation_in_expression(self, expression: Union[BinaryOperation, MemberAccess, CallExpression]) -> List[Union[Any, Tuple[str, str, str]]]: def detect_deprecation_in_expression(
self, expression: Union[BinaryOperation, MemberAccess, CallExpression]
) -> List[Union[Any, Tuple[str, str, str]]]:
"""Detects if an expression makes use of any deprecated standards. """Detects if an expression makes use of any deprecated standards.
Returns: Returns:
@ -101,7 +102,9 @@ contract ContractWithDeprecatedReferences {
return results return results
def detect_deprecated_references_in_node(self, node: Node) -> List[Union[Any, Tuple[str, str, str], Tuple[NodeType, str, str]]]: def detect_deprecated_references_in_node(
self, node: Node
) -> List[Union[Any, Tuple[str, str, str], Tuple[NodeType, str, str]]]:
"""Detects if a node makes use of any deprecated standards. """Detects if a node makes use of any deprecated standards.
Returns: Returns:
@ -120,7 +123,15 @@ contract ContractWithDeprecatedReferences {
return results return results
def detect_deprecated_references_in_contract(self, contract: Contract) -> List[Union[Any, Tuple[Node, List[Tuple[str, str, str]]], Tuple[Node, List[Tuple[NodeType, str, str]]]]]: def detect_deprecated_references_in_contract(
self, contract: Contract
) -> List[
Union[
Any,
Tuple[Node, List[Tuple[str, str, str]]],
Tuple[Node, List[Tuple[NodeType, str, str]]],
]
]:
"""Detects the usage of any deprecated built-in symbols. """Detects the usage of any deprecated built-in symbols.
Returns: Returns:

@ -2,6 +2,7 @@
Module detecting possible loss of precision due to divide before multiple Module detecting possible loss of precision due to divide before multiple
""" """
from collections import defaultdict from collections import defaultdict
from typing import Any, DefaultDict, List, Set, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import Binary, Assignment, BinaryType, LibraryCall from slither.slithir.operations import Binary, Assignment, BinaryType, LibraryCall
from slither.slithir.variables import Constant from slither.slithir.variables import Constant
@ -13,10 +14,11 @@ from slither.slithir.operations.high_level_call import HighLevelCall
from slither.slithir.operations.member import Member from slither.slithir.operations.member import Member
from slither.slithir.operations.return_operation import Return from slither.slithir.operations.return_operation import Return
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, DefaultDict, List, Set, Tuple, Union
def is_division(ir: Union[Member, slither.slithir.operations.binary.Binary, HighLevelCall, Return]) -> bool: def is_division(
ir: Union[Member, slither.slithir.operations.binary.Binary, HighLevelCall, Return]
) -> bool:
if isinstance(ir, Binary): if isinstance(ir, Binary):
if ir.type == BinaryType.DIVISION: if ir.type == BinaryType.DIVISION:
return True return True
@ -32,7 +34,9 @@ def is_division(ir: Union[Member, slither.slithir.operations.binary.Binary, High
return False return False
def is_multiplication(ir: Union[Member, slither.slithir.operations.binary.Binary, HighLevelCall, Return]) -> bool: def is_multiplication(
ir: Union[Member, slither.slithir.operations.binary.Binary, HighLevelCall, Return]
) -> bool:
if isinstance(ir, Binary): if isinstance(ir, Binary):
if ir.type == BinaryType.MULTIPLICATION: if ir.type == BinaryType.MULTIPLICATION:
return True return True
@ -59,7 +63,8 @@ def is_assert(node: Node) -> bool:
return False return False
def _explore(to_explore: Set[Node], f_results: List[Any], divisions: DefaultDict[Any, Any]) -> None: # pylint: disable=too-many-branches # pylint: disable=too-many-branches
def _explore(to_explore: Set[Node], f_results: List[Any], divisions: DefaultDict[Any, Any]) -> None:
explored = set() explored = set()
while to_explore: # pylint: disable=too-many-nested-blocks while to_explore: # pylint: disable=too-many-nested-blocks
node = to_explore.pop() node = to_explore.pop()
@ -113,7 +118,9 @@ def _explore(to_explore: Set[Node], f_results: List[Any], divisions: DefaultDict
to_explore.add(son) to_explore.add(son)
def detect_divide_before_multiply(contract: Contract) -> List[Union[Tuple[FunctionContract, List[Node]], Any]]: def detect_divide_before_multiply(
contract: Contract,
) -> List[Union[Tuple[FunctionContract, List[Node]], Any]]:
""" """
Detects and returns all nodes with multiplications of division results. Detects and returns all nodes with multiplications of division results.
:param contract: Contract to detect assignment within. :param contract: Contract to detect assignment within.

@ -2,7 +2,7 @@
Module detecting dangerous strict equality Module detecting dangerous strict equality
""" """
from typing import Any, Dict, List, Union
from slither.analyses.data_dependency.data_dependency import is_dependent_ssa from slither.analyses.data_dependency.data_dependency import is_dependent_ssa
from slither.core.declarations import Function from slither.core.declarations import Function
from slither.core.declarations.function_top_level import FunctionTopLevel from slither.core.declarations.function_top_level import FunctionTopLevel
@ -31,7 +31,6 @@ from slither.slithir.variables.constant import Constant
from slither.slithir.variables.local_variable import LocalIRVariable from slither.slithir.variables.local_variable import LocalIRVariable
from slither.slithir.variables.temporary_ssa import TemporaryVariableSSA from slither.slithir.variables.temporary_ssa import TemporaryVariableSSA
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, Dict, List, Union
class IncorrectStrictEquality(AbstractDetector): class IncorrectStrictEquality(AbstractDetector):
@ -74,7 +73,21 @@ contract Crowdsale{
return isinstance(ir, Binary) and ir.type == BinaryType.EQUAL return isinstance(ir, Binary) and ir.type == BinaryType.EQUAL
@staticmethod @staticmethod
def is_any_tainted(variables: List[Union[Constant, LocalIRVariable, TemporaryVariableSSA, SolidityVariableComposed, SolidityVariable]], taints: List[Union[LocalIRVariable, SolidityVariable, SolidityVariableComposed, TemporaryVariableSSA]], function: FunctionContract) -> bool: def is_any_tainted(
variables: List[
Union[
Constant,
LocalIRVariable,
TemporaryVariableSSA,
SolidityVariableComposed,
SolidityVariable,
]
],
taints: List[
Union[LocalIRVariable, SolidityVariable, SolidityVariableComposed, TemporaryVariableSSA]
],
function: FunctionContract,
) -> bool:
return any( return any(
( (
is_dependent_ssa(var, taint, function.contract) is_dependent_ssa(var, taint, function.contract)
@ -83,7 +96,9 @@ contract Crowdsale{
) )
) )
def taint_balance_equalities(self, functions: List[Union[FunctionContract, Any]]) -> List[Union[LocalIRVariable, TemporaryVariableSSA, Any]]: def taint_balance_equalities(
self, functions: List[Union[FunctionContract, Any]]
) -> List[Union[LocalIRVariable, TemporaryVariableSSA, Any]]:
taints = [] taints = []
for func in functions: for func in functions:
for node in func.nodes: for node in func.nodes:
@ -114,7 +129,11 @@ contract Crowdsale{
return taints return taints
# Retrieve all tainted (node, function) pairs # Retrieve all tainted (node, function) pairs
def tainted_equality_nodes(self, funcs: List[Union[FunctionContract, Any]], taints: List[Union[LocalIRVariable, TemporaryVariableSSA, Any]]) -> Dict[FunctionContract, List[Node]]: def tainted_equality_nodes(
self,
funcs: List[Union[FunctionContract, Any]],
taints: List[Union[LocalIRVariable, TemporaryVariableSSA, Any]],
) -> Dict[FunctionContract, List[Node]]:
results = {} results = {}
taints += self.sources_taint taints += self.sources_taint

@ -1,7 +1,7 @@
""" """
Detect deletion on structure containing a mapping Detect deletion on structure containing a mapping
""" """
from typing import Any, List, Tuple, Union
from slither.core.declarations import Structure from slither.core.declarations import Structure
from slither.core.solidity_types import MappingType, UserDefinedType from slither.core.solidity_types import MappingType, UserDefinedType
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
@ -11,7 +11,6 @@ from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.core.declarations.structure_contract import StructureContract from slither.core.declarations.structure_contract import StructureContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class MappingDeletionDetection(AbstractDetector): class MappingDeletionDetection(AbstractDetector):
@ -51,7 +50,9 @@ The mapping `balances` is never deleted, so `remove` does not work as intended."
) )
@staticmethod @staticmethod
def detect_mapping_deletion(contract: Contract) -> List[Union[Any, Tuple[FunctionContract, StructureContract, Node]]]: def detect_mapping_deletion(
contract: Contract,
) -> List[Union[Any, Tuple[FunctionContract, StructureContract, Node]]]:
"""Detect deletion on structure containing a mapping """Detect deletion on structure containing a mapping
Returns: Returns:

@ -1,14 +1,13 @@
""" """
Module detecting redundant statements. Module detecting redundant statements.
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.cfg.node import Node, NodeType from slither.core.cfg.node import Node, NodeType
from slither.core.expressions.elementary_type_name_expression import ElementaryTypeNameExpression from slither.core.expressions.elementary_type_name_expression import ElementaryTypeNameExpression
from slither.core.expressions.identifier import Identifier from slither.core.expressions.identifier import Identifier
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class RedundantStatements(AbstractDetector): class RedundantStatements(AbstractDetector):

@ -3,12 +3,13 @@ Module detecting numbers with too many digits.
""" """
import re import re
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.variables import Constant from slither.slithir.variables import Constant
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
_HEX_ADDRESS_REGEXP = re.compile("(0[xX])?[0-9a-fA-F]{40}") _HEX_ADDRESS_REGEXP = re.compile("(0[xX])?[0-9a-fA-F]{40}")

@ -1,13 +1,12 @@
""" """
Module detecting usage of `tx.origin` in a conditional node Module detecting usage of `tx.origin` in a conditional node
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class TxOrigin(AbstractDetector): class TxOrigin(AbstractDetector):
@ -57,7 +56,9 @@ Bob is the owner of `TxOrigin`. Bob calls Eve's contract. Eve's contract calls `
) )
return False return False
def detect_tx_origin(self, contract: Contract) -> List[Union[Tuple[FunctionContract, List[Node]], Any]]: def detect_tx_origin(
self, contract: Contract
) -> List[Union[Tuple[FunctionContract, List[Node]], Any]]:
ret = [] ret = []
for f in contract.functions: for f in contract.functions:

@ -1,17 +1,15 @@
""" """
Module detecting tautologies and contradictions based on types in comparison operations over integers Module detecting tautologies and contradictions based on types in comparison operations over integers
""" """
from typing import Any, List, Set, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import Binary, BinaryType from slither.slithir.operations import Binary, BinaryType
from slither.slithir.variables import Constant from slither.slithir.variables import Constant
from slither.core.solidity_types.elementary_type import Int, Uint from slither.core.solidity_types.elementary_type import Int, Uint
import slither.slithir.operations.binary
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Set, Tuple, Union
def typeRange(t: str) -> Tuple[int, int]: def typeRange(t: str) -> Tuple[int, int]:
@ -24,7 +22,7 @@ def typeRange(t: str) -> Tuple[int, int]:
return None return None
def _detect_tautology_or_contradiction(low: int, high: int, cval: int, op: slither.slithir.operations.binary.BinaryType) -> bool: def _detect_tautology_or_contradiction(low: int, high: int, cval: int, op: BinaryType) -> bool:
""" """
Return true if "[low high] op cval " is always true or always false Return true if "[low high] op cval " is always true or always false
:param low: :param low:
@ -116,7 +114,9 @@ contract A {
BinaryType.LESS_EQUAL: BinaryType.GREATER_EQUAL, BinaryType.LESS_EQUAL: BinaryType.GREATER_EQUAL,
} }
def detect_type_based_tautologies(self, contract: Contract) -> List[Union[Any, Tuple[FunctionContract, Set[Node]], Tuple[FunctionContract, Set[Any]]]]: def detect_type_based_tautologies(
self, contract: Contract
) -> List[Union[Any, Tuple[FunctionContract, Set[Node]], Tuple[FunctionContract, Set[Any]]]]:
""" """
Detects and returns all nodes with tautology/contradiction comparisons (based on type alone). Detects and returns all nodes with tautology/contradiction comparisons (based on type alone).
:param contract: Contract to detect assignment within. :param contract: Contract to detect assignment within.

@ -1,13 +1,12 @@
""" """
Module detecting the incorrect use of unary expressions Module detecting the incorrect use of unary expressions
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.visitors.expression.expression import ExpressionVisitor from slither.visitors.expression.expression import ExpressionVisitor
from slither.core.expressions.unary_operation import UnaryOperationType, UnaryOperation from slither.core.expressions.unary_operation import UnaryOperationType, UnaryOperation
from slither.core.expressions.assignment_operation import AssignmentOperation from slither.core.expressions.assignment_operation import AssignmentOperation
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class InvalidUnaryExpressionDetector(ExpressionVisitor): class InvalidUnaryExpressionDetector(ExpressionVisitor):

@ -4,7 +4,6 @@ from slither.core.declarations import SolidityFunction, Function
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import LowLevelCall, SolidityCall from slither.slithir.operations import LowLevelCall, SolidityCall
import slither.core.declarations.function
from slither.utils.output import Output from slither.utils.output import Output

@ -15,7 +15,6 @@ from slither.slithir.operations import (
) )
from slither.slithir.variables import ReferenceVariable, TemporaryVariable, TupleVariable from slither.slithir.variables import ReferenceVariable, TemporaryVariable, TupleVariable
from slither.slithir.variables.variable import SlithIRVariable from slither.slithir.variables.variable import SlithIRVariable
import slither.slithir.operations.operation
from slither.utils.output import Output from slither.utils.output import Output

@ -1,14 +1,13 @@
""" """
Module detecting state variables initializing from an immediate function call (prior to constructor run). Module detecting state variables initializing from an immediate function call (prior to constructor run).
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.visitors.expression.export_values import ExportValues from slither.visitors.expression.export_values import ExportValues
from slither.core.declarations.function import Function from slither.core.declarations.function import Function
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
def detect_function_init_state_vars(contract: Contract) -> List[Union[StateVariable, Any]]: def detect_function_init_state_vars(contract: Contract) -> List[Union[StateVariable, Any]]:

@ -1,14 +1,13 @@
""" """
Module detecting any path leading to usage of a local variable before it is declared. Module detecting any path leading to usage of a local variable before it is declared.
""" """
from typing import Any, List, Set, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.core.variables.local_variable import LocalVariable from slither.core.variables.local_variable import LocalVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Set, Tuple, Union
class PredeclarationUsageLocal(AbstractDetector): class PredeclarationUsageLocal(AbstractDetector):
@ -54,7 +53,13 @@ Additionally, the for-loop uses the variable `max`, which is declared in a previ
WIKI_RECOMMENDATION = "Move all variable declarations prior to any usage of the variable, and ensure that reaching a variable declaration does not depend on some conditional if it is used unconditionally." WIKI_RECOMMENDATION = "Move all variable declarations prior to any usage of the variable, and ensure that reaching a variable declaration does not depend on some conditional if it is used unconditionally."
def detect_predeclared_local_usage(self, node: Node, results: List[Union[Tuple[Node, LocalVariable], Any]], already_declared: Set[LocalVariable], visited: Set[Node]) -> None: def detect_predeclared_local_usage(
self,
node: Node,
results: List[Union[Tuple[Node, LocalVariable], Any]],
already_declared: Set[LocalVariable],
visited: Set[Node],
) -> None:
""" """
Detects if a given node uses a variable prior to declaration in any code path. Detects if a given node uses a variable prior to declaration in any code path.
:param node: The node to initiate the scan from (searches recursively through all sons) :param node: The node to initiate the scan from (searches recursively through all sons)
@ -93,7 +98,9 @@ Additionally, the for-loop uses the variable `max`, which is declared in a previ
for son in node.sons: for son in node.sons:
self.detect_predeclared_local_usage(son, results, already_declared, visited) self.detect_predeclared_local_usage(son, results, already_declared, visited)
def detect_predeclared_in_contract(self, contract: Contract) -> List[Union[Any, Tuple[FunctionContract, List[Tuple[Node, LocalVariable]]]]]: def detect_predeclared_in_contract(
self, contract: Contract
) -> List[Union[Any, Tuple[FunctionContract, List[Tuple[Node, LocalVariable]]]]]:
""" """
Detects and returns all nodes in a contract which use a variable before it is declared. Detects and returns all nodes in a contract which use a variable before it is declared.
:param contract: Contract to detect pre-declaration usage of locals within. :param contract: Contract to detect pre-declaration usage of locals within.

@ -3,12 +3,11 @@ Check for state variables too similar
Do not check contract inheritance Do not check contract inheritance
""" """
import difflib import difflib
from typing import Any, List, Set, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.variables.local_variable import LocalVariable from slither.core.variables.local_variable import LocalVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Set, Tuple, Union
class SimilarVarsDetection(AbstractDetector): class SimilarVarsDetection(AbstractDetector):

@ -4,12 +4,12 @@
Recursively explore the CFG to only report uninitialized local variables that are Recursively explore the CFG to only report uninitialized local variables that are
read before being written read before being written
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class UninitializedLocalVars(AbstractDetector): class UninitializedLocalVars(AbstractDetector):
@ -41,7 +41,9 @@ Bob calls `transfer`. As a result, all Ether is sent to the address `0x0` and is
key = "UNINITIALIZEDLOCAL" key = "UNINITIALIZEDLOCAL"
def _detect_uninitialized(self, function: FunctionContract, node: Node, visited: List[Union[Any, Node]]) -> None: def _detect_uninitialized(
self, function: FunctionContract, node: Node, visited: List[Union[Any, Node]]
) -> None:
if node in visited: if node in visited:
return return

@ -8,7 +8,7 @@
Only analyze "leaf" contracts (contracts that are not inherited by another contract) Only analyze "leaf" contracts (contracts that are not inherited by another contract)
""" """
from typing import Any, List, Tuple, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import InternalCall, LibraryCall from slither.slithir.operations import InternalCall, LibraryCall
from slither.slithir.variables import ReferenceVariable from slither.slithir.variables import ReferenceVariable
@ -16,7 +16,6 @@ from slither.core.declarations.contract import Contract
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.core.variables.state_variable import StateVariable from slither.core.variables.state_variable import StateVariable
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Tuple, Union
class UninitializedStateVarsDetection(AbstractDetector): class UninitializedStateVarsDetection(AbstractDetector):
@ -113,7 +112,9 @@ Initialize all the variables. If a variable is meant to be initialized to zero,
ret += f.state_variables_read ret += f.state_variables_read
return ret return ret
def _detect_uninitialized(self, contract: Contract) -> List[Union[Any, Tuple[StateVariable, List[FunctionContract]]]]: def _detect_uninitialized(
self, contract: Contract
) -> List[Union[Any, Tuple[StateVariable, List[FunctionContract]]]]:
written_variables = self._written_variables(contract) written_variables = self._written_variables(contract)
written_variables += self._written_variables_in_proxy(contract) written_variables += self._written_variables_in_proxy(contract)
read_variables = self._read_variables(contract) read_variables = self._read_variables(contract)

@ -4,12 +4,11 @@
Recursively explore the CFG to only report uninitialized storage variables that are Recursively explore the CFG to only report uninitialized storage variables that are
written before being read written before being read
""" """
from typing import Any, List, Union
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations.function_contract import FunctionContract from slither.core.declarations.function_contract import FunctionContract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Union
class UninitializedStorageVars(AbstractDetector): class UninitializedStorageVars(AbstractDetector):
@ -49,7 +48,9 @@ Bob calls `func`. As a result, `owner` is overridden to `0`.
# node.context[self.key] contains the uninitialized storage variables # node.context[self.key] contains the uninitialized storage variables
key = "UNINITIALIZEDSTORAGE" key = "UNINITIALIZEDSTORAGE"
def _detect_uninitialized(self, function: FunctionContract, node: Node, visited: List[Union[Any, Node]]) -> None: def _detect_uninitialized(
self, function: FunctionContract, node: Node, visited: List[Union[Any, Node]]
) -> None:
if node in visited: if node in visited:
return return

@ -1,6 +1,7 @@
""" """
Module detecting unused state variables Module detecting unused state variables
""" """
from typing import Any, List, Optional, Union
from slither.core.compilation_unit import SlitherCompilationUnit from slither.core.compilation_unit import SlitherCompilationUnit
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.solidity_types import ArrayType from slither.core.solidity_types import ArrayType
@ -9,7 +10,6 @@ from slither.core.variables.state_variable import StateVariable
from slither.formatters.variables.unused_state_variables import custom_format from slither.formatters.variables.unused_state_variables import custom_format
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.utils.output import Output from slither.utils.output import Output
from typing import Any, List, Optional, Union
def detect_unused(contract: Contract) -> Optional[List[StateVariable]]: def detect_unused(contract: Contract) -> Optional[List[StateVariable]]:

@ -1,9 +1,9 @@
from typing import Any, Union, List from typing import Any, Union, List
from slither.core.cfg.node import Node from slither.core.cfg.node import Node
from slither.core.declarations import Function, SolidityVariable from slither.core.declarations import Function, SolidityVariable
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations.high_level_call import HighLevelCall from slither.slithir.operations.high_level_call import HighLevelCall
import slither.core.declarations.function
from slither.utils.output import Output from slither.utils.output import Output

@ -12,7 +12,6 @@ from slither.exceptions import SlitherError
from slither.printers.abstract_printer import AbstractPrinter from slither.printers.abstract_printer import AbstractPrinter
from slither.solc_parsing.slither_compilation_unit_solc import SlitherCompilationUnitSolc from slither.solc_parsing.slither_compilation_unit_solc import SlitherCompilationUnitSolc
from slither.utils.output import Output from slither.utils.output import Output
import crytic_compile.crytic_compile
logger = logging.getLogger("Slither") logger = logging.getLogger("Slither")
logging.basicConfig() logging.basicConfig()

@ -1,3 +1,4 @@
from typing import List, Union
from slither.core.solidity_types import ElementaryType from slither.core.solidity_types import ElementaryType
from slither.slithir.operations.lvalue import OperationWithLValue from slither.slithir.operations.lvalue import OperationWithLValue
from slither.slithir.utils.utils import is_valid_lvalue, is_valid_rvalue from slither.slithir.utils.utils import is_valid_lvalue, is_valid_rvalue
@ -5,11 +6,14 @@ from slither.core.variables.local_variable import LocalVariable
from slither.slithir.variables.local_variable import LocalIRVariable from slither.slithir.variables.local_variable import LocalIRVariable
from slither.slithir.variables.reference import ReferenceVariable from slither.slithir.variables.reference import ReferenceVariable
from slither.slithir.variables.reference_ssa import ReferenceVariableSSA from slither.slithir.variables.reference_ssa import ReferenceVariableSSA
from typing import List, Union
class CodeSize(OperationWithLValue): class CodeSize(OperationWithLValue):
def __init__(self, value: Union[LocalVariable, LocalIRVariable], lvalue: Union[ReferenceVariableSSA, ReferenceVariable]) -> None: def __init__(
self,
value: Union[LocalVariable, LocalIRVariable],
lvalue: Union[ReferenceVariableSSA, ReferenceVariable],
) -> None:
super().__init__() super().__init__()
assert is_valid_rvalue(value) assert is_valid_rvalue(value)
assert is_valid_lvalue(lvalue) assert is_valid_lvalue(lvalue)

@ -116,7 +116,7 @@ class HighLevelCall(Call, OperationWithLValue):
return True return True
return False return False
def can_reenter(self, callstack: None=None) -> bool: def can_reenter(self, callstack: None = None) -> bool:
""" """
Must be called after slithIR analysis pass Must be called after slithIR analysis pass
For Solidity > 0.5, filter access to public variables and constant/pure/view For Solidity > 0.5, filter access to public variables and constant/pure/view

@ -12,7 +12,7 @@ class LibraryCall(HighLevelCall):
def _check_destination(self, destination: Contract) -> None: def _check_destination(self, destination: Contract) -> None:
assert isinstance(destination, Contract) assert isinstance(destination, Contract)
def can_reenter(self, callstack: None=None) -> bool: def can_reenter(self, callstack: None = None) -> bool:
""" """
Must be called after slithIR analysis pass Must be called after slithIR analysis pass
:return: bool :return: bool

@ -74,7 +74,7 @@ class LowLevelCall(Call, OperationWithLValue): # pylint: disable=too-many-insta
# remove None # remove None
return self._unroll([x for x in all_read if x]) return self._unroll([x for x in all_read if x])
def can_reenter(self, _callstack: None=None) -> bool: def can_reenter(self, _callstack: None = None) -> bool:
""" """
Must be called after slithIR analysis pass Must be called after slithIR analysis pass
:return: bool :return: bool

@ -1,5 +1,5 @@
from slither.slithir.operations.operation import Operation
from typing import Any, List from typing import Any, List
from slither.slithir.operations.operation import Operation
class OperationWithLValue(Operation): class OperationWithLValue(Operation):

@ -66,7 +66,7 @@ class NewContract(Call, OperationWithLValue): # pylint: disable=too-many-instan
################################################################################### ###################################################################################
################################################################################### ###################################################################################
def can_reenter(self, callstack: Optional[List[FunctionContract]]=None) -> bool: def can_reenter(self, callstack: Optional[List[FunctionContract]] = None) -> bool:
""" """
Must be called after slithIR analysis pass Must be called after slithIR analysis pass
For Solidity > 0.5, filter access to public variables and constant/pure/view For Solidity > 0.5, filter access to public variables and constant/pure/view

@ -1,10 +1,13 @@
from .operation import Operation from typing import List
from typing import Any, List
from slither.core.variables.variable import Variable
from slither.slithir.operations import Operation
class Nop(Operation): class Nop(Operation):
@property @property
def read(self) -> List[Any]: def read(self) -> List[Variable]:
return [] return []
@property @property

@ -3,6 +3,7 @@ from typing import Any, List
from slither.core.context.context import Context from slither.core.context.context import Context
from slither.core.children.child_expression import ChildExpression from slither.core.children.child_expression import ChildExpression
from slither.core.children.child_node import ChildNode from slither.core.children.child_node import ChildNode
from slither.core.variables.variable import Variable
from slither.utils.utils import unroll from slither.utils.utils import unroll
@ -26,7 +27,7 @@ class AbstractOperation(abc.ABC):
class Operation(Context, ChildExpression, ChildNode, AbstractOperation): class Operation(Context, ChildExpression, ChildNode, AbstractOperation):
@property @property
def used(self) -> List[Any]: def used(self) -> List[Variable]:
""" """
By default used is all the variables read By default used is all the variables read
""" """

@ -1,14 +1,20 @@
from typing import List, Union
from slither.slithir.operations.lvalue import OperationWithLValue from slither.slithir.operations.lvalue import OperationWithLValue
from slither.slithir.utils.utils import is_valid_lvalue from slither.slithir.utils.utils import is_valid_lvalue
from slither.slithir.variables.tuple import TupleVariable from slither.slithir.variables.tuple import TupleVariable
from slither.core.variables.local_variable_init_from_tuple import LocalVariableInitFromTuple from slither.core.variables.local_variable_init_from_tuple import LocalVariableInitFromTuple
from slither.slithir.variables.local_variable import LocalIRVariable from slither.slithir.variables.local_variable import LocalIRVariable
from slither.slithir.variables.tuple_ssa import TupleVariableSSA from slither.slithir.variables.tuple_ssa import TupleVariableSSA
from typing import List, Union
class Unpack(OperationWithLValue): class Unpack(OperationWithLValue):
def __init__(self, result: Union[LocalVariableInitFromTuple, LocalIRVariable], tuple_var: Union[TupleVariable, TupleVariableSSA], idx: int) -> None: def __init__(
self,
result: Union[LocalVariableInitFromTuple, LocalIRVariable],
tuple_var: Union[TupleVariable, TupleVariableSSA],
idx: int,
) -> None:
assert is_valid_lvalue(result) assert is_valid_lvalue(result)
assert isinstance(tuple_var, TupleVariable) assert isinstance(tuple_var, TupleVariable)
assert isinstance(idx, int) assert isinstance(idx, int)

@ -3,9 +3,9 @@
It is similar to the non-SSA version of slithIR It is similar to the non-SSA version of slithIR
as the ReferenceVariable are in SSA form in both version as the ReferenceVariable are in SSA form in both version
""" """
from typing import Union
from slither.slithir.variables.reference import ReferenceVariable from slither.slithir.variables.reference import ReferenceVariable
from slither.slithir.variables.tuple import TupleVariable from slither.slithir.variables.tuple import TupleVariable
from typing import Union
class ReferenceVariableSSA(ReferenceVariable): # pylint: disable=too-few-public-methods class ReferenceVariableSSA(ReferenceVariable): # pylint: disable=too-few-public-methods

@ -5,7 +5,9 @@ from slither.core.variables.local_variable_init_from_tuple import LocalVariableI
class LocalVariableInitFromTupleSolc(VariableDeclarationSolc): class LocalVariableInitFromTupleSolc(VariableDeclarationSolc):
def __init__(self, variable: LocalVariableInitFromTuple, variable_data: Dict, index: int) -> None: def __init__(
self, variable: LocalVariableInitFromTuple, variable_data: Dict, index: int
) -> None:
super().__init__(variable, variable_data) super().__init__(variable, variable_data)
variable.tuple_index = index variable.tuple_index = index

@ -16,12 +16,6 @@ from slither.core.variables.variable import Variable
from slither.exceptions import SlitherError from slither.exceptions import SlitherError
from slither.utils.colors import yellow from slither.utils.colors import yellow
from slither.utils.myprettytable import MyPrettyTable from slither.utils.myprettytable import MyPrettyTable
import slither.core.declarations.contract
import slither.core.declarations.enum
import slither.core.declarations.event
import slither.core.declarations.function
import slither.core.declarations.pragma_directive
import slither.core.declarations.structure
if TYPE_CHECKING: if TYPE_CHECKING:
from slither.core.compilation_unit import SlitherCompilationUnit from slither.core.compilation_unit import SlitherCompilationUnit
@ -305,7 +299,34 @@ def _convert_to_id(d: str) -> str:
def _create_base_element( def _create_base_element(
custom_type: str, name: str, source_mapping: Dict, type_specific_fields: Optional[Dict[str, Union[Dict[str, Union[str, Dict[str, Union[int, str, bool, List[int]]], Dict[str, Union[Dict[str, Union[str, Dict[str, Union[int, str, bool, List[int]]]]], str]]]], Dict[str, Union[str, Dict[str, Union[int, str, bool, List[int]]]]], str, List[str]]]]=None, additional_fields: Optional[Dict[str, str]]=None custom_type: str,
name: str,
source_mapping: Dict,
type_specific_fields: Optional[
Dict[
str,
Union[
Dict[
str,
Union[
str,
Dict[str, Union[int, str, bool, List[int]]],
Dict[
str,
Union[
Dict[str, Union[str, Dict[str, Union[int, str, bool, List[int]]]]],
str,
],
],
],
],
Dict[str, Union[str, Dict[str, Union[int, str, bool, List[int]]]]],
str,
List[str],
],
]
] = None,
additional_fields: Optional[Dict[str, str]] = None,
) -> Dict[str, Any]: ) -> Dict[str, Any]:
if additional_fields is None: if additional_fields is None:
additional_fields = {} additional_fields = {}
@ -319,7 +340,16 @@ def _create_base_element(
return element return element
def _create_parent_element(element: SourceMapping) -> Dict[str, Union[str, Dict[str, Union[int, str, bool, List[int]]], Dict[str, Union[Dict[str, Union[str, Dict[str, Union[int, str, bool, List[int]]]]], str]]]]: def _create_parent_element(
element: SourceMapping,
) -> Dict[
str,
Union[
str,
Dict[str, Union[int, str, bool, List[int]]],
Dict[str, Union[Dict[str, Union[str, Dict[str, Union[int, str, bool, List[int]]]]], str]],
],
]:
# pylint: disable=import-outside-toplevel # pylint: disable=import-outside-toplevel
from slither.core.children.child_contract import ChildContract from slither.core.children.child_contract import ChildContract
from slither.core.children.child_function import ChildFunction from slither.core.children.child_function import ChildFunction

@ -1,3 +1,4 @@
from typing import Any, List
from slither.visitors.expression.expression import ExpressionVisitor from slither.visitors.expression.expression import ExpressionVisitor
from slither.core.expressions.call_expression import CallExpression from slither.core.expressions.call_expression import CallExpression
from slither.core.expressions.identifier import Identifier from slither.core.expressions.identifier import Identifier
@ -7,7 +8,7 @@ from slither.core.expressions.expression import Expression
from slither.core.expressions.member_access import MemberAccess from slither.core.expressions.member_access import MemberAccess
from slither.core.expressions.tuple_expression import TupleExpression from slither.core.expressions.tuple_expression import TupleExpression
from slither.core.expressions.type_conversion import TypeConversion from slither.core.expressions.type_conversion import TypeConversion
from typing import Any, List
key = "ExportValues" key = "ExportValues"

Loading…
Cancel
Save