← Back to Pull requests

fix(lang): parse #[access_control] arguments as expressions #4980

Merged
valentynkit merged 2 files (155 lines) on Sep 07, 2026 16:13 UTC
View on GitHub
valentynkit valentynkit commented on Sep 02, 2026 18:12 UTC
Author

Fixes #4973.

#[access_control] split its stringified arguments on closing parens, so a check with a nested call failed to compile and string literals lost their whitespace. Arguments are now parsed as comma-separated expressions, same as the v2 parser.

The new tests in lang/tests/access_control.rs fail against the old parser.

Diff: 155 lines (+134 / -21) across 2 files Reviewer: jamie-osec Review duration: 7081m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.35) × (1 − Review Confidence (0.86)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 155 lines diff across 2 files
0.35
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.81 · 5 substantive comment(s)
0.81
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
86%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.302
Real PR Conversation Timeline
14 items
vercel[bot] vercel[bot] commented on Sep 02, 2026 18:12 UTC
Bot

@valentynkit is attempting to deploy a commit to the OtterSec Team on Vercel.

A member of the Team first needs to authorize it.

jamie-osec jamie-osec commented on code on Sep 02, 2026 18:34 UTC
Code Review
lang/attribute/access-control/src/lib.rs:1
@@ -1,10 +1,14 @@
 extern crate proc_macro;
 
-use {quote::quote, syn::parse_macro_input};
+use {
+    quote::quote,
+    syn::{parse::Parser, parse_macro_input, punctuated::Punctuated, Expr, Token},
+};
 
 /// Executes the given access control method before running the decorated

/// Executes the given access control methods before running the decorated

jamie-osec jamie-osec commented on code on Sep 02, 2026 18:34 UTC
Code Review
lang/attribute/access-control/src/lib.rs:1
@@ -1,10 +1,14 @@
 extern crate proc_macro;
 
-use {quote::quote, syn::parse_macro_input};
+use {
+    quote::quote,
+    syn::{parse::Parser, parse_macro_input, punctuated::Punctuated, Expr, Token},
+};
 
 /// Executes the given access control method before running the decorated
 /// instruction handler. Any method in scope of the attribute can be invoked
-/// with any arguments from the associated instruction handler.
+/// with any arguments from the associated instruction handler. Multiple

Please move the 'multiple methods' part to after the current examples, and add an example of that usage there.

jamie-osec jamie-osec commented on code on Sep 02, 2026 18:35 UTC
Code Review
lang/attribute/access-control/src/lib.rs:1
@@ -1,10 +1,14 @@
 extern crate proc_macro;
 
-use {quote::quote, syn::parse_macro_input};
+use {
+    quote::quote,
+    syn::{parse::Parser, parse_macro_input, punctuated::Punctuated, Expr, Token},
+};
 
 /// Executes the given access control method before running the decorated

Also, as a drive by, mention that methods must return Result<()>

jamie-osec jamie-osec commented on code on Sep 02, 2026 18:37 UTC
Code Review
lang/tests/access_control.rs:1

Thanks for adding dedicated tests here. Can you add a couple more to test general usage, such as accessing function arguments?

jamie-osec jamie-osec commented on Sep 02, 2026 18:37 UTC
Contributor

Thanks for the PR; I have a few nitpicks but generally good.

valentynkit valentynkit commented on code on Sep 04, 2026 17:04 UTC
Code Review
lang/attribute/access-control/src/lib.rs:1
@@ -1,10 +1,14 @@
 extern crate proc_macro;
 
-use {quote::quote, syn::parse_macro_input};
+use {
+    quote::quote,
+    syn::{parse::Parser, parse_macro_input, punctuated::Punctuated, Expr, Token},
+};
 
 /// Executes the given access control method before running the decorated

Thanks, addressed this in followup commit.

valentynkit valentynkit commented on Sep 04, 2026 17:05 UTC
Author

Thanks for review, addressed the comments. Please let me know if there anything else you would prefer differently.

jamie-osec jamie-osec approved these changes on Sep 05, 2026 11:33 UTC
Approved Reviewer

Thanks; will merge shortly

swaroop-osec swaroop-osec commented on Sep 07, 2026 11:21 UTC
Contributor

@valentynkit Could you please fix the Prettier formatting issue?

valentynkit valentynkit commented on Sep 07, 2026 11:41 UTC
Author

The prettier warning was because the PR was stale, should be fixed after rebasing from master.

swaroop-osec swaroop-osec approved these changes on Sep 07, 2026 11:59 UTC
Approved Reviewer

Approved these changes.

0x4ka5h 0x4ka5h approved these changes on Sep 07, 2026 12:12 UTC
Approved Reviewer

Approved these changes.

Reviewers
Assignees
valentynkit valentynkit
Labels
risk: low confidence: 86% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 34.7% (LOW) · Higher = larger blast radius
34.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 86% · Lower = rushed or shallow review
86%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 4.9% · Safe to merge
4.9%