fix: gate install success on doctor's auth-pattern security checks#175
Conversation
The installer ran build/typecheck self-correction but never ran doctor's authPatterns checks, so an insecure GET sign-out (SIGNOUT_GET_HANDLER) could pass the build and ship as a "successful" install while `workos doctor` immediately flagged it. - Add src/lib/validation/security-checks.ts: runs doctor's security subset (GET sign-out, client-leaked/in-source API keys, ungitignored .env, mixed env) against the install dir with no network. - Wire into agent-runner: the self-correction loop now feeds security findings back to the agent, and a final gate throws on error-severity findings that survive retries (success: false, non-zero exit, commit step skipped). - Point the SIGNOUT_GET_HANDLER finding at a live docs URL (old /docs/authkit/sign-out 404s).
Greptile SummaryThis PR closes the gap between
Confidence Score: 5/5The change tightens install correctness by adding a security gate — no existing behavior is weakened and the new gate is correctly placed after all retries exhaust. The new security-check module is pure file inspection with no network calls, the blocking/warning split is clean, and the two integration points in agent-runner (retry callback + final gate) are logically sound. The retry metric is correctly moved after the gate to avoid false positives. No pre-existing validation paths were removed or weakened, and the three blocking codes are well-tested with real file fixtures. No files require special attention. Important Files Changed
|
Picks up the Next.js sign-out POST server-action guidance (workos/skills#33), so the installer agent no longer scaffolds an unsafe GET sign-out route.
…omment Addresses Greptile review on #175: - Add a unit test for the API_KEY_LEAKED_TO_CLIENT blocking code (a NEXT_PUBLIC_-prefixed secret in .env.local), mirroring the API_KEY_IN_SOURCE test, so a regression in the prefix/key detection is caught. - Correct the self-correction comment: warning findings ride along only when a retry is already triggered by an error or build failure; they are otherwise surfaced in the final validation report.
Addresses Greptile review on #175: - Move the 'agent retry summary' (passed_after_retry: true) capture below the security gate so a blocked install no longer emits a contradictory pass-after-retry event alongside 'security gate blocked install'. - Use obviously-fake fixture key strings in the spec (still satisfy the detection regex) so secrets scanners and the no-hardcoded-secrets rule stay quiet.
Problem
workos installran build/typecheck self-correction but never randoctor'sauthPatternschecks. So an insecure GET sign-out (SIGNOUT_GET_HANDLER) could pass the build and ship as asuccess: trueinstall, whileworkos doctorimmediately flagged it. The install--validatestep anddoctorhad drifted apart.Repro: install into an empty dir scaffolds Next.js + AuthKit, generates
export async function GET() { return signOut() }+<form method="GET">, reports "validation passed, 0 issues", thendoctorfindsSIGNOUT_GET_HANDLER.Changes
src/lib/validation/security-checks.ts— runs the security subset ofdoctor'scheckAuthPatterns(GET sign-out, client-leaked / in-source API keys, ungitignored.env, mixed env) against the install dir. No network, so it's safe in the install loop. Unit-tested (9 cases).agent-runner.tswiring — two layers:success: false, non-zero exit, commit/PR steps skipped (insecure code stays uncommitted).auth-patterns.ts—SIGNOUT_GET_HANDLERdocsUrlnow points at the livehttps://workos.com/docs/authkit/nextjs#ending-the-session(old/docs/authkit/sign-out404s).The blocking set is deliberately tight (
SIGNOUT_GET_HANDLER,API_KEY_LEAKED_TO_CLIENT,API_KEY_IN_SOURCE) — high-confidence security errors only. Completeness checks (missing middleware/callback) overlapvalidateInstallationand are reported but never fail the install.Related
@workos/skills@0.6.1) mandates the POST server-action pattern. This PR bumps the dep to 0.6.1, so that guidance ships here.workos.com/docs/...deep-links across findings + framework configs are also 404 and need a verified sweep.Testing
pnpm typecheck,pnpm test(2091 passing),pnpm buildall pass.agent-runnerwiring is not separately tested (no existingagent-runner.spec.ts; logic lives in the tested module).workos install(needs credentials + network + LLM).🤖 Generated with Claude Code