Skip to content

feat: add review_project v1 — detect hand-written body validation - #446

Closed
jimhoyd wants to merge 1 commit into
mainfrom
feat/428-review-project-v1
Closed

jimhoyd wants to merge 1 commit into
mainfrom
feat/428-review-project-v1

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Scoped-down v1 of #428, per the agreed scoping comment on the issue (see gh issue view 428 --comments): the full native/extension/gap/manual-review taxonomy needs a general rule engine and an extension-alternative catalog this repo doesn't have yet, so this PR lands exactly one unambiguous pattern and proves the plumbing.

  • review_project v1 detects hand-written request.body validation (manual JSON.parse, typeof ... === '...' checks, Array.isArray(...) checks, explicit required-field checks like !body.name or body.email === undefined) in function/middleware source, and points at the declarative alternative (request.body.schema, src/body-schema.ts).
  • Reuses prepareFunctionSnapshot (itself built on collectSourcesFor/collectTrustedSources in src/function-sources.ts) to load function/middleware source — no new file access, no new trust boundary. Never executes project code, never reads env/secret bindings, never makes network calls, stays within the existing per-module/total byte budgets.
  • Registered as a read-only MCP tool review_project (same trust tier as inspect) and a CLI command urlcode review-project [--json], following the search_docs/docs search house style from Add function-handler section to llms.txt and urlcode docs search CLI #432.
  • Findings are deliberately conservative: matched only on a source line naming request.body directly or a whole-body alias (const body = request.body); destructured per-field aliases are intentionally not tracked to avoid false positives on generic short identifiers. Missing a real case is preferred over flagging an unrelated validation.
  • Capped at 50 findings ({format: 1, findings: [...], truncated?: true}), matching other bounded tool outputs in this codebase.
  • New docs/TOOLING.md section states the v1 scope and non-goals explicitly: no code execution, no other pattern types yet, native-alternative findings only.

Judgment calls

  • Only a single-identifier whole-body alias (const body = request.body) is tracked for aliasing; destructured field names (const { name } = request.body) are not, to keep false-positive risk low as the issue discussion asked.
  • reviewProject is exported from src/review-project.ts but not re-exported from src/index.ts, matching how searchDocs (the pattern this follows) is MCP/CLI-internal only.

Test plan

  • npm run typecheck
  • npm run lint
  • node --conditions=development --test test/review-project.test.ts test/mcp.test.ts test/mcp-authoring.test.ts test/exports.test.ts test/cli.test.ts (all pass; updated hardcoded MCP tool-list counts in test/mcp.test.ts and test/mcp-authoring.test.ts for the new tool)
  • node scripts/check-local-links.ts, check-trust-model-prose.ts, check-guidance-claims.ts
  • Manual smoke test of urlcode review-project --project ... and --json against a fixture project

Closes #428

🤖 Generated with Claude Code

Scoped-down v1 of issue #428 per the agreed issue-comment discussion: a
review_project MCP tool / CLI command that statically flags hand-written
request.body validation (manual JSON.parse, typeof/Array.isArray checks,
explicit required-field checks) in function/middleware source, pointing
authors at the declarative request.body.schema alternative instead.

Built on the existing collectSourcesFor/collectTrustedSources source
loader (via prepareFunctionSnapshot) so it inherits the same read-only,
no-execution, no-binding-read, byte-budgeted guarantees; no new trust
boundary is introduced. Only the one native-alternative pattern ships;
other pattern types and the extension-alternative/gap/manual-review
taxonomy are explicitly out of scope for this slice.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jimhoyd

jimhoyd commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator Author

Closing without merging — main already has a broader implementation of this from #437 (merged while this PR was in progress in an isolated worktree), covering 4 detection signals (manual body validation, cookie/session, global mutable state, outbound network calls) vs. this PR's single signal. No unique value left to carry over.

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.

[Request]: Add an MCP review of generated projects for avoidable imperative plumbing

1 participant