@bouncesecurity/aghast 0.0.13
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/LICENSE +661 -0
- package/README.md +111 -0
- package/config/prompts/generic-instructions.md +56 -0
- package/config/prompts/test-cheaper-instructions.md +57 -0
- package/dist/check-library.d.ts +87 -0
- package/dist/check-library.d.ts.map +1 -0
- package/dist/check-library.js +374 -0
- package/dist/check-library.js.map +1 -0
- package/dist/claude-code-provider.d.ts +26 -0
- package/dist/claude-code-provider.d.ts.map +1 -0
- package/dist/claude-code-provider.js +247 -0
- package/dist/claude-code-provider.js.map +1 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +78 -0
- package/dist/cli.js.map +1 -0
- package/dist/colors.d.ts +7 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +18 -0
- package/dist/colors.js.map +1 -0
- package/dist/error-codes.d.ts +42 -0
- package/dist/error-codes.d.ts.map +1 -0
- package/dist/error-codes.js +60 -0
- package/dist/error-codes.js.map +1 -0
- package/dist/formatters/index.d.ts +10 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +23 -0
- package/dist/formatters/index.js.map +1 -0
- package/dist/formatters/json-formatter.d.ts +11 -0
- package/dist/formatters/json-formatter.d.ts.map +1 -0
- package/dist/formatters/json-formatter.js +11 -0
- package/dist/formatters/json-formatter.js.map +1 -0
- package/dist/formatters/sarif-formatter.d.ts +18 -0
- package/dist/formatters/sarif-formatter.d.ts.map +1 -0
- package/dist/formatters/sarif-formatter.js +103 -0
- package/dist/formatters/sarif-formatter.js.map +1 -0
- package/dist/formatters/types.d.ts +11 -0
- package/dist/formatters/types.d.ts.map +1 -0
- package/dist/formatters/types.js +6 -0
- package/dist/formatters/types.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +406 -0
- package/dist/index.js.map +1 -0
- package/dist/logging.d.ts +26 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +79 -0
- package/dist/logging.js.map +1 -0
- package/dist/mock-ai-provider.d.ts +18 -0
- package/dist/mock-ai-provider.d.ts.map +1 -0
- package/dist/mock-ai-provider.js +28 -0
- package/dist/mock-ai-provider.js.map +1 -0
- package/dist/new-check.d.ts +13 -0
- package/dist/new-check.d.ts.map +1 -0
- package/dist/new-check.js +405 -0
- package/dist/new-check.js.map +1 -0
- package/dist/prompt-template.d.ts +12 -0
- package/dist/prompt-template.d.ts.map +1 -0
- package/dist/prompt-template.js +35 -0
- package/dist/prompt-template.js.map +1 -0
- package/dist/provider-registry.d.ts +15 -0
- package/dist/provider-registry.d.ts.map +1 -0
- package/dist/provider-registry.js +27 -0
- package/dist/provider-registry.js.map +1 -0
- package/dist/repository-analyzer.d.ts +68 -0
- package/dist/repository-analyzer.d.ts.map +1 -0
- package/dist/repository-analyzer.js +230 -0
- package/dist/repository-analyzer.js.map +1 -0
- package/dist/response-parser.d.ts +12 -0
- package/dist/response-parser.d.ts.map +1 -0
- package/dist/response-parser.js +109 -0
- package/dist/response-parser.js.map +1 -0
- package/dist/runtime-config.d.ts +15 -0
- package/dist/runtime-config.d.ts.map +1 -0
- package/dist/runtime-config.js +73 -0
- package/dist/runtime-config.js.map +1 -0
- package/dist/sarif-parser.d.ts +20 -0
- package/dist/sarif-parser.d.ts.map +1 -0
- package/dist/sarif-parser.js +76 -0
- package/dist/sarif-parser.js.map +1 -0
- package/dist/scan-runner.d.ts +29 -0
- package/dist/scan-runner.d.ts.map +1 -0
- package/dist/scan-runner.js +559 -0
- package/dist/scan-runner.js.map +1 -0
- package/dist/semgrep-runner.d.ts +25 -0
- package/dist/semgrep-runner.d.ts.map +1 -0
- package/dist/semgrep-runner.js +100 -0
- package/dist/semgrep-runner.js.map +1 -0
- package/dist/snippet-extractor.d.ts +25 -0
- package/dist/snippet-extractor.d.ts.map +1 -0
- package/dist/snippet-extractor.js +56 -0
- package/dist/snippet-extractor.js.map +1 -0
- package/dist/types.d.ts +206 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check Library / Config Manager.
|
|
3
|
+
* Two-layer config: Layer 1 (registry) maps checks to repos,
|
|
4
|
+
* Layer 2 (<id>.json) defines each check in its own folder.
|
|
5
|
+
* Implements spec Appendix B.1.
|
|
6
|
+
*/
|
|
7
|
+
import { readFile, readdir, access, constants } from 'node:fs/promises';
|
|
8
|
+
import { resolve, join, basename } from 'node:path';
|
|
9
|
+
import picomatch from 'picomatch';
|
|
10
|
+
import { normalizeRepoPath } from './repository-analyzer.js';
|
|
11
|
+
/**
|
|
12
|
+
* Load and parse the Layer 1 registry from <configDir>/checks-config.json.
|
|
13
|
+
* Throws on missing file, malformed JSON, or invalid structure.
|
|
14
|
+
*/
|
|
15
|
+
export async function loadCheckRegistry(configDir) {
|
|
16
|
+
const configPath = resolve(configDir, 'checks-config.json');
|
|
17
|
+
let raw;
|
|
18
|
+
try {
|
|
19
|
+
raw = await readFile(configPath, 'utf-8');
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
throw new Error(`Failed to read config file "${configPath}": ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
23
|
+
}
|
|
24
|
+
let parsed;
|
|
25
|
+
try {
|
|
26
|
+
parsed = JSON.parse(raw);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new Error(`Config file "${configPath}" contains invalid JSON: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
30
|
+
}
|
|
31
|
+
if (typeof parsed !== 'object' ||
|
|
32
|
+
parsed === null ||
|
|
33
|
+
!('checks' in parsed) ||
|
|
34
|
+
!Array.isArray(parsed.checks)) {
|
|
35
|
+
throw new Error(`Config file "${configPath}" has invalid structure: must contain a "checks" array`);
|
|
36
|
+
}
|
|
37
|
+
// Validate each registry entry has required fields with correct types
|
|
38
|
+
const checks = parsed.checks;
|
|
39
|
+
for (let i = 0; i < checks.length; i++) {
|
|
40
|
+
const entry = checks[i];
|
|
41
|
+
if (typeof entry !== 'object' || entry === null) {
|
|
42
|
+
throw new Error(`Config file "${configPath}": checks[${i}] must be an object`);
|
|
43
|
+
}
|
|
44
|
+
const obj = entry;
|
|
45
|
+
if (typeof obj.id !== 'string' || obj.id.trim() === '') {
|
|
46
|
+
throw new Error(`Config file "${configPath}": checks[${i}].id must be a non-empty string`);
|
|
47
|
+
}
|
|
48
|
+
if (!Array.isArray(obj.repositories)) {
|
|
49
|
+
throw new Error(`Config file "${configPath}": checks[${i}].repositories must be an array`);
|
|
50
|
+
}
|
|
51
|
+
for (let j = 0; j < obj.repositories.length; j++) {
|
|
52
|
+
if (typeof obj.repositories[j] !== 'string') {
|
|
53
|
+
throw new Error(`Config file "${configPath}": checks[${i}].repositories[${j}] must be a string`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (obj.enabled !== undefined && typeof obj.enabled !== 'boolean') {
|
|
57
|
+
throw new Error(`Config file "${configPath}": checks[${i}].enabled must be a boolean`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return parsed;
|
|
61
|
+
}
|
|
62
|
+
// --- Layer 2: Check Definitions ---
|
|
63
|
+
/**
|
|
64
|
+
* Load and parse a Layer 2 check definition from <checkFolderPath>/<id>.json.
|
|
65
|
+
* Throws on missing file, malformed JSON, or missing required fields.
|
|
66
|
+
*/
|
|
67
|
+
export async function loadCheckDefinition(checkFolderPath) {
|
|
68
|
+
const defPath = resolve(checkFolderPath, basename(checkFolderPath) + '.json');
|
|
69
|
+
let raw;
|
|
70
|
+
try {
|
|
71
|
+
raw = await readFile(defPath, 'utf-8');
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
throw new Error(`Failed to read check definition "${defPath}": ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
75
|
+
}
|
|
76
|
+
let parsed;
|
|
77
|
+
try {
|
|
78
|
+
parsed = JSON.parse(raw);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
throw new Error(`Check definition "${defPath}" contains invalid JSON: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
82
|
+
}
|
|
83
|
+
// Validate field types before casting
|
|
84
|
+
const obj = parsed;
|
|
85
|
+
if (typeof obj.id !== 'string' || obj.id.trim() === '') {
|
|
86
|
+
throw new Error(`Check definition "${defPath}": "id" must be a non-empty string`);
|
|
87
|
+
}
|
|
88
|
+
if (typeof obj.name !== 'string' || obj.name.trim() === '') {
|
|
89
|
+
throw new Error(`Check definition "${defPath}": "name" must be a non-empty string`);
|
|
90
|
+
}
|
|
91
|
+
if (obj.instructionsFile !== undefined && typeof obj.instructionsFile !== 'string') {
|
|
92
|
+
throw new Error(`Check definition "${defPath}": "instructionsFile" must be a string`);
|
|
93
|
+
}
|
|
94
|
+
if (obj.severity !== undefined && typeof obj.severity !== 'string') {
|
|
95
|
+
throw new Error(`Check definition "${defPath}": "severity" must be a string`);
|
|
96
|
+
}
|
|
97
|
+
if (obj.confidence !== undefined && typeof obj.confidence !== 'string') {
|
|
98
|
+
throw new Error(`Check definition "${defPath}": "confidence" must be a string`);
|
|
99
|
+
}
|
|
100
|
+
if (obj.applicablePaths !== undefined && !Array.isArray(obj.applicablePaths)) {
|
|
101
|
+
throw new Error(`Check definition "${defPath}": "applicablePaths" must be an array`);
|
|
102
|
+
}
|
|
103
|
+
if (obj.excludedPaths !== undefined && !Array.isArray(obj.excludedPaths)) {
|
|
104
|
+
throw new Error(`Check definition "${defPath}": "excludedPaths" must be an array`);
|
|
105
|
+
}
|
|
106
|
+
if (obj.checkTarget !== undefined) {
|
|
107
|
+
if (typeof obj.checkTarget !== 'object' || obj.checkTarget === null) {
|
|
108
|
+
throw new Error(`Check definition "${defPath}": "checkTarget" must be an object`);
|
|
109
|
+
}
|
|
110
|
+
const ct = obj.checkTarget;
|
|
111
|
+
const validTypes = ['semgrep', 'semgrep-only', 'repository'];
|
|
112
|
+
if (typeof ct.type !== 'string' || !validTypes.includes(ct.type)) {
|
|
113
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.type" must be one of: ${validTypes.join(', ')}`);
|
|
114
|
+
}
|
|
115
|
+
if (ct.rules !== undefined && typeof ct.rules !== 'string' && !Array.isArray(ct.rules)) {
|
|
116
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.rules" must be a string or array`);
|
|
117
|
+
}
|
|
118
|
+
if (ct.config !== undefined && typeof ct.config !== 'string') {
|
|
119
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.config" must be a string`);
|
|
120
|
+
}
|
|
121
|
+
if (ct.maxTargets !== undefined && (typeof ct.maxTargets !== 'number' || ct.maxTargets <= 0 || !Number.isInteger(ct.maxTargets))) {
|
|
122
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.maxTargets" must be a positive integer`);
|
|
123
|
+
}
|
|
124
|
+
if (ct.concurrency !== undefined && (typeof ct.concurrency !== 'number' || ct.concurrency <= 0 || !Number.isInteger(ct.concurrency))) {
|
|
125
|
+
throw new Error(`Check definition "${defPath}": "checkTarget.concurrency" must be a positive integer`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const def = parsed;
|
|
129
|
+
// instructionsFile is required for all check types except semgrep-only
|
|
130
|
+
if (def.checkTarget?.type !== 'semgrep-only' && !def.instructionsFile) {
|
|
131
|
+
throw new Error(`Check definition "${defPath}" is missing required field "instructionsFile" (required for non-semgrep-only checks)`);
|
|
132
|
+
}
|
|
133
|
+
return def;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Scan check directories for subfolders containing <id>.json.
|
|
137
|
+
* Returns a map of check id → folder path.
|
|
138
|
+
*/
|
|
139
|
+
export async function discoverCheckFolders(checksDirs) {
|
|
140
|
+
const result = new Map();
|
|
141
|
+
for (const dir of checksDirs) {
|
|
142
|
+
let entries;
|
|
143
|
+
try {
|
|
144
|
+
entries = await readdir(dir);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// Directory doesn't exist — skip
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
for (const entry of entries) {
|
|
151
|
+
const folderPath = join(dir, entry);
|
|
152
|
+
const checkJsonPath = join(folderPath, entry + '.json');
|
|
153
|
+
try {
|
|
154
|
+
await access(checkJsonPath, constants.R_OK);
|
|
155
|
+
// Load just to get the id
|
|
156
|
+
const def = await loadCheckDefinition(folderPath);
|
|
157
|
+
result.set(def.id, folderPath);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// Not a check folder or can't read — skip
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Merge Layer 1 registry entries with Layer 2 check definitions.
|
|
168
|
+
* Resolves instructionsFile and checkTarget.rules paths relative to check folder.
|
|
169
|
+
* Throws if a registry entry has no matching check folder.
|
|
170
|
+
*/
|
|
171
|
+
export async function resolveChecks(registry, checkFolders) {
|
|
172
|
+
const checks = [];
|
|
173
|
+
for (const entry of registry.checks) {
|
|
174
|
+
const folderPath = checkFolders.get(entry.id);
|
|
175
|
+
if (!folderPath) {
|
|
176
|
+
throw new Error(`Check "${entry.id}" is registered but no matching check folder was found in any checks directory`);
|
|
177
|
+
}
|
|
178
|
+
const def = await loadCheckDefinition(folderPath);
|
|
179
|
+
if (def.id !== entry.id) {
|
|
180
|
+
throw new Error(`Check ID mismatch: registry has "${entry.id}" but ${entry.id}.json has "${def.id}"`);
|
|
181
|
+
}
|
|
182
|
+
// Merge Layer 1 + Layer 2
|
|
183
|
+
const merged = {
|
|
184
|
+
id: entry.id,
|
|
185
|
+
name: def.name,
|
|
186
|
+
repositories: entry.repositories,
|
|
187
|
+
instructionsFile: def.instructionsFile ? resolve(folderPath, def.instructionsFile) : undefined,
|
|
188
|
+
enabled: entry.enabled,
|
|
189
|
+
checkDir: folderPath,
|
|
190
|
+
};
|
|
191
|
+
if (def.severity)
|
|
192
|
+
merged.severity = def.severity;
|
|
193
|
+
if (def.confidence)
|
|
194
|
+
merged.confidence = def.confidence;
|
|
195
|
+
if (def.applicablePaths)
|
|
196
|
+
merged.applicablePaths = def.applicablePaths;
|
|
197
|
+
if (def.excludedPaths)
|
|
198
|
+
merged.excludedPaths = def.excludedPaths;
|
|
199
|
+
if (def.checkTarget) {
|
|
200
|
+
merged.checkTarget = { ...def.checkTarget };
|
|
201
|
+
// Resolve rules paths relative to check folder
|
|
202
|
+
if (merged.checkTarget.rules) {
|
|
203
|
+
const rules = merged.checkTarget.rules;
|
|
204
|
+
merged.checkTarget.rules = Array.isArray(rules)
|
|
205
|
+
? rules.map((r) => resolve(folderPath, r))
|
|
206
|
+
: resolve(folderPath, rules);
|
|
207
|
+
}
|
|
208
|
+
if (merged.checkTarget.config) {
|
|
209
|
+
merged.checkTarget.config = resolve(folderPath, merged.checkTarget.config);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
checks.push(merged);
|
|
213
|
+
}
|
|
214
|
+
return checks;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Load and parse a flat JSON config file (old format).
|
|
218
|
+
* Kept for backward compatibility with existing test fixtures.
|
|
219
|
+
*/
|
|
220
|
+
export async function loadConfig(configPath) {
|
|
221
|
+
let raw;
|
|
222
|
+
try {
|
|
223
|
+
raw = await readFile(configPath, 'utf-8');
|
|
224
|
+
}
|
|
225
|
+
catch (err) {
|
|
226
|
+
throw new Error(`Failed to read config file "${configPath}": ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
227
|
+
}
|
|
228
|
+
let parsed;
|
|
229
|
+
try {
|
|
230
|
+
parsed = JSON.parse(raw);
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
throw new Error(`Config file "${configPath}" contains invalid JSON: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
234
|
+
}
|
|
235
|
+
if (typeof parsed !== 'object' ||
|
|
236
|
+
parsed === null ||
|
|
237
|
+
!('checks' in parsed) ||
|
|
238
|
+
!Array.isArray(parsed.checks)) {
|
|
239
|
+
throw new Error(`Config file "${configPath}" has invalid structure: must contain a "checks" array`);
|
|
240
|
+
}
|
|
241
|
+
return parsed;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Validate a single SecurityCheck definition.
|
|
245
|
+
* Checks that id is present and non-empty, and instructionsFile exists on disk.
|
|
246
|
+
* basePath is used to resolve instructionsFile if it's a relative path.
|
|
247
|
+
* If instructionsFile is already absolute, basePath is ignored.
|
|
248
|
+
*/
|
|
249
|
+
export async function validateCheck(check, basePath) {
|
|
250
|
+
const errors = [];
|
|
251
|
+
if (!check.id || typeof check.id !== 'string' || check.id.trim() === '') {
|
|
252
|
+
errors.push('Check is missing a valid "id" field');
|
|
253
|
+
}
|
|
254
|
+
// semgrep-only checks don't need an instructionsFile
|
|
255
|
+
if (check.checkTarget?.type === 'semgrep-only') {
|
|
256
|
+
// No instructionsFile validation needed
|
|
257
|
+
}
|
|
258
|
+
else if (!check.instructionsFile) {
|
|
259
|
+
errors.push('Check is missing required "instructionsFile" field');
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
// instructionsFile may already be an absolute path (from resolveChecks)
|
|
263
|
+
const instructionsPath = resolve(basePath, check.instructionsFile);
|
|
264
|
+
try {
|
|
265
|
+
await access(instructionsPath, constants.R_OK);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
errors.push(`Instructions file "${check.instructionsFile}" not found at "${instructionsPath}"`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return { valid: errors.length === 0, errors };
|
|
272
|
+
}
|
|
273
|
+
// --- Repository Matching (spec C.6) ---
|
|
274
|
+
// Re-export normalizeRepoPath from repository-analyzer for convenience
|
|
275
|
+
export { normalizeRepoPath } from './repository-analyzer.js';
|
|
276
|
+
/**
|
|
277
|
+
* Check if a single check matches the given repository URL/path.
|
|
278
|
+
* Empty repositories array matches all repos.
|
|
279
|
+
* Uses bidirectional substring matching on normalized paths.
|
|
280
|
+
*/
|
|
281
|
+
export function checkMatchesRepository(check, repositoryUrl) {
|
|
282
|
+
if (check.repositories.length === 0) {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
const normalizedRepo = normalizeRepoPath(repositoryUrl);
|
|
286
|
+
return check.repositories.some((checkRepo) => {
|
|
287
|
+
const normalizedCheckRepo = normalizeRepoPath(checkRepo);
|
|
288
|
+
return (normalizedRepo.includes(normalizedCheckRepo) ||
|
|
289
|
+
normalizedCheckRepo.includes(normalizedRepo));
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Filter checks to those matching the given repository URL/path.
|
|
294
|
+
* Also filters out disabled checks (enabled === false).
|
|
295
|
+
*/
|
|
296
|
+
export function filterChecksForRepository(checks, repositoryUrl) {
|
|
297
|
+
return checks
|
|
298
|
+
.filter((check) => check.enabled !== false)
|
|
299
|
+
.filter((check) => checkMatchesRepository(check, repositoryUrl));
|
|
300
|
+
}
|
|
301
|
+
// --- Markdown Parsing (spec A.7) ---
|
|
302
|
+
/**
|
|
303
|
+
* Parse a markdown check file into CheckDetails.
|
|
304
|
+
* Extracts name from first ### heading, overview from #### Overview section.
|
|
305
|
+
*/
|
|
306
|
+
export function parseCheckMarkdown(id, markdown) {
|
|
307
|
+
// Extract name from first ### heading
|
|
308
|
+
const nameMatch = markdown.match(/^###\s+(.+)$/m);
|
|
309
|
+
const name = nameMatch ? nameMatch[1].trim() : 'Unknown Check';
|
|
310
|
+
// Extract overview from #### Overview section
|
|
311
|
+
let overview = '';
|
|
312
|
+
const overviewMatch = markdown.match(/^####\s+Overview\s*\n([\s\S]*?)(?=^####\s|\s*$)/m);
|
|
313
|
+
if (overviewMatch) {
|
|
314
|
+
overview = overviewMatch[1].trim();
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
id,
|
|
318
|
+
name,
|
|
319
|
+
overview,
|
|
320
|
+
content: markdown,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Load check instructions from the markdown file referenced by a SecurityCheck.
|
|
325
|
+
* Resolves instructionsFile relative to basePath (or uses absolute path if already resolved).
|
|
326
|
+
*/
|
|
327
|
+
export async function loadCheckDetails(check, basePath) {
|
|
328
|
+
if (!check.instructionsFile) {
|
|
329
|
+
throw new Error(`Check "${check.id}" has no instructionsFile`);
|
|
330
|
+
}
|
|
331
|
+
const instructionsPath = resolve(basePath, check.instructionsFile);
|
|
332
|
+
let markdown;
|
|
333
|
+
try {
|
|
334
|
+
markdown = await readFile(instructionsPath, 'utf-8');
|
|
335
|
+
}
|
|
336
|
+
catch (err) {
|
|
337
|
+
throw new Error(`Failed to load instructions file "${check.instructionsFile}": ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
338
|
+
}
|
|
339
|
+
return parseCheckMarkdown(check.id, markdown);
|
|
340
|
+
}
|
|
341
|
+
// --- Path Filtering ---
|
|
342
|
+
// Note: These path filtering functions are implemented and tested but not yet
|
|
343
|
+
// wired into the scan execution path. They will be integrated in a future
|
|
344
|
+
// iteration when the AI provider interface supports scoped file lists.
|
|
345
|
+
/**
|
|
346
|
+
* Filter files to those matching applicablePaths globs.
|
|
347
|
+
* If applicablePaths is undefined or empty, returns all files.
|
|
348
|
+
*/
|
|
349
|
+
export function filterApplicablePaths(files, applicablePaths) {
|
|
350
|
+
if (!applicablePaths || applicablePaths.length === 0) {
|
|
351
|
+
return files;
|
|
352
|
+
}
|
|
353
|
+
const matcher = picomatch(applicablePaths);
|
|
354
|
+
return files.filter((file) => matcher(file));
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Filter out files matching excludedPaths globs.
|
|
358
|
+
* If excludedPaths is undefined or empty, returns all files.
|
|
359
|
+
*/
|
|
360
|
+
export function filterExcludedPaths(files, excludedPaths) {
|
|
361
|
+
if (!excludedPaths || excludedPaths.length === 0) {
|
|
362
|
+
return files;
|
|
363
|
+
}
|
|
364
|
+
const matcher = picomatch(excludedPaths);
|
|
365
|
+
return files.filter((file) => !matcher(file));
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Apply both applicablePaths and excludedPaths filtering.
|
|
369
|
+
*/
|
|
370
|
+
export function filterCheckPaths(files, check) {
|
|
371
|
+
const applicable = filterApplicablePaths(files, check.applicablePaths);
|
|
372
|
+
return filterExcludedPaths(applicable, check.excludedPaths);
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=check-library.js.map
|
|
@@ -0,0 +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,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAc7D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAAiB;IACvD,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;IAC5D,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,+BAA+B,UAAU,MAAM,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EACjG,EAAE,KAAK,EAAE,GAAG,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AC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAe,EACf,aAAwB;IAExB,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,aAAa,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAe,EACf,KAAoB;IAEpB,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACvE,OAAO,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code AI provider implementation.
|
|
3
|
+
* Uses @anthropic-ai/claude-agent-sdk per spec Section 6.2 / Appendix C.8.
|
|
4
|
+
*/
|
|
5
|
+
import type { AIProvider, AIResponse, ProviderConfig } from './types.js';
|
|
6
|
+
/** Type for the SDK query function — injectable for testing. */
|
|
7
|
+
export type QueryFn = (params: {
|
|
8
|
+
prompt: string;
|
|
9
|
+
options: Record<string, unknown>;
|
|
10
|
+
}) => AsyncIterable<Record<string, unknown>>;
|
|
11
|
+
export declare class ClaudeCodeProvider implements AIProvider {
|
|
12
|
+
private apiKey;
|
|
13
|
+
private useLocalClaude;
|
|
14
|
+
private model;
|
|
15
|
+
private _queryFn;
|
|
16
|
+
private debugEnabled;
|
|
17
|
+
constructor(options?: {
|
|
18
|
+
_queryFn?: QueryFn;
|
|
19
|
+
});
|
|
20
|
+
initialize(config: ProviderConfig): Promise<void>;
|
|
21
|
+
getModelName(): string;
|
|
22
|
+
enableDebug(): void;
|
|
23
|
+
executeCheck(instructions: string, repositoryPath: string, logPrefix?: string): Promise<AIResponse>;
|
|
24
|
+
validateConfig(): Promise<boolean>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=claude-code-provider.d.ts.map
|
|
@@ -0,0 +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;AASpG,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,WAAW,IAAI,IAAI;IAIb,YAAY,CAChB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC;IA6LhB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;CAGzC"}
|