Skip to content

Commit 6b03f3e

Browse files
committed
misc:
Add a static code analyzer to find potential vulnerabilities All reports from analyzer and gas cost reporter now are saved in the /reports folder All the flattened files are stored in build/flatten instead of build/full
1 parent 3a5c9a2 commit 6b03f3e

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

buidler.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const config = {
172172
enabled: process.env.REPORT_GAS ? true : false,
173173
showTimeSpent: true,
174174
currency: 'USD',
175-
outputFile: 'gas-report.log',
175+
outputFile: 'reports/gas-report.log',
176176
},
177177
}
178178

contracts/connext/test-fixtures/AppWithAction.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ contract AppWithAction is CounterfactualApp {
3333
returns (address)
3434
{
3535
State memory state = abi.decode(encodedState, (State));
36-
return participants[state.counter > 0 ? 0 : 1];
36+
uint256 p = state.counter > 0 ? 0 : 1;
37+
return participants[p];
3738
}
3839

3940
/// @dev NOTE: there is a slight difference here vs. the connext

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"prettier": "npm run prettier:ts && npm run prettier:sol",
8686
"prettier:ts": "prettier --write 'test/**/*.ts'",
8787
"prettier:sol": "prettier --write 'contracts/*.sol'",
88+
"analyze": "scripts/analyze",
8889
"flatten": "scripts/flatten",
8990
"abi:extract": "truffle-abi -d ./build/contracts -o ./build/abis/ -v",
9091
"typechain": "typechain --target ethers-v5 --outDir build/typechain/contracts 'build/abis/*.json'",

scripts/analyze

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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: https://github.com/crytic/slither#how-to-install
7+
# Usage: https://github.com/crytic/slither/wiki/Usage
8+
9+
mkdir -p reports
10+
11+
pip3 install --user slither-analyzer && \
12+
npm run build && \
13+
14+
echo "Analyzing contracts..."
15+
slither . \
16+
--filter-paths "staking/libs/abdk-libraries-solidity/*|connext/test-fixtures/*|bancor/*" \
17+
&> reports/analyzer-report.log && \
18+
slither-check-erc build/flatten/GraphToken.sol GraphToken &> reports/analyzer-report-erc.log
19+
20+
echo "Done!"

scripts/flatten

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
OUT_DIR="build/full"
3+
OUT_DIR="build/flatten"
44

55
echo ${OUT_DIR}/contracts
66
mkdir -p ${OUT_DIR}/contracts
@@ -17,4 +17,4 @@ for path in $files; do
1717
truffle-flattener "${path}" > "${OUT_DIR}/${name}"
1818
done
1919

20-
echo "Done."
20+
echo "Done!"

scripts/test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ fi
3535

3636
### Main
3737

38+
mkdir -p reports
39+
3840
npm run compile
3941
npm run typechain
4042

0 commit comments

Comments
 (0)