Skip to content

feat(go): per-route auth detection + gopls auth-flow refinement - #242

Merged
jaurakunal merged 1 commit into
mainfrom
feat/go-auth-refinement
Sep 14, 2026
Merged

jaurakunal merged 1 commit into
mainfrom
feat/go-auth-refinement

Conversation

@jaurakunal

Copy link
Copy Markdown
Owner

What

Brings Go auth analysis to parity with the JS/TS/Python/Java path — the tracked follow-up to Go SAST+LSP support.

Mapper — per-route auth (was file-level)

  • has_auth_check decided per route: a router/group .Use(authMw) guards its routes; every other route carries its handler body in handler_source. One guarded handler no longer vouches for an unguarded neighbour.
  • Fixed a real mis-mapping: r.Header.Get("Authorization") / c.Get("user") were mapped as routes. A registration must pass a handler after the path.

Shared auth patterns — Go idioms

Identity (Header.Get("Authorization"), RequireAuth, VerifyToken, session.Get, c.Get("user"), Context().Value), enforcement (http.StatusUnauthorized/Forbidden, WriteHeader(401/403), Gin AbortWithStatus, echo.NewHTTPError(401), Fiber), LSP terminals (+jwt.Parse).

Tracer — Go strategy

Per-route: group middleware → inline identity+refusal → cross-file auth helper resolved via gopls go-to-definition. Uses the RouteEntry's own content (fixes the tracer bailing early when file_index didn't resolve the Go path).

Verified live (real isitsecure scans)

  • Unprotected route → flagged missing-auth; inline-guarded route → verified.
  • Auth enforced only inside a cross-file helper: route_analyzer regex false-positives it → the LSP follows the helper with gopls → LSP validation: 1 findings suppressed. JS-level refinement, for Go.
  • Full suite: 2610 passed, 1 xfailed.

README marks Go Auth Detection: Yes; lsp-setup.md documents the three tracing modes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EZ4QoTqRoYWE25CNoV2Wfy

Brings Go auth analysis to parity with the JS/TS/Python/Java path.

Mapper (per-route, not file-level):
- has_auth_check is now decided per route — a router/group `.Use(authMw)`
  guards its routes; every other route carries its handler body in
  handler_source for the analyzer/LSP to judge. One guarded handler no longer
  vouches for an unguarded neighbour in the same file.
- Fixed a real mis-mapping the redesign surfaced: `r.Header.Get("Authorization")`
  and `c.Get("user")` were mapped as routes. A registration must pass a handler
  after the path, which separates `r.GET("/p", h)` from `.Get("X")`.

Shared auth patterns extended with Go idioms:
- identity: Header.Get("Authorization"), RequireAuth/Authenticate/VerifyToken/
  session.Get/c.Get("user"), r.Context().Value(...)
- enforcement: http.StatusUnauthorized/Forbidden, WriteHeader(401/403),
  Gin AbortWithStatus, echo.NewHTTPError(401), Fiber status
- LSP terminals: the identity idioms above + jwt.Parse

Tracer Go strategy (auth_flow_tracer):
- New per-route Go path: router/group middleware -> inline identity+refusal ->
  a cross-file auth helper resolved via gopls go-to-definition, whose body is
  then checked for an auth terminal.
- Uses the RouteEntry's own content (Go does not depend on file_index), fixing
  the tracer returning early when the index did not resolve the Go path.

Verified live end-to-end (real `isitsecure` scan of Go apps):
- unprotected route -> flagged missing-auth; inline-guarded route -> verified.
- auth enforced ONLY inside a cross-file helper: route_analyzer's regex
  false-positives it, then the LSP follows the helper with gopls and
  `LSP validation: 1 findings suppressed` — the JS-level refinement, for Go.
- Full suite: 2610 passed, 1 xfailed.

README marks Go Auth Detection as Yes; lsp-setup.md documents the three modes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ4QoTqRoYWE25CNoV2Wfy
@jaurakunal
jaurakunal merged commit d2c2033 into main Sep 14, 2026
8 checks passed
@jaurakunal
jaurakunal deleted the feat/go-auth-refinement branch September 14, 2026 14:12
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