@bouncesecurity/aghast 0.0.13 → 0.2.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 +8 -6
- package/config/prompts/generic-instructions.md +2 -0
- package/config/prompts/openant-security-instructions.md +94 -0
- package/config/prompts/sarif-validation-instructions.md +58 -0
- package/dist/check-library.d.ts.map +1 -1
- package/dist/check-library.js +61 -7
- package/dist/check-library.js.map +1 -1
- package/dist/check-types.d.ts +35 -0
- package/dist/check-types.d.ts.map +1 -0
- package/dist/check-types.js +66 -0
- package/dist/check-types.js.map +1 -0
- package/dist/claude-code-provider.d.ts +4 -1
- package/dist/claude-code-provider.d.ts.map +1 -1
- package/dist/claude-code-provider.js +23 -8
- package/dist/claude-code-provider.js.map +1 -1
- package/dist/discoveries/openant-discovery.d.ts +10 -0
- package/dist/discoveries/openant-discovery.d.ts.map +1 -0
- package/dist/discoveries/openant-discovery.js +44 -0
- package/dist/discoveries/openant-discovery.js.map +1 -0
- package/dist/discoveries/sarif-discovery.d.ts +9 -0
- package/dist/discoveries/sarif-discovery.d.ts.map +1 -0
- package/dist/discoveries/sarif-discovery.js +55 -0
- package/dist/discoveries/sarif-discovery.js.map +1 -0
- package/dist/discoveries/semgrep-discovery.d.ts +9 -0
- package/dist/discoveries/semgrep-discovery.d.ts.map +1 -0
- package/dist/discoveries/semgrep-discovery.js +51 -0
- package/dist/discoveries/semgrep-discovery.js.map +1 -0
- package/dist/discovery.d.ts +74 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +41 -0
- package/dist/discovery.js.map +1 -0
- package/dist/error-codes.d.ts +3 -1
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error-codes.js +4 -1
- package/dist/error-codes.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +123 -30
- package/dist/index.js.map +1 -1
- package/dist/logging.d.ts +108 -8
- package/dist/logging.d.ts.map +1 -1
- package/dist/logging.js +269 -43
- package/dist/logging.js.map +1 -1
- package/dist/mock-ai-provider.d.ts +4 -1
- package/dist/mock-ai-provider.d.ts.map +1 -1
- package/dist/mock-ai-provider.js +4 -1
- package/dist/mock-ai-provider.js.map +1 -1
- package/dist/new-check.d.ts.map +1 -1
- package/dist/new-check.js +81 -33
- package/dist/new-check.js.map +1 -1
- package/dist/openant-loader.d.ts +105 -0
- package/dist/openant-loader.d.ts.map +1 -0
- package/dist/openant-loader.js +135 -0
- package/dist/openant-loader.js.map +1 -0
- package/dist/openant-runner.d.ts +22 -0
- package/dist/openant-runner.d.ts.map +1 -0
- package/dist/openant-runner.js +102 -0
- package/dist/openant-runner.js.map +1 -0
- package/dist/runtime-config.d.ts.map +1 -1
- package/dist/runtime-config.js +15 -0
- package/dist/runtime-config.js.map +1 -1
- package/dist/scan-runner.d.ts.map +1 -1
- package/dist/scan-runner.js +175 -143
- package/dist/scan-runner.js.map +1 -1
- package/dist/types.d.ts +24 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -18,11 +18,11 @@ Define static rules, security checks as markdown instructions, point AGHAST at a
|
|
|
18
18
|
|
|
19
19
|
## What AGHAST Does
|
|
20
20
|
|
|
21
|
-
You can read the full background to this tool in our blogpost [here](https://bouncesecurity.com/aghast) but, to cut to the chase, AGHAST
|
|
21
|
+
You can read the full background to this tool in our blogpost [here](https://bouncesecurity.com/aghast) but, to cut to the chase, AGHAST uses three core mechanisms:
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
23
|
+
- **Repository-wide AI analysis** — let the LLM analyze the whole repo against your security check instructions
|
|
24
|
+
- **Targeted checks** — a pluggable discovery method (Semgrep rules, [OpenAnt](https://github.com/knostic/OpenAnt/) code units, or external SARIF findings) identifies specific code locations, then AI analyzes each independently. This is the sweet spot for most use cases
|
|
25
|
+
- **Static checks** — a discovery method (e.g., Semgrep) finds issues mapped directly to results with no AI involvement, for when a traditional static rule is all you need
|
|
26
26
|
|
|
27
27
|
The beauty of the approach is what you *don't* need:
|
|
28
28
|
|
|
@@ -41,8 +41,9 @@ There are almost certainly other ways of achieving this, but to our mind, this a
|
|
|
41
41
|
## Prerequisites
|
|
42
42
|
|
|
43
43
|
- **Node.js 20+**
|
|
44
|
-
- **[Semgrep Community Edition](https://semgrep.dev/docs/getting-started/)** (LGPL-2.1, optional) — only needed for checks that use Semgrep
|
|
45
|
-
- **
|
|
44
|
+
- **[Semgrep Community Edition](https://semgrep.dev/docs/getting-started/)** (LGPL-2.1, optional) — only needed for checks that use Semgrep discovery
|
|
45
|
+
- **[OpenAnt](https://github.com/knostic/OpenAnt/)** (Apache-2.0, optional) + **Python 3.11+** — only needed for checks that use OpenAnt discovery
|
|
46
|
+
- **Anthropic API key** — for AI-based checks (not needed for static checks)
|
|
46
47
|
|
|
47
48
|
## Installation
|
|
48
49
|
|
|
@@ -95,6 +96,7 @@ Results are structured JSON (or SARIF) with per-check status and detailed issues
|
|
|
95
96
|
## Documentation
|
|
96
97
|
|
|
97
98
|
- [Getting Started](docs/getting-started.md) — installation, setup, and first scan
|
|
99
|
+
- [Trying It Out](docs/trying-it-out.md) — example checks walkthrough and first scan guide
|
|
98
100
|
- [Scanning](docs/scanning.md) — scan command options, environment variables, output formats
|
|
99
101
|
- [Creating Checks](docs/creating-checks.md) — scaffolding new security checks
|
|
100
102
|
- [Configuration Reference](docs/configuration.md) — check schemas, check types, runtime config
|
|
@@ -3,10 +3,12 @@ GENERIC INSTRUCTIONS:
|
|
|
3
3
|
You are performing a SPECIFIC security check as defined in the CHECK INSTRUCTIONS below.
|
|
4
4
|
|
|
5
5
|
IMPORTANT:
|
|
6
|
+
- All file paths are relative to your working directory. Use them directly with the Read tool (e.g., Read "src/routes/handler.ts"). Do NOT prepend "/" or construct absolute paths.
|
|
6
7
|
- Focus ONLY on what the CHECK INSTRUCTIONS ask you to validate
|
|
7
8
|
- Do NOT perform general security testing or look for unrelated vulnerabilities
|
|
8
9
|
- Do NOT report issues outside the scope of the specific check
|
|
9
10
|
- Follow the CHECK INSTRUCTIONS exactly as written
|
|
11
|
+
- Be efficient — read only the files necessary to complete the check. Do not exhaustively explore the entire codebase.
|
|
10
12
|
|
|
11
13
|
OUTPUT FORMAT:
|
|
12
14
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
GENERIC INSTRUCTIONS:
|
|
2
|
+
|
|
3
|
+
You are performing a security review of a specific code unit within a live codebase that you can browse.
|
|
4
|
+
Your job is to read the actual source code, follow the data flow, and determine whether the unit
|
|
5
|
+
contains real, exploitable security vulnerabilities. Form your own independent judgment based on the code.
|
|
6
|
+
|
|
7
|
+
IMPORTANT:
|
|
8
|
+
- All file paths in the UNIT DETAILS section are relative to your working directory. Use them directly (e.g., Read "routes/orders.js"). Do NOT prepend "/" or construct absolute paths.
|
|
9
|
+
- START by reading the target file at the specified location using your file-reading tools
|
|
10
|
+
- USE the caller/callee metadata to trace data flow — read those functions to understand how input reaches this code and where output goes
|
|
11
|
+
- Be efficient — once you have enough information from the target file and 1-2 direct dependencies, stop and report. Do not exhaustively explore the entire codebase.
|
|
12
|
+
- If no issues are found, return {"issues": []} immediately — do not keep searching for problems.
|
|
13
|
+
- Report issues ONLY for the target unit location — do not report unrelated issues found while browsing
|
|
14
|
+
|
|
15
|
+
ANALYSIS APPROACH:
|
|
16
|
+
|
|
17
|
+
For each code unit, ask yourself:
|
|
18
|
+
- What can an attacker control? (request body, URL params, headers, query strings)
|
|
19
|
+
- Where does that input end up? (database queries, HTTP requests, file operations, authorization decisions)
|
|
20
|
+
- What guarantees does the code assume but not enforce? (atomicity, ownership, trust boundaries, data types)
|
|
21
|
+
- Are multi-step operations safe if executed concurrently by multiple users?
|
|
22
|
+
|
|
23
|
+
BEFORE REPORTING — VALIDATE EACH FINDING:
|
|
24
|
+
|
|
25
|
+
Before including any issue in your response, you MUST be able to answer YES to all of these:
|
|
26
|
+
1. Can I construct a specific HTTP request (or sequence of requests) that triggers this vulnerability?
|
|
27
|
+
2. After the exploit, what specific harm has occurred? Name ONE of: unauthorized data accessed, unauthorized action performed, authentication/authorization bypassed, server made to contact an attacker-controlled or internal endpoint, arbitrary code/query executed. If the harm is only "bad data in a database" (wrong types, negative numbers) with no further security consequence in this codebase, it is NOT a finding.
|
|
28
|
+
3. Does the exploit work against THIS codebase as written — including all middleware, route registrations, and existing validation? Do not ignore protections that exist outside the function body (e.g., middleware applied at route registration time).
|
|
29
|
+
|
|
30
|
+
If you cannot answer YES to all three, do not report the issue.
|
|
31
|
+
|
|
32
|
+
WHAT COUNTS AS A FINDING:
|
|
33
|
+
|
|
34
|
+
Only report vulnerabilities that meet ALL of these criteria:
|
|
35
|
+
- The vulnerability is exploitable by an attacker who can reach the endpoint (not just theoretical)
|
|
36
|
+
- The vulnerability leads to a concrete security impact (data breach, unauthorized access, privilege escalation, code execution, etc.)
|
|
37
|
+
- The vulnerability exists in the code AS WRITTEN — do not speculate about missing features, future code, or how the code might be used differently
|
|
38
|
+
- The impact is demonstrated end-to-end in THIS codebase — not dependent on hypothetical downstream consumers of stored data
|
|
39
|
+
|
|
40
|
+
Do NOT report:
|
|
41
|
+
- Missing input validation that has no security impact (e.g., missing length checks, type checks, or negative number checks unless they lead to a specific exploit like bypassing authorization)
|
|
42
|
+
- Information disclosure via error messages (e.g., leaking product names or stock counts in error responses) unless it exposes credentials or secrets
|
|
43
|
+
- Missing rate limiting or DoS concerns — these are operational, not application security vulnerabilities
|
|
44
|
+
- Code quality issues, defense-in-depth suggestions, or best-practice violations
|
|
45
|
+
- Vulnerabilities that require the attacker to already have the access they would gain (e.g., admin-only endpoint lacks additional validation)
|
|
46
|
+
|
|
47
|
+
OUTPUT FORMAT:
|
|
48
|
+
|
|
49
|
+
Return your findings in the following JSON format:
|
|
50
|
+
|
|
51
|
+
{
|
|
52
|
+
"issues": [
|
|
53
|
+
{
|
|
54
|
+
"file": "relative/path/to/file.ts",
|
|
55
|
+
"startLine": 40,
|
|
56
|
+
"endLine": 45,
|
|
57
|
+
"description": "Detailed explanation (see requirements below)",
|
|
58
|
+
"dataFlow": [
|
|
59
|
+
{ "file": "src/routes/handler.ts", "lineNumber": 12, "label": "User input received from request parameter" },
|
|
60
|
+
{ "file": "src/services/query.ts", "lineNumber": 38, "label": "Input passed to SQL query without sanitization" }
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
DESCRIPTION FORMATTING REQUIREMENTS:
|
|
67
|
+
|
|
68
|
+
Your description field MUST be detailed and well-structured:
|
|
69
|
+
- Use markdown formatting with headings (## Heading), bullet points, code blocks
|
|
70
|
+
- Use \n for line breaks to create structured, readable content
|
|
71
|
+
- Include an "Attack Scenario" section demonstrating exploitation
|
|
72
|
+
- Include a "Recommendation" section with specific remediation steps
|
|
73
|
+
|
|
74
|
+
DATA FLOW REQUIREMENTS:
|
|
75
|
+
|
|
76
|
+
When the issue involves data flowing through multiple locations (e.g., user input reaching a dangerous sink), include a "dataFlow" array. Each step represents a point in the call stack or data flow:
|
|
77
|
+
- "file": relative path to the source file
|
|
78
|
+
- "lineNumber": the line number at that step
|
|
79
|
+
- "label": a short description of what happens at this point (e.g., "User input received", "Passed to database query")
|
|
80
|
+
- Order steps from source (e.g., user input) to sink (e.g., SQL execution)
|
|
81
|
+
- Omit "dataFlow" entirely if the issue is localized to a single location
|
|
82
|
+
|
|
83
|
+
CRITICAL: Return ONLY valid JSON. No markdown code blocks, no explanations outside the JSON.
|
|
84
|
+
|
|
85
|
+
If no issues found, return: {"issues": []}
|
|
86
|
+
|
|
87
|
+
If a UNIT DETAILS section appears at the end of this prompt, analyze ONLY that code unit.
|
|
88
|
+
|
|
89
|
+
If CHECK INSTRUCTIONS appear below, follow them to narrow your analysis to a specific vulnerability class.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
CHECK INSTRUCTIONS:
|
|
94
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
GENERIC INSTRUCTIONS:
|
|
2
|
+
|
|
3
|
+
You are validating a security finding reported by an external tool. Your task is to determine whether this finding is a TRUE POSITIVE (real vulnerability) or a FALSE POSITIVE (not actually vulnerable).
|
|
4
|
+
|
|
5
|
+
IMPORTANT:
|
|
6
|
+
- All file paths are relative to your working directory. Use them directly with the Read tool (e.g., Read "src/routes/handler.ts"). Do NOT prepend "/" or construct absolute paths.
|
|
7
|
+
- Focus ONLY on validating the specific finding described below
|
|
8
|
+
- Read the actual code at the specified location and surrounding context
|
|
9
|
+
- Consider the full context: data flow, sanitization, framework protections, etc.
|
|
10
|
+
- Be efficient — read only the files necessary to validate the finding.
|
|
11
|
+
- If TRUE POSITIVE (real vulnerability), return it as an issue with your own detailed description
|
|
12
|
+
- If FALSE POSITIVE (not actually vulnerable), return {"issues": []}
|
|
13
|
+
- Do NOT search for or report other vulnerabilities — only validate the specific finding
|
|
14
|
+
|
|
15
|
+
OUTPUT FORMAT:
|
|
16
|
+
|
|
17
|
+
Return your findings in the following JSON format:
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
"issues": [
|
|
21
|
+
{
|
|
22
|
+
"file": "relative/path/to/file.ts",
|
|
23
|
+
"startLine": 40,
|
|
24
|
+
"endLine": 45,
|
|
25
|
+
"description": "Detailed explanation (see requirements below)",
|
|
26
|
+
"dataFlow": [
|
|
27
|
+
{ "file": "src/routes/handler.ts", "lineNumber": 12, "label": "User input received from request parameter" },
|
|
28
|
+
{ "file": "src/services/query.ts", "lineNumber": 38, "label": "Input passed to SQL query without sanitization" }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
DESCRIPTION FORMATTING REQUIREMENTS:
|
|
35
|
+
|
|
36
|
+
Your description field MUST be detailed and well-structured:
|
|
37
|
+
- Use markdown formatting with headings (## Heading), bullet points, code blocks
|
|
38
|
+
- Use \n for line breaks to create structured, readable content
|
|
39
|
+
- Include an "Attack Scenario" section demonstrating exploitation
|
|
40
|
+
- Include a "Recommendation" section with specific remediation steps
|
|
41
|
+
|
|
42
|
+
DATA FLOW REQUIREMENTS:
|
|
43
|
+
|
|
44
|
+
When the issue involves data flowing through multiple locations (e.g., user input reaching a dangerous sink), include a "dataFlow" array. Each step represents a point in the call stack or data flow:
|
|
45
|
+
- "file": relative path to the source file
|
|
46
|
+
- "lineNumber": the line number at that step
|
|
47
|
+
- "label": a short description of what happens at this point (e.g., "User input received", "Passed to database query")
|
|
48
|
+
- Order steps from source (e.g., user input) to sink (e.g., SQL execution)
|
|
49
|
+
- Omit "dataFlow" entirely if the issue is localized to a single location
|
|
50
|
+
|
|
51
|
+
CRITICAL: Return ONLY valid JSON. No markdown code blocks, no explanations outside the JSON.
|
|
52
|
+
|
|
53
|
+
If the finding is a false positive (not actually vulnerable), return: {"issues": []}
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
ADDITIONAL CONTEXT:
|
|
58
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-library.d.ts","sourceRoot":"","sources":["../src/check-library.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAChB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"check-library.d.ts","sourceRoot":"","sources":["../src/check-library.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAChB,MAAM,YAAY,CAAC;AAKpB,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA0DjF;AAID;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,eAAe,EAAE,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;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EAAE,EACf,eAAe,CAAC,EAAE,MAAM,EAAE,GACzB,MAAM,EAAE,CAOV;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EAAE,EACf,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,MAAM,EAAE,CAOV;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,aAAa,GACnB,MAAM,EAAE,CAGV"}
|
package/dist/check-library.js
CHANGED
|
@@ -8,6 +8,7 @@ import { readFile, readdir, access, constants } from 'node:fs/promises';
|
|
|
8
8
|
import { resolve, join, basename } from 'node:path';
|
|
9
9
|
import picomatch from 'picomatch';
|
|
10
10
|
import { normalizeRepoPath } from './repository-analyzer.js';
|
|
11
|
+
import { getCheckType, getValidCheckTypes } from './check-types.js';
|
|
11
12
|
/**
|
|
12
13
|
* Load and parse the Layer 1 registry from <configDir>/checks-config.json.
|
|
13
14
|
* Throws on missing file, malformed JSON, or invalid structure.
|
|
@@ -97,6 +98,9 @@ export async function loadCheckDefinition(checkFolderPath) {
|
|
|
97
98
|
if (obj.confidence !== undefined && typeof obj.confidence !== 'string') {
|
|
98
99
|
throw new Error(`Check definition "${defPath}": "confidence" must be a string`);
|
|
99
100
|
}
|
|
101
|
+
if (obj.model !== undefined && typeof obj.model !== 'string') {
|
|
102
|
+
throw new Error(`Check definition "${defPath}": "model" must be a string`);
|
|
103
|
+
}
|
|
100
104
|
if (obj.applicablePaths !== undefined && !Array.isArray(obj.applicablePaths)) {
|
|
101
105
|
throw new Error(`Check definition "${defPath}": "applicablePaths" must be an array`);
|
|
102
106
|
}
|
|
@@ -108,7 +112,7 @@ export async function loadCheckDefinition(checkFolderPath) {
|
|
|
108
112
|
throw new Error(`Check definition "${defPath}": "checkTarget" must be an object`);
|
|
109
113
|
}
|
|
110
114
|
const ct = obj.checkTarget;
|
|
111
|
-
const validTypes =
|
|
115
|
+
const validTypes = getValidCheckTypes();
|
|
112
116
|
if (typeof ct.type !== 'string' || !validTypes.includes(ct.type)) {
|
|
113
117
|
throw new Error(`Check definition "${defPath}": "checkTarget.type" must be one of: ${validTypes.join(', ')}`);
|
|
114
118
|
}
|
|
@@ -124,11 +128,55 @@ export async function loadCheckDefinition(checkFolderPath) {
|
|
|
124
128
|
if (ct.concurrency !== undefined && (typeof ct.concurrency !== 'number' || ct.concurrency <= 0 || !Number.isInteger(ct.concurrency))) {
|
|
125
129
|
throw new Error(`Check definition "${defPath}": "checkTarget.concurrency" must be a positive integer`);
|
|
126
130
|
}
|
|
131
|
+
// Validate discovery field for targeted/static types
|
|
132
|
+
if (ct.type === 'targeted' || ct.type === 'static') {
|
|
133
|
+
const validDiscoveries = ct.type === 'targeted' ? ['semgrep', 'openant', 'sarif'] : ['semgrep'];
|
|
134
|
+
if (typeof ct.discovery !== 'string' || !validDiscoveries.includes(ct.discovery)) {
|
|
135
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.discovery" is required for type "${ct.type}" and must be one of: ${validDiscoveries.join(', ')}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (ct.sarifFile !== undefined && typeof ct.sarifFile !== 'string') {
|
|
139
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.sarifFile" must be a string`);
|
|
140
|
+
}
|
|
141
|
+
if (ct.discovery === 'sarif' && !ct.sarifFile) {
|
|
142
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.sarifFile" is required when discovery is "sarif"`);
|
|
143
|
+
}
|
|
144
|
+
// Validate openant filter config
|
|
145
|
+
if (ct.openant !== undefined) {
|
|
146
|
+
if (typeof ct.openant !== 'object' || ct.openant === null) {
|
|
147
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.openant" must be an object`);
|
|
148
|
+
}
|
|
149
|
+
const oa = ct.openant;
|
|
150
|
+
if (oa.unitTypes !== undefined && !Array.isArray(oa.unitTypes)) {
|
|
151
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.openant.unitTypes" must be an array`);
|
|
152
|
+
}
|
|
153
|
+
if (oa.excludeUnitTypes !== undefined && !Array.isArray(oa.excludeUnitTypes)) {
|
|
154
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.openant.excludeUnitTypes" must be an array`);
|
|
155
|
+
}
|
|
156
|
+
if (oa.securityClassifications !== undefined && !Array.isArray(oa.securityClassifications)) {
|
|
157
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.openant.securityClassifications" must be an array`);
|
|
158
|
+
}
|
|
159
|
+
if (oa.reachableOnly !== undefined && typeof oa.reachableOnly !== 'boolean') {
|
|
160
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.openant.reachableOnly" must be a boolean`);
|
|
161
|
+
}
|
|
162
|
+
if (oa.entryPointsOnly !== undefined && typeof oa.entryPointsOnly !== 'boolean') {
|
|
163
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.openant.entryPointsOnly" must be a boolean`);
|
|
164
|
+
}
|
|
165
|
+
if (oa.minConfidence !== undefined && (typeof oa.minConfidence !== 'number' || oa.minConfidence < 0 || oa.minConfidence > 1)) {
|
|
166
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.openant.minConfidence" must be a number between 0 and 1`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
127
169
|
}
|
|
128
170
|
const def = parsed;
|
|
129
|
-
// instructionsFile is required for
|
|
130
|
-
|
|
131
|
-
|
|
171
|
+
// instructionsFile is required for check types where needsInstructions is true,
|
|
172
|
+
// UNLESS the discovery type provides a self-contained generic prompt.
|
|
173
|
+
// Discovery types with self-contained prompts (openant, sarif) don't need instructions.
|
|
174
|
+
const SELF_CONTAINED_DISCOVERIES = new Set(['openant', 'sarif']);
|
|
175
|
+
const discoveryIsSelfContained = def.checkTarget?.discovery
|
|
176
|
+
? SELF_CONTAINED_DISCOVERIES.has(def.checkTarget.discovery)
|
|
177
|
+
: false;
|
|
178
|
+
if (getCheckType(def.checkTarget?.type).needsInstructions && !discoveryIsSelfContained && !def.instructionsFile) {
|
|
179
|
+
throw new Error(`Check definition "${defPath}" is missing required field "instructionsFile"`);
|
|
132
180
|
}
|
|
133
181
|
return def;
|
|
134
182
|
}
|
|
@@ -192,6 +240,8 @@ export async function resolveChecks(registry, checkFolders) {
|
|
|
192
240
|
merged.severity = def.severity;
|
|
193
241
|
if (def.confidence)
|
|
194
242
|
merged.confidence = def.confidence;
|
|
243
|
+
if (def.model)
|
|
244
|
+
merged.model = def.model;
|
|
195
245
|
if (def.applicablePaths)
|
|
196
246
|
merged.applicablePaths = def.applicablePaths;
|
|
197
247
|
if (def.excludedPaths)
|
|
@@ -251,9 +301,13 @@ export async function validateCheck(check, basePath) {
|
|
|
251
301
|
if (!check.id || typeof check.id !== 'string' || check.id.trim() === '') {
|
|
252
302
|
errors.push('Check is missing a valid "id" field');
|
|
253
303
|
}
|
|
254
|
-
//
|
|
255
|
-
|
|
256
|
-
|
|
304
|
+
// Discovery types with self-contained generic prompts don't need instructions
|
|
305
|
+
const SELF_CONTAINED_DISCOVERIES_V = new Set(['openant', 'sarif']);
|
|
306
|
+
const discoverySelfContained = check.checkTarget?.discovery
|
|
307
|
+
? SELF_CONTAINED_DISCOVERIES_V.has(check.checkTarget.discovery)
|
|
308
|
+
: false;
|
|
309
|
+
if (!getCheckType(check.checkTarget?.type).needsInstructions || discoverySelfContained) {
|
|
310
|
+
// No instructionsFile validation needed for this check type/discovery
|
|
257
311
|
}
|
|
258
312
|
else if (!check.instructionsFile) {
|
|
259
313
|
errors.push('Check is missing required "instructionsFile" field');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-library.js","sourceRoot":"","sources":["../src/check-library.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,IAAI,E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UAAU,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check type descriptor system.
|
|
3
|
+
*
|
|
4
|
+
* Each check type declares its characteristics (needs AI, needs instructions, etc.)
|
|
5
|
+
* in one place. Code throughout the codebase queries these descriptors instead
|
|
6
|
+
* of comparing raw type strings.
|
|
7
|
+
*
|
|
8
|
+
* Check types describe *execution mode* (what happens with targets).
|
|
9
|
+
* Discovery type (how targets are found) is a separate axis — see src/discovery.ts.
|
|
10
|
+
*/
|
|
11
|
+
/** Characteristics of a check type. */
|
|
12
|
+
export interface CheckTypeDescriptor {
|
|
13
|
+
/** The string value used in check definitions. */
|
|
14
|
+
readonly type: string;
|
|
15
|
+
/** Whether the check requires an AI provider. */
|
|
16
|
+
readonly needsAI: boolean;
|
|
17
|
+
/** Whether the check requires an instructions markdown file. */
|
|
18
|
+
readonly needsInstructions: boolean;
|
|
19
|
+
/** Whether the check supports maxTargets (multi-target checks). */
|
|
20
|
+
readonly supportsMaxTargets: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the descriptor for a check type string.
|
|
24
|
+
* Returns conservative defaults for unknown/undefined types.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getCheckType(type: string | undefined): CheckTypeDescriptor;
|
|
27
|
+
/** All valid check type strings. */
|
|
28
|
+
export declare function getValidCheckTypes(): string[];
|
|
29
|
+
/** Check type string constants for use in routing (scan-runner switch). */
|
|
30
|
+
export declare const CHECK_TYPE: {
|
|
31
|
+
readonly REPOSITORY: string;
|
|
32
|
+
readonly TARGETED: string;
|
|
33
|
+
readonly STATIC: string;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=check-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-types.d.ts","sourceRoot":"","sources":["../src/check-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,gEAAgE;IAChE,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,mEAAmE;IACnE,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;CACtC;AA6CD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,mBAAmB,CAG1E;AAED,oCAAoC;AACpC,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAE7C;AAED,2EAA2E;AAC3E,eAAO,MAAM,UAAU;;;;CAIb,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check type descriptor system.
|
|
3
|
+
*
|
|
4
|
+
* Each check type declares its characteristics (needs AI, needs instructions, etc.)
|
|
5
|
+
* in one place. Code throughout the codebase queries these descriptors instead
|
|
6
|
+
* of comparing raw type strings.
|
|
7
|
+
*
|
|
8
|
+
* Check types describe *execution mode* (what happens with targets).
|
|
9
|
+
* Discovery type (how targets are found) is a separate axis — see src/discovery.ts.
|
|
10
|
+
*/
|
|
11
|
+
// --- Check Type Definitions ---
|
|
12
|
+
const REPOSITORY = {
|
|
13
|
+
type: 'repository',
|
|
14
|
+
needsAI: true,
|
|
15
|
+
needsInstructions: true,
|
|
16
|
+
supportsMaxTargets: false,
|
|
17
|
+
};
|
|
18
|
+
const TARGETED = {
|
|
19
|
+
type: 'targeted',
|
|
20
|
+
needsAI: true,
|
|
21
|
+
needsInstructions: true,
|
|
22
|
+
supportsMaxTargets: true,
|
|
23
|
+
};
|
|
24
|
+
const STATIC = {
|
|
25
|
+
type: 'static',
|
|
26
|
+
needsAI: false,
|
|
27
|
+
needsInstructions: false,
|
|
28
|
+
supportsMaxTargets: true,
|
|
29
|
+
};
|
|
30
|
+
/** All registered check types, keyed by their type string. */
|
|
31
|
+
const CHECK_TYPES = new Map([
|
|
32
|
+
[REPOSITORY.type, REPOSITORY],
|
|
33
|
+
[TARGETED.type, TARGETED],
|
|
34
|
+
[STATIC.type, STATIC],
|
|
35
|
+
]);
|
|
36
|
+
/**
|
|
37
|
+
* Default descriptor used when the type is unknown or undefined.
|
|
38
|
+
* Conservative defaults: requires AI and instructions (the common case).
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_DESCRIPTOR = {
|
|
41
|
+
type: '',
|
|
42
|
+
needsAI: true,
|
|
43
|
+
needsInstructions: true,
|
|
44
|
+
supportsMaxTargets: false,
|
|
45
|
+
};
|
|
46
|
+
// --- Public API ---
|
|
47
|
+
/**
|
|
48
|
+
* Get the descriptor for a check type string.
|
|
49
|
+
* Returns conservative defaults for unknown/undefined types.
|
|
50
|
+
*/
|
|
51
|
+
export function getCheckType(type) {
|
|
52
|
+
if (!type)
|
|
53
|
+
return DEFAULT_DESCRIPTOR;
|
|
54
|
+
return CHECK_TYPES.get(type) ?? DEFAULT_DESCRIPTOR;
|
|
55
|
+
}
|
|
56
|
+
/** All valid check type strings. */
|
|
57
|
+
export function getValidCheckTypes() {
|
|
58
|
+
return [...CHECK_TYPES.keys()];
|
|
59
|
+
}
|
|
60
|
+
/** Check type string constants for use in routing (scan-runner switch). */
|
|
61
|
+
export const CHECK_TYPE = {
|
|
62
|
+
REPOSITORY: REPOSITORY.type,
|
|
63
|
+
TARGETED: TARGETED.type,
|
|
64
|
+
STATIC: STATIC.type,
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=check-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-types.js","sourceRoot":"","sources":["../src/check-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAcH,iCAAiC;AAEjC,MAAM,UAAU,GAAwB;IACtC,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,IAAI;IACb,iB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odeProvider implements AIProvider {
|
|
|
19
19
|
});
|
|
20
20
|
initialize(config: ProviderConfig): Promise<void>;
|
|
21
21
|
getModelName(): string;
|
|
22
|
+
setModel(model: string): void;
|
|
22
23
|
enableDebug(): void;
|
|
23
|
-
executeCheck(instructions: string, repositoryPath: string, logPrefix?: string
|
|
24
|
+
executeCheck(instructions: string, repositoryPath: string, logPrefix?: string, options?: {
|
|
25
|
+
maxTurns?: number;
|
|
26
|
+
}): Promise<AIResponse>;
|
|
24
27
|
validateConfig(): Promise<boolean>;
|
|
25
28
|
}
|
|
26
29
|
//# sourceMappingURL=claude-code-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-code-provider.d.ts","sourceRoot":"","sources":["../src/claude-code-provider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAA6B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-code-provider.d.ts","sourceRoot":"","sources":["../src/claude-code-provider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAA6B,MAAM,YAAY,CAAC;AAUpG,gEAAgE;AAChE,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,KAAK,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAsC7C,qBAAa,kBAAmB,YAAW,UAAU;IACnD,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,YAAY,CAAkB;gBAE1B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE;IAItC,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBvD,YAAY,IAAI,MAAM;IAItB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,WAAW,IAAI,IAAI;IAIb,YAAY,CAChB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9B,OAAO,CAAC,UAAU,CAAC;IA4MhB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;CAGzC"}
|
|
@@ -8,6 +8,7 @@ import { logProgress, logDebug, logDebugFull, createTimer } from './logging.js';
|
|
|
8
8
|
const TAG = 'ai-provider';
|
|
9
9
|
const HEARTBEAT_INTERVAL_MS = 15000; // Log heartbeat every 15s if no activity
|
|
10
10
|
const MAX_API_ERROR_RETRIES = 3; // Fail after this many consecutive API errors
|
|
11
|
+
const MAX_ERROR_DETECTION_LENGTH = 200; // Only check short text chunks for SDK error patterns — longer text is AI analysis content
|
|
11
12
|
// JSON schema for structured output (matches spec Section 4.4)
|
|
12
13
|
const OUTPUT_SCHEMA = {
|
|
13
14
|
type: 'object',
|
|
@@ -60,7 +61,7 @@ export class ClaudeCodeProvider {
|
|
|
60
61
|
this.model = config.model;
|
|
61
62
|
}
|
|
62
63
|
if (!this.apiKey && !this.useLocalClaude) {
|
|
63
|
-
throw new Error('ANTHROPIC_API_KEY is required
|
|
64
|
+
throw new Error('ANTHROPIC_API_KEY is required');
|
|
64
65
|
}
|
|
65
66
|
if (this.useLocalClaude) {
|
|
66
67
|
logProgress(TAG, 'Using local Claude Code session for authentication');
|
|
@@ -73,15 +74,19 @@ export class ClaudeCodeProvider {
|
|
|
73
74
|
getModelName() {
|
|
74
75
|
return this.model;
|
|
75
76
|
}
|
|
77
|
+
setModel(model) {
|
|
78
|
+
this.model = model;
|
|
79
|
+
}
|
|
76
80
|
enableDebug() {
|
|
77
81
|
this.debugEnabled = true;
|
|
78
82
|
}
|
|
79
|
-
async executeCheck(instructions, repositoryPath, logPrefix) {
|
|
83
|
+
async executeCheck(instructions, repositoryPath, logPrefix, options) {
|
|
80
84
|
const queryFn = this._queryFn ?? (await import('@anthropic-ai/claude-agent-sdk')).query;
|
|
81
85
|
const timer = createTimer();
|
|
82
86
|
const prefix = logPrefix ? `${logPrefix} ` : '';
|
|
87
|
+
const effectiveMaxTurns = options?.maxTurns ?? 100;
|
|
83
88
|
const prompt = instructions;
|
|
84
|
-
logDebug(TAG, `${prefix}Starting query: model=${this.model}, cwd=${repositoryPath}, promptLen=${prompt.length}`);
|
|
89
|
+
logDebug(TAG, `${prefix}Starting query: model=${this.model}, cwd=${repositoryPath}, promptLen=${prompt.length}, maxTurns=${effectiveMaxTurns}`);
|
|
85
90
|
if (this.debugEnabled) {
|
|
86
91
|
logDebugFull(TAG, `${prefix}Full prompt sent to AI`, prompt);
|
|
87
92
|
}
|
|
@@ -91,7 +96,7 @@ export class ClaudeCodeProvider {
|
|
|
91
96
|
model: this.model,
|
|
92
97
|
cwd: repositoryPath,
|
|
93
98
|
allowedTools: ['Read', 'Glob', 'Grep', 'Bash', 'WebSearch', 'WebFetch'],
|
|
94
|
-
maxTurns:
|
|
99
|
+
maxTurns: effectiveMaxTurns,
|
|
95
100
|
permissionMode: 'bypassPermissions',
|
|
96
101
|
outputFormat: {
|
|
97
102
|
type: 'json_schema',
|
|
@@ -150,18 +155,28 @@ export class ClaudeCodeProvider {
|
|
|
150
155
|
.filter(Boolean);
|
|
151
156
|
if (textChunks.length > 0) {
|
|
152
157
|
logDebug(TAG, `${prefix}Assistant: ${textChunks.join(' | ')}`);
|
|
153
|
-
//
|
|
154
|
-
|
|
158
|
+
// Error detection: only check short text chunks to avoid matching the AI's
|
|
159
|
+
// own analysis text (e.g., a security finding mentioning "rate limiting").
|
|
160
|
+
// SDK/API error messages are typically short (under 200 chars), while AI analysis
|
|
161
|
+
// text is much longer.
|
|
162
|
+
const shortChunks = textChunks.filter((t) => t.length < MAX_ERROR_DETECTION_LENGTH);
|
|
163
|
+
// Detect rate-limit messages — fail immediately since retrying won't help.
|
|
164
|
+
const rateLimitMatch = shortChunks.find((t) => /you've hit your limit|API Error:\s*429|rate.?limit.?exceeded/i.test(t));
|
|
155
165
|
if (rateLimitMatch) {
|
|
156
166
|
throw new FatalProviderError(`AI provider rate limit reached: ${rateLimitMatch}`);
|
|
157
167
|
}
|
|
158
168
|
// Detect authentication errors (401) — fail immediately, unrecoverable
|
|
159
|
-
const authErrorMatch =
|
|
169
|
+
const authErrorMatch = shortChunks.find((t) => /API Error:\s*401/i.test(t));
|
|
160
170
|
if (authErrorMatch) {
|
|
161
171
|
throw new FatalProviderError(`AI provider authentication failed (401): ${authErrorMatch}`);
|
|
162
172
|
}
|
|
173
|
+
// Detect login required — fail immediately, unrecoverable without user action
|
|
174
|
+
const loginRequiredMatch = shortChunks.find((t) => /not logged in/i.test(t));
|
|
175
|
+
if (loginRequiredMatch) {
|
|
176
|
+
throw new FatalProviderError(`AI provider not logged in: ${loginRequiredMatch}. Please authenticate before running scans.`);
|
|
177
|
+
}
|
|
163
178
|
// Detect API errors surfaced as assistant text by the SDK
|
|
164
|
-
const apiErrorMatch =
|
|
179
|
+
const apiErrorMatch = shortChunks.find((t) => t.includes('API Error:'));
|
|
165
180
|
if (apiErrorMatch) {
|
|
166
181
|
consecutiveApiErrors++;
|
|
167
182
|
if (consecutiveApiErrors >= MAX_API_ERROR_RETRIES) {
|