Skip to content

Commit

Permalink
fix: RSR-05 | Missing Zero Address Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Feb 6, 2025
1 parent c8a5a08 commit 512d5bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/RiskSteward/RiskStewardReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ contract RiskStewardReceiver is IRiskStewardReceiver, PausableUpgradeable, Acces
* @custom:access Controlled by AccessControlManager
* @custom:error Throws UnsupportedUpdateType if the update type is an empty string
* @custom:error Throws InvalidDebounce if the debounce is 0
* @custom:error Throws ZeroAddressNotAllowed if the risk steward address is zero
*/
function setRiskParameterConfig(string calldata updateType, address riskSteward, uint256 debounce) external {
_checkAccessAllowed("setRiskParameterConfig(string,address,uint256)");
Expand All @@ -153,6 +154,7 @@ contract RiskStewardReceiver is IRiskStewardReceiver, PausableUpgradeable, Acces
if (debounce == 0 || debounce > UPDATE_EXPIRATION_TIME) {
revert InvalidDebounce();
}
ensureNonzeroAddress(riskSteward);
RiskParamConfig memory previousConfig = riskParameterConfigs[updateType];
riskParameterConfigs[updateType] = RiskParamConfig({
active: true,
Expand Down
6 changes: 6 additions & 0 deletions tests/RiskSteward/RiskStewardReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ describe.only("Risk Steward", async function () {
).to.be.rejectedWith("InvalidDebounce");
});

it("should not support zero risk steward address", async function () {
await expect(
riskStewardReceiver.setRiskParameterConfig("supplyCap", ethers.constants.AddressZero, 1),
).to.be.rejectedWith("ZeroAddressNotAllowed");
});

it("should revert if debounce is greater than UPDATE_EXPIRATION_TIME", async function () {
await expect(
riskStewardReceiver.setRiskParameterConfig("supplyCap", marketCapsRiskSteward.address, 60 * 60 * 24 + 1),
Expand Down

0 comments on commit 512d5bc

Please sign in to comment.