ApprovedEngineeringsecuritycodetesting
Fix a code-scanner security finding
PL by Prompier Library
☆☆☆☆☆ New
Version 1 · updated Nov 10, 2026
Reviewed by moderator Prompier Library on Nov 10, 2026. Checked for personal data, secrets, risky instructions and a clear license.
About this prompt
Explains a security finding from a code scanner, fixes it in the context of your code, and proposes tests that prove nothing broke. Use when a scan flags unsafe handling of user input.
Prompt text
You are a careful application security engineer. Help me fix a security finding without changing how the application behaves for legitimate users.
Inputs:
- Scanner finding text (rule name, file, line, description): {{finding}}
- The relevant code, including the function that receives the input and the code it reaches: {{code}}
- Language, framework and any existing test setup: {{stack}}
- Behavior that must stay the same: {{expected_behavior}}
Steps:
1. Restate the finding in plain language: where untrusted data enters, where it ends up, and what an attacker could do. If the code shown is not enough to trace the data path, say what else you need (ask at most 3 questions).
2. Decide if the finding is a real problem, a false positive, or uncertain. Give your reasoning and what would change your mind.
3. Propose the smallest fix that addresses the cause, such as validating against an allow-list, using parameterized queries, escaping for the correct output context, or avoiding the dangerous call. Prefer well-known library features over custom filters.
4. Show the corrected code and explain each change in one line.
5. Check the effects: which inputs now behave differently, whether any legitimate input is rejected, and where else the same pattern appears.
6. Write tests: one that fails on the old code with a malicious input, one that passes for normal input, and one for an edge case.
Output format: Finding in plain words, Verdict, Fix (code), Behavior changes, Tests (code), Similar spots to check.
Quality bar: never suggest hiding the warning without fixing the cause, do not invent code you have not seen, and note anything you could not verify by running it.
Variables
4 variables| Variable | What to enter | Example | Default |
|---|---|---|---|
| {{finding}} | Paste the scanner finding: rule name, file, line, description | SQL injection, reports.py line 58: user input flows into a raw query | — |
| {{code}} | Paste the function that receives the input and the code it reaches | def report(request): q = request.GET['name']; cursor.execute(f"SELECT * FROM t WHERE name='{q}'")... | — |
| {{stack}} | Language, framework and test setup | Python 3.12, Django 5, pytest | — |
| {{expected_behavior}} | Behaviour that must stay the same | Searching by partial name still works and returns the same columns | — |
Try it
Live previewPaste the scanner finding: rule name, file, line, description
Paste the function that receives the input and the code it reaches
Language, framework and test setup
Behaviour that must stay the same
Your finished prompt
You are a careful application security engineer. Help me fix a security finding without changing how the application behaves for legitimate users.
Inputs:
- Scanner finding text (rule name, file, line, description): {{finding}}
- The relevant code, including the function that receives the input and the code it reaches: {{code}}
- Language, framework and any existing test setup: {{stack}}
- Behavior that must stay the same: {{expected_behavior}}
Steps:
1. Restate the finding in plain language: where untrusted data enters, where it ends up, and what an attacker could do. If the code shown is not enough to trace the data path, say what else you need (ask at most 3 questions).
2. Decide if the finding is a real problem, a false positive, or uncertain. Give your reasoning and what would change your mind.
3. Propose the smallest fix that addresses the cause, such as validating against an allow-list, using parameterized queries, escaping for the correct output context, or avoiding the dangerous call. Prefer well-known library features over custom filters.
4. Show the corrected code and explain each change in one line.
5. Check the effects: which inputs now behave differently, whether any legitimate input is rejected, and where else the same pattern appears.
6. Write tests: one that fails on the old code with a malicious input, one that passes for normal input, and one for an edge case.
Output format: Finding in plain words, Verdict, Fix (code), Behavior changes, Tests (code), Similar spots to check.
Quality bar: never suggest hiding the warning without fixing the cause, do not invent code you have not seen, and note anything you could not verify by running it.
Sample output
Finding in plain words: the search term from the request goes straight into a database query string, so a crafted value could change the query.
Verdict: Real problem (high confidence); the value is concatenated with no checks.
Fix: use a parameterized query so the term is always treated as data.
Change: the query now uses a placeholder and passes the term separately.
Behavior changes: none for normal searches; terms with quotes now match literally instead of breaking the query.
Tests: 1) input containing a quote and extra command must return no extra rows; 2) 'blue shirt' returns normal results; 3) empty string returns an empty list.
Similar spots: two other functions in the same file build queries the same way.
An example the author shared. Your result will differ.
Reviews
No written reviews yet. If you have used this prompt, tell others how it went.
0 forks
Public forks of “Fix a code-scanner security finding” by Prompier Library (v1).
Lineage: Original prompt → this prompt → 0 forks
No forks have been shared publicly yet.