Skip to content

fix(daemon): enforce control tier for WebSocket zone layout preview mutations#85

Open
hyperb1iss wants to merge 1 commit into
mainfrom
codex/fix-websocket-layout-preview-authorization
Open

fix(daemon): enforce control tier for WebSocket zone layout preview mutations#85
hyperb1iss wants to merge 1 commit into
mainfrom
codex/fix-websocket-layout-preview-authorization

Conversation

@hyperb1iss
Copy link
Copy Markdown
Owner

Motivation

  • Prevent a read-tier WebSocket client from mutating transient zone_layout_previews (bypassing the HTTP router) which could be used to change live LED output or trigger large canvas allocations and OOMs.
  • Restore consistent control-tier enforcement for mutating operations over the websocket so preview messages obey the same access and rate-limit model as HTTP commands.

Description

  • Add RequestAuthContext::can_perform_write() to centralize the security check for write/control permission. (crates/hypercolor-daemon/src/api/security.rs).
  • Gate ClientMessage::ZoneLayoutPreview and ClientMessage::ZoneLayoutPreviewClear branches with ensure_control_tier(...) so they require control-tier permission before applying previews. (crates/hypercolor-daemon/src/api/ws/session.rs).
  • Add ensure_control_tier helper and focused unit tests (security_tests) asserting read-only contexts are rejected and unsecured/local contexts are allowed. (crates/hypercolor-daemon/src/api/ws/session.rs).
  • Run formatting on the modified files with cargo fmt to keep code style consistent.

Testing

  • Executed cargo fmt -- crates/hypercolor-daemon/src/api/security.rs crates/hypercolor-daemon/src/api/ws/session.rs which completed successfully.
  • Added unit tests in ws/session.rs (security_tests) that verify the new ensure_control_tier behavior; a targeted cargo test -p hypercolor-daemon security_tests:: run was started but the full dependency compile did not complete in this session due to environment/time constraints, so test execution should be validated by CI (expected to pass).
  • Recommend CI run full cargo test for the hypercolor-daemon crate to validate the new tests and ensure no regressions.

Codex Task

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Warning

Review limit reached

@hyperb1iss, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 24 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa8ad269-461e-423b-a6c0-c74ed1ec92d7

📥 Commits

Reviewing files that changed from the base of the PR and between 6f749b6 and 8002a59.

📒 Files selected for processing (2)
  • crates/hypercolor-daemon/src/api/security.rs
  • crates/hypercolor-daemon/src/api/ws/session.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-websocket-layout-preview-authorization

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant