Skip to content

fix(backend): harden guild automation route rbac - #381

Merged
LucasSantana-Dev merged 4 commits into
mainfrom
fix/guild-automation-rbac
Mar 30, 2026
Merged

LucasSantana-Dev merged 4 commits into
mainfrom
fix/guild-automation-rbac

Conversation

@LucasSantana-Dev

Copy link
Copy Markdown
Owner

Summary

  • All 8 guild automation endpoints now require `settings` module access via `requireGuildModuleAccess` middleware, replacing bare `requireAuth`
  • GET routes (`/manifest`, `/status`) require `view` access; all write routes require `manage` access
  • `requireGuildModuleAccess` updated to work standalone: uses `req.sessionID` when `req.sessionId` is absent, and populates both for downstream handlers
  • 3 new RBAC integration tests: 403 on insufficient module access, 403 on no guild access, 401 on missing session

Test plan

  • `PUT /automation/manifest` returns 403 when `hasAccess` returns false
  • `GET /automation/manifest` returns 403 when user has no guild context
  • `GET /automation/manifest` returns 401 when session is invalid
  • 624 backend tests passing

@vercel

vercel Bot commented Mar 30, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Mar 30, 2026 7:32pm

Request Review

@coderabbitai

coderabbitai Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@LucasSantana-Dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 55 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 14 minutes and 55 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2eadc8b4-4146-4223-badd-54eae576a736

📥 Commits

Reviewing files that changed from the base of the PR and between e0f5015 and 6e926af.

📒 Files selected for processing (3)
  • packages/backend/src/middleware/guildAccess.ts
  • packages/backend/src/routes/guildAutomation.ts
  • packages/backend/tests/integration/routes/guildAutomation.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/guild-automation-rbac

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.

Added tests for uncovered edge cases:
- Missing session cookie (401)
- Missing guildId parameter (400)
- UserId attachment from session data
- Auto mode resolution for POST and HEAD requests

Coverage improved:
- Line: 91.66% → 100%
- Branch: 82.75% → 93.1%
hoist mocked casts and repeated literals to describe scope to
reduce duplicated blocks below sonarcloud 3% threshold.
further reduce duplication below sonarcloud 3% threshold by extracting
an authed() helper for authenticated request setup.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
6.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
6.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@LucasSantana-Dev
LucasSantana-Dev merged commit 53c6663 into main Mar 30, 2026
11 of 12 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the fix/guild-automation-rbac branch March 30, 2026 19:38

This branch was successfully deployed

1 active deployment
Preview — 6e926af4 Deployed Mar 30, 2026 by vercel[bot]
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