Merge pull request #2431 from crytic/fix/evm-printer

Fix #2430
pull/2435/head
alpharush 6 months ago committed by GitHub
commit 0fad849612
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 19
      slither/printers/summary/evm.py

@ -1,6 +1,8 @@
"""
Module printing evm mapping of the contract
"""
import logging
from slither.printers.abstract_printer import AbstractPrinter
from slither.analyses.evm import (
generate_source_to_evm_ins_mapping,
@ -9,6 +11,9 @@ from slither.analyses.evm import (
from slither.utils.colors import blue, green, magenta, red
logger: logging.Logger = logging.getLogger("EVMPrinter")
def _extract_evm_info(slither):
"""
Extract evm information for all derived contracts using evm_cfg_builder
@ -24,6 +29,16 @@ def _extract_evm_info(slither):
contract_bytecode_runtime = contract.file_scope.bytecode_runtime(
contract.compilation_unit.crytic_compile_compilation_unit, contract.name
)
if not contract_bytecode_runtime:
logger.info(
"Contract %s (abstract: %r) has no bytecode runtime, skipping. ",
contract.name,
contract.is_abstract,
)
evm_info["empty", contract.name] = True
continue
contract_srcmap_runtime = contract.file_scope.srcmap_runtime(
contract.compilation_unit.crytic_compile_compilation_unit, contract.name
)
@ -80,6 +95,10 @@ class PrinterEVM(AbstractPrinter):
for contract in self.slither.contracts_derived:
txt += blue(f"Contract {contract.name}\n")
if evm_info.get(("empty", contract.name), False):
txt += "\tempty contract\n"
continue
contract_file = self.slither.source_code[
contract.source_mapping.filename.absolute
].encode("utf-8")

Loading…
Cancel
Save