Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add static contract analysis to CI #93

Merged
merged 33 commits into from
May 18, 2020

Conversation

elenadimitrova
Copy link
Contributor

@elenadimitrova elenadimitrova commented Apr 13, 2020

Enables static analysis on the contracts using slither https://github.com/crytic/slither
This is run by CI in a parallel python-based container on all builds now. Some valid suggested fixes were applied the rest were ignored in the slither.db.json. Two new npm commands added
security:slither and security:slither:triage, the former runs slither analyzer on the contracts and the latter runs the same but in triage mode allowing us to ignore errors that are either false positives or we don't consider a threat.

  • Includes extracting all test contracts out in a /contracts-test folder due to overlap in contract names between dappsys and openzeppelin contracts we use in unit testing, namely IERC20 which trips up slither atm.

  • Removes duplication of IUniswapExchange and IUniswapFactory contract definitions which otherwise causes slither to error .

Found and logged a couple of problems with the latest slither release 0.6.11 crytic/slither#456 and crytic/slither#457. Those were resolved in slither release 0.6.12

@elenadimitrova elenadimitrova self-assigned this Apr 13, 2020
@elenadimitrova elenadimitrova force-pushed the maintenance/security-testing branch from 58d5575 to 5027712 Compare April 13, 2020 12:02
@elenadimitrova elenadimitrova changed the title Add security testing to CI using slither Add static contract analysis to CI Apr 15, 2020
@elenadimitrova elenadimitrova force-pushed the maintenance/security-testing branch 4 times, most recently from ce4fa35 to 2443d17 Compare April 21, 2020 13:33
@elenadimitrova elenadimitrova marked this pull request as ready for review April 21, 2020 15:26
@elenadimitrova elenadimitrova requested a review from juniset April 21, 2020 15:26
@elenadimitrova elenadimitrova force-pushed the maintenance/security-testing branch from bdb0ee7 to 1f9ee17 Compare April 23, 2020 04:26
@elenadimitrova elenadimitrova force-pushed the maintenance/security-testing branch 2 times, most recently from 0e24b47 to ce8ef4d Compare May 12, 2020 09:06
@elenadimitrova elenadimitrova changed the base branch from develop to feature/relayer-rebase-all-modules May 13, 2020 09:06
@@ -125,7 +125,7 @@ contract ArgentENSManager is IENSManager, Owned, Managed {
* @param _subnode The target subnode.
* @return true if the subnode is available.
*/
function isAvailable(bytes32 _subnode) public view returns (bool) {
function isAvailable(bytes32 _subnode) external view returns (bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? I thought the idea was to not touch the infrastructure contracts for the next release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were raised by slither on the ENS contracts for this rule. They are not dangerous so have ignored them for now but good to fix in future.

@@ -46,7 +46,7 @@ contract ArgentENSResolver is Owned, Managed, ENSResolver {
* @param _node The node to update.
* @param _addr The address to set.
*/
function setAddr(bytes32 _node, address _addr) public onlyManager {
function setAddr(bytes32 _node, address _addr) external onlyManager {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above. Are these changes necessary for Slither or is just cleaning?

_wallet.setOwner(recoveryOwner);
guardianStorage.setLock(_wallet, 0);

emit RecoveryFinalized(address(_wallet), config.recovery);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be recoveryOwner and not config.recovery.

delete recoveryConfigs[address(_wallet)];
guardianStorage.setLock(_wallet, 0);

emit RecoveryCanceled(address(_wallet), config.recovery);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we deleted the storage slot at position recoveryConfigs[address(_wallet)], shouldn't config.recovery always return 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right.

@elenadimitrova elenadimitrova force-pushed the maintenance/security-testing branch from 2046893 to e3c35ce Compare May 14, 2020 08:48
@elenadimitrova elenadimitrova changed the base branch from feature/relayer-rebase-all-modules to develop May 14, 2020 08:50
@elenadimitrova elenadimitrova force-pushed the maintenance/security-testing branch from 81b43ee to d7ce2fc Compare May 14, 2020 09:19
as those won't be upgraded in next release 2.0
@@ -145,9 +145,11 @@ contract RecoveryManager is BaseModule, RelayerModule {
*/
function cancelRecovery(BaseWallet _wallet) external onlyExecute onlyWhenRecovery(_wallet) {
RecoveryConfig storage config = recoveryConfigs[address(_wallet)];
emit RecoveryCanceled(address(_wallet), config.recovery);
guardianStorage.setLock(_wallet, 0);
address recoveryOwner = config.recovery;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since config is only used to define recoveryOwner it is probably more efficient to do

address recoveryOwner = recoveryConfigs[address(_wallet)].recovery;

@elenadimitrova elenadimitrova merged commit 4532212 into develop May 18, 2020
@elenadimitrova elenadimitrova deleted the maintenance/security-testing branch May 18, 2020 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants