Implement `--exclude-<impact>`

for slither-check-upgradeability
pull/1532/head
webthethird 2 years ago
parent 9c339a6929
commit 194b1bd905
  1. 63
      slither/tools/upgradeability/__main__.py

@ -35,6 +35,8 @@ def parse_args(
usage="slither-check-upgradeability contract.sol ContractName", usage="slither-check-upgradeability contract.sol ContractName",
) )
group_checks = parser.add_argument_group("Checks")
parser.add_argument("contract.sol", help="Codebase to analyze") parser.add_argument("contract.sol", help="Codebase to analyze")
parser.add_argument("ContractName", help="Contract name (logic contract)") parser.add_argument("ContractName", help="Contract name (logic contract)")
@ -53,7 +55,7 @@ def parse_args(
default=False, default=False,
) )
parser.add_argument( group_checks.add_argument(
"--detect", "--detect",
help="Comma-separated list of detectors, defaults to all, " help="Comma-separated list of detectors, defaults to all, "
f"available detectors: {', '.join(d.ARGUMENT for d in check_classes)}", f"available detectors: {', '.join(d.ARGUMENT for d in check_classes)}",
@ -62,7 +64,15 @@ def parse_args(
default="all", default="all",
) )
parser.add_argument( group_checks.add_argument(
"--list-detectors",
help="List available detectors",
action=ListDetectors,
nargs=0,
default=False,
)
group_checks.add_argument(
"--exclude", "--exclude",
help="Comma-separated list of detectors that should be excluded", help="Comma-separated list of detectors that should be excluded",
action="store", action="store",
@ -70,11 +80,31 @@ def parse_args(
default=None, default=None,
) )
parser.add_argument( group_checks.add_argument(
"--list-detectors", "--exclude-informational",
help="List available detectors", help="Exclude informational impact analyses",
action=ListDetectors, action="store_true",
nargs=0, default=False,
)
group_checks.add_argument(
"--exclude-low",
help="Exclude low impact analyses",
action="store_true",
default=False,
)
group_checks.add_argument(
"--exclude-medium",
help="Exclude medium impact analyses",
action="store_true",
default=False,
)
group_checks.add_argument(
"--exclude-high",
help="Exclude high impact analyses",
action="store_true",
default=False, default=False,
) )
@ -144,6 +174,25 @@ def choose_checks(
raise Exception(f"Error: {detector} is not a detector") raise Exception(f"Error: {detector} is not a detector")
detectors_to_run = sorted(detectors_to_run, key=lambda x: x.IMPACT) detectors_to_run = sorted(detectors_to_run, key=lambda x: x.IMPACT)
return detectors_to_run return detectors_to_run
if args.exclude_informational:
detectors_to_run = [
d for d in detectors_to_run if d.IMPACT != DetectorClassification.INFORMATIONAL
]
if args.exclude_low:
detectors_to_run = [
d for d in detectors_to_run if d.IMPACT != DetectorClassification.LOW
]
if args.exclude_medium:
detectors_to_run = [
d for d in detectors_to_run if d.IMPACT != DetectorClassification.MEDIUM
]
if args.exclude_high:
detectors_to_run = [
d for d in detectors_to_run if d.IMPACT != DetectorClassification.HIGH
]
detectors_to_run = sorted(detectors_to_run, key=lambda x: x.IMPACT)
return detectors_to_run return detectors_to_run

Loading…
Cancel
Save