Skip to content

CodeDiag 0.9 "Perimeter" - #39

Merged
sabahattink merged 4 commits into
mainfrom
release/0.9
Oct 30, 2026
Merged

sabahattink merged 4 commits into
mainfrom
release/0.9

Conversation

@sabahattink

Copy link
Copy Markdown
Owner

CodeDiag 0.9 "Perimeter": tRPC apps that authenticate in front of their procedures stop getting missing-auth warnings, dependency audits are cached and run concurrently across monorepo packages, and Dependabot updates keep the Action bundle in step.

Changes

  • tRPC perimeters (src/analyzers/trpc-perimeter.ts): mutations are not reported as missing auth when the whole router is authenticated first:
    • a createContext (or a project function it calls) that throws TRPCError UNAUTHORIZED/FORBIDDEN or throws when the session is missing; T3's session-reading createTRPCContext does not count;
    • auth middleware ahead of the Express mount, in the same use() or an earlier global/enclosing-path use();
    • a Next.js middleware.ts / proxy.ts that rejects anonymous requests (next-auth/middleware, Clerk auth.protect() under a route matcher, or a redirect/401/403 when the session is missing) and whose matcher covers the tRPC route. Matchers are tested against the route path only, so /((?!api|...).*) does not count.
  • Audit cache (src/analyzers/audit-cache.ts): successful audits are kept for an hour in node_modules/.cache/codediag, keyed by command, lock file, and package.json; validated on read; failures never kept; nothing written without node_modules. The Dependencies summary says when a result was reused.
  • Concurrent workspace audits: --workspaces starts every package's audit up front, four at a time; package scans reuse the outcomes.
  • Dependabot bundle workflow: a read-only job rebuilds dist/action.cjs; a job that runs no repository or dependency code commits the two bundle files and starts CI through workflow_dispatch. Dependabot groups minor and patch npm updates.
  • VS Code extension 0.7.0.

Verification

  • npm run check: lint, format, typecheck, extension, 362 unit tests (361 pass, 1 skipped on Windows for symlinks), build, bundle:check, 33 CLI/Action tests.
  • Real npm audit on a three-package npm workspace: 2.8 s cold, 0.9 s with the cache; every package reports its vuln-high.
  • The Dependabot workflow can only be exercised by a real Dependabot pull request (chore(deps): bump ignore from 7.0.13 to 7.0.14 #32 after a rebase, or the next weekly update).

Mutations are not reported as missing auth middleware when the whole
router is authenticated before procedures run:

- a createContext (or a project function it calls) that throws
  TRPCError UNAUTHORIZED/FORBIDDEN or throws when the session is missing;
  T3's createTRPCContext, which only reads the session, does not count;
- auth middleware ahead of the Express mount that serves the adapter, in
  the same use() call or an earlier global or enclosing-path use();
- a Next.js middleware.ts (proxy.ts in Next.js 16) that rejects
  anonymous requests (next-auth/middleware, Clerk auth.protect() under a
  route matcher, or a redirect or 401/403 when the session is missing)
  and whose matcher covers the tRPC route. Matchers are tested against
  the route path only, so the common /((?!api|...).*) matcher that skips
  the API does not count.

The API Health summary names where the perimeter was found.
Dependency updates that change dist/action.cjs failed bundle:check until
someone rebuilt the bundle by hand. A read-only job now runs npm ci and the
build on Dependabot pull requests; when the bundle changes, a second job
that runs no repository or dependency code commits only the two bundle
files and starts CI for the new commit through workflow_dispatch, since
commits pushed with GITHUB_TOKEN do not trigger pull_request runs.
Dependabot groups minor and patch npm updates into one pull request.
…concurrently

Successful audits are written to node_modules/.cache/codediag, keyed by
the audit command and the exact lock file and package.json contents, and
reused for an hour by later scans and editor saves; entries are validated
on read, failed audits are never kept, and nothing is written when the
project has no node_modules. A reused result is named in the Dependencies
summary with its age.

--workspaces scans start every package's audit up front, four at a time,
and the package scans reuse those outcomes, so the waiting overlaps instead
of adding up. On a three-package npm workspace the scan takes 2.8 s, and
0.9 s once the audits are cached.
@github-actions

Copy link
Copy Markdown
Contributor

✅ CodeDiag: 95/100 (A+)

threshold 0

Analyzer Score Findings
Security 100/100 0
Dependencies 84/100 2
Testing 98/100 1
Structure 100/100 0

No findings in the files this pull request changes.

Not listed: 2 findings elsewhere in the project, 1 suppressed.

Scanned by CodeDiag · updated on every push

@sabahattink
sabahattink merged commit 7d2f13e into main Oct 30, 2026
7 checks passed
@sabahattink
sabahattink deleted the release/0.9 branch October 30, 2026 13:15
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