Experimental — Automated tests pass. Live model checks on a private gateway are working for several providers. Treat findings as advisory and verify them before acting. Licensed under MIT.
A Rust CLI for advisory source-code review. It reads selected files at an exact Git commit, sends their text to an OpenAI-compatible chat API, and validates a JSON report against paths, line numbers, and skill-pack categories (OWASP Web Top 10:2025 plus secrets/ASVS/Laravel/Node/Python/LLM/diff packs). The CLI gives the model zero tools and treats reviewed code as data only.
You need Docker and an OpenAI-compatible API key (AI_REVIEW_API_KEY).
mkdir -p .review-out
docker run --rm --user "$(id -u):$(id -g)" \
-v "$PWD:/work:ro" -v "$PWD/.review-out:/out:rw" \
-e AI_REVIEW_API_KEY \
-e AI_REVIEW_BASE_URL='https://api.deepseek.com' \
-e AI_REVIEW_MODELS='deepseek-chat' \
-e AI_REVIEW_SKILLS=auto \
-e AI_REVIEW_CRITIC=1 \
-e AI_REVIEW_HTML_OUT=/out/report.html \
ghcr.io/solutionforest/ai-security-review:latest \
/work "$(git rev-parse HEAD)" --auto-diff "$(git rev-parse HEAD~1)" > .review-out/review.json
open .review-out/report.html # or xdg-open / startFor a risk-ranked whole-tree pass (still capped at 20 files / 64 KiB, not an
unbounded full-repo dump), use --auto-tree instead of --auto-diff …, or set
workflow input scope: tree.
Offline preview of the HTML viewer (no API key): open
docs/examples/mock-report.html.
Want to help? See Contributing and CONTRIBUTING.md.
This project cannot run a real review without a model API key. The binary and the prebuilt Docker image only talk to an OpenAI-compatible chat endpoint; they do not ship a model.
| Where you run | What you must set |
|---|---|
| Local CLI / Docker | Env var AI_REVIEW_API_KEY (or legacy DEEPSEEK_API_KEY) |
| GitHub Actions (this repo or any consumer) | Repo or Environment secret AI_REVIEW_API_KEY — required before the reusable workflow will start |
| Optional | AI_REVIEW_BASE_URL (default https://api.deepseek.com; use your LAN gateway URL on a self-hosted runner) |
Without the key:
- Local runs exit immediately with a missing-key error
- The Actions reusable workflow fails in the review step with
Missing AI_REVIEW_API_KEY
Offline-only checks that do not need a key: cargo test and
python3 scripts/smoke-test.py (synthetic stub API).
Set the GitHub secret once per repo (Settings → Secrets and variables → Actions),
or use an Environment such as security-review and pass secrets: inherit from
the caller workflow. See §2. Set the provider and API secret.
Adding this AI reviewer does not make security “complete.” It is advisory LLM source review. Keep a deterministic SAST baseline next to it:
| Layer | What it is | Needs AI key? | In this repo |
|---|---|---|---|
| CodeQL | Official GitHub SAST (rules / dataflow) | No | .github/workflows/codeql.yml — Rust + Actions |
| AI Security Review | LLM reads selected commit source → JSON report | Yes | .github/workflows/ai-security-review.yml |
| Runtime agentic detections | Sigma / KQL / Suricata / Zeek / IOCs for agentic attack frameworks in logs and traffic | No | Separate — e.g. ThreatDefence/agentic-attack-detections |
| External host scan (e.g. scanhost / Pentra) | Nmap / ZAP / Nuclei against URL/IP | No | Separate product — not source review |
| Humans | Verify findings before shipping fixes | — | Always required |
CodeQL findings appear under the repo Security → Code scanning tab. AI review
artifacts (review.json / report.html) are separate workflow uploads. This
tool finds weak agent/MCP controls in source; runtime packs like ThreatDefence
detect agentic attack frameworks after deploy. Use both with humans; do not
treat either as a full pen-test or a substitute for owning the fix.
Security review still needs humans. This tool helps when you need:
- Fast first pass on changed files before or during PR review
- Consistent OWASP / secrets / framework checklists instead of ad-hoc prompts
- Validated JSON (coverage IDs, line bounds,
needs_validationfacts) so bad model output fails closed instead of looking like a real report - Multi-model consensus so one chatty model does not dominate triage
- Private gateway support (including LAN HTTP) without giving the model shell, browser, or exploit tools
It is not a replacement for SAST (CodeQL/Semgrep), dependency scanning, pen-tests, host scanners, or owning the fix. It is a structured assistant for source-only review.
We are actively looking for contributors. Highest-impact areas:
| Ask | Why it helps |
|---|---|
| More skill packs | New languages/frameworks beyond Laravel / Node / Python / GraphQL |
| Better critic logic | Fewer false confidence findings; clearer refute / overstated verdicts |
| Benchmarks | Compare models against known-vulnerable open codebases (fixtures only) |
| Documentation | Shorter paths, triage guides, clearer skill-pack docs |
| Alternative model adapters | Request-shape / gateway quirks for more OpenAI-compatible providers |
Start from the pinned overview
#12 Help wanted,
a good first issue,
or CONTRIBUTING.md. PRs that stay defensive and source-only
are welcome.
Possible later directions — not on the current roadmap, and must stay inside the zero-tool / source-only boundary:
| Idea | Why it might help | Explicitly out of scope |
|---|---|---|
| Specialized small critic / router | Fine-tune or distill a cheap model for “is this finding weak?” / route hard cases to a larger model (lower cost, faster CI) | Giving the reviewer shell, browser, MCP tools, or live probing |
| Held-out security eval gym | Fixed vulnerable fixtures + graders so model upgrades are measurable (extends fixtures/bench/) |
Training on private company source; exploit PoCs |
| Style / voice LoRAs | Interesting for product copy elsewhere | Not applicable to this CLI’s security JSON contract |
Inspiration for the first two rows includes public experiments with small specialized LoRAs + local graders (for example Jacob Posel’s tweet-model write-up) — useful as a methodology hint (cheap specialized model + eval gate), not as something to paste into this product. Prefer opening an issue before any fine-tune / training work.
On an intentional vulnerable PHP sample (SQL injection, missing authz,
hardcoded key, weak password) reviewed with owasp,secrets,asvs:
| Model | Result | Findings | Latency | Notes |
|---|---|---|---|---|
deepseek-flash |
OK | 15 | ~9s | Best default: fast + core issues hit |
deepseek-v4-pro |
OK | 12 | ~15s | Strong second vote for consensus |
google/gemini-3.8-flash |
OK | 12 | ~29s | Solid alternate |
openai/gpt-5.6-sol |
OK* | 6–8 | ~25s | Needs request_shape=auto (user_json) on some New API gateways |
openai/gpt-5.6-luna |
OK* | 7 | ~20s | Same gateway workaround as sol |
moonshotai/kimi-k3 |
OK | 18 | ~78s | Most findings; slower / noisier |
xiaomi/mimo-v2.6-pro |
OK | 17 | ~143s | Thorough but slow |
z-ai/glm-5.3-flash |
Fail often | — | high | Coverage/JSON issues under current schema |
qwen/qwen3.8-max |
Fail often | — | — | Invalid JSON for multi-skill schema |
*After automatic request-shape fallback.
Practical recommendation
export AI_REVIEW_MODELS='deepseek-flash,deepseek-v4-pro'
export AI_REVIEW_SKILLS=auto
export AI_REVIEW_REQUEST_SHAPE=autoUse kimi-k3 or mimo-v2.6-pro only when you want a slower, broader second pass.
More findings ≠ better — triage source_supported first, then
needs_validation.
- Run the CLI (or download the Actions artifact
review.json). - Confirm
reviewed_commitandreviewed_pathsmatch what you intended. - If present, read
stack(detected languages/frameworks) andselected_skills. - For a single model:
coverage/skills.*.coverage— every category should be labeledfindings[]— checkcategory,path,line,status,evidence
- For multi-model consensus:
- start with
consensus.findingswhereconfidenceishigh - treat
low/ disputed coverage as leads, not proof
- start with
- If
AI_REVIEW_CRITIC=1, readcritic.reviews:refuted/unsafe_to_report→ park or dropoverstated→ downgrade severity / dig for the missing factsound→ still verify in source before shipping a fix
- Verify each finding in the real source before changing production code.
Empty findings can still be a valid report (for example a docs-only fixture).
Illustrative output only — not a live run. Full fixtures:
docs/examples/mock-review.json,
docs/examples/mock-summary.json, and
docs/examples/mock-review.sarif.
After the CLI finishes, you typically have:
review.json— validated model report (skills, findings,unique_findings, optionalcritic)summary.json— compact counts for Actions job outputs / later stepsreview.sarif— SARIF 2.1.0 for GitHub Code Scanning / PR annotationsreport.html— self-contained offline HTML viewer (filters, KPIs, critic verdicts, coverage matrix)
All four come from the single Rust binary (no Python needed in workflows):
AI_REVIEW_HTML_OUT=report.html ./target/release/ai-security-review ../my-app "$COMMIT" app/Http/Controllers/ProfileController.php > review.json
# or build summary + SARIF + HTML afterwards:
./target/release/ai-security-review summary review.json --out summary.json --sarif review.sarif --html report.htmlsummary.json (mock)
{
"reviewed_commit": "a1b2c3d4e5f60718293a4b5c6d7e8f9012345678",
"models": ["deepseek-flash"],
"failed_model_count": 0,
"selected_skills": ["owasp", "secrets", "controls", "laravel"],
"finding_count": 4,
"unique_finding_count": 2,
"source_supported_count": 3,
"needs_validation_count": 1,
"critic_status": "ok",
"critic_counts": {
"sound": 3,
"overstated": 1,
"unsafe_to_report": 0,
"refuted": 0
},
"actionable_count": 1,
"has_findings": true,
"has_actionable": true
}review.json excerpt (mock)
{
"model": "deepseek-flash",
"reviewed_commit": "a1b2c3d4e5f60718293a4b5c6d7e8f9012345678",
"reviewed_paths": ["app/Http/Controllers/ProfileController.php"],
"selected_skills": ["owasp", "secrets", "controls", "laravel"],
"stack": {
"languages": ["php"],
"frameworks": ["laravel"],
"auto": true
},
"skills": {
"owasp": {
"findings": [
{
"category": "A01:2025",
"path": "app/Http/Controllers/ProfileController.php",
"line": 42,
"status": "source_supported",
"evidence": "show() loads a user by request id with no authorize() or policy call.",
"impact": "A caller who can hit this route may read another principal's profile.",
"remediation": "Authorize the target user before returning it.",
"missing_fact": null
},
{
"category": "A05:2025",
"path": "app/Http/Controllers/ProfileController.php",
"line": 58,
"status": "needs_validation",
"evidence": "whereRaw concatenates a request filter; parameterization is not visible.",
"impact": "Possible SQL injection if the value is attacker-controlled.",
"remediation": "Use bound parameters or query builder where().",
"missing_fact": "Whether $filter is validated before whereRaw."
}
]
}
},
"critic": {
"status": "ok",
"reviews": [
{
"category": "A01:2025",
"line": 42,
"verdict": "sound",
"note": "No authorization call is visible beside the id-based fetch."
},
{
"category": "A05:2025",
"line": 58,
"verdict": "overstated",
"severity_adjust": "lower",
"note": "Impact depends on an unseen sanitizer."
}
]
}
}Triage tip: start with source_supported + critic sound, then chase needs_validation /
overstated. In GitHub Actions, download the ai-security-review artifact or read
needs.review.outputs.has_actionable.
Prerequisite: set AI_REVIEW_API_KEY first (see Required: AI API key).
cargo +1.100.0 build --locked --release --bin ai-security-review
export AI_REVIEW_API_KEY='...' # required — review will not start without this
export AI_REVIEW_BASE_URL='https://api.deepseek.com' # or your OpenAI-compatible gateway
export AI_REVIEW_SKILLS=auto
export AI_REVIEW_CRITIC=1 # optional second pass that tries to break weak findings
./target/release/ai-security-review ../my-app "$COMMIT" path/to/File.php > review.jsonOffline checks (no API key):
cargo +1.100.0 test --locked
python3 scripts/smoke-test.py target/debug/ai-security-reviewSee SKILLS.md for skill packs (including source-of-truth links),
auto detection, optional critic, and the cron skill-refresh script
(scripts/update-skills-cron.sh).
GitHub Actions runs Rust checks and a synthetic end-to-end review on pull
requests and pushes to main. After the tests pass on main (or v* tags),
Actions builds and smoke-tests a Linux Docker image and pushes it to GHCR:
ghcr.io/solutionforest/ai-security-review:latest(latest testedmain)ghcr.io/solutionforest/ai-security-review:v0.3.0(semver release — prefer for consumers)ghcr.io/solutionforest/ai-security-review:<commit-sha>(immutable pin)
Zero-setup Docker run on any local Git repo (no Rust install needed):
mkdir -p .review-out
docker run --rm --user "$(id -u):$(id -g)" \
-v "$PWD:/work:ro" -v "$PWD/.review-out:/out:rw" \
-e AI_REVIEW_API_KEY -e AI_REVIEW_BASE_URL \
-e AI_REVIEW_MODELS='deepseek-flash,deepseek-v4-pro' \
-e AI_REVIEW_SKILLS=auto -e AI_REVIEW_CRITIC=1 \
-e AI_REVIEW_HTML_OUT=/out/report.html \
ghcr.io/solutionforest/ai-security-review:latest \
/work "$(git rev-parse HEAD)" --auto-diff "$(git rev-parse HEAD~5)" > .review-out/review.json
open .review-out/report.html(Note: on first publish, ensure the ai-security-review package in GitHub
Packages is visible to your target repos or set to Public.)
On Linux with Docker, build the image and run the Rust CLI inside it:
docker build -t ai-security-review:local .
docker run --rm ai-security-review:local --helpDocker compiles the CLI in a Rust build stage. The final image runs the compiled binary directly. To use the Rust binary without Docker, see Run locally or review a separate repo.
The smoke-test helper uses Python 3 on the host to start a mock model API and verify the Rust CLI's JSON report. It uses synthetic source and needs no API key. This is the only step here that requires Python.
python3 scripts/smoke-test.py --image ai-security-review:localThe public workflow uses only synthetic source and a local stub. Run model reviews that use real company source or provider credentials from a separate private automation repo.
-
Provision a dedicated, disposable Linux VM. Use an unprivileged account for the runner. Give the VM access to GitHub Actions, the Rust toolchain and crate sources needed by the build, and the selected model endpoint. Use the GitHub runner network requirements to configure outbound access, including access for artifact upload.
-
Install Git, a C compiler, CMake, CA certificates, and rustup under the runner account. On Ubuntu, the system prerequisites can be installed with
sudo apt-get install git build-essential cmake ca-certificates. From the runner account, install and verify the toolchain:rustup toolchain install 1.100.0 --profile minimal cargo +1.100.0 --version
-
In your private automation repo, open Settings → Actions → Runners → New self-hosted runner. Select Linux and the VM's architecture. Run the download and checksum commands GitHub provides on the VM. Run its generated
./config.shcommand with--labels ai-review --ephemeralappended. The generated token registers the runner with GitHub. Keep it private and use it only on the VM. -
From the runner directory, start
./run.shas the runner account and leave it running until the job picks it up. Verify GitHub shows the runner as Idle with theself-hosted,linux, andai-reviewlabels. An ephemeral runner takes one job and deregisters. Destroy the VM after the run and register a fresh one for the next job. GitHub registration · Ephemeral runners
For an organization-managed runner, use a dedicated runner group restricted
to your private automation repo. Restrict its workflow access to the protected
review workflow where available, and use the group along with the
ai-review label in runs-on.
Runner group access
- In your private automation repo, open Settings → Environments → New
environment and name it
security-review. - Under Deployment branches and tags, choose Selected branches and
tags and add a Branch rule for
main. Protectmainwith your usual pull request review rules. - Under Environment secrets, select Add secret. Set the name to
AI_REVIEW_API_KEYand paste the provider API key as the value. This is the model API credential. GitHub's runner registration token is used in step 1 above. Keep the API key out of source, YAML, command arguments, and logs. - For a non-default provider, add
AI_REVIEW_BASE_URLandAI_REVIEW_MODELunder Environment variables. Confirm the hostname and model together before using a provider key. Private repository environments require a GitHub plan that supports them. GitHub environment setup
| Setting | Default | Value |
|---|---|---|
AI_REVIEW_API_KEY |
Required | Bearer token. The CLI also accepts DEEPSEEK_API_KEY as a legacy fallback. The workflow below uses the primary name. |
AI_REVIEW_BASE_URL |
https://api.deepseek.com |
Base URL, for example https://api.deepseek.com or https://llm.internal.example/v1. The CLI appends /chat/completions. Use HTTPS, or HTTP only for loopback / private RFC1918 gateways on self-hosted runners (do not publish real LAN IPs in public docs). |
AI_REVIEW_MODEL |
deepseek-flash |
Exact model ID accepted by the endpoint. Ignored when AI_REVIEW_MODELS is set. |
AI_REVIEW_MODELS |
unset | Comma-separated model IDs (max 5). Runs all models in parallel and emits a consensus report with per_model, consensus, and unique_findings. |
AI_REVIEW_SKILLS |
owasp |
Comma-separated packs (owasp, secrets, asvs, controls, llm, aisvs, diff, laravel, node, python, graphql) or auto to detect language/framework and attach matching packs. Single owasp keeps the flat report shape. |
AI_REVIEW_CRITIC |
unset | Set 1/true for a source-only second pass that tries to break weak findings (critic block in the report). Automatically uses the 2nd model in AI_REVIEW_MODELS for cross-model critique. |
AI_REVIEW_CRITIC_MODEL |
unset | Optional explicit model ID for the critic pass (overrides the default 2nd-model cross-critic). |
AI_REVIEW_ALLOW_PARTIAL |
unset | Set 1/true in multi-model mode to return results from surviving models (with failed_models) instead of failing the whole run if one provider errors. |
AI_REVIEW_HTML_OUT |
unset | Optional output path to write a self-contained offline HTML report automatically after review completes. |
AI_REVIEW_MAX_TOKENS |
16384 |
Completion budget. Raise for reasoning models that otherwise finish with length. |
AI_REVIEW_TIMEOUT_SECS |
180 |
Per-request HTTP timeout. |
AI_REVIEW_REQUEST_SHAPE |
auto |
auto tries system_json → user_json → system_plain when a shape is rejected or returns unusable JSON. Force with system_json, user_json, or system_plain. |
The endpoint must support JSON object mode via
response_format: {"type": "json_object"}.
DeepSeek JSON output
Report validation rejects findings whose category is marked not_applicable,
requires missing_fact only for needs_validation, and accepts a complete JSON
review even when the provider reports finish_reason=length.
You do not need Rust, CMake, or Python on the runner — only Docker.
You do still need the AI_REVIEW_API_KEY secret in the target repo (or
Environment) before any review job will succeed — see
Required: AI API key.
Call the reusable workflow
.github/workflows/review.yml, which pulls the
prebuilt ghcr.io/solutionforest/ai-security-review:latest image, runs
--auto-diff (or explicit files), builds summary.json + review.sarif +
report.html, sets job outputs, and uploads the artifact.
This repo already ships a self-audit caller at
.github/workflows/ai-security-review.yml.
Copy .github/workflows/ai-security-review.example.yml
into .github/workflows/ai-security-review.yml in any other repo (for example HKAGE):
name: AI Security Review
on:
workflow_dispatch:
inputs:
files:
description: Optional space-separated files (blank = auto-diff)
required: false
default: ""
pull_request:
permissions:
contents: read
packages: read
jobs:
review:
# Pin to a full commit SHA (CodeQL / supply-chain hardening). Bump intentionally.
uses: solutionforest/ai-security-review/.github/workflows/review.yml@63116908c02cfe3a07970580ee0d740ef5bcb981
with:
# Use ["ubuntu-latest"] for HTTPS APIs, or your self-hosted runner for a LAN gateway:
runs_on: '["self-hosted", "linux", "ai-review"]'
environment: security-review
models: deepseek-flash,deepseek-v4-pro
skills: auto
critic: true
allow_partial: true
docker_network: host
files: ${{ inputs.files || '' }}
secrets: inherit
triage:
needs: review
runs-on: ubuntu-latest
if: needs.review.outputs.has_actionable == 'true'
steps:
- uses: actions/download-artifact@v7
with:
name: ai-security-review
path: reports
- run: |
echo "actionable=${{ needs.review.outputs.actionable_count }}"
cat reports/summary.jsonPrefer a semver image tag (image: ghcr.io/solutionforest/ai-security-review:v0.3.0) or an immutable <commit-sha> pin for change control. See CHANGELOG.md.
| Artifact / output | Use |
|---|---|
review.json |
Full validated model report (coverage, findings, unique_findings, consensus, critic) |
summary.json |
Compact deduplicated counts for gating / dashboards |
review.sarif |
SARIF 2.1.0 for GitHub Code Scanning / PR annotations |
report.html |
Self-contained offline HTML viewer with filters, critic verdicts, and coverage matrix |
needs.review.outputs.* |
finding_count, unique_finding_count, actionable_count, has_actionable, reviewed_commit without downloading |
On GitHub, select Actions → AI Security Review → Run workflow, choose
main, and open the run. Download ai-security-review under Artifacts.
For a single model, check that review.json records the reviewed commit, the
model, the fixture path, and coverage entries for all ten OWASP categories. For
AI_REVIEW_MODELS, check per_model and consensus instead. A valid report can
contain an empty findings list. Keep the report private and triage any findings
before acting on them.
If the workflow stays queued, check that a fresh runner is online and matches all labels. If the review step reports a missing key, check the secret name and environment branch rule. HTTP 401 usually means the model credential needs checking. HTTP 404 can indicate an incorrect base URL or model ID. For an invalid report, verify the provider supports JSON object mode and retry with the synthetic fixture.
Build from a trusted reviewer checkout with
cargo +1.100.0 build --locked --release --bin ai-security-review.
Offline synthetic checks (no API key):
cargo +1.100.0 test --locked
python3 scripts/smoke-test.py target/debug/ai-security-reviewLive local gateway check (fixture + optional consensus / skills):
export AI_REVIEW_API_KEY='...'
export AI_REVIEW_BASE_URL='https://api.deepseek.com' # or your private gateway URL locally
python3 scripts/local-live-test.py \
--models deepseek-flash,deepseek-v4-pro \
--skills autoManual single-model or consensus runs from the reviewer checkout:
target/release/ai-security-review . "$(git rev-parse HEAD)" fixtures/policy.txt > review.json
export AI_REVIEW_MODELS='deepseek-flash,deepseek-v4-pro'
export AI_REVIEW_SKILLS=auto
target/release/ai-security-review . "$(git rev-parse HEAD)" fixtures/policy.txt > consensus.jsonFor real source, pass a separate local Git checkout, the full commit SHA, and 1–20 explicit UTF-8 paths relative to that repo. The total limit is 64 KiB. Review target files as data. Build and run the reviewer from its trusted checkout.
target/release/ai-security-review ../my-app "$TARGET_COMMIT" src/routes.rs src/auth.rs > review.jsonTo let the CLI pick changed source between two commits (risk-ranked, still capped at 20 files / 64 KiB):
target/release/ai-security-review ../my-app "$TARGET_COMMIT" --auto-diff "$BASE_COMMIT" > review.jsonFor the next stage after the fixture, choose one private pilot repo and a small
set of source files approved for the model. If Actions needs to fetch another
private repo, give that checkout narrowly scoped read access. The automatically
issued GITHUB_TOKEN is scoped to the workflow's repository.
GitHub token scope
See SKILLS.md for additional review guidance and AGENTS.md for maintainer and coding-agent instructions.




