fix: skip VIEW Rules permission check when page has no rules (#35292)#35404
fix: skip VIEW Rules permission check when page has no rules (#35292)#35404gortiz-dotcms wants to merge 3 commits intomainfrom
Conversation
|
Claude finished @gortiz-dotcms's task in 3m 39s —— View job 🔍 dotCMS Backend Review
Review posted above. The |
🔍 dotCMS Backend ReviewThe Two medium findings remain. [🟡 Medium]
final List<Rule> rules = rulesFactory.getAllRulesByParent(parent);
if (rules.isEmpty()) {
return Collections.emptyList(); // permission check silently skipped
}
checkRulePermission(user, contentletParent, PermissionAPI.PERMISSION_READ, respectFrontendRoles);💡 If the trade-off is accepted (restoring v5.x copy behavior), add a comment explaining why the check is intentionally deferred so future readers do not treat it as a bug. [🟡 Medium]
// Both write methods delegate here:
List<Rule> rulesByParent = getAllRulesByParent(parent, user, respectFrontendRoles);
for (Rule rule : rulesByParent) { // empty list → no iteration, no permission error
deleteRule(rule, user, respectFrontendRoles);
}💡 For write operations, add an explicit upfront permission check independent of rule count, e.g. resolve Next steps
|
Summary
Fixes #35292
When a non-admin user ran the Copy workflow action on an HTML page, it failed with:
This happened even when the page had no rules attached.
Root Cause
RulesAPIImpl.getAllRulesByParent()enforced the VIEW Rules permission check before querying whether any rules existed for the page. As a result, any user without explicit View Rules permission on the site/folder was blocked — even when there was nothing to view or copy.Fix
Moved the permission check after the rules query. If the page has no rules, the method returns an empty list immediately without enforcing the permission. The check is only reached when there are actual rules to expose.
This restores the v5.x behavior where users with edit/publish permissions on a page could copy it freely when no rules were involved.
Impact
🤖 Generated with Claude Code