Skip to content

route_auth_map: NestJS review fixes (per-app guard scope, bounded decorators) - #2423

Merged
remigiusz-antczak merged 3 commits into
mainfrom
nestjs-route-auth-followups-1118
Nov 18, 2026
Merged

remigiusz-antczak merged 3 commits into
mainfrom
nestjs-route-auth-followups-1118

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

Follow-up to #2421: review fixes for NestJS route-auth mapping in route_auth_map.py.

Changes

  • Per-app global guard scoping. App roots come from nest-cli.json projects (root and sourceRoot). When there is no app manifest, the fallback is the nearest directory holding main.ts or tsconfig.app.json. In a root-manifest monorepo, a global guard in apps/a no longer hides a missing guard in apps/b.
  • Bounded decorator search. Member-level @Public() and @UseGuards(...) are read only from the decorator run above the signature, never from the method body. The run accepts @Name (, with a space before the paren, and @Name<T>(, with a generic argument.
  • HEAD and OPTIONS. These are exempt from HIGH only for NestJS rows. The comment notes that no other framework emits such rows today.
  • Documented limits, both erring toward HIGH:
    • A workspace lib with its own manifest is its own app, so its APP_GUARD does not reach the apps that import it.
    • A nested main.ts likewise becomes its own app.

Tests

  • scripts/test_route_auth_nestjs.py: 22/22. The new tests fail on the route_auth_map: inventory NestJS controllers and guards #2421 code. They cover:
    • nest-cli projects scoping
    • the main.ts / tsconfig.app.json fallback
    • a @Public inside a method body
    • a spaced or generic decorator, with a throttler twin
  • scripts/test_route_auth_map.py: 8/8.
  • Size gate passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc

remigiusz-antczak and others added 3 commits November 18, 2026 09:33
…al guard, member Public, class keyword)

HEAD/OPTIONS are exempt from HIGH only for NestJS rows; no other framework emits such rows today.
A global APP_GUARD reaches only controllers of its own app: the nearest directory above marked by
package.json, nest-cli.json (including each projects.*.root), main.ts or tsconfig.app.json, so a
root-manifest-only monorepo is split per app. A workspace lib with its own package.json, or a nested
main.ts app, is its own app and is not reached by the guard (safe direction, documented). A member
@public() or @UseGuards() is read only from the decorators above the signature (a spaced
`@UseGuards (X)` or a generic `@ApiBody<Foo>()` still counts as a decorator), so a call in a body or
parameter list does not count, and a member @public() beats a class-level @UseGuards. The class
keyword is found as a whole word. The docstring notes that setGlobalPrefix and URI versioning are not
applied to paths. MUTANTS rows updated to the new texts.

Tests: 22/22 (test_route_auth_nestjs), 8/8 (test_route_auth_map), route-auth-map.sh green

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc
…et, src-scoped guard)

HEAD/OPTIONS are exempt from HIGH only for NestJS rows; no other framework emits such rows today.
A global APP_GUARD reaches only controllers of its own app: the nearest directory above marked by
package.json, nest-cli.json (including each projects.*.root), main.ts or tsconfig.app.json, so a
root-manifest-only monorepo is split per app. A workspace lib with its own package.json, or a nested
main.ts app, is its own app and is not reached by the guard (safe direction, documented). A member
@public() or @UseGuards() is read only from the decorators above the signature (a spaced
`@UseGuards (X)` or a generic `@ApiBody<Foo>()` still counts as a decorator), so a call in a body or
parameter list does not count, and a member @public() beats a class-level @UseGuards. The class
keyword is found as a whole word. The docstring notes that setGlobalPrefix and URI versioning are not
applied to paths. MUTANTS rows updated to the new texts.

Follow-up: nested generics in decorators parse, NestJS scan state is reset per scan (a two-scan test
and a MUTANTS row fail if the reset is removed), the global guard is scoped to src, and the
Express/Fastify HEAD/OPTIONS assertions are restored in their own test.

Tests: 27/27 (test_route_auth_nestjs), 8/8 (test_route_auth_map), route-auth-map.sh green

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc
@remigiusz-antczak
remigiusz-antczak merged commit b9429af into main Nov 18, 2026
13 checks passed
@remigiusz-antczak
remigiusz-antczak deleted the nestjs-route-auth-followups-1118 branch November 18, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant