Commit 410310ea authored by Maurelian's avatar Maurelian

fix(ctb): Add auth to guard checkAfterExecution

Also added regression tests.
parent 8215444c
...@@ -60,10 +60,11 @@ contract LivenessGuard is ISemver, BaseGuard { ...@@ -60,10 +60,11 @@ contract LivenessGuard is ISemver, BaseGuard {
address gasToken, address gasToken,
address payable refundReceiver, address payable refundReceiver,
bytes memory signatures, bytes memory signatures,
address address msgSender
) )
external external
{ {
msgSender; // silence unused variable warning
require(msg.sender == address(SAFE), "LivenessGuard: only Safe can call this function"); require(msg.sender == address(SAFE), "LivenessGuard: only Safe can call this function");
// Cache the set of owners prior to execution. // Cache the set of owners prior to execution.
...@@ -105,6 +106,7 @@ contract LivenessGuard is ISemver, BaseGuard { ...@@ -105,6 +106,7 @@ contract LivenessGuard is ISemver, BaseGuard {
/// 1. Add new owners to the lastLive mapping /// 1. Add new owners to the lastLive mapping
/// 2. Delete removed owners from the lastLive mapping /// 2. Delete removed owners from the lastLive mapping
function checkAfterExecution(bytes32, bool) external { function checkAfterExecution(bytes32, bool) external {
require(msg.sender == address(SAFE), "LivenessGuard: only Safe can call this function");
// Get the current set of owners // Get the current set of owners
address[] memory ownersAfter = SAFE.getOwners(); address[] memory ownersAfter = SAFE.getOwners();
......
...@@ -40,6 +40,25 @@ contract LivenessGuard_Getters_Test is LivnessGuard_TestInit { ...@@ -40,6 +40,25 @@ contract LivenessGuard_Getters_Test is LivnessGuard_TestInit {
} }
} }
contract LivnessGuard_CheckTx_TestFails is LivnessGuard_TestInit {
function test_checkTransaction_callerIsNotSafe_revert() external {
vm.expectRevert("LivenessGuard: only Safe can call this function");
livenessGuard.checkTransaction({
to: address(0),
value: 0,
data: hex"00",
operation: Enum.Operation.Call,
safeTxGas: 0,
baseGas: 0,
gasPrice: 0,
gasToken: address(0),
refundReceiver: payable(address(0)),
signatures: hex"00",
msgSender: address(0)
});
}
}
contract LivnessGuard_CheckTx_Test is LivnessGuard_TestInit { contract LivnessGuard_CheckTx_Test is LivnessGuard_TestInit {
using SafeTestLib for SafeInstance; using SafeTestLib for SafeInstance;
...@@ -63,6 +82,15 @@ contract LivnessGuard_CheckTx_Test is LivnessGuard_TestInit { ...@@ -63,6 +82,15 @@ contract LivnessGuard_CheckTx_Test is LivnessGuard_TestInit {
} }
} }
contract LivnessGuard_CheckAfterExecution_TestFails is LivnessGuard_TestInit {
function test_checkAfterExecution_callerIsNotSafe_revert() external {
vm.expectRevert("LivenessGuard: only Safe can call this function");
livenessGuard.checkAfterExecution(bytes32(0), false);
}
}
contract LivnessGuard_CheckAfterExecution_Test is LivnessGuard_TestInit { }
contract LivenessGuard_ShowLiveness_Test is LivnessGuard_TestInit { contract LivenessGuard_ShowLiveness_Test is LivnessGuard_TestInit {
function test_showLiveness_succeeds() external { function test_showLiveness_succeeds() external {
// Cache the caller // Cache the caller
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment