Skip to content

Commit 3c50cc0

Browse files
skalermoAnze1m
andauthored
Make Circle CI fail if Slither finds a high impact detector (trusttoken#682)
* Rename requirements.txt to requirements-dev.txt * Make CI fail on slither * Exclude optimization and low impact detectors * Make slither script not stop at first non-zero status * Fix slither detectors2 (trusttoken#731) * Ignore slither warnings * Do not ignore reentrancy vulnerabilities * Exclude all but high impact detectors * Remove unnecessary slither annotations * split steps Co-authored-by: Anze1m <bartek@ethworks.io>
1 parent 8c8d0cb commit 3c50cc0

8 files changed

Lines changed: 36 additions & 18 deletions

File tree

.circleci/config.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ commands:
1111
- restore_cache:
1212
name: Restore modules cache
1313
keys:
14-
- node_modules-{{ checksum "yarn.lock" }}-{{ checksum "requirements.txt" }}
14+
- node_modules-{{ checksum "yarn.lock" }}-{{ checksum "requirements-dev.txt" }}
1515
- run:
1616
name: Install Dependencies
1717
command: |
1818
yarn install --frozen-lockfile
1919
pip3 install -U pip setuptools virtualenv
2020
python3 -m venv venv
2121
source venv/bin/activate
22-
pip3 install -r requirements.txt
22+
pip3 install -r requirements-dev.txt
2323
- save_cache:
2424
name: Save modules cache
25-
key: node_modules-{{ checksum "yarn.lock" }}-{{ checksum "requirements.txt" }}
25+
key: node_modules-{{ checksum "yarn.lock" }}-{{ checksum "requirements-dev.txt" }}
2626
paths:
2727
- ./node_modules
2828
- ./venv
@@ -72,7 +72,13 @@ jobs:
7272
steps:
7373
- attach_workspace:
7474
at: .
75-
- run: yarn test:governance && yarn test:proxy && yarn test:registry && yarn test:scripts && yarn test:true-currencies && yarn test:true-gold && yarn test:trusttoken
75+
- run: yarn test:governance
76+
- run: yarn test:proxy
77+
- run: yarn test:registry
78+
- run: yarn test:scripts
79+
- run: yarn test:true-currencies
80+
- run: yarn test:true-gold
81+
- run: yarn test:trusttoken
7682
test-truefi:
7783
docker:
7884
- image: cimg/node:16.1.0

contracts/governance/GovernorAlpha.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ contract GovernorAlpha is UpgradeableClaimable {
252252
proposal.executed = true;
253253
for (uint i = 0; i < proposal.targets.length; i++) {
254254
//OLD: timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
255+
// slither-disable-next-line arbitrary-send
255256
timelock.executeTransaction{value: proposal.values[i]}(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
256257
}
257258
emit ProposalExecuted(proposalId);

contracts/governance/StkTruToken.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ contract StkTruToken is VoteToken, StkClaimableContract, IPauseableContract, Ree
272272
* Claims rewards when unstaking
273273
* @param amount Amount of stkTRU to unstake for TRU
274274
*/
275+
// slither-disable-next-line reentrancy-eth
275276
function unstake(uint256 amount) external distribute update(msg.sender) nonReentrant {
276277
require(amount > 0, "StkTruToken: Cannot unstake 0");
277278

@@ -344,6 +345,7 @@ contract StkTruToken is VoteToken, StkClaimableContract, IPauseableContract, Ree
344345
/**
345346
* @dev Claim all rewards
346347
*/
348+
// slither-disable-next-line reentrancy-eth
347349
function claim() external distribute update(msg.sender) {
348350
_claim(tru);
349351
_claim(tfusd);

contracts/truefi/TrueLender.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ contract TrueLender is ITrueLender, Ownable {
430430
uint256 denominator
431431
) external override onlyPool {
432432
for (uint256 index = 0; index < _loans.length; index++) {
433-
_loans[index].transfer(recipient, numerator.mul(_loans[index].balanceOf(address(this))).div(denominator));
433+
if (!_loans[index].transfer(recipient, numerator.mul(_loans[index].balanceOf(address(this))).div(denominator))) {
434+
0;
435+
}
434436
}
435437
}
436438

contracts/truefi/TrueRatingAgencyV2.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ contract TrueRatingAgencyV2 is ITrueRatingAgencyV2, Ownable {
377377
* R = Total Reward = (interest * chi * rewardFactor)
378378
* @param id Loan ID
379379
*/
380+
// slither-disable-next-line reentrancy-no-eth
380381
modifier calculateTotalReward(address id) {
381382
if (loans[id].reward == 0) {
382383
uint256 interest = ILoanToken2(id).profit();
@@ -401,7 +402,10 @@ contract TrueRatingAgencyV2 is ITrueRatingAgencyV2, Ownable {
401402
loans[id].reward = ratersReward;
402403
if (totalReward > 0) {
403404
distributor.distribute(totalReward);
404-
TRU.transfer(address(stkTRU), totalReward.sub(ratersReward));
405+
if (!TRU.transfer(address(stkTRU), totalReward.sub(ratersReward))) {
406+
// handle transfer failure
407+
0;
408+
}
405409
}
406410
}
407411
_;
File renamed without changes.

slither.config.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
2+
"exclude_optimization": true,
23
"exclude_informational": true,
3-
"exclude_low": false,
4+
"exclude_low": true,
5+
"exclude_medium": true,
46
"solc_disable_warnings": true,
57
"detectors_to_exclude": ""
6-
}
8+
}

slither.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ solc-select use 0.6.10
2323

2424
yarn flatten
2525

26-
slither flatten/GovernorAlpha.sol --print human-summary
27-
slither flatten/Liquidator.sol --print human-summary
28-
slither flatten/LoanFactory.sol --print human-summary
29-
slither flatten/LoanToken.sol --print human-summary
30-
slither flatten/StkTruToken.sol --print human-summary
31-
slither flatten/TrueLender.sol --print human-summary
32-
slither flatten/TrueRatingAgencyV2.sol --print human-summary
33-
slither flatten/TrustToken.sol --print human-summary
34-
slither flatten/Timelock.sol --print human-summary
26+
status=0
27+
slither flatten/GovernorAlpha.sol || status=1
28+
slither flatten/Liquidator.sol || status=1
29+
slither flatten/LoanFactory.sol || status=1
30+
slither flatten/LoanToken.sol || status=1
31+
slither flatten/StkTruToken.sol || status=1
32+
slither flatten/TrueLender.sol || status=1
33+
slither flatten/TrueRatingAgencyV2.sol || status=1
34+
slither flatten/TrustToken.sol || status=1
35+
slither flatten/Timelock.sol || status=1
3536

36-
echo "Done."
37+
exit $status

0 commit comments

Comments
 (0)