Handle file mapping to yul files (#1498)

pull/1499/head
Nikhil Parasaram 3 years ago committed by GitHub
parent c72d212c7e
commit 6eb13dd3fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      mythril/analysis/report.py
  2. 9
      mythril/solidity/soliditycontract.py

@ -144,6 +144,12 @@ class Issue:
codeinfo = contract.get_source_info(
self.address, constructor=(self.function == "constructor")
)
if codeinfo is None:
self.source_mapping = self.address
self.filename = "Internal File"
return
self.filename = codeinfo.filename
self.code = codeinfo.code
self.lineno = codeinfo.lineno

@ -1,12 +1,15 @@
"""This module contains representation classes for Solidity files, contracts
and source mappings."""
from typing import Dict, Set
import logging
import mythril.laser.ethereum.util as helper
from mythril.ethereum.evmcontract import EVMContract
from mythril.ethereum.util import get_solc_json
from mythril.exceptions import NoContractFoundError
log = logging.getLogger(__name__)
class SourceMapping:
def __init__(self, solidity_file_idx, offset, length, lineno, mapping):
@ -191,8 +194,12 @@ class SolidityContract(EVMContract):
disassembly = self.creation_disassembly if constructor else self.disassembly
mappings = self.constructor_mappings if constructor else self.mappings
index = helper.get_instruction_index(disassembly.instruction_list, address)
file_index = mappings[index].solidity_file_idx
if file_index == -1:
# If issue is detected in an internal file
return None
solidity_file = self.solc_indices[mappings[index].solidity_file_idx]
solidity_file = self.solc_indices[file_index]
filename = solidity_file.filename
offset = mappings[index].offset

Loading…
Cancel
Save