agentaudit 3.9.45 → 3.9.47
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/cli.mjs +23 -2
- package/package.json +1 -1
- package/prompts/audit-prompt.md +14 -0
package/cli.mjs
CHANGED
|
@@ -75,6 +75,7 @@ let jsonMode = false;
|
|
|
75
75
|
let quietMode = false;
|
|
76
76
|
let modelOverride = null; // --model flag or AGENTAUDIT_MODEL env or config
|
|
77
77
|
let globalModelOverride = null; // same, but set early for resolveProvider
|
|
78
|
+
let llmTimeoutMs = null; // --timeout flag (seconds → ms)
|
|
78
79
|
|
|
79
80
|
// ── ANSI Colors (respects NO_COLOR and --no-color) ───────
|
|
80
81
|
|
|
@@ -1679,7 +1680,7 @@ async function auditRepo(url) {
|
|
|
1679
1680
|
system: systemPrompt,
|
|
1680
1681
|
messages: [{ role: 'user', content: userMessage }],
|
|
1681
1682
|
}),
|
|
1682
|
-
signal: AbortSignal.timeout(180_000),
|
|
1683
|
+
signal: AbortSignal.timeout(llmTimeoutMs || 180_000),
|
|
1683
1684
|
});
|
|
1684
1685
|
const data = await res.json();
|
|
1685
1686
|
if (data.error) {
|
|
@@ -1729,7 +1730,7 @@ async function auditRepo(url) {
|
|
|
1729
1730
|
{ role: 'user', content: userMessage },
|
|
1730
1731
|
],
|
|
1731
1732
|
}),
|
|
1732
|
-
signal: AbortSignal.timeout(resolvedProvider.id === 'ollama' ? 300_000 : 180_000),
|
|
1733
|
+
signal: AbortSignal.timeout(llmTimeoutMs || (resolvedProvider.id === 'ollama' ? 300_000 : 180_000)),
|
|
1733
1734
|
});
|
|
1734
1735
|
const data = await res.json();
|
|
1735
1736
|
if (data.error) {
|
|
@@ -1916,6 +1917,12 @@ async function auditRepo(url) {
|
|
|
1916
1917
|
console.log(` ${c.red}failed${c.reset}`);
|
|
1917
1918
|
const errMsg = result.error;
|
|
1918
1919
|
console.log(` ${c.red}API error: ${errMsg}${c.reset}`);
|
|
1920
|
+
if (/abort|timeout/i.test(errMsg)) {
|
|
1921
|
+
const currentTimeout = llmTimeoutMs ? (llmTimeoutMs / 1000) : 180;
|
|
1922
|
+
console.log(` ${c.dim}The model took longer than ${currentTimeout}s to respond.${c.reset}`);
|
|
1923
|
+
console.log(` ${c.dim}Try increasing the timeout: --timeout 300 (or --timeout 600 for reasoning models)${c.reset}`);
|
|
1924
|
+
console.log(` ${c.dim}You can also set AGENTAUDIT_TIMEOUT=300 as environment variable.${c.reset}`);
|
|
1925
|
+
}
|
|
1919
1926
|
if (/context.length|maximum.*tokens|too.many.tokens/i.test(errMsg)) {
|
|
1920
1927
|
console.log(` ${c.dim}This model's context window is too small for this repository.${c.reset}`);
|
|
1921
1928
|
console.log(` ${c.dim}Try a model with a larger context: --model anthropic/claude-sonnet-4 (200k) or --model openai/gpt-4o (128k)${c.reset}`);
|
|
@@ -2210,6 +2217,18 @@ async function main() {
|
|
|
2210
2217
|
|| null;
|
|
2211
2218
|
globalModelOverride = modelOverride;
|
|
2212
2219
|
|
|
2220
|
+
// --timeout flag: --timeout=<seconds> or --timeout <seconds>
|
|
2221
|
+
const timeoutFlagIdx = rawArgs.findIndex(a => a === '--timeout');
|
|
2222
|
+
const timeoutFlagEq = rawArgs.find(a => a.startsWith('--timeout='));
|
|
2223
|
+
const timeoutVal = timeoutFlagEq?.split('=')[1]
|
|
2224
|
+
|| (timeoutFlagIdx >= 0 ? rawArgs[timeoutFlagIdx + 1] : null)
|
|
2225
|
+
|| process.env.AGENTAUDIT_TIMEOUT
|
|
2226
|
+
|| null;
|
|
2227
|
+
if (timeoutVal) {
|
|
2228
|
+
const secs = parseInt(timeoutVal, 10);
|
|
2229
|
+
if (secs > 0) llmTimeoutMs = secs * 1000;
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2213
2232
|
// Strip global flags from args
|
|
2214
2233
|
const globalFlags = new Set(['--json', '--quiet', '-q', '--no-color']);
|
|
2215
2234
|
let args = rawArgs.filter(a => !globalFlags.has(a));
|
|
@@ -2217,6 +2236,8 @@ async function main() {
|
|
|
2217
2236
|
args = args.filter((a, i, arr) => {
|
|
2218
2237
|
if (a.startsWith('--model=')) return false;
|
|
2219
2238
|
if (a === '--model') { arr[i + 1] = '__skip__'; return false; }
|
|
2239
|
+
if (a.startsWith('--timeout=')) return false;
|
|
2240
|
+
if (a === '--timeout') { arr[i + 1] = '__skip__'; return false; }
|
|
2220
2241
|
if (a === '__skip__') return false;
|
|
2221
2242
|
return true;
|
|
2222
2243
|
});
|
package/package.json
CHANGED
package/prompts/audit-prompt.md
CHANGED
|
@@ -472,6 +472,7 @@ To find source_url: check `package.json` → `repository.url`, `_meta.json` →
|
|
|
472
472
|
{
|
|
473
473
|
"severity": "high",
|
|
474
474
|
"pattern_id": "CMD_INJECT_001",
|
|
475
|
+
"cwe_id": "CWE-78",
|
|
475
476
|
"title": "Unescaped user input passed to exec()",
|
|
476
477
|
"description": "User-controlled input from HTTP body is passed directly to exec() without sanitization.",
|
|
477
478
|
"file": "src/runner.js",
|
|
@@ -507,6 +508,19 @@ To find source_url: check `package.json` → `repository.url`, `_meta.json` →
|
|
|
507
508
|
### Version Tracking (Optional — Backend Auto-Enrichment)
|
|
508
509
|
Backend auto-extracts: `commit_sha`, `content_hash`, `package_version`. Per-finding `file_hash` (SHA-256) is recommended for staleness detection.
|
|
509
510
|
|
|
511
|
+
### CWE ID (Required)
|
|
512
|
+
Every finding MUST include a `cwe_id` field with the most specific applicable CWE identifier.
|
|
513
|
+
Common CWEs for MCP/package security:
|
|
514
|
+
- `CWE-78` Command Injection, `CWE-79` XSS, `CWE-89` SQL Injection, `CWE-94` Code Injection
|
|
515
|
+
- `CWE-22` Path Traversal, `CWE-918` SSRF, `CWE-502` Deserialization
|
|
516
|
+
- `CWE-798` Hardcoded Credentials, `CWE-321` Hardcoded Crypto Key
|
|
517
|
+
- `CWE-862` Missing Authorization (IDOR), `CWE-915` Mass Assignment
|
|
518
|
+
- `CWE-200`/`CWE-209` Information Exposure, `CWE-532` Log Injection
|
|
519
|
+
- `CWE-362` Race Condition, `CWE-601` Open Redirect, `CWE-434` Unrestricted Upload
|
|
520
|
+
- `CWE-444` HTTP Smuggling, `CWE-1321` Prototype Pollution
|
|
521
|
+
- `CWE-327` Weak Crypto, `CWE-338` Weak PRNG, `CWE-1333` ReDoS
|
|
522
|
+
If unsure, use the closest parent CWE. Never omit this field.
|
|
523
|
+
|
|
510
524
|
### Pattern ID Prefixes
|
|
511
525
|
Use: `CMD_INJECT`, `CRED_THEFT`, `DATA_EXFIL`, `DESTRUCT`, `OBF`, `SANDBOX_ESC`, `SUPPLY_CHAIN`, `SOCIAL_ENG`, `PRIV_ESC`, `INFO_LEAK`, `CRYPTO_WEAK`, `DESER`, `PATH_TRAV`, `SEC_BYPASS`, `PERSIST`, `AI_PROMPT`, `CORR`, `MCP_POISON`, `MCP_INJECT`, `MCP_TRAVERSAL`, `MCP_SUPPLY`, `MCP_PERM`, `WORM`, `CICD`, `MANUAL`.
|
|
512
526
|
|