diff --git a/slither/printers/summary/human_summary.py b/slither/printers/summary/human_summary.py index 9c986065d..37c3de19d 100644 --- a/slither/printers/summary/human_summary.py +++ b/slither/printers/summary/human_summary.py @@ -8,6 +8,8 @@ from slither.utils import output from slither.utils.code_complexity import compute_cyclomatic_complexity from slither.utils.colors import green, red, yellow from slither.utils.standard_libraries import is_standard_library +from slither.core.cfg.node import NodeType + class PrinterHumanSummary(AbstractPrinter): ARGUMENT = 'human-summary' @@ -29,14 +31,13 @@ class PrinterHumanSummary(AbstractPrinter): else: mint_limited = True else: - mint_limited = None # no minting + mint_limited = None # no minting - race_condition_mitigated = 'increaseApproval' in functions_name or\ + race_condition_mitigated = 'increaseApproval' in functions_name or \ 'safeIncreaseAllowance' in functions_name return pause, mint_limited, race_condition_mitigated - def get_summary_erc20(self, contract): txt = '' @@ -93,8 +94,6 @@ class PrinterHumanSummary(AbstractPrinter): issues_high = [c for c in issues_high if c] issues_high = [item for sublist in issues_high for item in sublist] - - return (len(issues_optimization), len(issues_informational), len(issues_low), @@ -159,6 +158,17 @@ class PrinterHumanSummary(AbstractPrinter): total_lines += lines return total_lines, total_dep_lines + def _get_number_of_assembly_lines(self): + total_asm_lines = 0 + for contract in self.contracts: + for function in contract.functions_declared: + for node in function.nodes: + if node.type == NodeType.ASSEMBLY: + inline_asm = node.inline_asm + if inline_asm: + total_asm_lines += len(inline_asm.splitlines()) + return total_asm_lines + def _compilation_type(self): if self.slither.crytic_compile is None: return 'Compilation non standard\n' @@ -202,17 +212,20 @@ class PrinterHumanSummary(AbstractPrinter): }, 'number_lines': 0, 'number_lines_in_dependencies': 0, + 'number_lines_assembly': 0, 'standard_libraries': [], 'ercs': [], } - lines_number = self._lines_number() if lines_number: total_lines, total_dep_lines = lines_number txt += f'Number of lines: {total_lines} (+ {total_dep_lines} in dependencies)\n' results['number_lines'] = total_lines results['number_lines__dependencies'] = total_dep_lines + total_asm_lines = self._get_number_of_assembly_lines() + txt += f"Number of assembly lines: {total_asm_lines}\n" + results['number_lines_assembly'] = total_asm_lines number_contracts, number_contracts_deps = self._number_contracts() txt += f'Number of contracts: {number_contracts} (+ {number_contracts_deps} in dependencies) \n\n' @@ -272,4 +285,3 @@ class PrinterHumanSummary(AbstractPrinter): json = self.generate_output(txt, additional_fields=results) return json -