Skip to content

route_auth_map: inventory NestJS controllers and guards - #2421

Merged
remigiusz-antczak merged 1 commit into
mainfrom
fix/route-auth-nestjs-sq
Nov 18, 2026
Merged

remigiusz-antczak merged 1 commit into
mainfrom
fix/route-auth-nestjs-sq

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

Supersedes #2419 with one squashed commit rebased on current main (the train requires one commit per PR).

What changes

route_auth_map.py now inventories NestJS controllers: @Controller prefixes, verb decorators, @UseGuards on member or class, @Public()-style decorators, and global guards (APP_GUARD, useGlobalGuards). Rate-limit-only guards do not count as auth. Before this change a NestJS monorepo produced 2 routes; it now produces 560.

Evidence

  • scripts/test_route_auth_nestjs.py: 14/14, with clean twins for controller guard, global auth guard vs throttler-only guard, and @Public under a global guard.
  • scripts/test_route_auth_map.py: 8/8; scripts/ci-tests.d/route-auth-map.sh green.
  • Held-out bench (12 repos, 59 seeds): recall 0.695 and false positives 49, identical to the pinned baseline.
  • Independent review: PASS, 0 critical. Four risks are queued for a follow-up: per-app scoping of global guards, HEAD/OPTIONS exemption limited to NestJS, \bclass\b matching, and global prefix or URI versioning not applied to paths.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc

…Guards, global guard)

A class @controller('prefix' | { path }) with @Get/@Post/@Put/@Patch/@Delete/@All/@Head/
@options('path' | ['a', 'b']) members is an inventoried route (METHOD /prefix/path); a
constant path reads {?}. @UseGuards(X) on the member or the class is the auth evidence;
a rate-limit guard (Throttler*, RateLimit*) is not, unless its name also says Auth, Jwt,
Session, Role or Permission. A @public()-style decorator reads auth=public. An unguarded
mutating route reads auth=none (HIGH) like the other frameworks; when the scanned tree
wires a non-rate-limit APP_GUARD (provider object read in either key order) or
useGlobalGuards(), it reads "global guard, unverified" (INFO) instead. The class-guard
window stops at the previous class.

New per-feature test scripts/test_route_auth_nestjs.py with fictional fixtures and clean
twins, registered in scripts/ci-tests.d/route-auth-map.sh. The route-auth-map MUTANTS rows
are widened so each old text occurs exactly once. On a read-only NestJS monorepo clone the
--all inventory went from 2 to 560 routes. Held-out bench: recall and false positives
unchanged against the pinned baseline.

Tests: 14/14 (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 23ba78a into main Nov 18, 2026
13 checks passed
@remigiusz-antczak
remigiusz-antczak deleted the fix/route-auth-nestjs-sq branch November 18, 2026 08:31
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