Command line changes:

- Add exclude flag for each detector
    - replace -low, -medium, -high by -exclude-low, ...
    - clean detectors/printers information and flags
    - detector follow this format '--detect-name'
    - close #1 and #10
Update README
pull/14/head
Josselin 6 years ago
parent fbaf655c5a
commit d7e15590df
  1. 40
      README.md
  2. 67
      slither/__main__.py
  3. 2
      slither/detectors/examples/backdoor.py
  4. 4
      slither/printers/functions/authorization.py
  5. 4
      slither/printers/inheritance/printerInheritance.py
  6. 4
      slither/printers/summary/printerQuickSummary.py
  7. 4
      slither/printers/summary/printerSummary.py

@ -43,43 +43,45 @@ $ slither file.sol
```
```
$ slither examples/uninitialized.sol
$ slither examples/bugs/uninitialized.sol
[..]
INFO:Detectors:Uninitialized state variables in examples/uninitialized.sol, Contract: Uninitialized, Vars: destination, Used in ['transfer']
INFO:Detectors:Uninitialized state variables in examples/bugs/uninitialized.sol, Contract: Uninitialized, Vars: destination, Used in ['transfer']
[..]
```
If Slither is applied on a directory, it will run on every `.sol` file of the directory.
## Options
## Checks available
By default, all the checks are run.
### Configuration
Check | Purpose | Impact | Confidence
--- | --- | --- | ---
`--detect-uninitialized`| Detect uninitialized variables | High | High
`--detect-pragma`| Detect if different pragma directives are used | Informational | High
`--detect-solc-version`| Detect if an old version of Solidity is used (<0.4.23) | Informational | High
### Exclude analyses
* `--exclude-informational`: Exclude informational impact analyses
* `--exclude-low`: Exclude low impact analyses
* `--exclude-medium`: Exclude medium impact analyses
* `--exclude-high`: Exclude high impact analyses
* `--exclude-name` will exclude the detector `name`
## Configuration
* `--solc SOLC`: Path to `solc` (default 'solc')
* `--solc-args SOLC_ARGS`: Add custom solc arguments. `SOLC_ARGS` can contain multiple arguments.
* `--disable-solc-warnings`: Do not print solc warnings
* `--solc-ast`: Use the solc AST file as input (`solc file.sol --ast-json > file.ast.json`)
* `--json FILE`: Export results as JSON
* `--solc-args SOLC_ARGS`: Add custom solc arguments. `SOLC_ARGS` can contain multiple arguments.
### Analyses
* `--high`: Run only medium/high severity checks with high confidence
* `--medium`: Run only medium/high severity checks with medium confidence
* `--low`: Run only low severity checks
### Printers
## Printers
* `--print-summary`: Print a summary of the contracts
* `--print-quick-summary`: Print a quick summary of the contracts
* `--print-inheritance`: Print the inheritance graph
For more information about printers, see the [Printers documentation](docs/PRINTERS.md)
## Checks available
Check | Purpose | Impact | Confidence
--- | --- | --- | ---
`--uninitialized`| Detect uninitialized variables | High | High
`--pragma`| Detect if different pragma directives are used | Informational | High
`--solc-version`| Detect if an old version of Solidity is used (<0.4.23) | Informational | High
## License

@ -17,16 +17,20 @@ logger = logging.getLogger("Slither")
def determineChecks(detectors, args):
if args.low:
return detectors.low
elif args.medium:
return detectors.medium + detectors.high
elif args.high:
return detectors.high
elif args.detectors_to_run:
if args.detectors_to_run:
return args.detectors_to_run
else:
return detectors.high + detectors.medium + detectors.low + detectors.code_quality
all_detectors = detectors.high + detectors.medium + detectors.low + detectors.code_quality
if args.exclude_informational:
all_detectors = [d for d in all_detectors if d not in detectors.code_quality]
if args.exclude_low:
all_detectors = [d for d in all_detectors if d not in detectors.low]
if args.exclude_medium:
all_detectors = [d for d in all_detectors if d not in detectors.medium]
if args.exclude_high:
all_detectors = [d for d in all_detectors if d not in detectors.high]
if args.detectors_to_exclude:
all_detectors = [d for d in all_detectors if d not in args.detectors_to_exclude]
return all_detectors
def process(filename, args, detectors, printers):
@ -58,7 +62,7 @@ def main():
printers = Printers()
parser = argparse.ArgumentParser(description='Slither',
usage="slither.py contract.sol [flag]")
usage="slither.py contract.sol [flag]", formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=35))
parser.add_argument('filename',
help='contract.sol file')
@ -83,38 +87,53 @@ def main():
action='store_true',
default=False)
parser.add_argument('--low',
help='Only low analyses',
parser.add_argument('--json',
help='Export results as JSON',
action='store',
default=None)
parser.add_argument('--exclude-informational',
help='Exclude informational impact analyses',
action='store_true',
default=False)
parser.add_argument('--medium',
help='Only medium and high analyses',
parser.add_argument('--exclude-low',
help='Exclude low impact analyses',
action='store_true',
default=False)
parser.add_argument('--high',
help='Only high analyses',
parser.add_argument('--exclude-medium',
help='Exclude medium impact analyses',
action='store_true',
default=False)
parser.add_argument('--exclude-high',
help='Exclude high impact analyses',
action='store_true',
default=False)
parser.add_argument('--json',
help='Export results as JSON',
action='store',
default=None)
for detector_name, Detector in detectors.detectors.items():
detector_arg = '--{}'.format(Detector.ARGUMENT)
detector_help = 'Detection of ' + Detector.HELP
detector_arg = '--detect-{}'.format(Detector.ARGUMENT)
detector_help = 'Detection of {}'.format(Detector.HELP)
parser.add_argument(detector_arg,
help=detector_help,
action="append_const",
dest="detectors_to_run",
const=detector_name)
for detector_name, Detector in detectors.detectors.items():
exclude_detector_arg = '--exclude-{}'.format(Detector.ARGUMENT)
exclude_detector_help = 'Exclude {} detector'.format(Detector.ARGUMENT)
parser.add_argument(exclude_detector_arg,
help=exclude_detector_help,
action="append_const",
dest="detectors_to_exclude",
const=detector_name)
for printer_name, Printer in printers.printers.items():
printer_arg = '--{}'.format(Printer.ARGUMENT)
printer_help = Printer.HELP
printer_arg = '--print-{}'.format(Printer.ARGUMENT)
printer_help = 'Print {}'.format(Printer.HELP)
parser.add_argument(printer_arg,
help=printer_help,
action="append_const",

@ -7,7 +7,7 @@ class Backdoor(AbstractDetector):
"""
ARGUMENT = 'backdoor' # slither will launch the detector with slither.py --mydetector
HELP = 'Function named backdoor (detector example)'
HELP = 'function named backdoor (detector example)'
CLASSIFICATION = DetectorClassification.HIGH
def detect(self):

@ -8,8 +8,8 @@ from slither.core.declarations.function import Function
class PrinterWrittenVariablesAndAuthorization(AbstractPrinter):
ARGUMENT = 'print-variables-written-and-authorization'
HELP = 'Print the the variables written and the authorization of the functions'
ARGUMENT = 'vars-and-auth'
HELP = 'the state variables written and the authorization of the functions'
@staticmethod
def get_msg_sender_checks(function):

@ -13,8 +13,8 @@ from slither.core.declarations.contract import Contract
class PrinterInheritance(AbstractPrinter):
ARGUMENT = 'print-inheritance'
HELP = 'Print the inheritance graph'
ARGUMENT = 'inheritance'
HELP = 'the inheritance graph'
def __init__(self, slither, logger):
super(PrinterInheritance, self).__init__(slither, logger)

@ -7,8 +7,8 @@ from slither.utils.colors import blue, green, magenta
class PrinterQuickSummary(AbstractPrinter):
ARGUMENT = 'print-quick-summary'
HELP = 'Print a quick summary of the contract'
ARGUMENT = 'quick-summary'
HELP = 'a quick summary of the contract'
def output(self, _filename):
"""

@ -7,8 +7,8 @@ from slither.printers.abstractPrinter import AbstractPrinter
class PrinterSummary(AbstractPrinter):
ARGUMENT = 'print-summary'
HELP = 'Print the summary of the contract'
ARGUMENT = 'summary'
HELP = 'the summary of the contract'
@staticmethod
def _convert(l):

Loading…
Cancel
Save