Skip to content

Commit

Permalink
[#95] Add rules
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-ap committed Sep 25, 2023
1 parent ef786a7 commit 4b3db3c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
17 changes: 12 additions & 5 deletions certora/specs/Manager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ rule onlyOwnerCanSetRegistry (method f) filtered {

}

rule onlyEnabledAndListedPluginCanExecuteCall() {
rule onlyEnabledAndListedPluginCanExecuteCall(method f) filtered {
f -> f.selector == sig:executeTransaction(address,SafeProtocolManager.SafeTransaction).selector || f.selector == sig:executeRootAccess(address,SafeProtocolManager.SafeRootAccess).selector
} {


method f; env e; calldataarg args;
env e; calldataarg args;

requireInvariant tempHooksStorage(e.msg.sender);

Expand Down Expand Up @@ -136,7 +137,13 @@ function getTempHooksData(address account) returns address {
}

invariant tempHooksStorage(address plugin)
getTempHooksData(plugin) != 0 => checkListedAndNotFlagged(getTempHooksData(plugin));
getTempHooksData(plugin) != 0 => checkListedAndNotFlagged(getTempHooksData(plugin))
filtered { f -> f.selector != sig:checkModuleTransaction(address,uint256,bytes,Enum.Operation,address).selector}

invariant tempHooksStorageIsAlwaysEmpty(address plugin)
getTempHooksData(plugin) == 0
filtered { f -> f.selector != sig:checkModuleTransaction(address,uint256,bytes,Enum.Operation,address).selector}


rule onlyOneStorageUpdates{
storage before = lastStorage;
Expand All @@ -145,4 +152,4 @@ rule onlyOneStorageUpdates{
storage after = lastStorage;
// Either storage of testExecutorCertora is updated or storage of testExecutorCertoraOther is updated
assert (before[testExecutorCertora] == after[testExecutorCertora]) || (before[testExecutorCertoraOther] == after[testExecutorCertoraOther]);
}
}
2 changes: 2 additions & 0 deletions contracts/SafeProtocolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ contract SafeProtocolManager is ISafeProtocolManager, RegistryManager, HooksMana
if (areHooksEnabled) {
// execution metadata for transaction execution through plugin is encoded address of the plugin i.e. msg.sender.
// executionType = 1 for plugin flow
// should check below exist here?
checkPermittedModule(hooksAddress);
preCheckData = ISafeProtocolHooks(hooksAddress).preCheckRootAccess(account, rootAccess, 1, abi.encode(msg.sender));
}

Expand Down
3 changes: 2 additions & 1 deletion contracts/base/FunctionHandlerManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ abstract contract FunctionHandlerManager is RegistryManager {
bytes4 functionSelector = bytes4(msg.data);

address functionHandler = functionHandlers[account][functionSelector];
checkPermittedModule(functionHandler);

// Revert if functionHandler is not set
if (functionHandler == address(0)) {
revert FunctionHandlerNotSet(account, functionSelector);
}

checkPermittedModule(functionHandler);

address sender;
// solhint-disable-next-line no-inline-assembly
assembly {
Expand Down

0 comments on commit 4b3db3c

Please sign in to comment.