Full prompt
Prompt text
Act as a senior software engineer performing a security-aware code review.
CODE
{code}
OBJECTIVE
Review the supplied code before rewriting anything.
ANALYSE:
1. CORRECTNESS
- logical errors
- edge cases
- invalid assumptions
- error handling
- concurrency/state issues where relevant
2. SECURITY
Check where applicable:
- input validation
- output escaping
- SQL injection
- command injection
- authentication
- authorisation
- CSRF
- file upload/path handling
- secret exposure
- insecure direct object references
- dangerous deserialisation
- external requests
3. DATA SAFETY
- destructive operations
- transaction handling
- duplicate writes
- data leakage
- unexpected NULL/empty values
4. MAINTAINABILITY
- duplicated logic
- confusing naming
- unnecessary coupling
- unreachable code
- fragile assumptions
5. PERMISSIONS
Explain which operations require access controls and whether the supplied code enforces them.
RANK FINDINGS:
Critical / High / Medium / Low / Informational
FOR EACH FINDING:
- location
- problem
- impact
- evidence from code
- recommended fix
ONLY AFTER THE REVIEW:
Provide a corrected example for issues that clearly require code changes.
Do not redesign unrelated working code.
OUTPUT FORMAT
## Executive Summary
## Risk-Ranked Findings
## Corrected Code
## Regression Risks
## Required Tests
## Assumptions / Missing Context
Secure Code Review
What a useful answer should look like
A risk-ranked code review with evidence, security and correctness findings, focused corrected code, regression risks and required tests.
How to get a better result
Add real context
Replace every placeholder and include constraints, audience and source material.
Verify claims
Open original sources for factual, legal, medical, financial or time-sensitive information.
Iterate deliberately
Ask for revisions against a rubric instead of accepting the first output.