|
|
@ -2,6 +2,7 @@ |
|
|
|
Module printing summary of the contract |
|
|
|
Module printing summary of the contract |
|
|
|
""" |
|
|
|
""" |
|
|
|
import logging |
|
|
|
import logging |
|
|
|
|
|
|
|
from typing import Tuple, List, Dict |
|
|
|
|
|
|
|
|
|
|
|
from slither.printers.abstract_printer import AbstractPrinter |
|
|
|
from slither.printers.abstract_printer import AbstractPrinter |
|
|
|
from slither.utils import output |
|
|
|
from slither.utils import output |
|
|
@ -63,7 +64,7 @@ class PrinterHumanSummary(AbstractPrinter): |
|
|
|
|
|
|
|
|
|
|
|
return txt |
|
|
|
return txt |
|
|
|
|
|
|
|
|
|
|
|
def _get_detectors_result(self): |
|
|
|
def _get_detectors_result(self) -> Tuple[List[Dict],int, int, int, int, int]: |
|
|
|
# disable detectors logger |
|
|
|
# disable detectors logger |
|
|
|
logger = logging.getLogger('Detectors') |
|
|
|
logger = logging.getLogger('Detectors') |
|
|
|
logger.setLevel(logging.ERROR) |
|
|
|
logger.setLevel(logging.ERROR) |
|
|
@ -94,27 +95,30 @@ class PrinterHumanSummary(AbstractPrinter): |
|
|
|
issues_high = [c for c in issues_high if c] |
|
|
|
issues_high = [c for c in issues_high if c] |
|
|
|
issues_high = [item for sublist in issues_high for item in sublist] |
|
|
|
issues_high = [item for sublist in issues_high for item in sublist] |
|
|
|
|
|
|
|
|
|
|
|
return (len(issues_optimization), |
|
|
|
all_results = issues_optimization + issues_informational + issues_low + issues_medium + issues_high |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (all_results, |
|
|
|
|
|
|
|
len(issues_optimization), |
|
|
|
len(issues_informational), |
|
|
|
len(issues_informational), |
|
|
|
len(issues_low), |
|
|
|
len(issues_low), |
|
|
|
len(issues_medium), |
|
|
|
len(issues_medium), |
|
|
|
len(issues_high)) |
|
|
|
len(issues_high)) |
|
|
|
|
|
|
|
|
|
|
|
def get_detectors_result(self): |
|
|
|
def get_detectors_result(self) -> Tuple[str, List[Dict],int, int, int, int, int]: |
|
|
|
issues_optimization, issues_informational, issues_low, issues_medium, issues_high = self._get_detectors_result() |
|
|
|
all_results, optimization, informational, low, medium, high = self._get_detectors_result() |
|
|
|
txt = "Number of optimization issues: {}\n".format(green(issues_optimization)) |
|
|
|
txt = "Number of optimization issues: {}\n".format(green(optimization)) |
|
|
|
txt += "Number of informational issues: {}\n".format(green(issues_informational)) |
|
|
|
txt += "Number of informational issues: {}\n".format(green(informational)) |
|
|
|
txt += "Number of low issues: {}\n".format(green(issues_low)) |
|
|
|
txt += "Number of low issues: {}\n".format(green(low)) |
|
|
|
if issues_medium > 0: |
|
|
|
if medium > 0: |
|
|
|
txt += "Number of medium issues: {}\n".format(yellow(issues_medium)) |
|
|
|
txt += "Number of medium issues: {}\n".format(yellow(medium)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
txt += "Number of medium issues: {}\n".format(green(issues_medium)) |
|
|
|
txt += "Number of medium issues: {}\n".format(green(medium)) |
|
|
|
if issues_high > 0: |
|
|
|
if high > 0: |
|
|
|
txt += "Number of high issues: {}\n".format(red(issues_high)) |
|
|
|
txt += "Number of high issues: {}\n".format(red(high)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
txt += "Number of high issues: {}\n\n".format(green(issues_high)) |
|
|
|
txt += "Number of high issues: {}\n\n".format(green(high)) |
|
|
|
|
|
|
|
|
|
|
|
return txt, issues_optimization, issues_informational, issues_low, issues_medium, issues_high |
|
|
|
return txt, all_results, optimization, informational, low, medium, high |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def _is_complex_code(contract): |
|
|
|
def _is_complex_code(contract): |
|
|
@ -215,7 +219,8 @@ class PrinterHumanSummary(AbstractPrinter): |
|
|
|
'number_lines_assembly': 0, |
|
|
|
'number_lines_assembly': 0, |
|
|
|
'standard_libraries': [], |
|
|
|
'standard_libraries': [], |
|
|
|
'ercs': [], |
|
|
|
'ercs': [], |
|
|
|
'number_findings': dict() |
|
|
|
'number_findings': dict(), |
|
|
|
|
|
|
|
'detectors': [] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lines_number = self._lines_number() |
|
|
|
lines_number = self._lines_number() |
|
|
@ -231,7 +236,7 @@ class PrinterHumanSummary(AbstractPrinter): |
|
|
|
number_contracts, number_contracts_deps = self._number_contracts() |
|
|
|
number_contracts, number_contracts_deps = self._number_contracts() |
|
|
|
txt += f'Number of contracts: {number_contracts} (+ {number_contracts_deps} in dependencies) \n\n' |
|
|
|
txt += f'Number of contracts: {number_contracts} (+ {number_contracts_deps} in dependencies) \n\n' |
|
|
|
|
|
|
|
|
|
|
|
txt, optimization, info, low, medium, high = self.get_detectors_result() |
|
|
|
txt, detectors_results, optimization, info, low, medium, high = self.get_detectors_result() |
|
|
|
|
|
|
|
|
|
|
|
results['number_findings'] = { |
|
|
|
results['number_findings'] = { |
|
|
|
'optimization_issues': optimization, |
|
|
|
'optimization_issues': optimization, |
|
|
@ -240,6 +245,7 @@ class PrinterHumanSummary(AbstractPrinter): |
|
|
|
'medium_issues': medium, |
|
|
|
'medium_issues': medium, |
|
|
|
'high_issues': high |
|
|
|
'high_issues': high |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
results['detectors'] = detectors_results |
|
|
|
|
|
|
|
|
|
|
|
libs = self._standard_libraries() |
|
|
|
libs = self._standard_libraries() |
|
|
|
if libs: |
|
|
|
if libs: |
|
|
|