Skip to content

Fix FastAPI router-level authentication detection - #73

Merged
haydenschmitty merged 1 commit into
haydenschmitty:mainfrom
spacecampkatie:fix/fastapi-router-auth-detection
Nov 15, 2026
Merged

haydenschmitty merged 1 commit into
haydenschmitty:mainfrom
spacecampkatie:fix/fastapi-router-auth-detection

Conversation

@spacecampkatie

Copy link
Copy Markdown
Contributor

FastAPI endpoints protected by APIRouter(dependencies=[...]) can be reported as open. The constructor regex stops at the first nested ), only the first dependency is examined, and the bare authenticate name is not recognized.

Read balanced constructor/list expressions, consider every dependency (including Security), and recognize authenticate/authorize. Database-only dependencies still do not count as authentication, and guards stay scoped to their router.

Validation: npm test — 203 passed, 1 platform-specific skip. Added a regression covering shared read/write protection, database-before-guard order, nested factories, qualified names, delimiter-containing strings/comments, and genuinely open sibling routers.

@spacecampkatie
spacecampkatie marked this pull request as ready for review November 3, 2026 17:59
@haydenschmitty
haydenschmitty merged commit c272a19 into haydenschmitty:main Nov 15, 2026
haydenschmitty added a commit that referenced this pull request Nov 15, 2026
#73's bracket walker finds where APIRouter(...) ends without stopping at
brackets in strings or comments, but the dependencies were then read from
the raw text, so a commented-out `# Depends(require_login)` or a description
mentioning one protected every route of the router. The walker now blanks
comments and string contents in what it returns. Near-miss tests for both
and for a router whose brackets never close; the test's comment names no
real project. Changelog line and tests table row.
@haydenschmitty

Copy link
Copy Markdown
Owner

Merged and released in 0.10.0, on top of 0.9.0's FastAPI work. I also made it ignore checks that only appear in a comment or a string inside the router. Thank you!

Update with claude plugin update floorplan@floorplan.

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.

2 participants