diff --git a/contracts/core/base/RuleBasedPrimitive.sol b/contracts/core/base/RuleBasedPrimitive.sol index 4b6840e..40b8eb6 100644 --- a/contracts/core/base/RuleBasedPrimitive.sol +++ b/contracts/core/base/RuleBasedPrimitive.sol @@ -165,6 +165,10 @@ abstract contract RuleBasedPrimitive { ); } for (uint256 j = 0; j < ruleChange.selectorChanges.length; j++) { + _validateIsSupportedRuleSelector( + ruleChange.selectorChanges[j].ruleSelector, + entityId == 0 ? _supportedPrimitiveRuleSelectors() : _supportedEntityRuleSelectors() + ); rulesStorage._changeRulesSelectors( ruleChanges[i].ruleAddress, ruleChange.configSalt, @@ -190,6 +194,18 @@ abstract contract RuleBasedPrimitive { return new bytes4[](0); } + function _validateIsSupportedRuleSelector(bytes4 ruleSelectorToValidate, bytes4[] memory supportedRuleSelectors) + internal + pure + { + for (uint256 i = 0; i < supportedRuleSelectors.length; i++) { + if (ruleSelectorToValidate == supportedRuleSelectors[i]) { + return; + } + } + revert(); + } + function _beforeChangeRules(uint256 entityId, RuleChange[] calldata ruleChanges) internal virtual { if (entityId == 0) { _beforeChangePrimitiveRules(ruleChanges);