Apply black

pull/845/head
Dominik Muhs 6 years ago
parent 49ca94c2da
commit a8f61a0f83
  1. 1
      mythril/analysis/modules/base.py
  2. 1
      mythril/analysis/modules/delegatecall.py
  3. 1
      mythril/analysis/modules/dependence_on_predictable_vars.py
  4. 1
      mythril/analysis/modules/deprecated_ops.py
  5. 1
      mythril/analysis/modules/ether_thief.py
  6. 1
      mythril/analysis/modules/exceptions.py
  7. 1
      mythril/analysis/modules/external_calls.py
  8. 1
      mythril/analysis/modules/integer.py
  9. 1
      mythril/analysis/modules/multiple_sends.py
  10. 1
      mythril/analysis/modules/suicide.py
  11. 1
      mythril/analysis/modules/transaction_order_dependence.py
  12. 1
      mythril/analysis/modules/unchecked_retval.py
  13. 5
      mythril/analysis/ops.py
  14. 2
      mythril/analysis/report.py
  15. 1
      mythril/ethereum/evmcontract.py
  16. 6
      mythril/ethereum/interface/rpc/exceptions.py
  17. 7
      mythril/exceptions.py
  18. 1
      mythril/interfaces/epic.py
  19. 3
      mythril/laser/ethereum/cfg.py
  20. 6
      mythril/laser/ethereum/evm_exceptions.py
  21. 1
      mythril/laser/ethereum/keccak.py
  22. 1
      mythril/laser/ethereum/natives.py
  23. 1
      mythril/laser/ethereum/state/annotation.py
  24. 3
      mythril/laser/ethereum/state/calldata.py
  25. 1
      mythril/laser/ethereum/state/memory.py
  26. 1
      mythril/laser/ethereum/strategy/__init__.py
  27. 3
      mythril/laser/ethereum/svm.py
  28. 2
      mythril/laser/smt/array.py
  29. 1
      mythril/mythril.py
  30. 4
      mythril/solidity/soliditycontract.py
  31. 1
      mythril/support/loader.py
  32. 3
      mythril/support/signatures.py

@ -11,6 +11,7 @@ class DetectionModule:
All custom-built detection modules must inherit from this class.
"""
def __init__(
self,
name: str,

@ -16,6 +16,7 @@ log = logging.getLogger(__name__)
class DelegateCallModule(DetectionModule):
"""This module detects calldata being forwarded using DELEGATECALL."""
def __init__(self):
"""

@ -15,6 +15,7 @@ log = logging.getLogger(__name__)
class PredictableDependenceModule(DetectionModule):
"""This module detects whether Ether is sent using predictable parameters."""
def __init__(self):
"""

@ -58,6 +58,7 @@ def _analyze_state(state):
class DeprecatedOperationsModule(DetectionModule):
"""This module checks for the usage of deprecated op codes."""
def __init__(self):
"""

@ -84,6 +84,7 @@ def _analyze_state(state):
class EtherThief(DetectionModule):
"""This module search for cases where Ether can be withdrawn to a user-specified address."""
def __init__(self):
"""

@ -59,6 +59,7 @@ class ReachableExceptionsModule(DetectionModule):
"""
"""
def __init__(self):
"""

@ -97,6 +97,7 @@ def _analyze_state(state):
class ExternalCalls(DetectionModule):
"""This module searches for low level calls (e.g. call.value()) that forward all gas to the callee."""
def __init__(self):
"""

@ -24,6 +24,7 @@ log = logging.getLogger(__name__)
class IntegerOverflowUnderflowModule(DetectionModule):
"""This module searches for integer over- and underflows."""
def __init__(self):
"""

@ -7,6 +7,7 @@ from mythril.laser.ethereum.cfg import JumpType
class MultipleSendsModule(DetectionModule):
"""This module checks for multiple sends in a single transaction."""
def __init__(self):
"""

@ -60,6 +60,7 @@ def _analyze_state(state):
class SuicideModule(DetectionModule):
"""This module checks if the contact can be 'accidentally' killed by anyone."""
def __init__(self):
super().__init__(
name="Unprotected Suicide",

@ -16,6 +16,7 @@ log = logging.getLogger(__name__)
class TxOrderDependenceModule(DetectionModule):
"""This module finds the existence of transaction order dependence."""
def __init__(self):
super().__init__(
name="Transaction Order Dependence",

@ -12,6 +12,7 @@ log = logging.getLogger(__name__)
class UncheckedRetvalModule(DetectionModule):
"""A detection module to test whether CALL return value is checked."""
def __init__(self):
super().__init__(
name="Unchecked Return Value",

@ -6,12 +6,14 @@ from mythril.laser.ethereum import util
class VarType(Enum):
"""An enum denoting whether a value is symbolic or concrete."""
SYMBOLIC = 1
CONCRETE = 2
class Variable:
"""The representation of a variable with value and type."""
def __init__(self, val, _type):
"""
@ -43,6 +45,7 @@ def get_variable(i):
class Op:
"""The base type for operations referencing current node and state."""
def __init__(self, node, state, state_index):
"""
@ -57,6 +60,7 @@ class Op:
class Call(Op):
"""The representation of a CALL operation."""
def __init__(
self,
node,
@ -89,6 +93,7 @@ class Call(Op):
class SStore(Op):
"""The respresentation of an SSTORE operation."""
def __init__(self, node, state, state_index, value):
super().__init__(node, state, state_index)
self.value = value

@ -11,6 +11,7 @@ log = logging.getLogger(__name__)
class Issue:
"""Representation of an issue and its location."""
def __init__(
self,
contract,
@ -104,6 +105,7 @@ class Issue:
class Report:
"""A report containing the content of multiple issues."""
environment = Environment(
loader=PackageLoader("mythril.analysis"), trim_blocks=True
)

@ -7,6 +7,7 @@ import re
class EVMContract(persistent.Persistent):
"""This class represents an address with associated code (Smart Contract)."""
def __init__(
self, code="", creation_code="", name="Unknown", enable_online_lookup=False
):

@ -1,25 +1,31 @@
"""This module contains exceptions regarding JSON-RPC communication."""
class EthJsonRpcError(Exception):
"""The JSON-RPC base exception type."""
pass
class ConnectionError(EthJsonRpcError):
"""An RPC exception denoting there was an error in connecting to the RPC instance."""
pass
class BadStatusCodeError(EthJsonRpcError):
"""An RPC exception denoting a bad status code returned by the RPC instance."""
pass
class BadJsonError(EthJsonRpcError):
"""An RPC exception denoting that the RPC instance returned a bad JSON object."""
pass
class BadResponseError(EthJsonRpcError):
"""An RPC exception denoting that the RPC instance returned a bad response."""
pass

@ -1,30 +1,37 @@
"""This module contains general exceptions used by Mythril."""
class MythrilBaseException(Exception):
"""The Mythril exception base type."""
pass
class CompilerError(MythrilBaseException):
"""A Mythril exception denoting an error during code compilation."""
pass
class UnsatError(MythrilBaseException):
"""A Mythril exception denoting the unsatisfiability of a series of constraints."""
pass
class NoContractFoundError(MythrilBaseException):
"""A Mythril exception denoting that a given contract file was not found."""
pass
class CriticalError(MythrilBaseException):
"""A Mythril exception denoting an unknown critical error has been encountered."""
pass
class AddressNotFoundError(MythrilBaseException):
"""A Mythril exception denoting the given smart contract address was not found."""
pass

@ -54,6 +54,7 @@ COLOR_ANSI = (
class LolCat(object):
"""Cats lel"""
def __init__(self, mode=256, output=sys.stdout):
self.mode = mode
self.output = output

@ -8,6 +8,7 @@ gbl_next_uid = 0 # node counter
class JumpType(Enum):
"""An enum to represent the types of possible JUMP scenarios."""
CONDITIONAL = 1
UNCONDITIONAL = 2
CALL = 3
@ -17,6 +18,7 @@ class JumpType(Enum):
class NodeFlags(Flags):
"""A collection of flags to denote the type a call graph node can have."""
FUNC_ENTRY = 1
CALL_RETURN = 2
@ -70,6 +72,7 @@ class Node:
class Edge:
"""The respresentation of a call graph edge."""
def __init__(
self,
node_from: int,

@ -3,29 +3,35 @@
class VmException(Exception):
"""The base VM exception type."""
pass
class StackUnderflowException(IndexError, VmException):
"""A VM exception regarding stack underflows."""
pass
class StackOverflowException(VmException):
"""A VM exception regarding stack overflows."""
pass
class InvalidJumpDestination(VmException):
"""A VM exception regarding JUMPs to invalid destinations."""
pass
class InvalidInstruction(VmException):
"""A VM exception denoting an invalid op code has been encountered."""
pass
class OutOfGasException(VmException):
"""A VM exception denoting the current execution has run out of gas."""
pass

@ -4,6 +4,7 @@ from mythril.laser.smt import Expression
class KeccakFunctionManager:
"""A keccak function manager for symbolic expressions."""
def __init__(self):
"""

@ -17,6 +17,7 @@ log = logging.getLogger(__name__)
class NativeContractException(Exception):
"""An exception denoting an error during a native call."""
pass

@ -4,6 +4,7 @@ This includes the base StateAnnotation class, as well as an adaption, which will
copied on every new state.
"""
class StateAnnotation:
"""
The StateAnnotation class is used to persist information over traces. This allows modules to reason about traces

@ -110,6 +110,7 @@ class BaseCalldata:
class ConcreteCalldata(BaseCalldata):
"""A concrete call data representation."""
def __init__(self, tx_id: int, calldata: list):
"""
Initializes the ConcreteCalldata object.
@ -203,6 +204,7 @@ class BasicConcreteCalldata(BaseCalldata):
class SymbolicCalldata(BaseCalldata):
"""A class for representing symbolic call data."""
def __init__(self, tx_id: int):
"""Initializes the SymbolicCalldata object.
@ -253,6 +255,7 @@ class SymbolicCalldata(BaseCalldata):
class BasicSymbolicCalldata(BaseCalldata):
"""A basic class representing symbolic call data."""
def __init__(self, tx_id: int):
"""
Initializes the SymbolicCalldata object

@ -15,6 +15,7 @@ from mythril.laser.ethereum import util
class Memory:
"""A class representing contract memory with random access."""
def __init__(self):
"""

@ -5,6 +5,7 @@ class BasicSearchStrategy(ABC):
"""
"""
__slots__ = "work_list", "max_depth"
def __init__(self, work_list, max_depth):

@ -29,6 +29,7 @@ log = logging.getLogger(__name__)
class SVMError(Exception):
"""An exception denoting an unexpected state in symbolic execution."""
pass
@ -492,6 +493,7 @@ class LaserEVM:
:param op_code:
:return:
"""
def hook_decorator(func: Callable):
"""
@ -511,6 +513,7 @@ class LaserEVM:
:param op_code:
:return:
"""
def hook_decorator(func: Callable):
"""

@ -26,6 +26,7 @@ class BaseArray:
class Array(BaseArray):
"""A basic symbolic array."""
def __init__(self, name: str, domain: int, value_range: int):
"""
Initializes a symbolic array
@ -40,6 +41,7 @@ class Array(BaseArray):
class K(BaseArray):
"""A basic symbolic array, which can be initialized with a default value."""
def __init__(self, domain: int, value_range: int, value: int):
"""
Initializes an array with a default value

@ -322,6 +322,7 @@ class Mythril(object):
:param search:
"""
def search_callback(_, address, balance):
"""

@ -7,6 +7,7 @@ from mythril.exceptions import NoContractFoundError
class SourceMapping:
"""Representation of a source mapping for a Solidity file."""
def __init__(self, solidity_file_idx, offset, length, lineno):
self.solidity_file_idx = solidity_file_idx
self.offset = offset
@ -16,6 +17,7 @@ class SourceMapping:
class SolidityFile:
"""Representation of a file containing Solidity code."""
def __init__(self, filename, data):
self.filename = filename
self.data = data
@ -23,6 +25,7 @@ class SolidityFile:
class SourceCodeInfo:
"""Metadata class containing a code reference for a specific file."""
def __init__(self, filename, lineno, code):
self.filename = filename
self.lineno = lineno
@ -54,6 +57,7 @@ def get_contracts_from_file(input_file, solc_args=None, solc_binary="solc"):
class SolidityContract(EVMContract):
"""Representation of a Solidity contract."""
def __init__(self, input_file, name=None, solc_args=None, solc_binary="solc"):
data = get_solc_json(input_file, solc_args=solc_args, solc_binary=solc_binary)

@ -8,6 +8,7 @@ log = logging.getLogger(__name__)
class DynLoader:
"""The dynamic loader class."""
def __init__(self, eth, contract_loading=True, storage_loading=True):
"""

@ -26,6 +26,7 @@ def synchronized(sync_lock):
:param f:
:return:
"""
@functools.wraps(f)
def inner_wrapper(*args, **kw):
"""
@ -44,6 +45,7 @@ def synchronized(sync_lock):
class Singleton(type):
"""A metaclass type implementing the singleton pattern."""
_instances = {}
@synchronized(lock)
@ -113,6 +115,7 @@ class SignatureDB(object, metaclass=Singleton):
"""
"""
def __init__(self, enable_online_lookup: bool = False, path: str = None) -> None:
"""
:param enable_online_lookup:

Loading…
Cancel
Save