Merge pull request #560 from crytic/dev-disallow-partial

Add --disallow-partial flag
pull/561/head
Feist Josselin 4 years ago committed by GitHub
commit f7d0c47501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      slither/__main__.py
  2. 15
      slither/core/slither_core.py
  3. 4
      slither/slither.py
  4. 7
      slither/solc_parsing/declarations/contract.py

@ -425,6 +425,12 @@ def parse_args(detector_classes, printer_classes):
action='store_true',
default=False)
# Disable the throw/catch on partial analyses
parser.add_argument('--disallow-partial',
help=argparse.SUPPRESS,
action="store_true",
default=False)
if len(sys.argv) == 1:
parser.print_help(sys.stderr)
sys.exit(1)

@ -59,6 +59,10 @@ class SlitherCore(Context):
self._storage_layouts: Dict[str, Dict[str, Tuple[int, int]]] = {}
# If set to true, slither will not catch errors during parsing
self._disallow_partial: bool = False
###################################################################################
###################################################################################
# region Source code
@ -365,6 +369,17 @@ class SlitherCore(Context):
def contracts_with_missing_inheritance(self) -> Set:
return self._contract_with_missing_inheritance
@property
def disallow_partial(self) -> bool:
"""
Return true if partial analyses are disallowed
For example, codebase with duplicate names will lead to partial analyses
:return:
"""
return self._disallow_partial
# endregion
###################################################################################
###################################################################################

@ -43,6 +43,10 @@ class Slither(SlitherCore):
"""
super().__init__()
self._parser: SlitherSolc # This could be another parser, like SlitherVyper, interface needs to be determined
self._disallow_partial: bool = kwargs.get("disallow_partial", False)
# list of files provided (see --splitted option)
if isinstance(target, list):
self._init_from_list(target)

@ -337,8 +337,11 @@ class ContractSolc:
###################################################################################
def log_incorrect_parsing(self, error):
LOGGER.error(error)
self._contract.is_incorrectly_parsed = True
if self._contract.slither.disallow_partial:
raise ParsingError(error)
else:
LOGGER.error(error)
self._contract.is_incorrectly_parsed = True
def analyze_content_modifiers(self):
try:

Loading…
Cancel
Save