From 74cabd3d3cf3c0d5e579cac15c4ce7b53c26f46e Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 4 Sep 2019 10:41:34 -0400 Subject: [PATCH] Fix issue reporting for trial analysis --- mythril/mythx/__init__.py | 6 ++++-- mythril/solidity/soliditycontract.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mythril/mythx/__init__.py b/mythril/mythx/__init__.py index ae105470..3f2b9616 100644 --- a/mythril/mythx/__init__.py +++ b/mythril/mythx/__init__.py @@ -79,8 +79,10 @@ def analyze(contracts: List[SolidityContract], analysis_mode: str = "quick") -> issue = Issue( contract=contract.name, function_name=None, - address=issue.locations[0].source_map.components[0].offset, - swc_id=issue.swc_id[4:], # remove 'SWC-' prefix + address=issue.locations[0].source_map.components[0].offset + if issue.locations + else -1, + swc_id=issue.swc_id[4:] or "None", # remove 'SWC-' prefix title=issue.swc_title, bytecode=contract.creation_code, severity=issue.severity.capitalize(), diff --git a/mythril/solidity/soliditycontract.py b/mythril/solidity/soliditycontract.py index 534189d3..772141c8 100644 --- a/mythril/solidity/soliditycontract.py +++ b/mythril/solidity/soliditycontract.py @@ -56,15 +56,15 @@ def get_contracts_from_file(input_file, solc_settings_json=None, solc_binary="so ) try: - for contractName in data["contracts"][input_file].keys(): + for contract_name in data["contracts"][input_file].keys(): if len( - data["contracts"][input_file][contractName]["evm"]["deployedBytecode"][ + data["contracts"][input_file][contract_name]["evm"]["deployedBytecode"][ "object" ] ): yield SolidityContract( input_file=input_file, - name=contractName, + name=contract_name, solc_settings_json=solc_settings_json, solc_binary=solc_binary, )