Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2430 #2431

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions slither/printers/summary/evm.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -9,6 +11,9 @@
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
Expand All @@ -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
)
Expand Down Expand Up @@ -80,6 +95,10 @@ def output(self, _filename):
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")
Expand Down
Loading