Skip to content

Commit 744e58c

Browse files
authored
add mythril reports and slither VSCode config (#504)
* add mythril reports and slither VSCode config * split analyze and myth scripts
1 parent c7b772b commit 744e58c

File tree

5 files changed

+82
-3
lines changed

5 files changed

+82
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@
105105
"prettier:ts": "prettier --write 'test/**/*.ts'",
106106
"prettier:sol": "prettier --write 'contracts/*.sol'",
107107
"analyze": "scripts/analyze",
108-
"flatten": "scripts/flatten",
108+
"myth": "scripts/myth",
109+
"flatten": "scripts/flatten && scripts/clean",
109110
"typechain": "hardhat typechain",
110111
"verify": "hardhat verify",
111112
"size": "hardhat size-contracts"

scripts/analyze

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
## Before running:
44
# This tool requires to have solc installed.
55
# Ensure that you have the binaries installed by pip3 in your path.
6-
# Install: https://github.com/crytic/slither#how-to-install
7-
# Usage: https://github.com/crytic/slither/wiki/Usage
6+
# Install:
7+
# - https://github.com/crytic/slither#how-to-install
8+
# Usage:
9+
# - https://github.com/crytic/slither/wiki/Usage
810

911
mkdir -p reports
1012

@@ -21,6 +23,9 @@ slither . \
2123
--exclude similar-names,naming-convention \
2224
--disable-color \
2325
&> reports/analyzer-report.sarif && \
26+
echo "Slither report generated at ./reports/analyzer-report.sarif"
27+
echo "Checking ERC compliance..."
2428
slither-check-erc build/flatten/GraphToken.sol GraphToken &> reports/analyzer-report-erc.log
29+
echo "Compliance report generated at ./reports/analyzer-report-erc.log"
2530

2631
echo "Done!"

scripts/clean

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
OUT_DIR="build/flatten"
4+
5+
mkdir -p ${OUT_DIR}
6+
7+
echo "Cleaning flattened contracts..."
8+
9+
FLATTENED_FILES=(
10+
"$OUT_DIR/Controller.sol"
11+
"$OUT_DIR/GraphGovernance.sol"
12+
"$OUT_DIR/GNS.sol"
13+
"$OUT_DIR/ServiceRegistry.sol"
14+
"$OUT_DIR/Curation.sol"
15+
"$OUT_DIR/GraphCurationToken.sol"
16+
"$OUT_DIR/Staking.sol"
17+
"$OUT_DIR/RewardsManager.sol"
18+
"$OUT_DIR/GraphToken.sol"
19+
"$OUT_DIR/EpochManager.sol"
20+
"$OUT_DIR/GraphProxy.sol"
21+
"$OUT_DIR/GDAI.sol"
22+
"$OUT_DIR/GSRManager.sol"
23+
)
24+
25+
for path in ${FLATTENED_FILES[@]}; do
26+
echo "Clean > ${path}"
27+
sed -i \
28+
-e "s|pragma solidity.*||g" \
29+
-e "s|// SPDX-License-Identifier:.*||g" \
30+
-e 's|pragma experimental ABIEncoderV2;|//pragma experimental ABIEncoderV2;|g' \
31+
-e '1s|^|pragma experimental ABIEncoderV2;\n|' $path
32+
done

scripts/myth

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
## Before running:
4+
# This tool requires to have solc installed.
5+
# Ensure that you have the binaries installed by pip3 in your path.
6+
# Install:
7+
# - https://github.com/ConsenSys/mythril#installation-and-setup
8+
# Usage:
9+
# - https://github.com/ConsenSys/mythril#usage
10+
11+
pip3 install --user mythril && \
12+
yarn build && \
13+
mkdir -p reports/myth
14+
15+
echo "Myth Analysis..."
16+
17+
start_time="$(date -u +%s)"
18+
19+
for filename in build/flatten/*.sol; do
20+
step_start_time="$(date -u +%s)"
21+
echo "Scanning $filename ..."
22+
myth analyze \
23+
--parallel-solving \
24+
--execution-timeout 30 \
25+
--solver-timeout 6000 \
26+
-o markdown "$filename" \
27+
&> "reports/myth/$(basename "$filename" .sol)-report.md" && \
28+
29+
end_time="$(date -u +%s)"
30+
total_elapsed="$(($end_time-$start_time))"
31+
step_elapsed="$(($end_time-$step_start_time))"
32+
echo "> Took $step_elapsed seconds. Total elapsed: $total_elapsed seconds."
33+
done
34+
35+
echo "Done!"

slither.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"hardhat_artifacts_directory": "./build/contracts",
3+
"filter_paths": "contracts/bancor/.*|contracts/tests/.*|contracts/staking/libs/Cobbs.*|contracts/staking/libs/LibFixedMath.*|contracts/staking/libs/MathUtils.*",
4+
"detectors_to_exclude": "similar-names,naming-convention",
5+
"exclude_dependencies": true
6+
}

0 commit comments

Comments
 (0)