Add docstrings to the analyzer class

pull/906/head
Nikhil Parasaram 6 years ago
parent 266179cb3d
commit 8c4e176779
  1. 90
      mythril/mythril/mythril_analyzer.py

@ -19,30 +19,21 @@ log = logging.getLogger(__name__)
class MythrilAnalyzer(object): class MythrilAnalyzer(object):
"""Mythril main interface class.
.. code-block:: python
mythril = Mythril()
# analyze
print(mythril.fire_lasers(args).as_text())
# (optional) graph
for contract in mythril.contracts:
# prints html or save it to file
print(mythril.graph_html(args))
# (optional) other funcs
mythril.dump_statespaces(args)
mythril.disassemble(contract)
mythril.get_state_variable_from_storage(args)
""" """
The Mythril Analyzer class
Responsible for the analysis of the smart contracts
"""
def __init__(self, disassembler, requires_dynld=False, onchain_storage_access=True):
"""
def __init__(self, disassembler, dynld=False, onchain_storage_access=True): :param disassembler: The MythrilDisassembler class
:param requires_dynld: whether dynamic loading should be done or not
:param onchain_storage_access: Whether onchain access should be done or not
"""
self.eth = disassembler.eth self.eth = disassembler.eth
self.contracts = disassembler.contracts or [] self.contracts = disassembler.contracts or []
self.enable_online_lookup = disassembler.enable_online_lookup self.enable_online_lookup = disassembler.enable_online_lookup
self.dynld = dynld self.dynld = requires_dynld
self.onchain_storage_access = onchain_storage_access self.onchain_storage_access = onchain_storage_access
def dump_statespace( def dump_statespace(
@ -56,15 +47,15 @@ class MythrilAnalyzer(object):
enable_iprof=False, enable_iprof=False,
): ):
""" """
Returns serializable statespace of the contract
:param strategy: :param strategy: The search strategy to go through the CFG
:param contract: :param contract: The Contract on which the analysis should be done
:param address: :param address: The Contract address
:param max_depth: :param max_depth: The max depth till which the CFG should be constructed
:param execution_timeout: :param execution_timeout: The total execution timeout of the contract
:param create_timeout: :param create_timeout: The total contract creation timeout
:param enable_iprof: :param enable_iprof: Enables/disables instruction profiler
:return: :return: The serialized state space
""" """
sym = SymExecWrapper( sym = SymExecWrapper(
contract, contract,
@ -97,16 +88,16 @@ class MythrilAnalyzer(object):
): ):
""" """
:param strategy: :param strategy: The search strategy to go through the CFG
:param contract: :param contract: The Contract on which the analysis should be done
:param address: :param address: The Contract address
:param max_depth: :param max_depth: The max depth till which the CFG should be constructed
:param enable_physics: :param enable_physics: If true then enables the graph physics simulation
:param phrackify: :param phrackify: If true generates Phrack-style call graph
:param execution_timeout: :param execution_timeout: The total execution timeout of the contract
:param create_timeout: :param create_timeout: The total contract creation timeout
:param enable_iprof: :param enable_iprof: Enables/disables instruction profiler
:return: :return: The generated graph in html format
""" """
sym = SymExecWrapper( sym = SymExecWrapper(
contract, contract,
@ -138,18 +129,17 @@ class MythrilAnalyzer(object):
enable_iprof=False, enable_iprof=False,
): ):
""" """
:param strategy: The search strategy to go through the CFG
:param strategy: :param contracts: The Contracts list on which the analysis should be done
:param contracts: :param address: The Contract address
:param address: :param modules: The analysis modules which should be executed
:param modules: :param verbose_report: Gives out the transaction sequence of the vulnerability
:param verbose_report: :param max_depth: The max depth till which the CFG should be constructed
:param max_depth: :param execution_timeout: The total execution timeout of the contract
:param execution_timeout: :param create_timeout: The total contract creation timeout
:param create_timeout: :param transaction_count: The amount of transactions to be executed
:param transaction_count: :param enable_iprof: Enables/disables instruction profiler
:param enable_iprof: :return: The Report class which contains the all the issues/vulnerabilities
:return:
""" """
all_issues = [] all_issues = []
for contract in contracts or self.contracts: for contract in contracts or self.contracts:

Loading…
Cancel
Save