---
title: "AI Secure Code Review: Triage SAST Output"
description: "Pipe Semgrep JSON or CodeQL SARIF into a security model that marks false positives, explains exploitability in words and drafts the fix."
canonical: https://pentestllm.ai/ai-secure-code-review
generated: 2026-11-27T06:35:45.260Z
source: https://pentestllm.ai/ai-secure-code-review
base_url: https://api.pentestllm.ai/v1
---

AI secure code review

# Triage SAST findings with a model

Feed Semgrep JSON or a CodeQL SARIF file to `auto/security` at https://api.pentestllm.ai/v1 and every finding comes back with a verdict, a plain note on whether it is exploitable, and a suggested fix. A reviewer still confirms each true positive, and what shrinks is the pile of noise they read first.

[Prices per token](https://pentestllm.ai/pricing)

[Get a key](https://app.pentestllm.ai/console) [Try it free in the browser](https://pentestllm.ai/playground)

```
from openai import OpenAI

client = OpenAI(base_url="https://api.pentestllm.ai/v1", api_key="sk-ptl-live-…")

reply = client.chat.completions.create(
    model="auto/security",
    messages=[{"role": "user", "content": "Explain this advisory and list what to check on an affected host."}],
)
print(reply.model)  # the build that answered
print(reply.choices[0].message.content)
```

## Where this sits in a review

When a scanner runs in your pipeline, [CI security report review](https://pentestllm.ai/ci-security-report-review) keeps the optional reading job separate from the release gate.

A secure code review usually starts with a scanner pass that produces hundreds of findings, most of them unreachable or already handled. Sorting them is slow, repetitive reading: open the file, find the source of the tainted value, check for a sanitiser, decide. That reading is what you hand to the model. The decision stays with the reviewer, and the repository stays inside the scope the client signed.

Before any client code leaves your machine, settle what the contract allows. The [privacy page](https://pentestllm.ai/privacy) lists what PentestLLM keeps, and the files-and-redaction feature covers the header that strips keys and tokens from snippets before the request is forwarded.

## Get findings a script can read

Semgrep prints its own JSON format with --json, and -o writes it to a file. For CodeQL, pin the SARIF version, because the manual warns that sarif-latest can change between releases and break automation, so use sarifv2.1.0. One catch with Semgrep: since version 1.98.0 some fields, including the matched lines, need a logged-in session, so the script below reads the code from disk instead and works either way.

```bash
semgrep scan --config p/default --json -o semgrep.json
codeql database analyze app-db codeql/python-queries \
  --format=sarifv2.1.0 --output=codeql.sarif
```

## The triage script

This reads semgrep.json, adds about fifteen lines of context on each side of every finding, and asks the model for a JSON verdict. It targets `auto/security`, because the router sends a structured-output request to a balanced security build; with the gateway’s redaction setting on (`secrets`), API keys, tokens and private keys in the snippet become placeholders before the request is forwarded. The [redaction page](https://pentestllm.ai/features/files-and-redaction) has the header. Run it from the repository root; for CodeQL, keep the loop and swap the field lookups for the SARIF paths, falling back to the start line when a result omits the end line. Asking for a json_object has a billing note worth knowing: on a non-streamed request, an answer that does not parse is retried once and the missed answer is free; the response headers record the miss and the refund, and per-token rates are on [pricing](https://pentestllm.ai/pricing).

```
import json, sys, os
from openai import OpenAI
client = OpenAI(base_url="https://api.pentestllm.ai/v1", api_key=os.environ["PTL_KEY"])
SYSTEM = ("You triage static analysis findings for an authorized secure code review. "
          "Answer in JSON: verdict (true_positive, false_positive or needs_review), reason, "
          "exploitability (which input reaches the sink and what an attacker would gain; no exploit "
          "code, no payloads), fix (the smallest code change), confidence (low, medium or high).")
def snippet(path, start, end, pad=15):
    lines = open(path, encoding="utf-8", errors="replace").read().splitlines()
    lo, hi = max(start - pad, 1), min(end + pad, len(lines))
    return "\n".join(f"{n}: {lines[n-1]}" for n in range(lo, hi + 1))
for f in json.load(open(sys.argv[1]))["results"]:
    s, e = f["start"]["line"], f["end"]["line"]
    prompt = f"Rule: {f['check_id']}\nFile: {f['path']}, lines {s}-{e}\n\n" + snippet(f["path"], s, e)
    reply = client.chat.completions.create(model="auto/security",
        response_format={"type": "json_object"}, extra_headers={"x-redact": "secrets"},
        messages=[{"role": "system", "content": SYSTEM}, {"role": "user", "content": prompt}])
    print(reply.choices[0].message.content)
```

## Read the verdicts like a reviewer

Sort by verdict and confidence. A high-confidence false positive usually points at a sanitiser or framework guard the rule does not know about, which is a rule-tuning note for the client; spot-check a sample. A needs_review means the model saw only the snippet, so taint that crosses files, middleware or configuration is invisible and you widen the context or read it yourself. A true positive you confirm for reachability inside scope, score with the CVSS calculator, and move to the [triage](https://pentestllm.ai/ai-vulnerability-triage) and [report writing](https://pentestllm.ai/pentest-report-writing) steps. Never let the script close a finding on its own; a verdict file is a reading order, not an audit trail.

## Keep the run reproducible

Store the scanner version, the rule set, the model id and the system prompt next to the verdict file. When the client asks months later why a finding was marked as noise, you can show the exact input and the reason the model gave, with the reviewer’s own note beside it. Changing the prompt between runs makes verdicts incomparable, so version it like code. The exploitability field asks for words, not code: which input reaches the sink and what an attacker would gain is what a client needs to prioritise a fix, while proofs of concept, where the rules of engagement call for them, are the tester’s job on the authorised target.

## Where each field sits in the two formats

- Rule: Semgrep: results[].check_id; CodeQL: runs[].results[].ruleId.
- Message: Semgrep: extra.message; CodeQL: message.text.
- File: Semgrep: path; CodeQL: locations[0].physicalLocation.artifactLocation.uri.
- Line: Semgrep: start.line and end.line; CodeQL: physicalLocation.region.startLine.

## 16 security builds, priced per token

USD per million tokens, live on 2026-11-27; `auto/security` bills at the build that answers.

Detected refusals and invalid non-streamed JSON qualify for automatic refunds within the daily cap. [Verify your receipt](https://pentestllm.ai/statements/verify).

| Model | Build | Input $/M | Output $/M | Context | Wire formats |
| --- | --- | --- | --- | --- | --- |
| [Qwen3.8 27B Cybersecurity](https://pentestllm.ai/models/qwen3.8-27b-cybersecurity) qwen3.8-27b-cybersecurity | Security | $0.40 | $2.40 | 262K | openai |
| [Uncensored Qwen3.8 27b Cybersecurity](https://pentestllm.ai/models/qwen3.8-27b-cybersecurity-uncensored) qwen3.8-27b-cybersecurity-uncensored | Security | $0.40 | $2.40 | 262K | openai |
| [Gemma 4 26B A4B Cybersecurity](https://pentestllm.ai/models/gemma-4-26b-a4b-it-cybersecurity) gemma-4-26b-a4b-it-cybersecurity | Security | $0.4224 | $1.3376 | 262K | openai |
| [Gemma 4 26B A4B Cybersecurity (Uncensored)](https://pentestllm.ai/models/gemma-4-26b-a4b-it-cybersecurity-uncensored) gemma-4-26b-a4b-it-cybersecurity-uncensored | Security | $0.48 | $1.52 | 262K | openai |
| [GLM-5.3 Flash Cybersecurity](https://pentestllm.ai/models/glm-5.3-flash-cybersecurity) glm-5.3-flash-cybersecurity | Security | $0.4935 | $1.645 | 1049K | openai |
| [GLM-5.3 Flash Cybersecurity (Uncensored)](https://pentestllm.ai/models/glm-5.3-flash-cybersecurity-uncensored) glm-5.3-flash-cybersecurity-uncensored | Security | $0.5093 | $1.6975 | 1049K | openai |
| [Red Team (Flash)](https://pentestllm.ai/models/uplink-red-team-flash) uplink-red-team-flash | Security | $0.90 | $3.00 | 1000K | openai |
| [Red Team (Pro)](https://pentestllm.ai/models/uplink-red-team-pro) uplink-red-team-pro | Security | $1.50 | $6.00 | – | openai |
| [OrcaCyber MiniMax M3.1 Flash](https://pentestllm.ai/models/minimax-m3.1-flash-cybersecurity) minimax-m3.1-flash-cybersecurity | Security | $2.00 | $4.00 | 262K | openai |
| [OrcaCyber MiniMax M3.1 Flash (Uncensored)](https://pentestllm.ai/models/minimax-m3.1-flash-cybersecurity-uncensored) minimax-m3.1-flash-cybersecurity-uncensored | Security | $2.00 | $4.00 | 262K | openai |
| [OrcaCyber Qwen3.8 Flash Next (Uncensored)](https://pentestllm.ai/models/orcacyber-qwen3.8-flash-next-uncensored) orcacyber-qwen3.8-flash-next-uncensored | Security | $2.00 | $4.00 | 262K | openai |
| [OrcaCyber Qwen3.8 Flash Next](https://pentestllm.ai/models/qwen3.8-flash-next-cybersecurity) qwen3.8-flash-next-cybersecurity | Security | $2.00 | $4.00 | 262K | openai |
| [Uncensored Qwen3.8 Flash Next Cybersecurity](https://pentestllm.ai/models/qwen3.8-flash-next-cybersecurity-uncensored) qwen3.8-flash-next-cybersecurity-uncensored | Security | $2.00 | $4.00 | 262K | openai |
| [Cyber Frontier](https://pentestllm.ai/models/cyber-frontier) cyber-frontier | Security | $5.25 | $15.75 | 1049K | openai |
| [OrcaCyber Zero 1.5](https://pentestllm.ai/models/orca-zero-1.5-cybersecurity) orca-zero-1.5-cybersecurity | Security | $7.50 | $18.75 | 999K | openai |
| [OrcaCyber Zero 1.5 (Uncensored)](https://pentestllm.ai/models/orca-zero-1.5-cybersecurity-uncensored) orca-zero-1.5-cybersecurity-uncensored | Security | $7.50 | $18.75 | 999K | openai |

[Full price list and tool fees](https://pentestllm.ai/pricing) · [Every model](https://pentestllm.ai/models) · [API docs](https://pentestllm.ai/docs)

## Questions

### Can a model replace a person in SAST triage?

No. It removes the first pass of reading: obvious false positives, duplicates across rules, findings in test fixtures. A reviewer signs off every true positive and samples the false positives the model dismissed.

### Does the model see the whole repository?

Only what the script sends: the rule, the file path and about thirty lines around each finding. That limit is why cross-file data flow lands in needs_review. Send more context for those findings rather than trusting a guess.

### Which build fits SAST triage?

Send auto/security, as in the script: the router answers each request with a security build and sends a structured-output request to the balanced tier. There is no public benchmark of these builds on SAST triage yet, so compare a few hundred verdicts against your own decisions before you rely on one.

### Does redaction keep secrets out of the snippet?

Yes for credentials: with redaction set to secrets, the gateway swaps API keys, tokens and private keys for placeholders before the request is forwarded. Hostnames, internal IPs and client names are not in that class, so scrub those yourself before the request goes out.

## Read next

[Vulnerability research Models for code review, CVE and patch analysis, and advisory writing.](https://pentestllm.ai/vulnerability-research) [AI YARA and Sigma rules Draft YARA and Sigma detection rules with a security model, then prove each one before you deploy it.](https://pentestllm.ai/yara-sigma-rule-generation) [Pentest report writing Drafting findings, impact, remediation and the executive summary, with client data redacted first.](https://pentestllm.ai/pentest-report-writing) [Threat modeling with AI Paste an architecture as text and get a STRIDE table, attack trees and in-scope test cases back.](https://pentestllm.ai/threat-modeling-ai)

Facts about other products and tools on this page were read from their own pages on 21 November 2026: [Semgrep CLI reference](https://semgrep.dev/docs/cli-reference), [CodeQL CLI: database analyze](https://docs.github.com/en/code-security/codeql-cli/codeql-cli-manual/database-analyze), [PentestLLM files and redaction](https://pentestllm.ai/features/files-and-redaction). They change; check the source before relying on a figure.

## One key, from $3

For systems you own or may test in writing: [acceptable use](https://pentestllm.ai/acceptable-use).

[Get a key](https://app.pentestllm.ai/console)
