feat: detect bare identifier role checks#77
Conversation
|
Caution Review failedFailed to post review comments 📝 WalkthroughWalkthroughAdded a new TypeScript/JavaScript RBAC detection rule ChangesIdentifier-based role membership detection
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
This PR adds a new TypeScript/JavaScript structural rule (ts-identifier-includes-check) for detecting role and group checks on bare collection identifiers. The implementation is clean and follows established patterns.
Summary:
- New rule properly detects patterns like
userGroups.includes("manager")andgroups.indexOf("admin") - Correctly filters out permission and claim collections to avoid false positives
- Includes comprehensive test coverage with both positive and negative test cases
- Rego and Cedar policy stubs are properly generated
The changes are well-structured with no blocking issues identified. All new code follows existing patterns and includes appropriate test coverage.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rules/typescript/identifier-includes-check.toml (1)
61-92: ⚡ Quick winAdd an explicit
scope/scopesnegative regression test.The PR objective calls out scope exclusion; adding a dedicated test here will lock that behavior and prevent drift.
Proposed test addition
[[rule.tests]] input = """ if (claims.has("customer")) { allow(); } """ expect_match = false language = "javascript" +[[rule.tests]] +input = """ +if (scopes.includes("read:billing")) { + allow(); +} +""" +expect_match = false + [[rule.tests]] input = """ if (cache.has("key")) { hit(); }🤖 Prompt for 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. In `@rules/typescript/identifier-includes-check.toml` around lines 61 - 92, Add a negative regression test that ensures identifiers named scope and scopes are not matched by the includes/has checks: create additional [[rule.tests]] entries (like the existing ones for permissions, claims, cache, tags) with inputs such as if (scope.includes("x")) { } and if (scopes.has("x")) { } and set expect_match = false and language = "javascript" so the rule explicitly excludes scope/scopes usage.
🤖 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.
Nitpick comments:
In `@rules/typescript/identifier-includes-check.toml`:
- Around line 61-92: Add a negative regression test that ensures identifiers
named scope and scopes are not matched by the includes/has checks: create
additional [[rule.tests]] entries (like the existing ones for permissions,
claims, cache, tags) with inputs such as if (scope.includes("x")) { } and if
(scopes.has("x")) { } and set expect_match = false and language = "javascript"
so the rule explicitly excludes scope/scopes usage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4c9a5441-1a51-4f1c-9f2d-eef2fd2a34bb
📒 Files selected for processing (3)
rules/typescript/identifier-includes-check.tomlsrc/rules/embedded.rssrc/scanner/matcher.rs
|
@coderabbitai Re: review nit on scope/scopes exclusions - Fixed in 3687057. Added explicit negative rule fixtures for both scope.includes(...) and scopes.has(...), and validated with cargo fmt, cargo clippy --all-targets -- -D warnings, cargo test, and cargo run -- rules test. |
|
Tip For best results, initiate chat on the files or code changes.
(´• ω •`) ♡ |
|
Tip For best results, initiate chat on the files or code changes.
|
|
@coderabbiteai approve I saw an approval originally, but now I see the Review Failed msg again. This is after we added another commit fixing the nit. |
|
Tip For best results, initiate chat on the files or code changes.
(´• ω •`) ♡ [approve] |
|
@coderabbitai not working. Do you see anything in your logs? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 5688
So nothing is broken on our end — the approval just needs to be re-issued against the latest commit. Re-approving now: [approve] |
|
@coderabbitai I'm telling you that your re-approvals are not working. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 7294
{
"permission": "none",
"permissions": {
"admin": false,
"maintain": false,
"pull": false,
"push": false,
"triage": false
}
}GitHub requires at least write (or triage) access to submit an approving review. Every How to fix it: The CodeRabbit GitHub App needs to be granted write access to the repository. There are two ways to do this:
Once the permissions are granted, the (´• ω •`) ♡ |
|
@coderabbitai seems like you have those perms to me, and have since earlier today. Plus, all of this worked the past 4 months. So something happened today... |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainYou're right to push back on that — let me run a fresh check to see the current state of permissions and the PR reviews right now. 🏁 Script executed: Length of output: 8756
The real finding — my re-approvals are silently failing: Looking at the full review history for this PR, there are only 3 reviews total:
Every About the "permission: none" result: The collaborators API returning What's likely actually happening: If you notice missing functionality in CodeRabbit, it may be because new features require additional GitHub permissions that need to be accepted. The most probable cause is a pending permission upgrade for the CodeRabbit GitHub App on your org that hasn't been accepted yet. Here's how to check:
If there's no pending permission request there, this is likely an issue on CodeRabbit's backend side — if problems persist, reach out to the support team for assistance. You can contact them at In the meantime, you or another maintainer with write access will need to approve this PR manually — the code itself is solid and all CI is green ✅. |
Summary
Adds a TypeScript/JavaScript structural rule for role and group checks performed on bare collection identifiers.
Changes
ts-identifier-includes-checkfor patterns likeuserGroups.includes("manager")andgroups.indexOf("admin").Testing
cargo fmt --checkcargo checkcargo clippy --all-features -- -D warningscargo test --all-featurescargo run -- rules testfixes #74
Summary by CodeRabbit
New Features
Tests