Merge pull request #438 from crytic/dev-human-summary-asm

Add assembly information to the human summary printer
pull/445/head
Feist Josselin 5 years ago committed by GitHub
commit aee840fc6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      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'
@ -31,12 +33,11 @@ class PrinterHumanSummary(AbstractPrinter):
else:
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

Loading…
Cancel
Save