Source-code review

Follow untrusted input into a sensitive operation. Ask for a small patch, a counterexample and a regression test.

Useful code review follows data across function boundaries. A risky-looking call may be protected by an earlier check; a clean handler may rely on a helper that drops the tenant predicate.

Select the relevant source and its immediate callers. Ask for an explicit path from input to operation, with missing context called out. A proposed patch is easier to assess when it includes a test showing the original failure.

Start with this material

  • The selected handler, helper or query and enough caller context to identify the trust boundary.
  • Relevant types, schema constraints and existing tests; remove keys and connection strings.
  • The expected invariant, such as tenant ownership, argument allowlisting or single-use token consumption.

Work through the evidence

  1. Ask for entry points, transformations, validation and the final operation. Require file and line references for each claim.
  2. Look for a concrete counterexample that violates the invariant. Check whether middleware or database constraints already block it.
  3. Request the smallest compatible patch and a regression test. Include failure and concurrency cases where the invariant depends on atomic behavior.
  4. Review and run the test before applying the patch. CLI patch review is a separate local confirmation; a model suggestion does not itself write your working tree.

A prompt to adapt

Adapt to your evidence
Trace the selected request parameter into the database query. Our invariant is that a tenant can read only its own reports. Cite each relevant check, identify missing caller context and construct a failing cross-tenant test if the path is vulnerable. Propose a minimal patch that preserves the existing response contract.

Check the result

  • The finding identifies a reachable path and explains why existing validation does not stop it.
  • The test exercises the public behavior rather than repeating the implementation.
  • The patch preserves valid requests, handles errors and uses the project’s existing authorization and transaction patterns.

Bring your own evidence into a conversation and work through the next question.

Open chat