@lhi/tdd-audit 1.15.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -39
- package/SKILL.md +6 -0
- package/docs/ai-remediation.md +114 -42
- package/docs/rest-api.md +144 -131
- package/docs/scanner.md +5 -3
- package/docs/vulnerability-patterns.md +241 -1
- package/index.js +40 -28
- package/lib/auditor.js +879 -0
- package/lib/badge.js +19 -5
- package/lib/config.js +13 -0
- package/lib/plugin.js +118 -23
- package/lib/reporter.js +6 -3
- package/lib/scanner.js +29 -0
- package/package.json +1 -1
- package/prompts/ai-security.md +329 -0
- package/prompts/auto-audit.md +270 -12
- package/prompts/node-advanced-security.md +394 -0
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# @lhi/tdd-audit
|
|
2
|
+

|
|
2
3
|
[](https://www.npmjs.com/package/@lhi/tdd-audit) <!-- tdd-audit-badge -->
|
|
3
4
|
|
|
4
|
-
> **v1.
|
|
5
|
+
> **v1.18.0** — AI-powered security audit skill for **Claude Code, Gemini CLI, Cursor, Codex, and OpenCode**. Four output depth tiers let you choose between a fast scan report, a rich findings report, copy-ready patches, or fully automated patch application — all backed by an agentic LLM with tool use.
|
|
5
6
|
|
|
6
7
|
## Install
|
|
7
8
|
|
|
@@ -11,11 +12,10 @@ npx @lhi/tdd-audit
|
|
|
11
12
|
|
|
12
13
|
On first run the installer:
|
|
13
14
|
|
|
14
|
-
1.
|
|
15
|
-
2.
|
|
16
|
-
3.
|
|
17
|
-
4.
|
|
18
|
-
5. Installs the `/tdd-audit` skill for your AI agent
|
|
15
|
+
1. Scaffolds `__tests__/security/` with a framework-matched exploit test boilerplate
|
|
16
|
+
2. Adds `test:security` to `package.json`
|
|
17
|
+
3. Creates `.github/workflows/security-tests.yml` with SHA-pinned actions and `npm audit`
|
|
18
|
+
4. Installs the `/tdd-audit` skill for your AI agent
|
|
19
19
|
|
|
20
20
|
### Flags
|
|
21
21
|
|
|
@@ -25,9 +25,6 @@ On first run the installer:
|
|
|
25
25
|
| `--claude` | Use `.claude/` instead of `.agents/` |
|
|
26
26
|
| `--with-hooks` | Add a pre-commit hook that blocks commits on failing security tests |
|
|
27
27
|
| `--skip-scan` | Skip the vulnerability scan on install |
|
|
28
|
-
| `--scan` / `--scan-only` | Scan only — no install, no code changes |
|
|
29
|
-
| `--json` | Output findings as JSON |
|
|
30
|
-
| `--format sarif` | Output findings as SARIF 2.1.0 (GitHub code scanning) |
|
|
31
28
|
| `--config <path>` | Load config from an explicit file path |
|
|
32
29
|
|
|
33
30
|
### Platform
|
|
@@ -37,13 +34,57 @@ On first run the installer:
|
|
|
37
34
|
| Claude Code | `npx @lhi/tdd-audit --local --claude` |
|
|
38
35
|
| Gemini CLI / Codex / OpenCode | `npx @lhi/tdd-audit --local` |
|
|
39
36
|
|
|
40
|
-
##
|
|
37
|
+
## AI Audit (`--ai`)
|
|
41
38
|
|
|
42
|
-
```
|
|
43
|
-
/tdd-audit
|
|
39
|
+
```bash
|
|
40
|
+
npx @lhi/tdd-audit --ai \
|
|
41
|
+
--provider anthropic \
|
|
42
|
+
--api-key $ANTHROPIC_API_KEY \
|
|
43
|
+
--depth tier-2 \
|
|
44
|
+
--format json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The `--ai` flag triggers a full agentic audit: the LLM explores your codebase using `read_file`, `list_files`, and `search_in_files` tool calls, then produces a structured findings report shaped by `--depth`.
|
|
48
|
+
|
|
49
|
+
### Depth tiers
|
|
50
|
+
|
|
51
|
+
| Tier | Mode | Output | Billing unit |
|
|
52
|
+
|---|---|---|---|
|
|
53
|
+
| `tier-1` | scan-only | `name`, `severity`, `file`, `line`, `snippet` | per report |
|
|
54
|
+
| `tier-2` | scan-only | + `risk`, `effort`, `cwe`, `owasp`, `references` | per report |
|
|
55
|
+
| `tier-3` | full audit, read-only | + `patch` (copy-ready), `testSnippet` | per report |
|
|
56
|
+
| `tier-4` | full audit, writes enabled | LLM applies patches via `write_file`; `patchesApplied` in envelope | per applied patch |
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Minimal scan report
|
|
60
|
+
npx @lhi/tdd-audit --ai --depth tier-1 --format json
|
|
61
|
+
|
|
62
|
+
# Rich report with CWE/OWASP/references — no changes made
|
|
63
|
+
npx @lhi/tdd-audit --ai --depth tier-2 --format json
|
|
64
|
+
|
|
65
|
+
# Copy-ready patches in every finding — apply manually
|
|
66
|
+
npx @lhi/tdd-audit --ai --depth tier-3 --format json
|
|
67
|
+
|
|
68
|
+
# Let the LLM apply the patches for you
|
|
69
|
+
npx @lhi/tdd-audit --ai --depth tier-4 --allow-writes
|
|
70
|
+
|
|
71
|
+
# Targeted apply: apply one specific patch from a prior tier-3 report
|
|
72
|
+
# (via REST API — see docs/rest-api.md)
|
|
44
73
|
```
|
|
45
74
|
|
|
46
|
-
|
|
75
|
+
### AI flags
|
|
76
|
+
|
|
77
|
+
| Flag | Description |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `--ai` | Enable LLM agentic audit |
|
|
80
|
+
| `--depth tier-1\|tier-2\|tier-3\|tier-4` | Output depth tier (default: `tier-1`) |
|
|
81
|
+
| `--allow-writes` | Permit the LLM to write files (auto-enabled for `tier-4`) |
|
|
82
|
+
| `--provider <name>` | `anthropic` \| `openai` \| `gemini` \| `ollama` |
|
|
83
|
+
| `--api-key <key>` | Provider API key |
|
|
84
|
+
| `--model <name>` | Model override (e.g. `claude-opus-4-6`, `gpt-4o`) |
|
|
85
|
+
| `--base-url <url>` | Base URL for any OpenAI-compatible service |
|
|
86
|
+
| `--format json\|sarif` | Structured output format (default: streaming text) |
|
|
87
|
+
| `--verbose` | Print tool call details to stderr |
|
|
47
88
|
|
|
48
89
|
## Config file
|
|
49
90
|
|
|
@@ -63,7 +104,7 @@ npx @lhi/tdd-audit init ~/configs/my-audit.json
|
|
|
63
104
|
"model": "gpt-4o",
|
|
64
105
|
"apiKeyEnv": "OPENAI_API_KEY",
|
|
65
106
|
"baseUrl": null,
|
|
66
|
-
"output": "
|
|
107
|
+
"output": "json",
|
|
67
108
|
"severityThreshold": "LOW",
|
|
68
109
|
"port": 3000,
|
|
69
110
|
"serverApiKey": null,
|
|
@@ -78,30 +119,36 @@ Point to a config anywhere with `--config`:
|
|
|
78
119
|
npx @lhi/tdd-audit serve --config ~/configs/prod-audit.json
|
|
79
120
|
```
|
|
80
121
|
|
|
81
|
-
## REST API
|
|
122
|
+
## REST API
|
|
82
123
|
|
|
83
124
|
```bash
|
|
84
|
-
# Start the API server
|
|
125
|
+
# Start the API server
|
|
85
126
|
npx @lhi/tdd-audit serve --port 3000 --api-key YOUR_SECRET
|
|
86
127
|
|
|
87
|
-
#
|
|
88
|
-
curl -X POST http://localhost:3000/
|
|
89
|
-
-H "Authorization: Bearer YOUR_SECRET" \
|
|
90
|
-
-d '{"path": "."}' | jq '.summary'
|
|
91
|
-
|
|
92
|
-
# Full automated pipeline: scan + remediate in one shot
|
|
93
|
-
curl -X POST http://localhost:3000/audit \
|
|
128
|
+
# AI audit — returns jobId immediately
|
|
129
|
+
curl -X POST http://localhost:3000/audit/ai \
|
|
94
130
|
-H "Authorization: Bearer YOUR_SECRET" \
|
|
95
131
|
-H "Content-Type: application/json" \
|
|
96
|
-
-d '{"
|
|
132
|
+
-d '{"provider": "anthropic", "apiKey": "sk-ant-...", "depth": "tier-2"}' \
|
|
97
133
|
| jq '.jobId'
|
|
98
134
|
|
|
99
135
|
# Poll job status
|
|
100
136
|
curl http://localhost:3000/jobs/<jobId>
|
|
101
137
|
|
|
102
|
-
# Or stream real-time
|
|
138
|
+
# Or stream real-time LLM output via SSE
|
|
103
139
|
curl -N http://localhost:3000/jobs/<jobId>/stream
|
|
104
140
|
|
|
141
|
+
# Targeted apply: re-apply a specific patch from a tier-3 report
|
|
142
|
+
curl -X POST http://localhost:3000/audit/ai \
|
|
143
|
+
-H "Authorization: Bearer YOUR_SECRET" \
|
|
144
|
+
-H "Content-Type: application/json" \
|
|
145
|
+
-d '{
|
|
146
|
+
"provider": "anthropic",
|
|
147
|
+
"apiKey": "sk-ant-...",
|
|
148
|
+
"depth": "tier-4",
|
|
149
|
+
"findings": [{ "name": "SQL Injection", "file": "src/db.js", "line": 10, "patch": "..." }]
|
|
150
|
+
}'
|
|
151
|
+
|
|
105
152
|
# Use any OpenAI-compatible service (Groq, OpenRouter, Together AI, etc.)
|
|
106
153
|
npx @lhi/tdd-audit serve \
|
|
107
154
|
--provider openai \
|
|
@@ -117,41 +164,40 @@ Supported providers: `anthropic` · `openai` · `gemini` · `ollama` (local) ·
|
|
|
117
164
|
| Method | Path | Auth | Description |
|
|
118
165
|
|---|---|---|---|
|
|
119
166
|
| `GET` | `/health` | No | Version + liveness check |
|
|
120
|
-
| `POST` | `/
|
|
121
|
-
| `POST` | `/remediate` | Yes | AI-fix a findings list; returns `jobId` |
|
|
122
|
-
| `POST` | `/audit` | Yes |
|
|
167
|
+
| `POST` | `/audit/ai` | Yes | Agentic LLM audit with depth tiers; returns `jobId` |
|
|
168
|
+
| `POST` | `/remediate` | Yes | AI-fix a provided findings list; returns `jobId` |
|
|
169
|
+
| `POST` | `/audit` | Yes | Static scan + AI remediation pipeline; returns `jobId` |
|
|
123
170
|
| `GET` | `/jobs/:id` | Yes | Poll job status |
|
|
124
171
|
| `GET` | `/jobs/:id/stream` | Yes | SSE stream — real-time job progress |
|
|
125
172
|
|
|
126
|
-
##
|
|
173
|
+
## Agent skill
|
|
127
174
|
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
npx @lhi/tdd-audit --scan --format sarif # GitHub code scanning (inline PR annotations)
|
|
131
|
-
npx @lhi/tdd-audit --scan # human-readable text (default)
|
|
175
|
+
```text
|
|
176
|
+
/tdd-audit
|
|
132
177
|
```
|
|
133
178
|
|
|
179
|
+
The agent detects your stack, presents a CRITICAL → LOW findings report, waits for confirmation, then works through each vulnerability one at a time using Red-Green-Refactor (prove the hole exists, apply the fix, prove it's closed). Enforces ≥ 95% test coverage, README badge, and SECURITY.md on every audit.
|
|
180
|
+
|
|
134
181
|
## Testing
|
|
135
182
|
|
|
136
|
-
|
|
183
|
+
791 tests across unit, E2E, and security suites:
|
|
137
184
|
|
|
138
185
|
```bash
|
|
139
186
|
npm test # full suite
|
|
140
|
-
npm run test:unit # unit tests with coverage (
|
|
187
|
+
npm run test:unit # unit tests with coverage (95.6% branch coverage)
|
|
141
188
|
npm run test:security # security regression tests only
|
|
142
189
|
npm run test:e2e # end-to-end REST API tests
|
|
143
190
|
```
|
|
144
191
|
|
|
145
|
-
Security tests cover prompt injection, path traversal, rate limiting, timing-safe auth, job store bounds, SARIF schema, and more. See [__tests__/security/](__tests__/security/) for all
|
|
192
|
+
Security tests cover prompt injection, path traversal, rate limiting, timing-safe auth, job store bounds, SARIF schema, and more. See [__tests__/security/](__tests__/security/) for all regression tests.
|
|
146
193
|
|
|
147
194
|
## Documentation
|
|
148
195
|
|
|
149
196
|
| | |
|
|
150
197
|
|---|---|
|
|
151
|
-
| [REST API](docs/rest-api.md) | Endpoints, auth, rate limiting,
|
|
198
|
+
| [REST API](docs/rest-api.md) | Endpoints, auth, rate limiting, depth tiers, targeted apply |
|
|
152
199
|
| [AI Remediation](docs/ai-remediation.md) | Provider setup, `--base-url` for compatible APIs, config file |
|
|
153
|
-
| [
|
|
154
|
-
| [Vulnerability Patterns](docs/vulnerability-patterns.md) | All 57 patterns — descriptions, grep signatures, fix pointers |
|
|
200
|
+
| [Vulnerability Patterns](docs/vulnerability-patterns.md) | All 79 patterns — descriptions, grep signatures, fix pointers |
|
|
155
201
|
| [TDD Protocol](docs/tdd-protocol.md) | Red-Green-Refactor in full, with framework templates for all 6 stacks |
|
|
156
202
|
| [Agentic AI Security](docs/agentic-ai-security.md) | ASI01–ASI10 — prompt injection, MCP supply chain, Actions injection |
|
|
157
203
|
| [Hardening](docs/hardening.md) | Phase 4 controls — Helmet, CSP, CSRF, rate limiting, gitleaks, SRI |
|
package/SKILL.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
---
|
|
2
|
+
# IMPORTANT CONSTRAINTS
|
|
3
|
+
# 1. NEVER add AI attribution trailers to commits (no "Co-Authored-By: Claude ..." lines).
|
|
4
|
+
# 2. NEVER add AI attribution to any file, comment, or commit message.
|
|
5
|
+
# 3. All commits must appear as human-authored work only.
|
|
2
6
|
name: TDD Remediation Protocol
|
|
3
7
|
description: A comprehensive toolkit for applying Red-Green-Refactor to fix security vulnerabilities.
|
|
4
8
|
category: security
|
|
@@ -12,6 +16,8 @@ audit_status: safe
|
|
|
12
16
|
|
|
13
17
|
# TDD Remediation Protocol
|
|
14
18
|
|
|
19
|
+
> **Non-negotiable rule:** Never add AI attribution to any commit, file, or comment. Do not append `Co-Authored-By`, `Generated by`, or any similar trailer. All commits must be plain, human-authored messages.
|
|
20
|
+
|
|
15
21
|
Applying Test-Driven Development (TDD) to code that has already been generated requires Test-Driven Remediation. You must prove the security hole exists by writing a test that exploits it, apply the fix, and then prove the hole is closed.
|
|
16
22
|
|
|
17
23
|
## Autonomous Audit Mode
|
package/docs/ai-remediation.md
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
# AI Remediation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`tdd-audit --ai` runs a fully agentic LLM audit: the model explores your codebase with tool calls, identifies vulnerabilities, and (depending on the depth tier) provides copy-ready patches or applies them directly. No agent shell required.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Depth tiers
|
|
8
|
+
|
|
9
|
+
| Tier | What you get | Writes files? | Billing unit |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `tier-1` | Scan report: name, severity, file, line, snippet | no | per report |
|
|
12
|
+
| `tier-2` | + risk, effort, CWE, OWASP category, references | no | per report |
|
|
13
|
+
| `tier-3` | + copy-ready `patch` and `testSnippet` per finding | no | per report |
|
|
14
|
+
| `tier-4` | LLM applies patches via `write_file`; `patchesApplied` count in envelope | yes | per applied patch |
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Fast scan report
|
|
18
|
+
npx @lhi/tdd-audit --ai --depth tier-1 --format json
|
|
19
|
+
|
|
20
|
+
# Rich report with CWE/OWASP — review and decide what to fix
|
|
21
|
+
npx @lhi/tdd-audit --ai --depth tier-2 --format json
|
|
22
|
+
|
|
23
|
+
# Patch included in every finding — copy and apply yourself
|
|
24
|
+
npx @lhi/tdd-audit --ai --depth tier-3 --format json
|
|
25
|
+
|
|
26
|
+
# Let the LLM write the fixes
|
|
27
|
+
npx @lhi/tdd-audit --ai --depth tier-4
|
|
28
|
+
```
|
|
4
29
|
|
|
5
30
|
---
|
|
6
31
|
|
|
@@ -25,13 +50,13 @@ Edit `.tdd-audit.json`:
|
|
|
25
50
|
`apiKeyEnv` names the environment variable to read the key from — no key ever touches disk. Then just:
|
|
26
51
|
|
|
27
52
|
```bash
|
|
28
|
-
npx @lhi/tdd-audit
|
|
53
|
+
npx @lhi/tdd-audit --ai --depth tier-2 --format json
|
|
29
54
|
```
|
|
30
55
|
|
|
31
56
|
Point to a config at any path:
|
|
32
57
|
|
|
33
58
|
```bash
|
|
34
|
-
npx @lhi/tdd-audit
|
|
59
|
+
npx @lhi/tdd-audit --ai --config ~/configs/my-audit.json --depth tier-3
|
|
35
60
|
```
|
|
36
61
|
|
|
37
62
|
---
|
|
@@ -40,15 +65,17 @@ npx @lhi/tdd-audit serve --config ~/configs/my-audit.json
|
|
|
40
65
|
|
|
41
66
|
```bash
|
|
42
67
|
# Anthropic
|
|
43
|
-
npx @lhi/tdd-audit
|
|
68
|
+
npx @lhi/tdd-audit --ai \
|
|
44
69
|
--provider anthropic \
|
|
45
|
-
--api-key $ANTHROPIC_API_KEY
|
|
70
|
+
--api-key $ANTHROPIC_API_KEY \
|
|
71
|
+
--depth tier-2
|
|
46
72
|
|
|
47
73
|
# OpenAI
|
|
48
|
-
npx @lhi/tdd-audit
|
|
74
|
+
npx @lhi/tdd-audit --ai \
|
|
49
75
|
--provider openai \
|
|
50
76
|
--api-key $OPENAI_API_KEY \
|
|
51
|
-
--model gpt-4o-mini
|
|
77
|
+
--model gpt-4o-mini \
|
|
78
|
+
--depth tier-1
|
|
52
79
|
```
|
|
53
80
|
|
|
54
81
|
---
|
|
@@ -60,28 +87,28 @@ The API key is sent in the `Authorization: Bearer` header — never in the URL.
|
|
|
60
87
|
|
|
61
88
|
```bash
|
|
62
89
|
# Groq (fast inference)
|
|
63
|
-
npx @lhi/tdd-audit
|
|
90
|
+
npx @lhi/tdd-audit --ai \
|
|
64
91
|
--provider openai \
|
|
65
92
|
--base-url https://api.groq.com/openai/v1 \
|
|
66
93
|
--model llama-3.3-70b-versatile \
|
|
67
94
|
--api-key $GROQ_API_KEY
|
|
68
95
|
|
|
69
96
|
# OpenRouter (access 200+ models)
|
|
70
|
-
npx @lhi/tdd-audit
|
|
97
|
+
npx @lhi/tdd-audit --ai \
|
|
71
98
|
--provider openai \
|
|
72
99
|
--base-url https://openrouter.ai/api/v1 \
|
|
73
100
|
--model meta-llama/llama-3.3-70b-instruct \
|
|
74
101
|
--api-key $OPENROUTER_API_KEY
|
|
75
102
|
|
|
76
103
|
# Together AI
|
|
77
|
-
npx @lhi/tdd-audit
|
|
104
|
+
npx @lhi/tdd-audit --ai \
|
|
78
105
|
--provider openai \
|
|
79
106
|
--base-url https://api.together.xyz/v1 \
|
|
80
107
|
--model mistralai/Mixtral-8x7B-Instruct-v0.1 \
|
|
81
108
|
--api-key $TOGETHER_API_KEY
|
|
82
109
|
|
|
83
110
|
# LM Studio / vLLM / llama.cpp (fully local)
|
|
84
|
-
npx @lhi/tdd-audit
|
|
111
|
+
npx @lhi/tdd-audit --ai \
|
|
85
112
|
--provider openai \
|
|
86
113
|
--base-url http://localhost:1234/v1 \
|
|
87
114
|
--model local-model
|
|
@@ -116,53 +143,95 @@ In `.tdd-audit.json`:
|
|
|
116
143
|
## REST API usage
|
|
117
144
|
|
|
118
145
|
```bash
|
|
119
|
-
#
|
|
120
|
-
|
|
121
|
-
-H "Authorization: Bearer $SERVER_KEY" \
|
|
122
|
-
-H "Content-Type: application/json" \
|
|
123
|
-
-d '{"path": "."}' | jq '.findings')
|
|
146
|
+
# Start the server
|
|
147
|
+
npx @lhi/tdd-audit serve --port 3000 --api-key $SERVER_KEY
|
|
124
148
|
|
|
125
|
-
# 2
|
|
126
|
-
JOB=$(curl -s -X POST http://localhost:3000/
|
|
149
|
+
# Launch a tier-2 audit job
|
|
150
|
+
JOB=$(curl -s -X POST http://localhost:3000/audit/ai \
|
|
127
151
|
-H "Authorization: Bearer $SERVER_KEY" \
|
|
128
152
|
-H "Content-Type: application/json" \
|
|
129
153
|
-d "{
|
|
130
|
-
\"findings\": $FINDINGS,
|
|
131
154
|
\"provider\": \"openai\",
|
|
132
|
-
\"apiKey\":
|
|
133
|
-
\"baseUrl\":
|
|
134
|
-
\"model\":
|
|
135
|
-
\"
|
|
136
|
-
}")
|
|
155
|
+
\"apiKey\": \"$GROQ_API_KEY\",
|
|
156
|
+
\"baseUrl\": \"https://api.groq.com/openai/v1\",
|
|
157
|
+
\"model\": \"llama-3.3-70b-versatile\",
|
|
158
|
+
\"depth\": \"tier-2\"
|
|
159
|
+
}" | jq -r '.jobId')
|
|
160
|
+
|
|
161
|
+
# Poll until done
|
|
162
|
+
while true; do
|
|
163
|
+
STATUS=$(curl -s http://localhost:3000/jobs/$JOB \
|
|
164
|
+
-H "Authorization: Bearer $SERVER_KEY" | jq -r '.status')
|
|
165
|
+
[ "$STATUS" = "done" ] || [ "$STATUS" = "error" ] && break
|
|
166
|
+
sleep 3
|
|
167
|
+
done
|
|
168
|
+
|
|
169
|
+
# Print summary
|
|
170
|
+
curl -s http://localhost:3000/jobs/$JOB \
|
|
171
|
+
-H "Authorization: Bearer $SERVER_KEY" | jq '.result.summary'
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Targeted apply (tier-4)
|
|
137
175
|
|
|
138
|
-
|
|
176
|
+
Take a single finding from a tier-3 report and apply its patch without re-scanning:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Get the first finding from a previous tier-3 job
|
|
180
|
+
FINDING=$(curl -s http://localhost:3000/jobs/$TIER3_JOB_ID \
|
|
181
|
+
-H "Authorization: Bearer $SERVER_KEY" \
|
|
182
|
+
| jq '.result.findings[0]')
|
|
139
183
|
|
|
140
|
-
#
|
|
141
|
-
curl -s
|
|
142
|
-
-H "Authorization: Bearer $SERVER_KEY"
|
|
184
|
+
# Apply only that patch
|
|
185
|
+
curl -s -X POST http://localhost:3000/audit/ai \
|
|
186
|
+
-H "Authorization: Bearer $SERVER_KEY" \
|
|
187
|
+
-H "Content-Type: application/json" \
|
|
188
|
+
-d "{
|
|
189
|
+
\"provider\": \"anthropic\",
|
|
190
|
+
\"apiKey\": \"$ANTHROPIC_API_KEY\",
|
|
191
|
+
\"depth\": \"tier-4\",
|
|
192
|
+
\"findings\": [$FINDING]
|
|
193
|
+
}" | jq '.jobId'
|
|
143
194
|
```
|
|
144
195
|
|
|
196
|
+
See [REST API](rest-api.md) for the full endpoint reference.
|
|
197
|
+
|
|
145
198
|
---
|
|
146
199
|
|
|
147
|
-
##
|
|
200
|
+
## Output envelope
|
|
148
201
|
|
|
149
|
-
|
|
202
|
+
All structured output (`--format json` or via REST API) returns the same envelope shape regardless of tier:
|
|
150
203
|
|
|
151
204
|
```json
|
|
152
205
|
{
|
|
153
|
-
"
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
"
|
|
206
|
+
"version": "1.17.0",
|
|
207
|
+
"provider": "anthropic",
|
|
208
|
+
"model": "claude-opus-4-6",
|
|
209
|
+
"depth": "tier-3",
|
|
210
|
+
"mode": "full",
|
|
211
|
+
"stack": "Node.js / Express",
|
|
212
|
+
"summary": { "CRITICAL": 0, "HIGH": 1, "MEDIUM": 2, "LOW": 0 },
|
|
213
|
+
"patchesApplied": 0,
|
|
214
|
+
"findings": [
|
|
215
|
+
{
|
|
216
|
+
"name": "SQL Injection",
|
|
217
|
+
"severity": "HIGH",
|
|
218
|
+
"file": "src/db.js",
|
|
219
|
+
"line": 42,
|
|
220
|
+
"snippet": "db.query(userInput)",
|
|
221
|
+
"risk": "Full database read/write via UNION injection",
|
|
222
|
+
"effort": "low",
|
|
223
|
+
"cwe": "CWE-89",
|
|
224
|
+
"patch": "const stmt = db.prepare('SELECT ...');\nstmt.run(id);",
|
|
225
|
+
"testSnippet": "test('prevents injection', () => { ... });"
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"likelyFalsePositives": [],
|
|
229
|
+
"remediation": [],
|
|
230
|
+
"scannedAt": "2026-03-26T12:00:00.000Z"
|
|
162
231
|
}
|
|
163
232
|
```
|
|
164
233
|
|
|
165
|
-
|
|
234
|
+
`patchesApplied` is always `0` for tiers 1–3 (no files written). For tier-4 it counts `remediation` entries where `status === "fixed"` — the billable unit.
|
|
166
235
|
|
|
167
236
|
---
|
|
168
237
|
|
|
@@ -174,9 +243,12 @@ ollama pull codellama
|
|
|
174
243
|
ollama serve
|
|
175
244
|
|
|
176
245
|
# Run tdd-audit against it
|
|
177
|
-
npx @lhi/tdd-audit
|
|
246
|
+
npx @lhi/tdd-audit --ai \
|
|
178
247
|
--provider ollama \
|
|
179
|
-
--model codellama
|
|
248
|
+
--model codellama \
|
|
249
|
+
--depth tier-1
|
|
180
250
|
```
|
|
181
251
|
|
|
182
252
|
No API key required. Ollama must be running on `http://localhost:11434`.
|
|
253
|
+
|
|
254
|
+
Ollama does not support the tool-use API, so the audit runs in single-shot mode: the project files are bundled into the prompt rather than explored interactively with tool calls. For best results, use `tier-1` or `tier-2` with Ollama.
|