-
Notifications
You must be signed in to change notification settings - Fork 9
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 audit fixes #41
Add audit fixes #41
Changes from 5 commits
003123c
801fc68
4f0d782
2670be9
eb668a5
b6acd37
4b387da
9760ad4
630baae
3d39050
cef236a
055ed35
c6eb136
374a6f0
ee2c007
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { IERC7579Account } from "erc7579/interfaces/IERC7579Account.sol"; | |
import { ISafe } from "src/interfaces/ISafe.sol"; | ||
import { EmailRecoveryModuleBase } from "./EmailRecoveryModuleBase.t.sol"; | ||
import { EmailRecoveryModule } from "src/modules/EmailRecoveryModule.sol"; | ||
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; | ||
|
||
contract EmailRecoveryModule_constructor_Test is EmailRecoveryModuleBase { | ||
function setUp() public override { | ||
|
@@ -28,42 +29,59 @@ contract EmailRecoveryModule_constructor_Test is EmailRecoveryModuleBase { | |
); | ||
} | ||
|
||
function test_Constructor_RevertWhen_UnsafeOnInstallSelector() public { | ||
vm.expectRevert( | ||
abi.encodeWithSelector( | ||
EmailRecoveryModule.InvalidSelector.selector, IModule.onInstall.selector | ||
) | ||
function test_Constructor_When_SafeAddOwnerSelector() public { | ||
_skipIfNotSafeAccountType(); | ||
new EmailRecoveryModule( | ||
address(verifier), | ||
address(dkimRegistry), | ||
address(emailAuthImpl), | ||
address(emailRecoveryHandler), | ||
validatorAddress, | ||
ISafe.addOwnerWithThreshold.selector | ||
); | ||
} | ||
|
||
function test_Constructor_When_SafeRemoveOwnerSelector() public { | ||
_skipIfNotSafeAccountType(); | ||
new EmailRecoveryModule( | ||
address(verifier), | ||
address(dkimRegistry), | ||
address(emailAuthImpl), | ||
address(emailRecoveryHandler), | ||
validatorAddress, | ||
IModule.onInstall.selector | ||
ISafe.removeOwner.selector | ||
); | ||
} | ||
|
||
function test_Constructor_RevertWhen_UnsafeOnUninstallSelector() public { | ||
vm.expectRevert( | ||
abi.encodeWithSelector( | ||
EmailRecoveryModule.InvalidSelector.selector, IModule.onUninstall.selector | ||
) | ||
function test_Constructor_When_SafeSwapOwnerSelector() public { | ||
_skipIfNotSafeAccountType(); | ||
new EmailRecoveryModule( | ||
address(verifier), | ||
address(dkimRegistry), | ||
address(emailAuthImpl), | ||
address(emailRecoveryHandler), | ||
validatorAddress, | ||
ISafe.swapOwner.selector | ||
); | ||
} | ||
|
||
function test_Constructor_When_SafeChangeThresholdSelector() public { | ||
_skipIfNotSafeAccountType(); | ||
new EmailRecoveryModule( | ||
address(verifier), | ||
address(dkimRegistry), | ||
address(emailAuthImpl), | ||
address(emailRecoveryHandler), | ||
validatorAddress, | ||
IModule.onUninstall.selector | ||
ISafe.changeThreshold.selector | ||
); | ||
} | ||
|
||
function test_Constructor_RevertWhen_UnsafeExecuteSelector() public { | ||
function test_Constructor_RevertWhen_SafeNotAllowedSelector() public { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: Don't think this minor duplication matters, but fyi Happy to leave as is |
||
_skipIfNotSafeAccountType(); | ||
vm.expectRevert( | ||
abi.encodeWithSelector( | ||
EmailRecoveryModule.InvalidSelector.selector, IERC7579Account.execute.selector | ||
EmailRecoveryModule.InvalidSelector.selector, IModule.onInstall.selector | ||
) | ||
); | ||
new EmailRecoveryModule( | ||
|
@@ -72,14 +90,14 @@ contract EmailRecoveryModule_constructor_Test is EmailRecoveryModuleBase { | |
address(emailAuthImpl), | ||
address(emailRecoveryHandler), | ||
validatorAddress, | ||
IERC7579Account.execute.selector | ||
IModule.onInstall.selector | ||
); | ||
} | ||
|
||
function test_Constructor_RevertWhen_UnsafeSetFallbackHandlerSelector() public { | ||
function test_Constructor_RevertWhen_UnsafeOnInstallSelector() public { | ||
vm.expectRevert( | ||
abi.encodeWithSelector( | ||
EmailRecoveryModule.InvalidSelector.selector, ISafe.setFallbackHandler.selector | ||
EmailRecoveryModule.InvalidSelector.selector, IModule.onInstall.selector | ||
) | ||
); | ||
new EmailRecoveryModule( | ||
|
@@ -88,14 +106,14 @@ contract EmailRecoveryModule_constructor_Test is EmailRecoveryModuleBase { | |
address(emailAuthImpl), | ||
address(emailRecoveryHandler), | ||
validatorAddress, | ||
ISafe.setFallbackHandler.selector | ||
IModule.onInstall.selector | ||
); | ||
} | ||
|
||
function test_Constructor_RevertWhen_UnsafeSetGuardSelector() public { | ||
function test_Constructor_RevertWhen_UnsafeOnUninstallSelector() public { | ||
vm.expectRevert( | ||
abi.encodeWithSelector( | ||
EmailRecoveryModule.InvalidSelector.selector, ISafe.setGuard.selector | ||
EmailRecoveryModule.InvalidSelector.selector, IModule.onUninstall.selector | ||
) | ||
); | ||
new EmailRecoveryModule( | ||
|
@@ -104,7 +122,7 @@ contract EmailRecoveryModule_constructor_Test is EmailRecoveryModuleBase { | |
address(emailAuthImpl), | ||
address(emailRecoveryHandler), | ||
validatorAddress, | ||
ISafe.setGuard.selector | ||
IModule.onUninstall.selector | ||
); | ||
} | ||
|
||
|
@@ -135,4 +153,13 @@ contract EmailRecoveryModule_constructor_Test is EmailRecoveryModuleBase { | |
assertEq(validatorAddress, emailRecoveryModule.validator()); | ||
assertEq(functionSelector, emailRecoveryModule.selector()); | ||
} | ||
|
||
function _skipIfNotSafeAccountType() private { | ||
string memory currentAccountType = vm.envOr("ACCOUNT_TYPE", string("")); | ||
if (Strings.equal(currentAccountType, "SAFE")) { | ||
vm.skip(false); | ||
} else { | ||
vm.skip(true); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For completeness even though risk is low, can you add unit tests for this new function?
You can just replicate
EmailRecoveryManager_deInitRecoveryModule_Test
, but for the new internal function with the account argument. You could even add tests in the same file.Would need to update the harness to expose the internal function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I've just added deInitRecoveryModuleWithAddress.t.sol.