-
Notifications
You must be signed in to change notification settings - Fork 516
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
Checkout plugin and proxy #598
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #598 +/- ##
==========================================
+ Coverage 64.08% 64.14% +0.06%
==========================================
Files 215 218 +3
Lines 6632 6708 +76
==========================================
+ Hits 4250 4303 +53
- Misses 2382 2405 +23 ☔ View full report in Codecov by Sentry. |
function _execute(UserOp memory op) internal { | ||
bool success; | ||
if (op.currency == CurrencyTransferLib.NATIVE_TOKEN) { | ||
(success, ) = op.target.call{ value: op.valueToSend }(op.data); | ||
} else { | ||
if (op.valueToSend != 0 && op.approvalRequired) { | ||
IERC20(op.currency).approve(op.target, op.valueToSend); | ||
} | ||
|
||
(success, ) = op.target.call(op.data); | ||
} | ||
|
||
require(success, "Execution failed"); | ||
} |
Check failure
Code scanning / Slither
Functions that send Ether to arbitrary destinations High
Dangerous calls:
- (success,None) = op.target.call{value: op.valueToSend}(op.data)
function _execute(UserOp memory op) internal { | ||
bool success; | ||
if (op.currency == CurrencyTransferLib.NATIVE_TOKEN) { | ||
(success, ) = op.target.call{ value: op.valueToSend }(op.data); | ||
} else { | ||
if (op.valueToSend != 0 && op.approvalRequired) { | ||
IERC20(op.currency).approve(op.target, op.valueToSend); | ||
} | ||
|
||
(success, ) = op.target.call(op.data); | ||
} | ||
|
||
require(success, "Execution failed"); | ||
} |
Check warning
Code scanning / Slither
Unused return Medium
function _execute(UserOp memory op) internal { | ||
bool success; | ||
if (op.currency == CurrencyTransferLib.NATIVE_TOKEN) { | ||
(success, ) = op.target.call{ value: op.valueToSend }(op.data); | ||
} else { | ||
if (op.valueToSend != 0 && op.approvalRequired) { | ||
IERC20(op.currency).approve(op.target, op.valueToSend); | ||
} | ||
|
||
(success, ) = op.target.call(op.data); | ||
} | ||
|
||
require(success, "Execution failed"); | ||
} |
Check warning
Code scanning / Slither
Low-level calls Warning
function _installPlugin(IPRBProxyPlugin plugin) internal { | ||
// Retrieve the methods to install. | ||
bytes4[] memory methods = plugin.getMethods(); | ||
|
||
// The plugin must implement at least one method. | ||
uint256 length = methods.length; | ||
if (length == 0) { | ||
revert PRBProxyRegistry_PluginWithZeroMethods(plugin); | ||
} | ||
|
||
// Install every method in the list. | ||
address owner = msg.sender; | ||
for (uint256 i = 0; i < length; ) { | ||
// Check for collisions. | ||
bytes4 method = methods[i]; | ||
if (address(_plugins[owner][method]) != address(0)) { | ||
revert PRBProxyRegistry_PluginMethodCollision({ | ||
currentPlugin: _plugins[owner][method], | ||
newPlugin: plugin, | ||
method: method | ||
}); | ||
} | ||
_plugins[owner][method] = plugin; | ||
unchecked { | ||
i += 1; | ||
} | ||
} | ||
|
||
// Set the methods in the reverse mapping. | ||
_methods[owner][plugin] = methods; | ||
|
||
// Log the plugin installation. | ||
emit InstallPlugin(owner, _proxies[owner], plugin, methods); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities Low
External calls:
- methods = plugin.getMethods()
State variables written after the call(s):
- _methods[owner][plugin] = methods
- _plugins[owner][method] = plugin
function deployAndInstallPlugin( | ||
IPRBProxyPlugin plugin | ||
) external onlyNonProxyOwner(msg.sender) returns (IPRBProxy proxy) { | ||
proxy = _deploy({ owner: msg.sender, target: address(0), data: "" }); | ||
_installPlugin(plugin); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities Low
External calls:
- proxy = _deploy({owner:msg.sender,target:address(0),data:})
- proxy = new PRBProxy()
- _installPlugin(plugin)
- methods = plugin.getMethods()
State variables written after the call(s):
- _installPlugin(plugin)
- _methods[owner][plugin] = methods
function _deploy(address owner, address target, bytes memory data) internal returns (IPRBProxy proxy) { | ||
// Use the address of the owner as the CREATE2 salt. | ||
bytes32 salt = bytes32(abi.encodePacked(owner)); | ||
|
||
// Set the owner and empty out the target and the data to prevent reentrancy. | ||
constructorParams = ConstructorParams({ owner: owner, target: target, data: data }); | ||
|
||
// Deploy the proxy with CREATE2. | ||
proxy = new PRBProxy{ salt: salt }(); | ||
delete constructorParams; | ||
|
||
// Associate the owner and the proxy. | ||
_proxies[owner] = proxy; | ||
|
||
// Log the creation of the proxy. | ||
emit DeployProxy({ operator: msg.sender, owner: owner, proxy: proxy }); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities Low
External calls:
- proxy = new PRBProxy()
State variables written after the call(s):
- _proxies[owner] = proxy
- delete constructorParams
function deployAndExecuteAndInstallPlugin( | ||
address target, | ||
bytes calldata data, | ||
IPRBProxyPlugin plugin | ||
) external override onlyNonProxyOwner(msg.sender) returns (IPRBProxy proxy) { | ||
proxy = _deploy({ owner: msg.sender, target: target, data: data }); | ||
_installPlugin(plugin); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities Low
External calls:
- proxy = _deploy({owner:msg.sender,target:target,data:data})
- proxy = new PRBProxy()
- _installPlugin(plugin)
- methods = plugin.getMethods()
State variables written after the call(s):
- _installPlugin(plugin)
- _methods[owner][plugin] = methods
function deployAndExecuteAndInstallPlugin( | ||
address target, | ||
bytes calldata data, | ||
IPRBProxyPlugin plugin | ||
) external override onlyNonProxyOwner(msg.sender) returns (IPRBProxy proxy) { | ||
proxy = _deploy({ owner: msg.sender, target: target, data: data }); | ||
_installPlugin(plugin); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities Low
External calls:
- proxy = _deploy({owner:msg.sender,target:target,data:data})
- proxy = new PRBProxy()
- _installPlugin(plugin)
- methods = plugin.getMethods()
Event emitted after the call(s):
- InstallPlugin(owner,_proxies[owner],plugin,methods)
- _installPlugin(plugin)
function deployAndInstallPlugin( | ||
IPRBProxyPlugin plugin | ||
) external onlyNonProxyOwner(msg.sender) returns (IPRBProxy proxy) { | ||
proxy = _deploy({ owner: msg.sender, target: address(0), data: "" }); | ||
_installPlugin(plugin); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities Low
External calls:
- proxy = _deploy({owner:msg.sender,target:address(0),data:})
- proxy = new PRBProxy()
- _installPlugin(plugin)
- methods = plugin.getMethods()
Event emitted after the call(s):
- InstallPlugin(owner,_proxies[owner],plugin,methods)
- _installPlugin(plugin)
function _installPlugin(IPRBProxyPlugin plugin) internal { | ||
// Retrieve the methods to install. | ||
bytes4[] memory methods = plugin.getMethods(); | ||
|
||
// The plugin must implement at least one method. | ||
uint256 length = methods.length; | ||
if (length == 0) { | ||
revert PRBProxyRegistry_PluginWithZeroMethods(plugin); | ||
} | ||
|
||
// Install every method in the list. | ||
address owner = msg.sender; | ||
for (uint256 i = 0; i < length; ) { | ||
// Check for collisions. | ||
bytes4 method = methods[i]; | ||
if (address(_plugins[owner][method]) != address(0)) { | ||
revert PRBProxyRegistry_PluginMethodCollision({ | ||
currentPlugin: _plugins[owner][method], | ||
newPlugin: plugin, | ||
method: method | ||
}); | ||
} | ||
_plugins[owner][method] = plugin; | ||
unchecked { | ||
i += 1; | ||
} | ||
} | ||
|
||
// Set the methods in the reverse mapping. | ||
_methods[owner][plugin] = methods; | ||
|
||
// Log the plugin installation. | ||
emit InstallPlugin(owner, _proxies[owner], plugin, methods); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities Low
External calls:
- methods = plugin.getMethods()
Event emitted after the call(s):
- InstallPlugin(owner,_proxies[owner],plugin,methods)
function _deploy(address owner, address target, bytes memory data) internal returns (IPRBProxy proxy) { | ||
// Use the address of the owner as the CREATE2 salt. | ||
bytes32 salt = bytes32(abi.encodePacked(owner)); | ||
|
||
// Set the owner and empty out the target and the data to prevent reentrancy. | ||
constructorParams = ConstructorParams({ owner: owner, target: target, data: data }); | ||
|
||
// Deploy the proxy with CREATE2. | ||
proxy = new PRBProxy{ salt: salt }(); | ||
delete constructorParams; | ||
|
||
// Associate the owner and the proxy. | ||
_proxies[owner] = proxy; | ||
|
||
// Log the creation of the proxy. | ||
emit DeployProxy({ operator: msg.sender, owner: owner, proxy: proxy }); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities Low
External calls:
- proxy = new PRBProxy()
Event emitted after the call(s):
- DeployProxy({operator:msg.sender,owner:owner,proxy:proxy})
@@ -0,0 +1,251 @@ | |||
// SPDX-License-Identifier: MIT | |||
pragma solidity >=0.8.18; |
Check warning
Code scanning / Slither
Different pragma directives are used Warning
- Version used: ['>=0.8.18', '>=0.8.4', '^0.8.0', '^0.8.1', '^0.8.10', '^0.8.11', '^0.8.12', '^0.8.2', '^0.8.4', '^0.8.8', '^0.8.9']
- >=0.8.18
- >=0.8.18
- >=0.8.4
- >=0.8.4
- >=0.8.4
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- ^0.8.0
- [^0.8.0](contracts/extension/SignatureAction.sol#L2
No description provided.