fix(security): harden CSS override pipeline and fix frontend wiring - #83
Conversation
The REST write gate already requires --sf-[a-z0-9-]+ (tightened in the previous commit), but generate_flat_override_declarations() still matched any --[a-z0-9-]+ key at emission time. Align the two so pre-existing DB rows with non-namespaced keys are also silently dropped at render. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CE6esDyehWhYtjFK2jiADG
Plugin Check flags $_POST['rebemer_map'] as InputNotSanitized because wp_unslash() alone is not a sanitizer. Wrap each value with sanitize_text_field() via array_map so the sniff sees explicit sanitization at the point of input. Values were already safe downstream (sanitize_rebemer_element_map() re-validates via sanitize_key + regex) but the early sanitize makes the intent explicit and silences the warning. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CE6esDyehWhYtjFK2jiADG
|
Warning Review limit reached
More reviews will be available in 52 minutes and 42 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughTwo single-line hardening changes: ChangesInput Sanitization Hardening
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoHarden CSS override sanitization and fix override emission namespace Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
1. rebemer_map POST handling: replace array_map('sanitize_text_field')
with an explicit loop that skips non-string entries. array_map would
coerce nested arrays to empty strings, which the save loop reads as
"clear this override" — an unintended side-effect on malformed input.
2. has_overrides(): apply the same --sf- key filter as
generate_flat_override_declarations() when scanning the flat override
map. Without this the two functions could disagree: has_overrides()
returning true while the emitter silently skips every entry.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CE6esDyehWhYtjFK2jiADG
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@SLASHED-for-WP/includes/class-css-generator.php`:
- Line 154: The emit gate in class-css-generator still allows uppercase
custom-property names because the preg_match in the CSS name check uses a
case-insensitive flag. Update the validation in the relevant method to match the
save gate exactly by removing the /i behavior from the `--sf-[a-z0-9-]+`
pattern, so stored data outside the allowed contract is not rendered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6f188287-045f-4d3e-a9d0-c373aef5765c
📒 Files selected for processing (2)
SLASHED-for-WP/includes/class-bricks-settings-page.phpSLASHED-for-WP/includes/class-css-generator.php
…sensitive) All three occurrences of /^--sf-[a-z0-9-]+$/i — in has_overrides(), generate_flat_override_declarations(), and sanitize_overrides() — used a case-insensitive match. CSS custom properties are case-sensitive and SLASHED tokens are always lowercase, so /i was accepting --SF-* keys it should not. Remove the flag to enforce exact lowercase matching. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CE6esDyehWhYtjFK2jiADG
Summary
is_css_safe()now rejects{ } ;globally, andvalid_font_family()'svar()branch is anchored to a full match (no prefix-only bypass). Together these ensure no validator can return a value containing CSS declaration delimiters.sanitize_overrides) and the CSS generator (generate_flat_override_declarations) both now enforce--sf-[a-z0-9-]+so only Slashed-namespaced custom properties can be persisted or rendered.sanitize_overrides()previously droppedint/floatvalues before validation; they now reachvalidate_override_value().POST /tokens/overrides→slashed_overridesoption) were never rendered on the public site.get_override_css()/generate_flat_override_declarations()now read and emit that flat map, re-validating every entry at emission time.$_POST['rebemer_map']at point of read. Plugin Check flagged the rawwp_unslash()without an explicit sanitizer. Values are now run throughsanitize_text_field()viaarray_map()before processing; downstreamsanitize_rebemer_element_map()still validates with its regex.Type
Checklist
feat:,fix:,docs:, …)npm testpassesnpm run lintpasses (stylelint +php -l)npm run verifypasses (version metadata in sync)CHANGELOG.mdupdated under## [Unreleased](for user-facing changes)editor-app/admin-appsource changedNotes
The configurator wiring fix (flat
slashed_overrides→get_override_css()) is the only user-visible behaviour change. All other commits are hardening of the sanitization pipeline with no observable effect for clean inputs.Plugin Check report (2026-06-28): 1 finding resolved (
InputNotSanitizedon$_POST['rebemer_map']). No remaining findings.Generated by Claude Code
Summary by CodeRabbit
--sf-style variables are allowed.