@oculum/scanner 1.0.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/dist/formatters/cli-terminal.d.ts +27 -0
- package/dist/formatters/cli-terminal.d.ts.map +1 -0
- package/dist/formatters/cli-terminal.js +412 -0
- package/dist/formatters/cli-terminal.js.map +1 -0
- package/dist/formatters/github-comment.d.ts +41 -0
- package/dist/formatters/github-comment.d.ts.map +1 -0
- package/dist/formatters/github-comment.js +306 -0
- package/dist/formatters/github-comment.js.map +1 -0
- package/dist/formatters/grouping.d.ts +52 -0
- package/dist/formatters/grouping.d.ts.map +1 -0
- package/dist/formatters/grouping.js +152 -0
- package/dist/formatters/grouping.js.map +1 -0
- package/dist/formatters/index.d.ts +9 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +35 -0
- package/dist/formatters/index.js.map +1 -0
- package/dist/formatters/vscode-diagnostic.d.ts +103 -0
- package/dist/formatters/vscode-diagnostic.d.ts.map +1 -0
- package/dist/formatters/vscode-diagnostic.js +151 -0
- package/dist/formatters/vscode-diagnostic.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +648 -0
- package/dist/index.js.map +1 -0
- package/dist/layer1/comments.d.ts +8 -0
- package/dist/layer1/comments.d.ts.map +1 -0
- package/dist/layer1/comments.js +203 -0
- package/dist/layer1/comments.js.map +1 -0
- package/dist/layer1/config-audit.d.ts +8 -0
- package/dist/layer1/config-audit.d.ts.map +1 -0
- package/dist/layer1/config-audit.js +252 -0
- package/dist/layer1/config-audit.js.map +1 -0
- package/dist/layer1/entropy.d.ts +8 -0
- package/dist/layer1/entropy.d.ts.map +1 -0
- package/dist/layer1/entropy.js +500 -0
- package/dist/layer1/entropy.js.map +1 -0
- package/dist/layer1/file-flags.d.ts +7 -0
- package/dist/layer1/file-flags.d.ts.map +1 -0
- package/dist/layer1/file-flags.js +112 -0
- package/dist/layer1/file-flags.js.map +1 -0
- package/dist/layer1/index.d.ts +36 -0
- package/dist/layer1/index.d.ts.map +1 -0
- package/dist/layer1/index.js +132 -0
- package/dist/layer1/index.js.map +1 -0
- package/dist/layer1/patterns.d.ts +8 -0
- package/dist/layer1/patterns.d.ts.map +1 -0
- package/dist/layer1/patterns.js +482 -0
- package/dist/layer1/patterns.js.map +1 -0
- package/dist/layer1/urls.d.ts +8 -0
- package/dist/layer1/urls.d.ts.map +1 -0
- package/dist/layer1/urls.js +296 -0
- package/dist/layer1/urls.js.map +1 -0
- package/dist/layer1/weak-crypto.d.ts +7 -0
- package/dist/layer1/weak-crypto.d.ts.map +1 -0
- package/dist/layer1/weak-crypto.js +291 -0
- package/dist/layer1/weak-crypto.js.map +1 -0
- package/dist/layer2/ai-agent-tools.d.ts +19 -0
- package/dist/layer2/ai-agent-tools.d.ts.map +1 -0
- package/dist/layer2/ai-agent-tools.js +528 -0
- package/dist/layer2/ai-agent-tools.js.map +1 -0
- package/dist/layer2/ai-endpoint-protection.d.ts +36 -0
- package/dist/layer2/ai-endpoint-protection.d.ts.map +1 -0
- package/dist/layer2/ai-endpoint-protection.js +332 -0
- package/dist/layer2/ai-endpoint-protection.js.map +1 -0
- package/dist/layer2/ai-execution-sinks.d.ts +18 -0
- package/dist/layer2/ai-execution-sinks.d.ts.map +1 -0
- package/dist/layer2/ai-execution-sinks.js +496 -0
- package/dist/layer2/ai-execution-sinks.js.map +1 -0
- package/dist/layer2/ai-fingerprinting.d.ts +7 -0
- package/dist/layer2/ai-fingerprinting.d.ts.map +1 -0
- package/dist/layer2/ai-fingerprinting.js +654 -0
- package/dist/layer2/ai-fingerprinting.js.map +1 -0
- package/dist/layer2/ai-prompt-hygiene.d.ts +19 -0
- package/dist/layer2/ai-prompt-hygiene.d.ts.map +1 -0
- package/dist/layer2/ai-prompt-hygiene.js +356 -0
- package/dist/layer2/ai-prompt-hygiene.js.map +1 -0
- package/dist/layer2/ai-rag-safety.d.ts +21 -0
- package/dist/layer2/ai-rag-safety.d.ts.map +1 -0
- package/dist/layer2/ai-rag-safety.js +459 -0
- package/dist/layer2/ai-rag-safety.js.map +1 -0
- package/dist/layer2/ai-schema-validation.d.ts +25 -0
- package/dist/layer2/ai-schema-validation.d.ts.map +1 -0
- package/dist/layer2/ai-schema-validation.js +375 -0
- package/dist/layer2/ai-schema-validation.js.map +1 -0
- package/dist/layer2/auth-antipatterns.d.ts +20 -0
- package/dist/layer2/auth-antipatterns.d.ts.map +1 -0
- package/dist/layer2/auth-antipatterns.js +333 -0
- package/dist/layer2/auth-antipatterns.js.map +1 -0
- package/dist/layer2/byok-patterns.d.ts +12 -0
- package/dist/layer2/byok-patterns.d.ts.map +1 -0
- package/dist/layer2/byok-patterns.js +299 -0
- package/dist/layer2/byok-patterns.js.map +1 -0
- package/dist/layer2/dangerous-functions.d.ts +7 -0
- package/dist/layer2/dangerous-functions.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions.js +1375 -0
- package/dist/layer2/dangerous-functions.js.map +1 -0
- package/dist/layer2/data-exposure.d.ts +16 -0
- package/dist/layer2/data-exposure.d.ts.map +1 -0
- package/dist/layer2/data-exposure.js +279 -0
- package/dist/layer2/data-exposure.js.map +1 -0
- package/dist/layer2/framework-checks.d.ts +7 -0
- package/dist/layer2/framework-checks.d.ts.map +1 -0
- package/dist/layer2/framework-checks.js +388 -0
- package/dist/layer2/framework-checks.js.map +1 -0
- package/dist/layer2/index.d.ts +58 -0
- package/dist/layer2/index.d.ts.map +1 -0
- package/dist/layer2/index.js +380 -0
- package/dist/layer2/index.js.map +1 -0
- package/dist/layer2/logic-gates.d.ts +7 -0
- package/dist/layer2/logic-gates.d.ts.map +1 -0
- package/dist/layer2/logic-gates.js +182 -0
- package/dist/layer2/logic-gates.js.map +1 -0
- package/dist/layer2/risky-imports.d.ts +7 -0
- package/dist/layer2/risky-imports.d.ts.map +1 -0
- package/dist/layer2/risky-imports.js +161 -0
- package/dist/layer2/risky-imports.js.map +1 -0
- package/dist/layer2/variables.d.ts +8 -0
- package/dist/layer2/variables.d.ts.map +1 -0
- package/dist/layer2/variables.js +152 -0
- package/dist/layer2/variables.js.map +1 -0
- package/dist/layer3/anthropic.d.ts +83 -0
- package/dist/layer3/anthropic.d.ts.map +1 -0
- package/dist/layer3/anthropic.js +1745 -0
- package/dist/layer3/anthropic.js.map +1 -0
- package/dist/layer3/index.d.ts +24 -0
- package/dist/layer3/index.d.ts.map +1 -0
- package/dist/layer3/index.js +119 -0
- package/dist/layer3/index.js.map +1 -0
- package/dist/layer3/openai.d.ts +25 -0
- package/dist/layer3/openai.d.ts.map +1 -0
- package/dist/layer3/openai.js +238 -0
- package/dist/layer3/openai.js.map +1 -0
- package/dist/layer3/package-check.d.ts +63 -0
- package/dist/layer3/package-check.d.ts.map +1 -0
- package/dist/layer3/package-check.js +508 -0
- package/dist/layer3/package-check.js.map +1 -0
- package/dist/modes/incremental.d.ts +66 -0
- package/dist/modes/incremental.d.ts.map +1 -0
- package/dist/modes/incremental.js +200 -0
- package/dist/modes/incremental.js.map +1 -0
- package/dist/tiers.d.ts +125 -0
- package/dist/tiers.d.ts.map +1 -0
- package/dist/tiers.js +234 -0
- package/dist/tiers.js.map +1 -0
- package/dist/types.d.ts +175 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +50 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/auth-helper-detector.d.ts +56 -0
- package/dist/utils/auth-helper-detector.d.ts.map +1 -0
- package/dist/utils/auth-helper-detector.js +360 -0
- package/dist/utils/auth-helper-detector.js.map +1 -0
- package/dist/utils/context-helpers.d.ts +96 -0
- package/dist/utils/context-helpers.d.ts.map +1 -0
- package/dist/utils/context-helpers.js +493 -0
- package/dist/utils/context-helpers.js.map +1 -0
- package/dist/utils/diff-detector.d.ts +53 -0
- package/dist/utils/diff-detector.d.ts.map +1 -0
- package/dist/utils/diff-detector.js +104 -0
- package/dist/utils/diff-detector.js.map +1 -0
- package/dist/utils/diff-parser.d.ts +80 -0
- package/dist/utils/diff-parser.d.ts.map +1 -0
- package/dist/utils/diff-parser.js +202 -0
- package/dist/utils/diff-parser.js.map +1 -0
- package/dist/utils/imported-auth-detector.d.ts +37 -0
- package/dist/utils/imported-auth-detector.d.ts.map +1 -0
- package/dist/utils/imported-auth-detector.js +251 -0
- package/dist/utils/imported-auth-detector.js.map +1 -0
- package/dist/utils/middleware-detector.d.ts +55 -0
- package/dist/utils/middleware-detector.d.ts.map +1 -0
- package/dist/utils/middleware-detector.js +260 -0
- package/dist/utils/middleware-detector.js.map +1 -0
- package/dist/utils/oauth-flow-detector.d.ts +41 -0
- package/dist/utils/oauth-flow-detector.d.ts.map +1 -0
- package/dist/utils/oauth-flow-detector.js +202 -0
- package/dist/utils/oauth-flow-detector.js.map +1 -0
- package/dist/utils/path-exclusions.d.ts +55 -0
- package/dist/utils/path-exclusions.d.ts.map +1 -0
- package/dist/utils/path-exclusions.js +222 -0
- package/dist/utils/path-exclusions.js.map +1 -0
- package/dist/utils/project-context-builder.d.ts +119 -0
- package/dist/utils/project-context-builder.d.ts.map +1 -0
- package/dist/utils/project-context-builder.js +534 -0
- package/dist/utils/project-context-builder.js.map +1 -0
- package/dist/utils/registry-clients.d.ts +93 -0
- package/dist/utils/registry-clients.d.ts.map +1 -0
- package/dist/utils/registry-clients.js +273 -0
- package/dist/utils/registry-clients.js.map +1 -0
- package/dist/utils/trpc-analyzer.d.ts +78 -0
- package/dist/utils/trpc-analyzer.d.ts.map +1 -0
- package/dist/utils/trpc-analyzer.js +297 -0
- package/dist/utils/trpc-analyzer.js.map +1 -0
- package/package.json +45 -0
- package/src/__tests__/benchmark/fixtures/false-positives.ts +227 -0
- package/src/__tests__/benchmark/fixtures/index.ts +68 -0
- package/src/__tests__/benchmark/fixtures/layer1/config-audit.ts +364 -0
- package/src/__tests__/benchmark/fixtures/layer1/hardcoded-secrets.ts +173 -0
- package/src/__tests__/benchmark/fixtures/layer1/high-entropy.ts +234 -0
- package/src/__tests__/benchmark/fixtures/layer1/index.ts +31 -0
- package/src/__tests__/benchmark/fixtures/layer1/sensitive-urls.ts +90 -0
- package/src/__tests__/benchmark/fixtures/layer1/weak-crypto.ts +197 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-agent-tools.ts +170 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-endpoint-protection.ts +418 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-execution-sinks.ts +189 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-fingerprinting.ts +316 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-prompt-hygiene.ts +178 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-rag-safety.ts +184 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-schema-validation.ts +434 -0
- package/src/__tests__/benchmark/fixtures/layer2/auth-antipatterns.ts +159 -0
- package/src/__tests__/benchmark/fixtures/layer2/byok-patterns.ts +112 -0
- package/src/__tests__/benchmark/fixtures/layer2/dangerous-functions.ts +246 -0
- package/src/__tests__/benchmark/fixtures/layer2/data-exposure.ts +168 -0
- package/src/__tests__/benchmark/fixtures/layer2/framework-checks.ts +346 -0
- package/src/__tests__/benchmark/fixtures/layer2/index.ts +67 -0
- package/src/__tests__/benchmark/fixtures/layer2/injection-vulnerabilities.ts +239 -0
- package/src/__tests__/benchmark/fixtures/layer2/logic-gates.ts +246 -0
- package/src/__tests__/benchmark/fixtures/layer2/risky-imports.ts +231 -0
- package/src/__tests__/benchmark/fixtures/layer2/variables.ts +167 -0
- package/src/__tests__/benchmark/index.ts +29 -0
- package/src/__tests__/benchmark/run-benchmark.ts +144 -0
- package/src/__tests__/benchmark/run-depth-validation.ts +206 -0
- package/src/__tests__/benchmark/run-real-world-test.ts +243 -0
- package/src/__tests__/benchmark/security-benchmark-script.ts +1737 -0
- package/src/__tests__/benchmark/tier-integration-script.ts +177 -0
- package/src/__tests__/benchmark/types.ts +144 -0
- package/src/__tests__/benchmark/utils/test-runner.ts +475 -0
- package/src/__tests__/regression/known-false-positives.test.ts +467 -0
- package/src/__tests__/snapshots/__snapshots__/scan-depth.test.ts.snap +178 -0
- package/src/__tests__/snapshots/scan-depth.test.ts +258 -0
- package/src/__tests__/validation/analyze-results.ts +542 -0
- package/src/__tests__/validation/extract-for-triage.ts +146 -0
- package/src/__tests__/validation/fp-deep-analysis.ts +327 -0
- package/src/__tests__/validation/run-validation.ts +364 -0
- package/src/__tests__/validation/triage-template.md +132 -0
- package/src/formatters/cli-terminal.ts +446 -0
- package/src/formatters/github-comment.ts +382 -0
- package/src/formatters/grouping.ts +190 -0
- package/src/formatters/index.ts +47 -0
- package/src/formatters/vscode-diagnostic.ts +243 -0
- package/src/index.ts +823 -0
- package/src/layer1/comments.ts +218 -0
- package/src/layer1/config-audit.ts +289 -0
- package/src/layer1/entropy.ts +583 -0
- package/src/layer1/file-flags.ts +127 -0
- package/src/layer1/index.ts +181 -0
- package/src/layer1/patterns.ts +516 -0
- package/src/layer1/urls.ts +334 -0
- package/src/layer1/weak-crypto.ts +328 -0
- package/src/layer2/ai-agent-tools.ts +601 -0
- package/src/layer2/ai-endpoint-protection.ts +387 -0
- package/src/layer2/ai-execution-sinks.ts +580 -0
- package/src/layer2/ai-fingerprinting.ts +758 -0
- package/src/layer2/ai-prompt-hygiene.ts +411 -0
- package/src/layer2/ai-rag-safety.ts +511 -0
- package/src/layer2/ai-schema-validation.ts +421 -0
- package/src/layer2/auth-antipatterns.ts +394 -0
- package/src/layer2/byok-patterns.ts +336 -0
- package/src/layer2/dangerous-functions.ts +1563 -0
- package/src/layer2/data-exposure.ts +315 -0
- package/src/layer2/framework-checks.ts +433 -0
- package/src/layer2/index.ts +473 -0
- package/src/layer2/logic-gates.ts +206 -0
- package/src/layer2/risky-imports.ts +186 -0
- package/src/layer2/variables.ts +166 -0
- package/src/layer3/anthropic.ts +2030 -0
- package/src/layer3/index.ts +130 -0
- package/src/layer3/package-check.ts +604 -0
- package/src/modes/incremental.ts +293 -0
- package/src/tiers.ts +318 -0
- package/src/types.ts +284 -0
- package/src/utils/auth-helper-detector.ts +443 -0
- package/src/utils/context-helpers.ts +535 -0
- package/src/utils/diff-detector.ts +135 -0
- package/src/utils/diff-parser.ts +272 -0
- package/src/utils/imported-auth-detector.ts +320 -0
- package/src/utils/middleware-detector.ts +333 -0
- package/src/utils/oauth-flow-detector.ts +246 -0
- package/src/utils/path-exclusions.ts +266 -0
- package/src/utils/project-context-builder.ts +707 -0
- package/src/utils/registry-clients.ts +351 -0
- package/src/utils/trpc-analyzer.ts +382 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Layer 2: AI Execution Sink Detection
|
|
4
|
+
* Detects patterns where LLM output is fed into dangerous execution sinks
|
|
5
|
+
*
|
|
6
|
+
* Covers B2: Unsafe execution of model output (LLM02)
|
|
7
|
+
*
|
|
8
|
+
* Sinks include:
|
|
9
|
+
* - Code execution: eval(), Function(), vm.runInContext()
|
|
10
|
+
* - Shell execution: exec(), spawn(), child_process
|
|
11
|
+
* - SQL builders: .query(), .execute(), .raw()
|
|
12
|
+
* - Template rendering: innerHTML, dangerouslySetInnerHTML
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.detectAIExecutionSinks = detectAIExecutionSinks;
|
|
16
|
+
const context_helpers_1 = require("../utils/context-helpers");
|
|
17
|
+
const ai_prompt_hygiene_1 = require("./ai-prompt-hygiene");
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// LLM Output Variable Detection
|
|
20
|
+
// ============================================================================
|
|
21
|
+
/**
|
|
22
|
+
* Check if line contains LLM API response context
|
|
23
|
+
*/
|
|
24
|
+
function hasLLMResponseContext(lineContent, surroundingContext) {
|
|
25
|
+
const llmResponsePatterns = [
|
|
26
|
+
/\.choices\[0\]\.message\.content/i, // OpenAI response
|
|
27
|
+
/\.content\[0\]\.text/i, // Anthropic response
|
|
28
|
+
/completion\.text/i, // Generic completion
|
|
29
|
+
/\.data\.choices/i, // API response
|
|
30
|
+
/await\s+\w+\.(?:chat|messages|completions)\.create/i, // API call
|
|
31
|
+
/response\.text\s*\(/i, // Response text method
|
|
32
|
+
];
|
|
33
|
+
const fullContext = lineContent + '\n' + surroundingContext;
|
|
34
|
+
return llmResponsePatterns.some(p => p.test(fullContext));
|
|
35
|
+
}
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// UI Suggestion / Template Pattern Detection (False Positive Filters)
|
|
38
|
+
// ============================================================================
|
|
39
|
+
/**
|
|
40
|
+
* Check if this is a UI suggestion/template pattern rather than execution sink
|
|
41
|
+
* These patterns create display strings for command palettes, autocomplete, etc.
|
|
42
|
+
*/
|
|
43
|
+
function isUITemplateSuggestion(lineContent, surroundingContext) {
|
|
44
|
+
const fullContext = lineContent + '\n' + surroundingContext;
|
|
45
|
+
// UI suggestion object patterns (command palette, autocomplete suggestions)
|
|
46
|
+
const uiSuggestionPatterns = [
|
|
47
|
+
// Object property patterns for suggestion items
|
|
48
|
+
/(?:id|key|label|title|name|description|completion|display|text|value|placeholder):\s*`[^`]*\$\{/i,
|
|
49
|
+
// Common suggestion UI patterns
|
|
50
|
+
/suggestions?\s*[=:]/i,
|
|
51
|
+
/completions?\s*[=:]/i,
|
|
52
|
+
/autocomplete/i,
|
|
53
|
+
/command\s*palette/i,
|
|
54
|
+
/fuzzy\s*search/i,
|
|
55
|
+
/search\s*result/i,
|
|
56
|
+
// UI component context patterns
|
|
57
|
+
/\.map\s*\(\s*\(?(?:item|result|suggestion|node|entry)/i,
|
|
58
|
+
/\.filter\s*\(/i,
|
|
59
|
+
// React/UI state patterns
|
|
60
|
+
/useState|setItems|setResults|setSuggestions/i,
|
|
61
|
+
// Template ID generation for UI
|
|
62
|
+
/id:\s*`[a-z]+-\$\{/i, // id: `delete-${...}`, id: `edit-${...}`
|
|
63
|
+
];
|
|
64
|
+
// These patterns should NOT be considered UI suggestions
|
|
65
|
+
const notUISuggestionPatterns = [
|
|
66
|
+
/\.query\s*\(/i,
|
|
67
|
+
/\.execute\s*\(/i,
|
|
68
|
+
/\.raw\s*\(/i,
|
|
69
|
+
/await\s+db\./i,
|
|
70
|
+
/prisma\./i,
|
|
71
|
+
/supabase\./i,
|
|
72
|
+
/knex\./i,
|
|
73
|
+
/sequelize\./i,
|
|
74
|
+
/child_process/i,
|
|
75
|
+
/exec\s*\(/i,
|
|
76
|
+
/spawn\s*\(/i,
|
|
77
|
+
/eval\s*\(/i,
|
|
78
|
+
];
|
|
79
|
+
// Check if context matches UI pattern but NOT execution pattern
|
|
80
|
+
const matchesUIPattern = uiSuggestionPatterns.some(p => p.test(fullContext));
|
|
81
|
+
const matchesExecutionPattern = notUISuggestionPatterns.some(p => p.test(lineContent));
|
|
82
|
+
return matchesUIPattern && !matchesExecutionPattern;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Check if this is a static template string (no actual LLM output interpolation)
|
|
86
|
+
* e.g., `delete ${node.title}` where node is app data, not LLM output
|
|
87
|
+
*/
|
|
88
|
+
function isAppDataInterpolation(lineContent, surroundingContext) {
|
|
89
|
+
const fullContext = lineContent + '\n' + surroundingContext;
|
|
90
|
+
// Patterns indicating the interpolated variable is app data, not LLM output
|
|
91
|
+
const appDataPatterns = [
|
|
92
|
+
// Database result/record properties
|
|
93
|
+
/\$\{(?:result|item|record|row|entry|node)\.(?:id|title|name|slug|key|label)\}/i,
|
|
94
|
+
// UI state properties
|
|
95
|
+
/\$\{(?:selected|current|active|item|node)\.(?:id|title|name|value)\}/i,
|
|
96
|
+
// Form/input data
|
|
97
|
+
/\$\{(?:data|values|form|input)\.(?:id|name|value)\}/i,
|
|
98
|
+
// Array iteration context
|
|
99
|
+
/\.map\s*\(\s*\(?(?:item|node|row|entry|result)/i,
|
|
100
|
+
/\.forEach\s*\(\s*\(?(?:item|node|row|entry|result)/i,
|
|
101
|
+
];
|
|
102
|
+
// Patterns that suggest LLM output (should not skip)
|
|
103
|
+
const llmOutputPatterns = [
|
|
104
|
+
/\$\{(?:response|completion|generated|output|answer|reply|message)\.?/i,
|
|
105
|
+
/\$\{(?:ai|llm|gpt|claude|chat)(?:Response|Output|Result)/i,
|
|
106
|
+
/\.choices\[0\]/i,
|
|
107
|
+
/\.content\[0\]\.text/i,
|
|
108
|
+
];
|
|
109
|
+
const isAppData = appDataPatterns.some(p => p.test(fullContext));
|
|
110
|
+
const isLLMOutput = llmOutputPatterns.some(p => p.test(fullContext));
|
|
111
|
+
return isAppData && !isLLMOutput;
|
|
112
|
+
}
|
|
113
|
+
// ============================================================================
|
|
114
|
+
// Sandbox and Validation Detection
|
|
115
|
+
// ============================================================================
|
|
116
|
+
/**
|
|
117
|
+
* Check if execution is sandboxed
|
|
118
|
+
*/
|
|
119
|
+
function isSandboxedExecution(content, lineNumber) {
|
|
120
|
+
const lines = content.split('\n');
|
|
121
|
+
const contextStart = Math.max(0, lineNumber - 25);
|
|
122
|
+
const contextEnd = Math.min(lines.length, lineNumber + 10);
|
|
123
|
+
const context = lines.slice(contextStart, contextEnd).join('\n');
|
|
124
|
+
const sandboxPatterns = [
|
|
125
|
+
/vm2/i,
|
|
126
|
+
/isolated-vm/i,
|
|
127
|
+
/safeeval/i,
|
|
128
|
+
/safe-eval/i,
|
|
129
|
+
/sandbox/i,
|
|
130
|
+
/runInNewContext.*\{.*timeout/i,
|
|
131
|
+
/runInContext.*\{.*timeout/i,
|
|
132
|
+
/allowedGlobals/i,
|
|
133
|
+
/allowedModules/i,
|
|
134
|
+
/quickjs/i,
|
|
135
|
+
/webworker/i,
|
|
136
|
+
/iframe.*sandbox/i,
|
|
137
|
+
];
|
|
138
|
+
return sandboxPatterns.some(p => p.test(context));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Check if output has validation before execution
|
|
142
|
+
*/
|
|
143
|
+
function hasOutputValidation(content, lineNumber) {
|
|
144
|
+
const lines = content.split('\n');
|
|
145
|
+
const contextStart = Math.max(0, lineNumber - 15);
|
|
146
|
+
const contextEnd = Math.min(lines.length, lineNumber + 5);
|
|
147
|
+
const context = lines.slice(contextStart, contextEnd).join('\n');
|
|
148
|
+
const validationPatterns = [
|
|
149
|
+
/validate/i,
|
|
150
|
+
/sanitize/i,
|
|
151
|
+
/escape/i,
|
|
152
|
+
/filter/i,
|
|
153
|
+
/parse.*catch/i,
|
|
154
|
+
/schema\./i,
|
|
155
|
+
/\.parse\s*\(/i,
|
|
156
|
+
/allowlist/i,
|
|
157
|
+
/whitelist/i,
|
|
158
|
+
/blocklist/i,
|
|
159
|
+
/blacklist/i,
|
|
160
|
+
/JSON\.parse.*catch/i,
|
|
161
|
+
/DOMPurify/i,
|
|
162
|
+
/xss/i,
|
|
163
|
+
];
|
|
164
|
+
return validationPatterns.some(p => p.test(context));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Check if this appears to be display-only usage (not execution)
|
|
168
|
+
*/
|
|
169
|
+
function isDisplayOnly(lineContent, surroundingContext) {
|
|
170
|
+
const displayPatterns = [
|
|
171
|
+
/console\.(log|info|debug|warn)/i,
|
|
172
|
+
/textContent\s*=/i,
|
|
173
|
+
/innerText\s*=/i,
|
|
174
|
+
/\.text\s*=/i,
|
|
175
|
+
/setState.*display/i,
|
|
176
|
+
/render.*\{/i,
|
|
177
|
+
/<p>|<div>|<span>/i,
|
|
178
|
+
/\.send\s*\(/i,
|
|
179
|
+
/\.json\s*\(/i,
|
|
180
|
+
/return\s+.*response/i,
|
|
181
|
+
];
|
|
182
|
+
const fullContext = lineContent + '\n' + surroundingContext;
|
|
183
|
+
return displayPatterns.some(p => p.test(fullContext));
|
|
184
|
+
}
|
|
185
|
+
const EXECUTION_SINK_PATTERNS = [
|
|
186
|
+
// ========== Code Execution Sinks ==========
|
|
187
|
+
{
|
|
188
|
+
name: 'LLM output to eval()',
|
|
189
|
+
pattern: /eval\s*\(\s*(?:response|result|output|completion|message|content|answer|generated|text)(?:\.|\.data\.|\.text|\.content)?/gi,
|
|
190
|
+
sinkType: 'code_execution',
|
|
191
|
+
baseSeverity: 'critical',
|
|
192
|
+
description: 'LLM output is passed directly to eval(). This allows arbitrary code execution if the model is manipulated via prompt injection.',
|
|
193
|
+
suggestedFix: 'Never eval() LLM output. Use structured output (JSON schema) and validate before processing. Consider using a sandboxed environment like vm2 if code execution is required.',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'LLM output to Function constructor',
|
|
197
|
+
pattern: /new\s+Function\s*\([^)]*(?:response|result|output|completion|message|content|answer|generated)/gi,
|
|
198
|
+
sinkType: 'code_execution',
|
|
199
|
+
baseSeverity: 'critical',
|
|
200
|
+
description: 'LLM output is passed to Function constructor, which is equivalent to eval().',
|
|
201
|
+
suggestedFix: 'Use JSON schemas to define expected output structure. Validate output before any processing.',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'LLM output to vm.runInContext',
|
|
205
|
+
pattern: /vm\.run(?:InContext|InNewContext|InThisContext)\s*\(\s*(?:response|result|output|completion|content)/gi,
|
|
206
|
+
sinkType: 'code_execution',
|
|
207
|
+
baseSeverity: 'high',
|
|
208
|
+
description: 'LLM output executed in Node.js VM context. While isolated, VM can still be escaped in some versions.',
|
|
209
|
+
suggestedFix: 'Use vm2 or isolated-vm for proper sandboxing. Add timeout and memory limits. Validate output structure before execution.',
|
|
210
|
+
},
|
|
211
|
+
// Generic pattern for code from LLM
|
|
212
|
+
{
|
|
213
|
+
name: 'Dynamic code execution from AI',
|
|
214
|
+
pattern: /(?:eval|exec|execute)\s*\(\s*(?:ai|llm|gpt|claude|chat)(?:Response|Output|Result|Code)/gi,
|
|
215
|
+
sinkType: 'code_execution',
|
|
216
|
+
baseSeverity: 'critical',
|
|
217
|
+
description: 'AI-generated code is being executed dynamically.',
|
|
218
|
+
suggestedFix: 'Use a sandboxed code execution environment. Validate and restrict the allowed operations.',
|
|
219
|
+
},
|
|
220
|
+
// ========== Shell Command Sinks ==========
|
|
221
|
+
{
|
|
222
|
+
name: 'LLM output to exec()',
|
|
223
|
+
pattern: /(?:exec|execSync)\s*\(\s*(?:response|result|output|completion|command|content)(?:\.|\.data\.|\.text)?/gi,
|
|
224
|
+
sinkType: 'shell_command',
|
|
225
|
+
baseSeverity: 'critical',
|
|
226
|
+
description: 'LLM output is passed to shell exec(). Attackers can execute arbitrary system commands via prompt injection.',
|
|
227
|
+
suggestedFix: 'Never pass LLM output directly to shell. Use allowlists for permitted commands. Parse structured output and use execFile() with fixed command and arguments.',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'LLM output to spawn()',
|
|
231
|
+
pattern: /spawn\s*\(\s*(?:response|result|output|completion|command|content)(?:\.|\.data\.|\.text)?/gi,
|
|
232
|
+
sinkType: 'shell_command',
|
|
233
|
+
baseSeverity: 'critical',
|
|
234
|
+
description: 'LLM output is passed to spawn(), allowing command execution.',
|
|
235
|
+
suggestedFix: 'Use a predefined list of allowed commands. Parse LLM output to extract only arguments, not command names.',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: 'LLM output in shell template',
|
|
239
|
+
pattern: /`[^`]*\$\{(?:response|result|output|completion|command|content)[^}]*\}[^`]*`\s*(?:,|\))\s*(?:exec|spawn|child_process)/gi,
|
|
240
|
+
sinkType: 'shell_command',
|
|
241
|
+
baseSeverity: 'critical',
|
|
242
|
+
description: 'LLM output is interpolated into a shell command template.',
|
|
243
|
+
suggestedFix: 'Use execFile() with separate command and arguments array. Never interpolate AI output into shell strings.',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: 'child_process with AI output',
|
|
247
|
+
pattern: /child_process\.\w+\s*\([^)]*(?:ai|llm|gpt|claude|chat)(?:Response|Output|Result)/gi,
|
|
248
|
+
sinkType: 'shell_command',
|
|
249
|
+
baseSeverity: 'critical',
|
|
250
|
+
description: 'AI-generated content passed to child_process module.',
|
|
251
|
+
suggestedFix: 'Implement strict allowlisting of commands. Parse structured output from LLM.',
|
|
252
|
+
},
|
|
253
|
+
// ========== SQL Builder Sinks ==========
|
|
254
|
+
{
|
|
255
|
+
name: 'LLM output in raw SQL',
|
|
256
|
+
pattern: /\.(?:query|execute|raw)\s*\(\s*(?:response|result|output|generated|sql|completion)(?:\.|\.data\.|\.text)?/gi,
|
|
257
|
+
sinkType: 'sql_builder',
|
|
258
|
+
baseSeverity: 'critical',
|
|
259
|
+
description: 'LLM-generated SQL is executed directly. This enables SQL injection via prompt manipulation.',
|
|
260
|
+
suggestedFix: 'Use parameterized queries. Have LLM generate query parameters, not raw SQL. Validate generated SQL against an allowlist of patterns.',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: 'LLM output in SQL template',
|
|
264
|
+
pattern: /`(?:SELECT|INSERT|UPDATE|DELETE)[^`]*\$\{(?:response|result|output|generated|completion)/gi,
|
|
265
|
+
sinkType: 'sql_builder',
|
|
266
|
+
baseSeverity: 'critical',
|
|
267
|
+
description: 'LLM output interpolated into SQL query template.',
|
|
268
|
+
suggestedFix: 'Use parameterized queries. Have LLM output structured data (table names, conditions) that you validate against allowlists.',
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'Dynamic SQL from AI',
|
|
272
|
+
pattern: /(?:query|execute|sql)\s*\(\s*(?:ai|llm|gpt|claude)(?:Query|Sql|Response)/gi,
|
|
273
|
+
sinkType: 'sql_builder',
|
|
274
|
+
baseSeverity: 'critical',
|
|
275
|
+
description: 'AI-generated SQL query being executed.',
|
|
276
|
+
suggestedFix: 'Validate SQL structure. Use read-only database connections. Implement query allowlisting.',
|
|
277
|
+
},
|
|
278
|
+
// ========== Template/DOM Sinks ==========
|
|
279
|
+
{
|
|
280
|
+
name: 'LLM output to innerHTML',
|
|
281
|
+
pattern: /\.innerHTML\s*=\s*(?:response|result|output|completion|message|content)(?:\.|\.data\.|\.text|\.content)?/gi,
|
|
282
|
+
sinkType: 'template_render',
|
|
283
|
+
baseSeverity: 'high',
|
|
284
|
+
description: 'LLM output assigned to innerHTML. If the model outputs malicious HTML/JS, it will execute (XSS).',
|
|
285
|
+
suggestedFix: 'Use textContent for plain text. Sanitize HTML with DOMPurify before rendering. Use React/Vue which auto-escape by default.',
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: 'LLM output to dangerouslySetInnerHTML',
|
|
289
|
+
pattern: /dangerouslySetInnerHTML\s*=\s*\{\s*\{\s*__html:\s*(?:response|result|output|completion|message|content)/gi,
|
|
290
|
+
sinkType: 'template_render',
|
|
291
|
+
baseSeverity: 'high',
|
|
292
|
+
description: 'LLM output used in React dangerouslySetInnerHTML without sanitization.',
|
|
293
|
+
suggestedFix: 'Sanitize with DOMPurify: dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(content) }}',
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
name: 'LLM output to document.write',
|
|
297
|
+
pattern: /document\.write\s*\(\s*(?:response|result|output|completion|message|content)/gi,
|
|
298
|
+
sinkType: 'template_render',
|
|
299
|
+
baseSeverity: 'high',
|
|
300
|
+
description: 'LLM output passed to document.write, allowing script injection.',
|
|
301
|
+
suggestedFix: 'Use DOM manipulation methods with proper escaping. Never use document.write with dynamic content.',
|
|
302
|
+
},
|
|
303
|
+
// ========== M5: File System Sinks ==========
|
|
304
|
+
{
|
|
305
|
+
name: 'LLM output in file path',
|
|
306
|
+
pattern: /(?:readFile|writeFile|readFileSync|writeFileSync|unlink|unlinkSync|mkdir|mkdirSync|rmdir|rmSync)\s*\(\s*(?:response|result|output|completion|message|content|path)(?:\.|\.data\.|\.path)?/gi,
|
|
307
|
+
sinkType: 'code_execution', // Path traversal is code-level risk
|
|
308
|
+
baseSeverity: 'critical',
|
|
309
|
+
description: 'LLM-generated value used as file path. Path traversal attack possible - model could access or modify arbitrary files.',
|
|
310
|
+
suggestedFix: 'Validate AI output against allowed paths: if (!allowedPaths.some(p => path.resolve(output).startsWith(p))) throw. Use path.resolve() and check the result is within allowed directory.',
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: 'LLM output in fs operation',
|
|
314
|
+
pattern: /fs\.(?:read|write|append|unlink|mkdir|rm|stat|access)\w*\s*\(\s*(?:response|result|output|completion|aiPath|generatedPath)/gi,
|
|
315
|
+
sinkType: 'code_execution',
|
|
316
|
+
baseSeverity: 'critical',
|
|
317
|
+
description: 'AI-generated path passed to filesystem operation. Model could traverse to sensitive directories.',
|
|
318
|
+
suggestedFix: 'Create allowlist of permitted paths/directories. Use path.resolve() and validate result is within allowed boundaries.',
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: 'LLM output in path.join',
|
|
322
|
+
pattern: /path\.(?:join|resolve)\s*\([^)]*(?:response|result|output|completion|content|aiPath)[^)]*\).*(?:fs\.|readFile|writeFile)/gi,
|
|
323
|
+
sinkType: 'code_execution',
|
|
324
|
+
baseSeverity: 'high',
|
|
325
|
+
description: 'AI output used in path construction before file operation. Validate the final path.',
|
|
326
|
+
suggestedFix: 'After path.join/resolve, check result is within allowed directory: const resolved = path.resolve(base, aiPath); if (!resolved.startsWith(allowedRoot)) throw',
|
|
327
|
+
},
|
|
328
|
+
// ========== M5: Dynamic Import Sinks ==========
|
|
329
|
+
{
|
|
330
|
+
name: 'LLM output in dynamic import',
|
|
331
|
+
pattern: /import\s*\(\s*(?:response|result|output|completion|message|content|moduleName|aiModule)/gi,
|
|
332
|
+
sinkType: 'code_execution',
|
|
333
|
+
baseSeverity: 'critical',
|
|
334
|
+
description: 'AI-generated value used in dynamic import(). Arbitrary module loading enables code execution.',
|
|
335
|
+
suggestedFix: 'Use allowlist for permitted modules: const allowed = ["lodash", "moment"]; if (!allowed.includes(moduleName)) throw. Never dynamically import AI-generated module paths.',
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: 'LLM output in require()',
|
|
339
|
+
pattern: /require\s*\(\s*(?:response|result|output|completion|message|content|moduleName|aiModule)/gi,
|
|
340
|
+
sinkType: 'code_execution',
|
|
341
|
+
baseSeverity: 'critical',
|
|
342
|
+
description: 'AI-generated value used in require(). Can load arbitrary modules including native code.',
|
|
343
|
+
suggestedFix: 'Use allowlist for permitted modules. Consider using import maps or module aliases instead of dynamic require.',
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
name: 'LLM output in module resolution',
|
|
347
|
+
pattern: /(?:require\.resolve|import\.meta\.resolve)\s*\(\s*(?:response|result|output|completion|moduleName)/gi,
|
|
348
|
+
sinkType: 'code_execution',
|
|
349
|
+
baseSeverity: 'high',
|
|
350
|
+
description: 'AI output used in module path resolution. Could leak information about file system or enable module confusion attacks.',
|
|
351
|
+
suggestedFix: 'Validate module name against allowlist before resolution.',
|
|
352
|
+
},
|
|
353
|
+
];
|
|
354
|
+
// ============================================================================
|
|
355
|
+
// Main Detection Function
|
|
356
|
+
// ============================================================================
|
|
357
|
+
/**
|
|
358
|
+
* Get surrounding context for analysis
|
|
359
|
+
*/
|
|
360
|
+
function getSurroundingContext(content, lineIndex, windowSize = 15) {
|
|
361
|
+
const lines = content.split('\n');
|
|
362
|
+
const start = Math.max(0, lineIndex - windowSize);
|
|
363
|
+
const end = Math.min(lines.length, lineIndex + windowSize);
|
|
364
|
+
return lines.slice(start, end).join('\n');
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Calculate severity based on sandbox and validation status
|
|
368
|
+
*/
|
|
369
|
+
function calculateSeverity(baseSeverity, sinkType, isSandboxed, hasValidation, isTestFile, isExample = false, isLibrary = false) {
|
|
370
|
+
let severity = baseSeverity;
|
|
371
|
+
// Test files get significant downgrade
|
|
372
|
+
if (isTestFile) {
|
|
373
|
+
return 'info';
|
|
374
|
+
}
|
|
375
|
+
// Example/demo code - not production, for tutorials
|
|
376
|
+
if (isExample) {
|
|
377
|
+
return 'info';
|
|
378
|
+
}
|
|
379
|
+
// Library code - base utilities, consumers add restrictions
|
|
380
|
+
if (isLibrary) {
|
|
381
|
+
return 'info';
|
|
382
|
+
}
|
|
383
|
+
// Sandboxing provides major protection for code execution
|
|
384
|
+
if (isSandboxed) {
|
|
385
|
+
if (sinkType === 'code_execution') {
|
|
386
|
+
severity = hasValidation ? 'low' : 'medium';
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
// Sandboxing less relevant for SQL/shell
|
|
390
|
+
severity = hasValidation ? 'medium' : 'high';
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
else if (hasValidation) {
|
|
394
|
+
// Validation alone helps but doesn't eliminate risk
|
|
395
|
+
if (baseSeverity === 'critical') {
|
|
396
|
+
severity = 'high';
|
|
397
|
+
}
|
|
398
|
+
else if (baseSeverity === 'high') {
|
|
399
|
+
severity = 'medium';
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return severity;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Main detection function for LLM output execution sinks
|
|
406
|
+
*/
|
|
407
|
+
function detectAIExecutionSinks(content, filePath) {
|
|
408
|
+
const vulnerabilities = [];
|
|
409
|
+
// Skip non-applicable files
|
|
410
|
+
if ((0, context_helpers_1.isScannerOrFixtureFile)(filePath))
|
|
411
|
+
return vulnerabilities;
|
|
412
|
+
// Only deeply scan files that appear to be in LLM context
|
|
413
|
+
// But still do basic scanning on all files for obvious patterns
|
|
414
|
+
const isLLMFile = (0, ai_prompt_hygiene_1.isLLMContextFile)(filePath, content);
|
|
415
|
+
const lines = content.split('\n');
|
|
416
|
+
const isTestFile = (0, context_helpers_1.isTestOrMockFile)(filePath);
|
|
417
|
+
const isExample = (0, context_helpers_1.isExampleDirectory)(filePath);
|
|
418
|
+
const isLibrary = (0, context_helpers_1.isLibraryCode)(filePath);
|
|
419
|
+
for (const pattern of EXECUTION_SINK_PATTERNS) {
|
|
420
|
+
const regex = new RegExp(pattern.pattern.source, pattern.pattern.flags);
|
|
421
|
+
let match;
|
|
422
|
+
while ((match = regex.exec(content)) !== null) {
|
|
423
|
+
const lineNumber = content.substring(0, match.index).split('\n').length;
|
|
424
|
+
const lineContent = lines[lineNumber - 1]?.trim() || '';
|
|
425
|
+
// Skip comments
|
|
426
|
+
if ((0, context_helpers_1.isComment)(lineContent))
|
|
427
|
+
continue;
|
|
428
|
+
const surroundingContext = getSurroundingContext(content, lineNumber - 1);
|
|
429
|
+
// Check if this is actually in an LLM context
|
|
430
|
+
const hasLLMContext = isLLMFile || hasLLMResponseContext(lineContent, surroundingContext);
|
|
431
|
+
// ===== FALSE POSITIVE FILTERS =====
|
|
432
|
+
// Skip UI suggestion/template patterns (command palettes, autocomplete, etc.)
|
|
433
|
+
// These are display strings, not execution sinks
|
|
434
|
+
if (isUITemplateSuggestion(lineContent, surroundingContext)) {
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
// Skip app data interpolation (e.g., ${node.title}, ${item.id})
|
|
438
|
+
// where the interpolated data is from the app, not LLM output
|
|
439
|
+
if (isAppDataInterpolation(lineContent, surroundingContext)) {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
// For non-LLM files, require stronger signal
|
|
443
|
+
if (!hasLLMContext) {
|
|
444
|
+
// Check if the matched variable looks like LLM output
|
|
445
|
+
const matchText = match[0];
|
|
446
|
+
const variableMatch = matchText.match(/(?:response|result|output|completion|message|content|answer|generated|text)/i);
|
|
447
|
+
if (!variableMatch)
|
|
448
|
+
continue;
|
|
449
|
+
// Skip if this looks like display-only usage
|
|
450
|
+
if (isDisplayOnly(lineContent, surroundingContext))
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
// Check for sandboxing and validation
|
|
454
|
+
const isSandboxed = isSandboxedExecution(content, lineNumber);
|
|
455
|
+
const hasValidation = hasOutputValidation(content, lineNumber);
|
|
456
|
+
// Calculate final severity
|
|
457
|
+
const severity = calculateSeverity(pattern.baseSeverity, pattern.sinkType, isSandboxed, hasValidation, isTestFile, isExample, isLibrary);
|
|
458
|
+
// Build description with context
|
|
459
|
+
let description = pattern.description;
|
|
460
|
+
if (isSandboxed) {
|
|
461
|
+
description += ' (Sandbox detected - risk somewhat mitigated.)';
|
|
462
|
+
}
|
|
463
|
+
if (hasValidation) {
|
|
464
|
+
description += ' (Some validation detected nearby.)';
|
|
465
|
+
}
|
|
466
|
+
if (isTestFile) {
|
|
467
|
+
description += ' (In test file.)';
|
|
468
|
+
}
|
|
469
|
+
else if (isExample) {
|
|
470
|
+
description += ' (In example/demo directory - tutorial code.)';
|
|
471
|
+
}
|
|
472
|
+
else if (isLibrary) {
|
|
473
|
+
description += ' (Library code - consumers add restrictions.)';
|
|
474
|
+
}
|
|
475
|
+
// Skip info-level in non-LLM files to reduce noise
|
|
476
|
+
if (severity === 'info' && !isLLMFile)
|
|
477
|
+
continue;
|
|
478
|
+
vulnerabilities.push({
|
|
479
|
+
id: `ai-exec-${filePath}-${lineNumber}-${pattern.sinkType}`,
|
|
480
|
+
filePath,
|
|
481
|
+
lineNumber,
|
|
482
|
+
lineContent,
|
|
483
|
+
severity,
|
|
484
|
+
category: 'ai_unsafe_execution',
|
|
485
|
+
title: pattern.name,
|
|
486
|
+
description,
|
|
487
|
+
suggestedFix: pattern.suggestedFix,
|
|
488
|
+
confidence: hasLLMContext ? 'high' : 'medium',
|
|
489
|
+
layer: 2,
|
|
490
|
+
requiresAIValidation: severity !== 'info' && severity !== 'low',
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return vulnerabilities;
|
|
495
|
+
}
|
|
496
|
+
//# sourceMappingURL=ai-execution-sinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-execution-sinks.js","sourceRoot":"","sources":["../../src/layer2/ai-execution-sinks.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AA0cH,wDA8GC;AArjBD,8DAMiC;AACjC,2DAAsD;AAEtD,+EAA+E;AAC/E,gCAAgC;AAChC,+EAA+E;AAE/E;;GAEG;AACH,SAAS,qBAAqB,CAAC,WAAmB,EAAE,kBAA0B;IAC5E,MAAM,mBAAmB,GAAG;QAC1B,mCAAmC,EAAM,kBAAkB;QAC3D,uBAAuB,EAAmB,qBAAqB;QAC/D,mBAAmB,EAAwB,q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ects patterns commonly found in AI-generated code that may indicate security risks
|
|
4
|
+
*/
|
|
5
|
+
import type { Vulnerability } from '../types';
|
|
6
|
+
export declare function detectAIFingerprints(content: string, filePath: string): Vulnerability[];
|
|
7
|
+
//# sourceMappingURL=ai-fingerprinting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-fingerprinting.d.ts","sourceRoot":"","sources":["../../src/layer2/ai-fingerprinting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAyB,MAAM,UAAU,CAAA;AAmnBpE,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,aAAa,EAAE,CA0HjB"}
|