Skip to content

Commit

Permalink
include slitherin detectors
Browse files Browse the repository at this point in the history
  • Loading branch information
julianmrodri committed May 7, 2024
1 parent 7acd6d8 commit 5298ad2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- run: yarn install --immutable
- run: yarn lint
- run: pip3 install solc-select slither-analyzer
- run: pip3 install slitherin
- run: solc-select install 0.8.19
- run: solc-select use 0.8.19
- run: yarn slither
Expand Down
18 changes: 12 additions & 6 deletions docs/dev-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
We're using:

- [Hardhat](hardhat.org) to compile, test, and deploy our smart contracts.
- [Slither][] and [Echidna][], from the [Trail of Bits contract security toolkit][tob-suite] for static analysis, fuzz checking, and differential testing.
- [Slither][], [Slitherin][], and [Echidna][], from the [Trail of Bits contract security toolkit][tob-suite] for static analysis, fuzz checking, and differential testing.
- [Prettier][] to auto-format both Solidity and Typescript (test) code
- [Solhint][] for Solidity linting
- [ESlint][] for Typescript linting

[echidna]: https://github.com/crytic/echidna
[slither]: https://github.com/crytic/slither
[slitherin]: https://github.com/pessimistic-io/slitherin
[tob-suite]: https://blog.trailofbits.com/2018/03/23/use-our-suite-of-ethereum-security-tools/
[prettier]: https://prettier.io/
[solhint]: https://protofire.github.io/solhint/
Expand Down Expand Up @@ -56,18 +57,24 @@ tenderly login --authentication-method access-key --access-key {your_access_key}

### Slither

You should also setup `slither`. The [Trail of Bits tools][tob-suite] require solc-select. Check [the installation instructions](https://github.com/crytic/solc-select) to ensure you have all prerequisites. Then:
You should also setup `slither` and `slitherin`. The [Trail of Bits tools][tob-suite] require solc-select. Check [the installation instructions](https://github.com/crytic/solc-select) to ensure you have all prerequisites. Then:

```bash
# Install solc-select and slither
pip3 install solc-select slither-analyzer

# Include slitherin detectors within slither
pip3 install slitherin

# Install and use solc version 0.8.19
solc-select install 0.8.19
solc-select use 0.8.19

# Double-check that your slither version is at least 0.8.3!
hash -r && slither --version

# Slitherin version should be at least 0.7.0
slitherin --version
```

## Usage
Expand All @@ -83,7 +90,7 @@ hash -r && slither --version
- Run integration tests: `yarn test:integration`
- Run tests and report test coverage: `yarn test:coverage`
- Lint Solidity + Typescript code: `yarn lint`
- Run the Slither static checker: `yarn slither`
- Run the Slither static checker: `yarn slither` (will include Slitherin detectors)
- Run a local mainnet fork devchain: `yarn devchain`
- Deploy to devchain: `yarn deploy:run --network localhost`

Expand All @@ -107,7 +114,6 @@ We _have_ some tooling for testing with Echidna, but it is specifically in `fuzz

See our [deployment documentation](deployment.md).

## Slither Analysis

The ToB Sliter tool is run on any pull request, and is expected to be checked by devs for any unexpected high or medium issues raised.
## Slither/Slitherin Analysis

The ToB Sliter tool is run on any pull request, and is expected to be checked by devs for any unexpected high or medium issues raised. It also includes the additional Slitherin detectors developed by Pessimistic.
2 changes: 1 addition & 1 deletion docs/solidity-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ We're using 192 bits instead of the full 256 bits because it makes typical multi
Initial versions of this code were written using the custom type `Fix` everywhere, and `Fixed` contained the line `type Fix is int192`. We found later that:

- We had essentially no need for negative `Fix` values, so spending a storage bit on sign, and juggling the possibility of negative values, cost extra gas and harmed the clarity of our code.
- While `solc 0.8.19` allows custom types without any issue, practically all of the other tools we want to use on our Solidity source -- `slither`, `prettier`, `solhint` -- would fail when encountering substantial code using a custom type.
- While `solc 0.8.19` allows custom types without any issue, practically all of the other tools we want to use on our Solidity source -- `slither`, `slitherin`, `prettier`, `solhint` -- would fail when encountering substantial code using a custom type.

Reintroducing this custom type should be mostly mechanicanizable, but now that P1 contains a handful of hotspot optimizations that do raw arithmetic internally to eliminate Fixlib calls, it won't be trivial to do so. Still, if and when those tools achieve adequate support for custom types, we will probably do this conversion ourselves, if only to ensure that conversions between the Fix and integer interpretations of uints are carefully type-checked.

Expand Down
2 changes: 1 addition & 1 deletion tools/slither.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def proj_root():
if file_orig.exists():
rename(file_orig, file_temp)

# run slither from inside the tools directory
# run slither from inside the tools directory (includes slitherin detectors)
args = argv[1:]
run(["slither", "../", *args], cwd=project / "tools")

Expand Down

0 comments on commit 5298ad2

Please sign in to comment.