feat: add security-scopes-defined rule#2951
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 4b709a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
Performance Benchmark (Lower is Faster)
|
JLekawa
reviewed
Jul 20, 2026
JLekawa
approved these changes
Jul 20, 2026
Co-authored-by: Jacek Łękawa <164185257+JLekawa@users.noreply.github.com>
DmitryAnansky
force-pushed
the
feat/security-scopes-defined-rule
branch
from
July 21, 2026 10:07
52d8436 to
1c1ae4b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1c1ae4b. Configure here.
vadyvas
approved these changes
Jul 21, 2026
vadyvas
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What/Why/How?
Added security-scopes-defined rule.
It supports OpenAPI 2.0/3.x and AsyncAPI 2.6/3.0, suggests the closest defined scope for typos, and has an opt-in
requireScopesoption that requires OAuth2 security requirements to list at least one scope.Reference
Testing
Screenshots (optional)
Check yourself
Security
Note
Low Risk
Read-only spec linting with no runtime auth behavior; recommended
warnmay surface new findings on existing APIs with mismatched OAuth2 scopes.Overview
Adds a new built-in lint rule
security-scopes-definedthat flags OAuth2 scopes used in security requirements when they are not declared on the corresponding security scheme. It is wired into OpenAPI 2.x/3.x and AsyncAPI 2.6/3.0 rule sets, with a dedicated AsyncAPI 3.0 visitor that matches scopes on the scheme againstavailableScopesin flows (AsyncAPI 3’s model).The rule resolves
$ref’d flows when building the allowed scope list, skips non-oauth2schemes and undefined schemes (left tosecurity-defined), and can suggest a close declared scope for typos. OptionalrequireScopesenforces at least one scope on OAuth2 requirements (OAS/Async2) or on referenced schemes (Async3).Recommended presets enable it at
warn(errorinrecommended-strict/all); minimal / spec keep it off. Docs, sidebar, ruleset templates, config snapshots, and unit tests are updated accordingly.Reviewed by Cursor Bugbot for commit 4b709a5. Bugbot is set up for automated code reviews on this repo. Configure here.