PR Risk Reviewer
A static review of a supplied unified diff, grounded in changed-line evidence.
- Input
- A selected ordinary unified text diff
- Output
- A report of specific changed-line review cues and relative paths; it is a static review, not a runtime safety result.
What it does
- Highlights changed lines and risk cues
- Reviews only supported text diff formats
- Does not run tests, Git commands, or changed code
Overview
PR Risk Reviewer is a local Python 3.11+ CLI that inspects standard UTF-8 unified diffs and emits structured JSON review cues for high-attention code changes such as dynamic execution additions. It runs offline with zero third-party dependencies, executes no target code, and labels findings as textual review cues rather than proven vulnerabilities.
When to use it
- Pre-screening pull request diffs from human contributors or autonomous coding agents before manual review.
- Flagging newly added dynamic execution or high-attention patterns with exact file path and line numbers in JSON.
- Integrating a deterministic, zero-network diff screen into local pre-commit or code-review checklists.
Review a unified diff
Needs Python 3.11 or newer and only the standard library. Run from the package directory and pass it a UTF-8 unified diff.
python3 scripts/pr_risk_reviewer.py change.diffSample output
Abridged output from version 0.1.0, run on a small synthetic fixture. The diff added a function that calls eval.
{
"status": "ok",
"findings": [
{
"code": "DYNAMIC_EXECUTION_ADDED",
"path": "service.py",
"line": 2,
"severity": "high"
}
],
"files": [
{
"path": "service.py",
"added_lines": 2,
"deleted_lines": 0,
"hunks": 1
}
],
"analysis": "textual change cues; risk score and runtime behavior UNKNOWN"
}Exit codes and limits
- Exit 0 means the inspection completed, including when it has findings. Exit 2 means invalid or unreadable input.
- Static evidence only: no customer code, imports, tests or network requests are executed.
- Only ordinary text unified diffs are supported; binary, rename metadata, mode changes, combined diffs and quoted paths are rejected.
- Findings are review cues, not proven vulnerabilities.
Questions
What diff formats does PR Risk Reviewer accept?
It accepts ordinary UTF-8 text unified diffs. Binary diffs, rename metadata, file-mode changes, combined diffs, and quoted paths are rejected with exit code 2.
Does PR Risk Reviewer prove that a diff contains an exploitable vulnerability?
No. Findings are deterministic textual change cues (such as DYNAMIC_EXECUTION_ADDED with file and line numbers) meant to focus human review; runtime behavior remains UNKNOWN.
Does it send code or diff contents to an external API or LLM?
No. It runs 100% locally on Python 3.11+ using only the standard library, with zero network requests and zero code execution.
What do exit codes 0 and 2 mean?
Exit 0 means the diff was parsed and inspected successfully, regardless of whether findings were emitted. Exit 2 means the input file was invalid, unreadable, or used an unsupported diff format.