Skip to content

Commit 4b2eb0c

Browse files
authored
[STABLE-7559]: Migrate from Slither to Mythril for static analysis (#51)
### Summary Migrate from Slither to Mythril for static analysis ### Detail - update Makefile command and update CI - remove Slither relevant configs and add Mythril config - update Readme
1 parent e4e6e2f commit 4b2eb0c

File tree

6 files changed

+55
-20
lines changed

6 files changed

+55
-20
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,45 @@ jobs:
2727
- name: Run Unit Tests
2828
run: make test
2929

30+
- name: Set up Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.10'
34+
3035
- name: Run Integration Tests
3136
run: make anvil-test
3237

33-
- name: Run Slither
34-
uses: crytic/[email protected]
38+
analyze-message-transmitter:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Check out repository code
42+
uses: actions/checkout@v4
43+
with:
44+
submodules: 'true'
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: '3.10'
50+
51+
- name: Run Static Analysis on Message Transmitter
52+
run: make analyze-message-transmitter
53+
54+
analyze-token-messenger-minter:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Check out repository code
58+
uses: actions/checkout@v4
59+
with:
60+
submodules: 'true'
61+
62+
- name: Set up Python
63+
uses: actions/setup-python@v5
3564
with:
36-
fail-on: none
65+
python-version: '3.10'
66+
67+
- name: Run Static Analysis on Token Messenger Minter
68+
run: make analyze-token-messenger-minter
3769

3870
scan:
3971
needs: lint-and-test

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ deploy:
1717

1818
anvil:
1919
docker rm -f anvil || true
20-
@${ANVIL} "anvil --host 0.0.0.0 -a 13 --code-size-limit 250000"
20+
@${ANVIL} "anvil --host 0.0.0.0 -a 13 --code-size-limit 250000"
2121

2222
anvil-test: anvil
2323
pip3 install -r requirements.txt
@@ -31,10 +31,15 @@ cast-call:
3131

3232
cast-send:
3333
@docker exec anvil cast send ${contract_address} "${function}" --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
34-
34+
3535
clean:
3636
@${FOUNDRY} "forge clean"
3737

38-
analyze:
39-
pip3 install -r requirements.txt
40-
slither .
38+
analyze-message-transmitter:
39+
pip3 install mythril==0.24.8
40+
myth -v4 analyze src/MessageTransmitter.sol --solc-json mythril.config.json --solv 0.7.6
41+
42+
analyze-token-messenger-minter:
43+
pip3 install mythril==0.24.8
44+
myth -v4 analyze src/TokenMessenger.sol --solc-json mythril.config.json --solv 0.7.6
45+
myth -v4 analyze src/TokenMinter.sol --solc-json mythril.config.json --solv 0.7.6

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Run `make anvil-test` to setup `anvil` test node in docker container and run int
3838
Run `yarn lint` to lint all `.sol` files in the `src` and `test` directories.
3939

4040
### Static analysis
41-
Run `make analyze` to set up Python dependencies from `requirements.txt` and run Slither on all source files, requiring the foundry cli to be installed locally. If all dependencies have been installed, alternatively run `slither .` to run static analysis on all `.sol` files in the `src` directory.
41+
Run `make analyze-{message-transmitter | token-messenger-minter}` to set up Mythril dependency and run Mythril on all source files. If Mythril dependency has been installed, alternatively run `myth -v4 analyze $FILE_PATH --solc-json mythril.config.json --solv 0.7.6` to run static analysis on a `.sol` file at the given `$FILE_PATH`. Please note that this can take several minutes.
4242

4343
### Continuous Integration using Github Actions
4444
We use Github actions to run linter and all the tests. The workflow configuration can be found in [.github/workflows/ci.yml](.github/workflows/ci.yml)
@@ -79,4 +79,4 @@ The contracts are deployed using [Forge Scripts](https://book.getfoundry.sh/tuto
7979
3. Run `make deploy RPC_URL=<RPC_URL> SENDER=<SENDER>` to deploy the contracts
8080

8181
## License
82-
For license information, see LICENSE and additional notices stored in NOTICES.
82+
For license information, see LICENSE and additional notices stored in NOTICES.

mythril.config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"remappings": [
3+
"@memview-sol/=lib/memview-sol/",
4+
"@openzeppelin/=lib/openzeppelin-contracts/",
5+
"ds-test/=lib/ds-test/src/",
6+
"forge-std/=lib/forge-std/src/"
7+
]
8+
}

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ requests==2.28.1
3434
rlp==2.0.1
3535
semantic-version==2.10.0
3636
six==1.16.0
37-
slither-analyzer==0.8.3
3837
toolz==0.12.0
3938
urllib3==1.26.11
4039
varint==1.0.2

slither.config.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)