08月12, 2019

Slither - a solidity static analysis framework

https://blog.trailofbits.com/2018/10/19/slither-a-solidity-static-analysis-framework/

https://github.com/crytic/slither/wiki

contributions

  1. Detector modules for new conditions and vulnerability patterns
  2. Enhancements to existing detector modules to improve confidence in the analysis
  3. Enhancements and refinements to the SlithIR intermediate representation Architectural and code quality improvements of any kind
  4. 3rd-party writeups and blogs that demonstrate advanced usage of Slither
  5. Help with any issues labeled "good first issue" or "help wanted"
apt install python3
pip3 install slither-analyzer

Several printers use the dot format. To install it

apt install graphviz
apt install xdot
usage: slither.py contract.sol [flag]

Slither. For usage information, see
https://github.com/crytic/slither/wiki/Usage

positional arguments:
  filename              contract.sol

optional arguments:
  -h, --help            show this help message and exit
  --version             displays the current version

Compile options:
  --compile-force-framework COMPILE_FORCE_FRAMEWORK
                        Force the compile to a given framework (truffle,
                        embark, dapp, etherlime, etherscan)
  --compile-remove-metadata
                        Remove the metadata from the bytecodes
  --compile-custom-build COMPILE_CUSTOM_BUILD
                        Replace platform specific build command

Solc options:
  --solc SOLC           solc path
  --solc-remaps SOLC_REMAPS
                        Add remapping
  --solc-args SOLC_ARGS
                        Add custom solc arguments. Example: --solc-args "--
                        allow-path /tmp --evm-version byzantium".
  --solc-disable-warnings
                        Disable solc warnings
  --solc-working-dir SOLC_WORKING_DIR
                        Change the default working directory
  --solc-solcs-select SOLC_SOLCS_SELECT
                        Specify different solc version to try (env config).
                        Depends on solc-select
  --solc-solcs-bin SOLC_SOLCS_BIN
                        Specify different solc version to try (path config).
                        Example: --solc-solcs-path solc-0.4.24,solc-0.5.3

Truffle options:
  --truffle-ignore-compile
                        Do not run truffle compile
  --truffle-build-directory TRUFFLE_BUILD_DIRECTORY
                        Use an alternative truffle build directory
  --truffle-version TRUFFLE_VERSION
                        Use a local Truffle version (with npx)

Embark options:
  --embark-ignore-compile
                        Do not run embark build
  --embark-overwrite-config
                        Install @trailofbits/embark-contract-export and add it
                        to embark.json

Dapp options:
  --dapp-ignore-compile
                        Do not run dapp build

Etherlime options:
  --etherlime-ignore-compile
                        Do not run etherlime compile
  --etherlime-compile-arguments
                        Add arbitrary arguments to etherlime compile (note:
                        [dir] is the the directory provided to crytic-compile)

Detectors:
  --detect DETECTORS_TO_RUN
                        Comma-separated list of detectors, defaults to all,
                        available detectors: arbitrary-send, assembly,
                        backdoor, shadowing-builtin, constable-states,
                        constant-function, pragma, controlled-delegatecall,
                        deprecated-standards, external-function,
                        erc20-interface, erc721-interface, solc-version,
                        incorrect-equality, shadowing-local, locked-ether,
                        low-level-calls, calls-loop, naming-convention,
                        reentrancy-benign, reentrancy-eth, reentrancy-no-eth,
                        rtlo, shadowing-abstract, shadowing-state, suicidal,
                        timestamp, too-many-digits, tx-origin, unchecked-
                        lowlevel, unchecked-send, erc20-indexed,
                        uninitialized-local, uninitialized-state,
                        uninitialized-storage, unused-return, unused-state
  --list-detectors      List available detectors
  --exclude DETECTORS_TO_EXCLUDE
                        Comma-separated list of detectors that should be
                        excluded
  --exclude-informational
                        Exclude informational impact analyses
  --exclude-low         Exclude low impact analyses
  --exclude-medium      Exclude medium impact analyses
  --exclude-high        Exclude high impact analyses

Printers:
  --print PRINTERS_TO_RUN
                        Comma-separated list fo contract information printers,
                        available printers: cfg, contract-summary, data-
                        dependency, function-id, function-summary, modifiers,
                        call-graph, human-summary, inheritance, inheritance-
                        graph, slithir, slithir-ssa, vars-and-auth, require,
                        variable-order
  --list-printers       List available printers

Additional option:
  --json JSON           Export the results as a JSON file ("--json -" to
                        export to stdout)
  --disable-color       Disable output colorization
  --filter-paths FILTER_PATHS
                        Comma-separated list of paths for which results will
                        be excluded
  --triage-mode         Run triage mode (save results in slither.db.json)
  --config-file CONFIG_FILE
                        Provide a config file (default: slither.config.json)
  --solc-ast            Provide the contract as a json AST

本文链接:https://harry.ren/post/slither-static-analysis.html

-- EOF --

Comments