@clear-capabilities/agentic-security-scanner 0.76.1 → 0.78.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/bin/.agentic-security/findings.json +320 -9
- package/bin/.agentic-security/last-scan.json +320 -9
- package/bin/.agentic-security/last-scan.json.sig +1 -1
- package/bin/.agentic-security/scan-history.json +17 -377
- package/bin/.agentic-security/streak.json +11 -16
- package/bin/agentic-security.js +33 -2
- package/dist/178.index.js +1 -1
- package/dist/384.index.js +1 -1
- package/dist/637.index.js +1 -1
- package/dist/718.index.js +106 -0
- package/dist/824.index.js +126 -0
- package/dist/838.index.js +1 -1
- package/dist/agentic-security.mjs +32 -32
- package/dist/agentic-security.mjs.sha256 +1 -1
- package/package.json +7 -7
- package/src/.agentic-security/findings.json +5731 -3933
- package/src/.agentic-security/last-scan.json +5731 -3933
- package/src/.agentic-security/last-scan.json.sig +1 -1
- package/src/.agentic-security/scan-history.json +2533 -887
- package/src/.agentic-security/streak.json +11 -16
- package/src/dataflow/.agentic-security/findings.json +52 -24
- package/src/dataflow/.agentic-security/last-scan.json +52 -24
- package/src/dataflow/.agentic-security/last-scan.json.sig +1 -1
- package/src/dataflow/.agentic-security/scan-history.json +101 -134
- package/src/dataflow/.agentic-security/streak.json +8 -10
- package/src/dataflow/async-sequencing.js +16 -7
- package/src/dataflow/builtin-summaries.js +131 -0
- package/src/dataflow/catalog.js +107 -0
- package/src/dataflow/cross-repo.js +75 -1
- package/src/dataflow/engine.js +129 -0
- package/src/dataflow/implicit-flow.js +24 -6
- package/src/dataflow/stub-aware-filter.js +69 -11
- package/src/dataflow/summaries.js +28 -3
- package/src/engine-parallel.js +70 -0
- package/src/engine.js +165 -15
- package/src/ir/.agentic-security/findings.json +757 -16
- package/src/ir/.agentic-security/last-scan.json +757 -16
- package/src/ir/.agentic-security/last-scan.json.sig +1 -1
- package/src/ir/.agentic-security/scan-history.json +545 -138
- package/src/ir/.agentic-security/streak.json +11 -13
- package/src/ir/index.js +22 -1
- package/src/ir/parser-go.js +403 -0
- package/src/ir/parser-js.js +2 -0
- package/src/ir/parser-php.js +330 -0
- package/src/ir/parser-py.helper.py +137 -11
- package/src/ir/parser-rb.js +309 -0
- package/src/posture/.agentic-security/findings.json +407 -84
- package/src/posture/.agentic-security/last-scan.json +407 -84
- package/src/posture/.agentic-security/last-scan.json.sig +1 -1
- package/src/posture/.agentic-security/scan-history.json +16 -4923
- package/src/posture/.agentic-security/streak.json +10 -14
- package/src/posture/calibration.js +14 -0
- package/src/posture/triage.js +13 -0
- package/src/report/.agentic-security/findings.json +6 -5
- package/src/report/.agentic-security/last-scan.json +6 -5
- package/src/report/.agentic-security/last-scan.json.sig +1 -1
- package/src/report/.agentic-security/scan-history.json +3 -300
- package/src/report/.agentic-security/streak.json +7 -8
- package/src/report/index.js +23 -2
- package/src/sast/.agentic-security/findings.json +195 -56
- package/src/sast/.agentic-security/last-scan.json +195 -56
- package/src/sast/.agentic-security/last-scan.json.sig +1 -1
- package/src/sast/.agentic-security/scan-history.json +14 -394
- package/src/sast/.agentic-security/streak.json +10 -13
- package/src/sast/cache-poisoning.js +77 -0
- package/src/sast/comparison-safety.js +73 -0
- package/src/sast/db-taint.js +54 -0
- package/src/sast/graphql.js +127 -0
- package/src/sast/llm-stored-prompt.js +57 -0
- package/src/sast/mutation-xss.js +43 -0
- package/src/sast/nosql-injection.js +5 -0
- package/src/sast/null-byte-injection.js +76 -0
- package/src/sast/redos-nfa.js +338 -0
- package/src/sast/sensitive-data-logging.js +73 -0
- package/src/sast/weak-password-hash.js +77 -0
- package/src/sast/weak-randomness.js +100 -0
- package/src/sca/.agentic-security/findings.json +502 -11
- package/src/sca/.agentic-security/last-scan.json +502 -11
- package/src/sca/.agentic-security/last-scan.json.sig +1 -1
- package/src/sca/.agentic-security/scan-history.json +19 -1
- package/src/sca/.agentic-security/streak.json +6 -6
- package/src/sca/llm-function-extract.js +107 -0
- package/src/sca/vendor-detect.js +91 -0
- package/dist/218.index.js +0 -793
- package/dist/601.index.js +0 -1038
- package/dist/634.index.js +0 -1892
- package/src/integrations/.agentic-security/findings.json +0 -1504
- package/src/integrations/.agentic-security/last-scan.json +0 -1504
- package/src/integrations/.agentic-security/scan-history.json +0 -40
- package/src/integrations/.agentic-security/streak.json +0 -21
- package/src/llm-validator/.agentic-security/findings.json +0 -1891
- package/src/llm-validator/.agentic-security/last-scan.json +0 -1891
- package/src/llm-validator/.agentic-security/last-scan.json.sig +0 -1
- package/src/llm-validator/.agentic-security/scan-history.json +0 -168
- package/src/llm-validator/.agentic-security/streak.json +0 -20
- package/src/lsp/.agentic-security/findings.json +0 -28
- package/src/lsp/.agentic-security/last-scan.json +0 -28
- package/src/lsp/.agentic-security/scan-history.json +0 -79
- package/src/lsp/.agentic-security/streak.json +0 -22
- package/src/mcp/.agentic-security/findings.json +0 -8403
- package/src/mcp/.agentic-security/last-scan.json +0 -8403
- package/src/mcp/.agentic-security/last-scan.json.sig +0 -1
- package/src/mcp/.agentic-security/scan-history.json +0 -1182
- package/src/mcp/.agentic-security/streak.json +0 -22
- package/src/sast/bench-shape/.agentic-security/findings.json +0 -28
- package/src/sast/bench-shape/.agentic-security/last-scan.json +0 -28
- package/src/sast/bench-shape/.agentic-security/scan-history.json +0 -24
- package/src/sast/bench-shape/.agentic-security/streak.json +0 -22
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// LLM-assisted vulnerable function extraction for SCA findings.
|
|
2
|
+
//
|
|
3
|
+
// For CVEs without OSV ecosystem_specific data or GHSA fix commits,
|
|
4
|
+
// uses an LLM to extract vulnerable function names from the CVE description.
|
|
5
|
+
//
|
|
6
|
+
// Gated behind AGENTIC_SECURITY_LLM_SCA=1 (opt-in).
|
|
7
|
+
// Uses the same LLM endpoint config as the SAST validator.
|
|
8
|
+
|
|
9
|
+
import * as crypto from 'node:crypto';
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
|
|
13
|
+
const CACHE_DIR = process.env.XDG_CONFIG_HOME
|
|
14
|
+
? path.join(process.env.XDG_CONFIG_HOME, 'agentic-security', 'llm-sca-cache')
|
|
15
|
+
: path.join(process.env.HOME || '/tmp', '.config', 'agentic-security', 'llm-sca-cache');
|
|
16
|
+
|
|
17
|
+
function _cacheKey(osvId) {
|
|
18
|
+
return crypto.createHash('sha256').update(`sca-fn:${osvId}`).digest('hex').slice(0, 16);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _readCache(osvId) {
|
|
22
|
+
try {
|
|
23
|
+
const fp = path.join(CACHE_DIR, _cacheKey(osvId) + '.json');
|
|
24
|
+
return JSON.parse(fs.readFileSync(fp, 'utf8'));
|
|
25
|
+
} catch { return null; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _writeCache(osvId, data) {
|
|
29
|
+
try {
|
|
30
|
+
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
31
|
+
fs.writeFileSync(path.join(CACHE_DIR, _cacheKey(osvId) + '.json'), JSON.stringify(data));
|
|
32
|
+
} catch { /* cache write failure is non-fatal */ }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isLlmScaEnabled() {
|
|
36
|
+
return process.env.AGENTIC_SECURITY_LLM_SCA === '1';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function _endpointConfig() {
|
|
40
|
+
const endpoint = process.env.AGENTIC_SECURITY_LLM_ENDPOINT;
|
|
41
|
+
const apiKey = process.env.AGENTIC_SECURITY_LLM_API_KEY;
|
|
42
|
+
const model = process.env.AGENTIC_SECURITY_LLM_MODEL || 'unknown';
|
|
43
|
+
return endpoint ? { endpoint, apiKey, model } : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function _askLlm(prompt, config) {
|
|
47
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
48
|
+
if (config.apiKey) headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
49
|
+
const resp = await fetch(config.endpoint, {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers,
|
|
52
|
+
body: JSON.stringify({ prompt, model: config.model }),
|
|
53
|
+
signal: AbortSignal.timeout(15000),
|
|
54
|
+
});
|
|
55
|
+
if (!resp.ok) return null;
|
|
56
|
+
const text = await resp.text();
|
|
57
|
+
const jsonMatch = text.match(/\{[^{}]*"functions"\s*:\s*\[[^\]]*\][^{}]*\}/);
|
|
58
|
+
if (!jsonMatch) return null;
|
|
59
|
+
try { return JSON.parse(jsonMatch[0]); } catch { return null; }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function extractVulnFunctionsViaLLM(supplyChain, opts = {}) {
|
|
63
|
+
if (!isLlmScaEnabled()) return [];
|
|
64
|
+
const config = _endpointConfig();
|
|
65
|
+
if (!config) return [];
|
|
66
|
+
|
|
67
|
+
const enriched = [];
|
|
68
|
+
const candidates = (supplyChain || []).filter(sc =>
|
|
69
|
+
sc.type === 'vulnerable_dep' &&
|
|
70
|
+
(!sc.osvVulnFunctions || !sc.osvVulnFunctions.length) &&
|
|
71
|
+
sc.noKnownCallSite &&
|
|
72
|
+
sc.description
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const BATCH_LIMIT = 20;
|
|
76
|
+
for (const sc of candidates.slice(0, BATCH_LIMIT)) {
|
|
77
|
+
const cached = _readCache(sc.osvId);
|
|
78
|
+
if (cached) {
|
|
79
|
+
if (cached.functions && cached.functions.length) {
|
|
80
|
+
sc.osvVulnFunctions = cached.functions;
|
|
81
|
+
sc._llmFunctionExtracted = true;
|
|
82
|
+
enriched.push(sc);
|
|
83
|
+
}
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const prompt = `Given security advisory ${sc.osvId || ''} (${sc.cveAliases?.[0] || ''}) affecting npm package "${sc.name}" version ${sc.version}:\n\nDescription: ${sc.description.slice(0, 500)}\n\nWhat specific exported function(s) in this package are vulnerable? Return ONLY a JSON object: { "functions": ["functionName1", "functionName2"] }\n\nIf you cannot determine the specific functions, return: { "functions": [] }`;
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const result = await _askLlm(prompt, config);
|
|
91
|
+
if (result && Array.isArray(result.functions)) {
|
|
92
|
+
const fns = result.functions.filter(f => typeof f === 'string' && f.length > 0 && f.length < 100);
|
|
93
|
+
_writeCache(sc.osvId, { functions: fns, model: config.model, extractedAt: new Date().toISOString() });
|
|
94
|
+
if (fns.length) {
|
|
95
|
+
sc.osvVulnFunctions = fns;
|
|
96
|
+
sc._llmFunctionExtracted = true;
|
|
97
|
+
enriched.push(sc);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
_writeCache(sc.osvId, { functions: [], model: config.model, extractedAt: new Date().toISOString() });
|
|
101
|
+
}
|
|
102
|
+
} catch {
|
|
103
|
+
// LLM call failure — skip, don't cache (may be transient)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return enriched;
|
|
107
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Vendored / copied library detection via version-string fingerprinting.
|
|
2
|
+
//
|
|
3
|
+
// Detects library code copied into src/ that bypasses SCA. Uses version
|
|
4
|
+
// string patterns (_.VERSION, jQuery.fn.jquery, etc.) and characteristic
|
|
5
|
+
// function signatures to identify vendored libraries.
|
|
6
|
+
|
|
7
|
+
const VERSION_FINGERPRINTS = [
|
|
8
|
+
{ pkg: 'lodash', ecosystem: 'npm', patterns: [
|
|
9
|
+
{ re: /\b(?:lodash|_)\.VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
10
|
+
{ re: /\b__lodash_hash_undefined__\b/, version: null },
|
|
11
|
+
]},
|
|
12
|
+
{ pkg: 'jquery', ecosystem: 'npm', patterns: [
|
|
13
|
+
{ re: /jQuery\.fn\.jquery\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
14
|
+
{ re: /\bjQuery\.fn\.init\b/, version: null },
|
|
15
|
+
]},
|
|
16
|
+
{ pkg: 'underscore', ecosystem: 'npm', patterns: [
|
|
17
|
+
{ re: /\b_\.VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
18
|
+
]},
|
|
19
|
+
{ pkg: 'moment', ecosystem: 'npm', patterns: [
|
|
20
|
+
{ re: /\bmoment\.version\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
21
|
+
{ re: /\bmoment\.(?:utc|parseZone|duration|locale)\b/, version: null },
|
|
22
|
+
]},
|
|
23
|
+
{ pkg: 'handlebars', ecosystem: 'npm', patterns: [
|
|
24
|
+
{ re: /\bHandlebars\.VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
25
|
+
]},
|
|
26
|
+
{ pkg: 'backbone', ecosystem: 'npm', patterns: [
|
|
27
|
+
{ re: /\bBackbone\.VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
28
|
+
]},
|
|
29
|
+
{ pkg: 'angular', ecosystem: 'npm', patterns: [
|
|
30
|
+
{ re: /\bangular\.version\s*=\s*\{[^}]*full\s*:\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
31
|
+
]},
|
|
32
|
+
{ pkg: 'vue', ecosystem: 'npm', patterns: [
|
|
33
|
+
{ re: /\bVue\.version\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
34
|
+
]},
|
|
35
|
+
{ pkg: 'react', ecosystem: 'npm', patterns: [
|
|
36
|
+
{ re: /\bReactVersion\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
37
|
+
]},
|
|
38
|
+
{ pkg: 'dompurify', ecosystem: 'npm', patterns: [
|
|
39
|
+
{ re: /\bDOMPurify\.version\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
40
|
+
]},
|
|
41
|
+
{ pkg: 'marked', ecosystem: 'npm', patterns: [
|
|
42
|
+
{ re: /\bmarked\.(?:defaults|setOptions|use|parse)\b[\s\S]{0,200}version\s*[:=]\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
43
|
+
]},
|
|
44
|
+
{ pkg: 'axios', ecosystem: 'npm', patterns: [
|
|
45
|
+
{ re: /\baxios\.VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
46
|
+
]},
|
|
47
|
+
{ pkg: 'socket.io-client', ecosystem: 'npm', patterns: [
|
|
48
|
+
{ re: /\bio\.protocol\s*=\s*(\d+)/, version: null },
|
|
49
|
+
]},
|
|
50
|
+
{ pkg: 'highlight.js', ecosystem: 'npm', patterns: [
|
|
51
|
+
{ re: /\bhljs\.versionString\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
52
|
+
]},
|
|
53
|
+
{ pkg: 'chart.js', ecosystem: 'npm', patterns: [
|
|
54
|
+
{ re: /\bChart\.version\s*=\s*['"](\d+\.\d+\.\d+)['"]/, versionGroup: 1 },
|
|
55
|
+
]},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const SKIP_DIRS = /(?:^|[/\\])(?:node_modules|vendor|dist|build|\.next|__pycache__|\.git)[/\\]/;
|
|
59
|
+
|
|
60
|
+
export function detectVendoredLibraries(fileContents) {
|
|
61
|
+
if (!fileContents || typeof fileContents !== 'object') return [];
|
|
62
|
+
const detected = [];
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
|
|
65
|
+
for (const [fp, content] of Object.entries(fileContents)) {
|
|
66
|
+
if (!content || typeof content !== 'string') continue;
|
|
67
|
+
if (SKIP_DIRS.test(fp)) continue;
|
|
68
|
+
if (content.length < 500) continue;
|
|
69
|
+
|
|
70
|
+
for (const lib of VERSION_FINGERPRINTS) {
|
|
71
|
+
for (const pat of lib.patterns) {
|
|
72
|
+
const m = content.match(pat.re);
|
|
73
|
+
if (!m) continue;
|
|
74
|
+
const version = pat.versionGroup ? m[pat.versionGroup] : null;
|
|
75
|
+
const key = `${lib.pkg}:${fp}`;
|
|
76
|
+
if (seen.has(key)) continue;
|
|
77
|
+
seen.add(key);
|
|
78
|
+
detected.push({
|
|
79
|
+
name: lib.pkg,
|
|
80
|
+
version: version || 'unknown',
|
|
81
|
+
ecosystem: lib.ecosystem,
|
|
82
|
+
file: fp,
|
|
83
|
+
scope: 'vendored',
|
|
84
|
+
isVendored: true,
|
|
85
|
+
});
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return detected;
|
|
91
|
+
}
|