@houtini/lm 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/CHANGELOG.md +273 -0
- package/LICENSE +21 -0
- package/README.md +203 -0
- package/dist/cache/analysis-cache.d.ts +33 -0
- package/dist/cache/analysis-cache.d.ts.map +1 -0
- package/dist/cache/analysis-cache.js +56 -0
- package/dist/cache/analysis-cache.js.map +1 -0
- package/dist/cache/cache-manager.d.ts +29 -0
- package/dist/cache/cache-manager.d.ts.map +1 -0
- package/dist/cache/cache-manager.js +85 -0
- package/dist/cache/cache-manager.js.map +1 -0
- package/dist/cache/index.d.ts +16 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +17 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/prompt-cache.d.ts +33 -0
- package/dist/cache/prompt-cache.d.ts.map +1 -0
- package/dist/cache/prompt-cache.js +61 -0
- package/dist/cache/prompt-cache.js.map +1 -0
- package/dist/config.d.ts +43 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +70 -0
- package/dist/config.js.map +1 -0
- package/dist/core/ThreeStagePromptManager.d.ts +39 -0
- package/dist/core/ThreeStagePromptManager.d.ts.map +1 -0
- package/dist/core/ThreeStagePromptManager.js +176 -0
- package/dist/core/ThreeStagePromptManager.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +230 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/base-plugin.d.ts +47 -0
- package/dist/plugins/base-plugin.d.ts.map +1 -0
- package/dist/plugins/base-plugin.js +90 -0
- package/dist/plugins/base-plugin.js.map +1 -0
- package/dist/plugins/index.d.ts +58 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +161 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/types.d.ts +5 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +5 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/prompts/analyze/code-quality.d.ts +116 -0
- package/dist/prompts/analyze/code-quality.d.ts.map +1 -0
- package/dist/prompts/analyze/code-quality.js +433 -0
- package/dist/prompts/analyze/code-quality.js.map +1 -0
- package/dist/prompts/analyze/compare-integration.d.ts +130 -0
- package/dist/prompts/analyze/compare-integration.d.ts.map +1 -0
- package/dist/prompts/analyze/compare-integration.js +543 -0
- package/dist/prompts/analyze/compare-integration.js.map +1 -0
- package/dist/prompts/analyze/count-files.d.ts +109 -0
- package/dist/prompts/analyze/count-files.d.ts.map +1 -0
- package/dist/prompts/analyze/count-files.js +399 -0
- package/dist/prompts/analyze/count-files.js.map +1 -0
- package/dist/prompts/analyze/database-queries.d.ts +156 -0
- package/dist/prompts/analyze/database-queries.d.ts.map +1 -0
- package/dist/prompts/analyze/database-queries.js +759 -0
- package/dist/prompts/analyze/database-queries.js.map +1 -0
- package/dist/prompts/analyze/dependencies.d.ts +97 -0
- package/dist/prompts/analyze/dependencies.d.ts.map +1 -0
- package/dist/prompts/analyze/dependencies.js +333 -0
- package/dist/prompts/analyze/dependencies.js.map +1 -0
- package/dist/prompts/analyze/diff-signatures.d.ts +139 -0
- package/dist/prompts/analyze/diff-signatures.d.ts.map +1 -0
- package/dist/prompts/analyze/diff-signatures.js +702 -0
- package/dist/prompts/analyze/diff-signatures.js.map +1 -0
- package/dist/prompts/analyze/find-patterns.d.ts +128 -0
- package/dist/prompts/analyze/find-patterns.d.ts.map +1 -0
- package/dist/prompts/analyze/find-patterns.js +520 -0
- package/dist/prompts/analyze/find-patterns.js.map +1 -0
- package/dist/prompts/analyze/find-unused-css.d.ts +151 -0
- package/dist/prompts/analyze/find-unused-css.d.ts.map +1 -0
- package/dist/prompts/analyze/find-unused-css.js +754 -0
- package/dist/prompts/analyze/find-unused-css.js.map +1 -0
- package/dist/prompts/analyze/n8n-workflow.d.ts +137 -0
- package/dist/prompts/analyze/n8n-workflow.d.ts.map +1 -0
- package/dist/prompts/analyze/n8n-workflow.js +529 -0
- package/dist/prompts/analyze/n8n-workflow.js.map +1 -0
- package/dist/prompts/analyze/project-structure.d.ts +126 -0
- package/dist/prompts/analyze/project-structure.d.ts.map +1 -0
- package/dist/prompts/analyze/project-structure.js +569 -0
- package/dist/prompts/analyze/project-structure.js.map +1 -0
- package/dist/prompts/analyze/security-audit.d.ts +142 -0
- package/dist/prompts/analyze/security-audit.d.ts.map +1 -0
- package/dist/prompts/analyze/security-audit.js +637 -0
- package/dist/prompts/analyze/security-audit.js.map +1 -0
- package/dist/prompts/analyze/single-file.d.ts +162 -0
- package/dist/prompts/analyze/single-file.d.ts.map +1 -0
- package/dist/prompts/analyze/single-file.js +665 -0
- package/dist/prompts/analyze/single-file.js.map +1 -0
- package/dist/prompts/analyze/trace-execution.d.ts +126 -0
- package/dist/prompts/analyze/trace-execution.d.ts.map +1 -0
- package/dist/prompts/analyze/trace-execution.js +609 -0
- package/dist/prompts/analyze/trace-execution.js.map +1 -0
- package/dist/prompts/analyze/wordpress-plugin-audit.d.ts +116 -0
- package/dist/prompts/analyze/wordpress-plugin-audit.d.ts.map +1 -0
- package/dist/prompts/analyze/wordpress-plugin-audit.js +454 -0
- package/dist/prompts/analyze/wordpress-plugin-audit.js.map +1 -0
- package/dist/prompts/analyze/wordpress-security.d.ts +146 -0
- package/dist/prompts/analyze/wordpress-security.d.ts.map +1 -0
- package/dist/prompts/analyze/wordpress-security.js +698 -0
- package/dist/prompts/analyze/wordpress-security.js.map +1 -0
- package/dist/prompts/analyze/wordpress-theme-audit.d.ts +114 -0
- package/dist/prompts/analyze/wordpress-theme-audit.d.ts.map +1 -0
- package/dist/prompts/analyze/wordpress-theme-audit.js +538 -0
- package/dist/prompts/analyze/wordpress-theme-audit.js.map +1 -0
- package/dist/prompts/custom/custom-prompt.d.ts +135 -0
- package/dist/prompts/custom/custom-prompt.d.ts.map +1 -0
- package/dist/prompts/custom/custom-prompt.js +419 -0
- package/dist/prompts/custom/custom-prompt.js.map +1 -0
- package/dist/prompts/fun/arcade-game.d.ts +152 -0
- package/dist/prompts/fun/arcade-game.d.ts.map +1 -0
- package/dist/prompts/fun/arcade-game.js +653 -0
- package/dist/prompts/fun/arcade-game.js.map +1 -0
- package/dist/prompts/fun/create_text_adventure.d.ts +100 -0
- package/dist/prompts/fun/create_text_adventure.d.ts.map +1 -0
- package/dist/prompts/fun/create_text_adventure.js +397 -0
- package/dist/prompts/fun/create_text_adventure.js.map +1 -0
- package/dist/prompts/fun/css-art-generator.d.ts +168 -0
- package/dist/prompts/fun/css-art-generator.d.ts.map +1 -0
- package/dist/prompts/fun/css-art-generator.js +827 -0
- package/dist/prompts/fun/css-art-generator.js.map +1 -0
- package/dist/prompts/generate/project-documentation.d.ts +137 -0
- package/dist/prompts/generate/project-documentation.d.ts.map +1 -0
- package/dist/prompts/generate/project-documentation.js +666 -0
- package/dist/prompts/generate/project-documentation.js.map +1 -0
- package/dist/prompts/generate/refactoring.d.ts +164 -0
- package/dist/prompts/generate/refactoring.d.ts.map +1 -0
- package/dist/prompts/generate/refactoring.js +621 -0
- package/dist/prompts/generate/refactoring.js.map +1 -0
- package/dist/prompts/generate/responsive-component.d.ts +147 -0
- package/dist/prompts/generate/responsive-component.d.ts.map +1 -0
- package/dist/prompts/generate/responsive-component.js +955 -0
- package/dist/prompts/generate/responsive-component.js.map +1 -0
- package/dist/prompts/generate/typescript-conversion.d.ts +144 -0
- package/dist/prompts/generate/typescript-conversion.d.ts.map +1 -0
- package/dist/prompts/generate/typescript-conversion.js +527 -0
- package/dist/prompts/generate/typescript-conversion.js.map +1 -0
- package/dist/prompts/generate/unit-tests.d.ts +139 -0
- package/dist/prompts/generate/unit-tests.d.ts.map +1 -0
- package/dist/prompts/generate/unit-tests.js +578 -0
- package/dist/prompts/generate/unit-tests.js.map +1 -0
- package/dist/prompts/generate/wordpress-plugin.d.ts +179 -0
- package/dist/prompts/generate/wordpress-plugin.d.ts.map +1 -0
- package/dist/prompts/generate/wordpress-plugin.js +763 -0
- package/dist/prompts/generate/wordpress-plugin.js.map +1 -0
- package/dist/prompts/generate/wordpress-theme-from-static.d.ts +177 -0
- package/dist/prompts/generate/wordpress-theme-from-static.d.ts.map +1 -0
- package/dist/prompts/generate/wordpress-theme-from-static.js +695 -0
- package/dist/prompts/generate/wordpress-theme-from-static.js.map +1 -0
- package/dist/prompts/shared/cache-manager.d.ts +45 -0
- package/dist/prompts/shared/cache-manager.d.ts.map +1 -0
- package/dist/prompts/shared/cache-manager.js +129 -0
- package/dist/prompts/shared/cache-manager.js.map +1 -0
- package/dist/prompts/shared/helpers.d.ts +39 -0
- package/dist/prompts/shared/helpers.d.ts.map +1 -0
- package/dist/prompts/shared/helpers.js +151 -0
- package/dist/prompts/shared/helpers.js.map +1 -0
- package/dist/prompts/shared/templates.d.ts +35 -0
- package/dist/prompts/shared/templates.d.ts.map +1 -0
- package/dist/prompts/shared/templates.js +77 -0
- package/dist/prompts/shared/templates.js.map +1 -0
- package/dist/prompts/shared/types.d.ts +112 -0
- package/dist/prompts/shared/types.d.ts.map +1 -0
- package/dist/prompts/shared/types.js +5 -0
- package/dist/prompts/shared/types.js.map +1 -0
- package/dist/prompts/system/find-unused-files.d.ts +106 -0
- package/dist/prompts/system/find-unused-files.d.ts.map +1 -0
- package/dist/prompts/system/find-unused-files.js +353 -0
- package/dist/prompts/system/find-unused-files.js.map +1 -0
- package/dist/security/index.d.ts +39 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +46 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/integration-helpers.d.ts +121 -0
- package/dist/security/integration-helpers.d.ts.map +1 -0
- package/dist/security/integration-helpers.js +190 -0
- package/dist/security/integration-helpers.js.map +1 -0
- package/dist/security/output-encoder.d.ts +94 -0
- package/dist/security/output-encoder.d.ts.map +1 -0
- package/dist/security/output-encoder.js +295 -0
- package/dist/security/output-encoder.js.map +1 -0
- package/dist/security/prompt-injection-guard.d.ts +59 -0
- package/dist/security/prompt-injection-guard.d.ts.map +1 -0
- package/dist/security/prompt-injection-guard.js +249 -0
- package/dist/security/prompt-injection-guard.js.map +1 -0
- package/dist/security/sanitisation.d.ts +67 -0
- package/dist/security/sanitisation.d.ts.map +1 -0
- package/dist/security/sanitisation.js +398 -0
- package/dist/security/sanitisation.js.map +1 -0
- package/dist/security/security-service.d.ts +103 -0
- package/dist/security/security-service.d.ts.map +1 -0
- package/dist/security/security-service.js +303 -0
- package/dist/security/security-service.js.map +1 -0
- package/dist/security-config.d.ts +45 -0
- package/dist/security-config.d.ts.map +1 -0
- package/dist/security-config.js +63 -0
- package/dist/security-config.js.map +1 -0
- package/dist/system/function-list.d.ts +61 -0
- package/dist/system/function-list.d.ts.map +1 -0
- package/dist/system/function-list.js +111 -0
- package/dist/system/function-list.js.map +1 -0
- package/dist/system/function-registry.d.ts +23 -0
- package/dist/system/function-registry.d.ts.map +1 -0
- package/dist/system/function-registry.js +136 -0
- package/dist/system/function-registry.js.map +1 -0
- package/dist/system/health-check.d.ts +33 -0
- package/dist/system/health-check.d.ts.map +1 -0
- package/dist/system/health-check.js +98 -0
- package/dist/system/health-check.js.map +1 -0
- package/dist/system/path-resolver.d.ts +55 -0
- package/dist/system/path-resolver.d.ts.map +1 -0
- package/dist/system/path-resolver.js +90 -0
- package/dist/system/path-resolver.js.map +1 -0
- package/dist/templates/plugin-template.d.ts +121 -0
- package/dist/templates/plugin-template.d.ts.map +1 -0
- package/dist/templates/plugin-template.js +450 -0
- package/dist/templates/plugin-template.js.map +1 -0
- package/dist/types/chunking-types.d.ts +88 -0
- package/dist/types/chunking-types.d.ts.map +1 -0
- package/dist/types/chunking-types.js +18 -0
- package/dist/types/chunking-types.js.map +1 -0
- package/dist/types/prompt-stages.d.ts +42 -0
- package/dist/types/prompt-stages.d.ts.map +1 -0
- package/dist/types/prompt-stages.js +6 -0
- package/dist/types/prompt-stages.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/css-parser.d.ts +26 -0
- package/dist/utils/css-parser.d.ts.map +1 -0
- package/dist/utils/css-parser.js +117 -0
- package/dist/utils/css-parser.js.map +1 -0
- package/dist/utils/path-resolver.d.ts +13 -0
- package/dist/utils/path-resolver.d.ts.map +1 -0
- package/dist/utils/path-resolver.js +78 -0
- package/dist/utils/path-resolver.js.map +1 -0
- package/dist/utils/plugin-utilities.d.ts +171 -0
- package/dist/utils/plugin-utilities.d.ts.map +1 -0
- package/dist/utils/plugin-utilities.js +221 -0
- package/dist/utils/plugin-utilities.js.map +1 -0
- package/dist/utils/streamHandler.d.ts +3 -0
- package/dist/utils/streamHandler.d.ts.map +1 -0
- package/dist/utils/streamHandler.js +137 -0
- package/dist/utils/streamHandler.js.map +1 -0
- package/dist/validation/output-validator.d.ts +136 -0
- package/dist/validation/output-validator.d.ts.map +1 -0
- package/dist/validation/output-validator.js +262 -0
- package/dist/validation/output-validator.js.map +1 -0
- package/dist/validation/response-factory.d.ts +44 -0
- package/dist/validation/response-factory.d.ts.map +1 -0
- package/dist/validation/response-factory.js +202 -0
- package/dist/validation/response-factory.js.map +1 -0
- package/dist/validation/schemas.d.ts +519 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +6 -0
- package/dist/validation/schemas.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Template - Modern v4.2 (Single Source of Truth)
|
|
3
|
+
*
|
|
4
|
+
* Universal template that intelligently handles both single-file and multi-file analysis
|
|
5
|
+
* Automatically detects analysis type based on provided parameters
|
|
6
|
+
*
|
|
7
|
+
* Copy this template for creating any new plugin - it adapts to your needs
|
|
8
|
+
*/
|
|
9
|
+
import { BasePlugin } from '../../plugins/base-plugin.js';
|
|
10
|
+
import { ThreeStagePromptManager } from '../../core/ThreeStagePromptManager.js';
|
|
11
|
+
import { withSecurity } from '../../security/integration-helpers.js';
|
|
12
|
+
import { readFileContent } from '../shared/helpers.js';
|
|
13
|
+
import { ModelSetup, ResponseProcessor, ParameterValidator, ErrorHandler, MultiFileAnalysis } from '../../utils/plugin-utilities.js';
|
|
14
|
+
import { getAnalysisCache } from '../../cache/index.js';
|
|
15
|
+
export class SecurityAuditor extends BasePlugin {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.name = 'security_audit';
|
|
19
|
+
this.category = 'analyze';
|
|
20
|
+
this.description = 'Perform comprehensive security audit across entire project, analyzing data flows, authentication chains, and cross-file vulnerabilities with OWASP compliance checking';
|
|
21
|
+
// Universal parameter set - supports both single and multi-file scenarios
|
|
22
|
+
this.parameters = {
|
|
23
|
+
// Single-file parameters
|
|
24
|
+
code: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'The code to analyze for security issues (for single-file analysis)',
|
|
27
|
+
required: false
|
|
28
|
+
},
|
|
29
|
+
filePath: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'Path to single file to analyze for security vulnerabilities',
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
34
|
+
// Multi-file parameters
|
|
35
|
+
projectPath: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Absolute path to project root directory',
|
|
38
|
+
required: false
|
|
39
|
+
},
|
|
40
|
+
files: {
|
|
41
|
+
type: 'array',
|
|
42
|
+
description: 'Array of specific file paths (for multi-file analysis)',
|
|
43
|
+
required: false,
|
|
44
|
+
items: { type: 'string' }
|
|
45
|
+
},
|
|
46
|
+
maxDepth: {
|
|
47
|
+
type: 'number',
|
|
48
|
+
description: 'Maximum directory depth for multi-file discovery (1-5)',
|
|
49
|
+
required: false,
|
|
50
|
+
default: 4
|
|
51
|
+
},
|
|
52
|
+
// Security-specific parameters
|
|
53
|
+
projectType: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'Project type for specific security checks',
|
|
56
|
+
required: false,
|
|
57
|
+
enum: ['wordpress-plugin', 'wordpress-theme', 'react-app', 'react-component', 'node-api', 'browser-extension', 'cli-tool', 'n8n-node', 'n8n-workflow', 'html-component', 'generic'],
|
|
58
|
+
default: 'generic'
|
|
59
|
+
},
|
|
60
|
+
auditDepth: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'Depth of security audit',
|
|
63
|
+
enum: ['basic', 'standard', 'comprehensive'],
|
|
64
|
+
default: 'standard',
|
|
65
|
+
required: false
|
|
66
|
+
},
|
|
67
|
+
includeOwasp: {
|
|
68
|
+
type: 'boolean',
|
|
69
|
+
description: 'Include OWASP Top 10 checks',
|
|
70
|
+
required: false,
|
|
71
|
+
default: true
|
|
72
|
+
},
|
|
73
|
+
focusAreas: {
|
|
74
|
+
type: 'array',
|
|
75
|
+
description: 'Specific areas to focus on: authentication, data-flow, input-validation, authorization',
|
|
76
|
+
required: false,
|
|
77
|
+
items: { type: 'string' }
|
|
78
|
+
},
|
|
79
|
+
// Universal parameters
|
|
80
|
+
language: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
description: 'Programming language',
|
|
83
|
+
required: false,
|
|
84
|
+
default: 'javascript'
|
|
85
|
+
},
|
|
86
|
+
analysisDepth: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
description: 'Level of analysis detail',
|
|
89
|
+
enum: ['basic', 'detailed', 'comprehensive'],
|
|
90
|
+
default: 'detailed',
|
|
91
|
+
required: false
|
|
92
|
+
},
|
|
93
|
+
analysisType: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: 'Type of analysis to perform',
|
|
96
|
+
enum: ['security', 'owasp', 'comprehensive'],
|
|
97
|
+
default: 'comprehensive',
|
|
98
|
+
required: false
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
this.analysisCache = getAnalysisCache();
|
|
102
|
+
this.multiFileAnalysis = new MultiFileAnalysis();
|
|
103
|
+
// Cache and analysis utilities are initialized above
|
|
104
|
+
}
|
|
105
|
+
async execute(params, llmClient) {
|
|
106
|
+
return await withSecurity(this, params, llmClient, async (secureParams) => {
|
|
107
|
+
try {
|
|
108
|
+
// 1. Auto-detect analysis mode based on parameters
|
|
109
|
+
const analysisMode = this.detectAnalysisMode(secureParams);
|
|
110
|
+
// 2. Validate parameters based on detected mode
|
|
111
|
+
this.validateParameters(secureParams, analysisMode);
|
|
112
|
+
// 3. Setup model
|
|
113
|
+
const { model, contextLength } = await ModelSetup.getReadyModel(llmClient);
|
|
114
|
+
// 4. Route to appropriate analysis method
|
|
115
|
+
if (analysisMode === 'single-file') {
|
|
116
|
+
return await this.executeSingleFileAnalysis(secureParams, model, contextLength);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
return await this.executeMultiFileAnalysis(secureParams, model, contextLength);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
return ErrorHandler.createExecutionError('security_audit', error);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Auto-detect whether this is single-file or multi-file analysis
|
|
129
|
+
*/
|
|
130
|
+
detectAnalysisMode(params) {
|
|
131
|
+
// Single-file indicators (check these first)
|
|
132
|
+
if (params.code || params.filePath) {
|
|
133
|
+
return 'single-file';
|
|
134
|
+
}
|
|
135
|
+
// Multi-file indicators
|
|
136
|
+
if (params.projectPath || params.files) {
|
|
137
|
+
return 'multi-file';
|
|
138
|
+
}
|
|
139
|
+
// Default to multi-file for project security audits
|
|
140
|
+
return 'multi-file';
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Validate parameters based on detected analysis mode
|
|
144
|
+
*/
|
|
145
|
+
validateParameters(params, mode) {
|
|
146
|
+
if (mode === 'single-file') {
|
|
147
|
+
// For single-file, we need either code OR filePath
|
|
148
|
+
if (!params.code && !params.filePath) {
|
|
149
|
+
throw new Error('Either code or filePath must be provided for single-file analysis');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// For multi-file, we need either projectPath OR files array
|
|
154
|
+
if (!params.projectPath && !params.files) {
|
|
155
|
+
throw new Error('Either projectPath or files array must be provided');
|
|
156
|
+
}
|
|
157
|
+
ParameterValidator.validateDepth(params);
|
|
158
|
+
}
|
|
159
|
+
// Universal validations
|
|
160
|
+
ParameterValidator.validateEnum(params, 'analysisType', ['security', 'owasp', 'comprehensive']);
|
|
161
|
+
ParameterValidator.validateEnum(params, 'analysisDepth', ['basic', 'detailed', 'comprehensive']);
|
|
162
|
+
ParameterValidator.validateEnum(params, 'projectType', ['wordpress-plugin', 'wordpress-theme', 'react-app', 'react-component', 'node-api', 'browser-extension', 'cli-tool', 'n8n-node', 'n8n-workflow', 'html-component', 'generic']);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Execute single-file analysis
|
|
166
|
+
*/
|
|
167
|
+
async executeSingleFileAnalysis(params, model, contextLength) {
|
|
168
|
+
// Process single file input
|
|
169
|
+
let codeToAnalyze = params.code;
|
|
170
|
+
if (params.filePath) {
|
|
171
|
+
codeToAnalyze = await readFileContent(params.filePath);
|
|
172
|
+
}
|
|
173
|
+
// Generate prompt stages for single file
|
|
174
|
+
const promptStages = this.getSingleFilePromptStages({
|
|
175
|
+
...params,
|
|
176
|
+
code: codeToAnalyze
|
|
177
|
+
});
|
|
178
|
+
// Execute with appropriate method
|
|
179
|
+
const promptManager = new ThreeStagePromptManager(contextLength);
|
|
180
|
+
const needsChunking = promptManager.needsChunking(promptStages);
|
|
181
|
+
if (needsChunking) {
|
|
182
|
+
const conversation = promptManager.createChunkedConversation(promptStages);
|
|
183
|
+
const messages = [
|
|
184
|
+
conversation.systemMessage,
|
|
185
|
+
...conversation.dataMessages,
|
|
186
|
+
conversation.analysisMessage
|
|
187
|
+
];
|
|
188
|
+
return await ResponseProcessor.executeChunked(messages, model, contextLength, 'security_audit', 'single');
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
return await ResponseProcessor.executeDirect(promptStages, model, contextLength, 'security_audit');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Execute multi-file analysis
|
|
196
|
+
*/
|
|
197
|
+
async executeMultiFileAnalysis(params, model, contextLength) {
|
|
198
|
+
// Discover files
|
|
199
|
+
let filesToAnalyze = params.files ||
|
|
200
|
+
await this.discoverRelevantFiles(params.projectPath, params.maxDepth, params.projectType);
|
|
201
|
+
// Perform multi-file analysis with caching
|
|
202
|
+
const analysisResult = await this.performMultiFileAnalysis(filesToAnalyze, params, model, contextLength);
|
|
203
|
+
// Generate prompt stages for multi-file
|
|
204
|
+
const promptStages = this.getMultiFilePromptStages({
|
|
205
|
+
...params,
|
|
206
|
+
analysisResult,
|
|
207
|
+
fileCount: filesToAnalyze.length
|
|
208
|
+
});
|
|
209
|
+
// Always use chunking for multi-file
|
|
210
|
+
const promptManager = new ThreeStagePromptManager(contextLength);
|
|
211
|
+
const conversation = promptManager.createChunkedConversation(promptStages);
|
|
212
|
+
const messages = [
|
|
213
|
+
conversation.systemMessage,
|
|
214
|
+
...conversation.dataMessages,
|
|
215
|
+
conversation.analysisMessage
|
|
216
|
+
];
|
|
217
|
+
return await ResponseProcessor.executeChunked(messages, model, contextLength, 'security_audit', 'multifile');
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Implement single-file security audit prompt stages
|
|
221
|
+
*/
|
|
222
|
+
getSingleFilePromptStages(params) {
|
|
223
|
+
const { code, language, analysisDepth, projectType, includeOwasp, focusAreas } = params;
|
|
224
|
+
const systemAndContext = `You are a senior cybersecurity expert with 15+ years of experience in application security, penetration testing, and secure code review. You specialize in identifying vulnerabilities across all major programming languages and frameworks.
|
|
225
|
+
|
|
226
|
+
**YOUR EXPERTISE:**
|
|
227
|
+
- OWASP Top 10 vulnerabilities and mitigation strategies
|
|
228
|
+
- Cross-site scripting (XSS), SQL injection, and injection attack vectors
|
|
229
|
+
- Authentication bypass and authorization flaws
|
|
230
|
+
- Cryptographic failures and insecure data storage
|
|
231
|
+
- Security misconfigurations and exposed components
|
|
232
|
+
- Modern framework security patterns (React, Node.js, PHP, etc.)
|
|
233
|
+
- Static code analysis and dynamic security testing
|
|
234
|
+
- Compliance with security standards (NIST, ISO 27001, PCI DSS)
|
|
235
|
+
|
|
236
|
+
**ANALYSIS CONTEXT:**
|
|
237
|
+
- Programming Language: ${language}
|
|
238
|
+
- Project Type: ${projectType}
|
|
239
|
+
- Analysis Depth: ${analysisDepth}
|
|
240
|
+
- OWASP Analysis: ${includeOwasp ? 'ENABLED - Include OWASP Top 10 checks' : 'DISABLED'}
|
|
241
|
+
- Focus Areas: ${focusAreas?.length > 0 ? focusAreas.join(', ') : 'All security domains'}
|
|
242
|
+
- Mode: Single File Security Analysis
|
|
243
|
+
|
|
244
|
+
**SECURITY ASSESSMENT METHODOLOGY:**
|
|
245
|
+
1. **Static Code Analysis**: Examine code patterns for known vulnerability signatures
|
|
246
|
+
2. **Data Flow Analysis**: Trace user input from entry points through processing
|
|
247
|
+
3. **Authentication/Authorization**: Verify access controls and privilege escalation risks
|
|
248
|
+
4. **Input Validation**: Check for sanitization and validation of all user inputs
|
|
249
|
+
5. **Output Encoding**: Ensure proper encoding prevents XSS and injection attacks
|
|
250
|
+
6. **Cryptographic Review**: Assess encryption, hashing, and key management practices
|
|
251
|
+
7. **Configuration Security**: Review security-relevant configuration and defaults
|
|
252
|
+
8. **Business Logic Flaws**: Identify application-specific security weaknesses
|
|
253
|
+
|
|
254
|
+
Your task is to perform a comprehensive security audit of this individual file, identifying vulnerabilities with precise locations, assessing their severity, and providing actionable remediation guidance.`;
|
|
255
|
+
const dataPayload = `**SECURITY AUDIT TARGET:**
|
|
256
|
+
|
|
257
|
+
File: ${params.filePath || 'Inline Code'}
|
|
258
|
+
Language: ${language}
|
|
259
|
+
Project Type: ${projectType}
|
|
260
|
+
|
|
261
|
+
**SOURCE CODE TO AUDIT:**
|
|
262
|
+
|
|
263
|
+
\`\`\`${language}
|
|
264
|
+
${code}
|
|
265
|
+
\`\`\``;
|
|
266
|
+
const outputInstructions = `**PROVIDE COMPREHENSIVE SECURITY AUDIT REPORT:**
|
|
267
|
+
|
|
268
|
+
Your analysis must be thorough, actionable, and prioritized by business risk. Focus on real vulnerabilities that could be exploited, not theoretical concerns.
|
|
269
|
+
|
|
270
|
+
**EXECUTIVE SUMMARY:**
|
|
271
|
+
Begin with an overall assessment including:
|
|
272
|
+
- **Overall Risk Level**: Critical, High, Medium, or Low
|
|
273
|
+
- **Total Vulnerabilities Found**: Count by severity (critical, high, medium, low)
|
|
274
|
+
- **Most Critical Issue**: Brief description of the most severe vulnerability
|
|
275
|
+
- **OWASP Compliance Status**: How well the code follows OWASP Top 10 guidelines
|
|
276
|
+
- **Business Impact**: What these vulnerabilities mean for the organization
|
|
277
|
+
|
|
278
|
+
**DETAILED VULNERABILITY ASSESSMENT:**
|
|
279
|
+
For EACH vulnerability found, provide a comprehensive analysis:
|
|
280
|
+
|
|
281
|
+
**Vulnerability Analysis Format:**
|
|
282
|
+
- **Vulnerability Name & Type**: Clear, descriptive name of the security issue
|
|
283
|
+
- **Severity Level**: CRITICAL, HIGH, MEDIUM, or LOW with justification
|
|
284
|
+
- **OWASP Category**: Reference to OWASP Top 10 category if applicable (A01-A10)
|
|
285
|
+
- **Location Details**: Specific line numbers, functions, or code sections affected
|
|
286
|
+
- **Vulnerable Code**: Show the exact problematic code snippet
|
|
287
|
+
- **Attack Vector**: Detailed explanation of how an attacker would exploit this
|
|
288
|
+
- **Impact Assessment**: What happens if successfully exploited (data loss, access, etc.)
|
|
289
|
+
- **Proof of Concept**: Example exploit code or attack payload demonstrating the vulnerability
|
|
290
|
+
- **Fix Implementation**: Specific code changes needed with secure implementation examples
|
|
291
|
+
- **Prevention Strategy**: Long-term approaches to prevent similar issues
|
|
292
|
+
|
|
293
|
+
**SECURITY STRENGTHS ASSESSMENT:**
|
|
294
|
+
Highlight positive security practices found:
|
|
295
|
+
- **Good Practices Identified**: Security measures already implemented correctly
|
|
296
|
+
- **Framework Security Features**: Built-in security features being used appropriately
|
|
297
|
+
- **Defense in Depth**: Multiple security layers and their effectiveness
|
|
298
|
+
- **Code Quality**: Security-aware coding practices being followed
|
|
299
|
+
|
|
300
|
+
**RISK-PRIORITIZED ACTION PLAN:**
|
|
301
|
+
Organize remediation by urgency and impact:
|
|
302
|
+
|
|
303
|
+
**IMMEDIATE ACTIONS** (Fix within 24 hours):
|
|
304
|
+
- Critical and high severity vulnerabilities that pose immediate risk
|
|
305
|
+
- Specific steps for emergency patching
|
|
306
|
+
|
|
307
|
+
**SHORT-TERM IMPROVEMENTS** (Fix within 1 week):
|
|
308
|
+
- Medium severity issues and important security enhancements
|
|
309
|
+
- Implementation timeline and resource requirements
|
|
310
|
+
|
|
311
|
+
**LONG-TERM ENHANCEMENTS** (Address in next development cycle):
|
|
312
|
+
- Low severity items and architectural security improvements
|
|
313
|
+
- Strategic security initiatives and process improvements
|
|
314
|
+
|
|
315
|
+
**SECURE CODE EXAMPLES:**
|
|
316
|
+
Provide practical, working code examples demonstrating:
|
|
317
|
+
- **Input Validation**: Proper techniques for validating and sanitizing user input
|
|
318
|
+
- **Output Encoding**: Methods to prevent XSS and injection attacks
|
|
319
|
+
- **Authentication Patterns**: Secure authentication and session management
|
|
320
|
+
- **Database Security**: Parameterized queries and database access controls
|
|
321
|
+
- **Error Handling**: Secure error handling that doesn't leak information
|
|
322
|
+
- **Access Controls**: Proper authorization and privilege checking
|
|
323
|
+
|
|
324
|
+
**IMPLEMENTATION GUIDANCE:**
|
|
325
|
+
- **Priority Matrix**: Risk vs. effort assessment for each recommendation
|
|
326
|
+
- **Dependencies**: Issues that must be fixed together or in sequence
|
|
327
|
+
- **Testing Strategy**: How to verify fixes without breaking functionality
|
|
328
|
+
- **Monitoring**: What to monitor after implementing security fixes
|
|
329
|
+
|
|
330
|
+
**COMPLIANCE & STANDARDS:**
|
|
331
|
+
- **Industry Standards**: Alignment with relevant security standards
|
|
332
|
+
- **Regulatory Requirements**: Compliance with applicable regulations
|
|
333
|
+
- **Best Practices**: Industry best practices being followed or needed
|
|
334
|
+
|
|
335
|
+
**CRITICAL REQUIREMENTS:**
|
|
336
|
+
- Every vulnerability MUST include precise line numbers where possible
|
|
337
|
+
- Every fix MUST include working, tested code examples
|
|
338
|
+
- Focus on exploitable vulnerabilities that pose real business risk
|
|
339
|
+
- Prioritize recommendations by likelihood and impact of exploitation
|
|
340
|
+
- Include specific attack scenarios that clearly demonstrate each vulnerability
|
|
341
|
+
- Provide actionable steps that development teams can implement immediately
|
|
342
|
+
|
|
343
|
+
Be comprehensive but practical - focus on security issues that matter most to the business and can be realistically addressed by the development team.`;
|
|
344
|
+
return { systemAndContext, dataPayload, outputInstructions };
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Implement multi-file security audit prompt stages
|
|
348
|
+
*/
|
|
349
|
+
getMultiFilePromptStages(params) {
|
|
350
|
+
const { analysisResult, projectType, auditDepth, includeOwasp, fileCount, focusAreas } = params;
|
|
351
|
+
const systemAndContext = `You are a senior cybersecurity expert and application security architect with 15+ years of experience in enterprise security audits. You specialize in comprehensive cross-file security analysis and identifying complex attack vectors that span multiple components.
|
|
352
|
+
|
|
353
|
+
**YOUR EXPERTISE:**
|
|
354
|
+
- Multi-tier application security architecture review
|
|
355
|
+
- Cross-component vulnerability analysis and attack chain identification
|
|
356
|
+
- Data flow security analysis across entire applications
|
|
357
|
+
- Authentication and authorization workflow security
|
|
358
|
+
- API security and microservices security patterns
|
|
359
|
+
- DevSecOps and secure development lifecycle implementation
|
|
360
|
+
- Enterprise compliance (SOX, HIPAA, PCI DSS, GDPR)
|
|
361
|
+
- Advanced persistent threat (APT) defense strategies
|
|
362
|
+
|
|
363
|
+
**PROJECT SECURITY AUDIT CONTEXT:**
|
|
364
|
+
- Project Type: ${projectType}
|
|
365
|
+
- Audit Depth: ${auditDepth}
|
|
366
|
+
- Files Analyzed: ${fileCount}
|
|
367
|
+
- OWASP Analysis: ${includeOwasp ? 'ENABLED - Full OWASP Top 10 coverage' : 'DISABLED'}
|
|
368
|
+
- Focus Areas: ${focusAreas?.length > 0 ? focusAreas.join(', ') : 'Comprehensive security domains'}
|
|
369
|
+
- Mode: Multi-File Cross-Component Security Analysis
|
|
370
|
+
|
|
371
|
+
**MULTI-FILE SECURITY METHODOLOGY:**
|
|
372
|
+
1. **Attack Surface Mapping**: Identify all entry points and data flow paths
|
|
373
|
+
2. **Cross-File Data Flow Analysis**: Trace user input through entire application
|
|
374
|
+
3. **Authentication Chain Analysis**: Review complete auth/authz workflows
|
|
375
|
+
4. **Privilege Escalation Assessment**: Find vertical and horizontal privilege issues
|
|
376
|
+
5. **Business Logic Security**: Identify workflow and process vulnerabilities
|
|
377
|
+
6. **Configuration Drift Analysis**: Find security misconfigurations across components
|
|
378
|
+
7. **Supply Chain Security**: Assess dependencies and third-party component risks
|
|
379
|
+
8. **Architectural Security Patterns**: Evaluate security design patterns and anti-patterns
|
|
380
|
+
|
|
381
|
+
Your task is to perform a comprehensive enterprise-grade security audit across all files, focusing on cross-component vulnerabilities, attack chains, and systemic security weaknesses that could compromise the entire application.`;
|
|
382
|
+
const dataPayload = `**COMPREHENSIVE PROJECT SECURITY AUDIT DATA:**
|
|
383
|
+
|
|
384
|
+
Project Type: ${projectType}
|
|
385
|
+
Total Files Analyzed: ${fileCount}
|
|
386
|
+
Analysis Scope: ${auditDepth} depth review
|
|
387
|
+
|
|
388
|
+
**CROSS-FILE ANALYSIS RESULTS:**
|
|
389
|
+
|
|
390
|
+
${JSON.stringify(analysisResult, null, 2)}`;
|
|
391
|
+
const outputInstructions = `**PROVIDE ENTERPRISE-GRADE MULTI-FILE SECURITY AUDIT:**
|
|
392
|
+
|
|
393
|
+
Your analysis must identify systemic vulnerabilities, attack chains spanning multiple files, and architectural security flaws. Focus on risks that could lead to complete system compromise.
|
|
394
|
+
|
|
395
|
+
**ENTERPRISE-GRADE MULTI-FILE SECURITY ASSESSMENT:**
|
|
396
|
+
|
|
397
|
+
**EXECUTIVE SUMMARY:**
|
|
398
|
+
- **Overall Security Posture**: Critical, High, Medium, or Low assessment
|
|
399
|
+
- **Business Risk Rating**: Extreme, High, Moderate, or Low business impact
|
|
400
|
+
- **Total Security Findings**: Count of systemic vulnerabilities, cross-file issues, configuration flaws, and architectural weaknesses
|
|
401
|
+
- **Critical Attack Chains**: Description of the most dangerous attack paths that span multiple files
|
|
402
|
+
- **Compliance Gaps**: OWASP Top 10 or other compliance issues identified
|
|
403
|
+
- **Business Impact**: Potential impact on business operations, data, and reputation
|
|
404
|
+
|
|
405
|
+
**CROSS-FILE ATTACK CHAIN ANALYSIS:**
|
|
406
|
+
For each attack chain that spans multiple files, provide:
|
|
407
|
+
|
|
408
|
+
**Attack Chain Analysis Format:**
|
|
409
|
+
- **Attack Chain Name & Severity**: Descriptive name and Critical/High/Medium/Low rating
|
|
410
|
+
- **Attack Path Flow**: File A → File B → File C → Complete System Compromise
|
|
411
|
+
- **Entry Point Details**: Specific file, function, and line where the attack begins
|
|
412
|
+
- **Exploitation Flow**: Step-by-step progression of how the attack moves through files
|
|
413
|
+
- **Files Involved**: Complete list of all files that participate in this attack chain
|
|
414
|
+
- **Business Function Impact**: What critical business function gets compromised
|
|
415
|
+
- **Complete Exploit Scenario**: Full working proof-of-concept demonstrating the attack
|
|
416
|
+
- **Systemic Fix Strategy**: Architectural changes needed across all involved files
|
|
417
|
+
- **Detection & Monitoring**: How to monitor for this attack pattern in production
|
|
418
|
+
|
|
419
|
+
**DATA FLOW SECURITY ANALYSIS:**
|
|
420
|
+
- **User Input Entry Points**: Comprehensive mapping of all places user data enters the system
|
|
421
|
+
- **Data Processing Chain**: How user data flows through components and transformations
|
|
422
|
+
- **Validation Gaps**: Where input validation is missing, insufficient, or inconsistently applied
|
|
423
|
+
- **Output Vulnerabilities**: Where unencoded data reaches outputs and could cause XSS/injection
|
|
424
|
+
- **Data Leakage Risks**: Where sensitive data could be inadvertently exposed or logged
|
|
425
|
+
|
|
426
|
+
**AUTHENTICATION & AUTHORIZATION ARCHITECTURE REVIEW:**
|
|
427
|
+
- **Authentication Flow Analysis**: Complete auth workflow security across all components
|
|
428
|
+
- **Session Management**: Session creation, validation, termination, and storage security
|
|
429
|
+
- **Authorization Consistency**: Access control implementation across all system components
|
|
430
|
+
- **Privilege Escalation Risks**: Both horizontal and vertical privilege escalation opportunities
|
|
431
|
+
- **Account Management**: User creation, deletion, role management, and password security
|
|
432
|
+
|
|
433
|
+
### 5. Configuration Security Assessment
|
|
434
|
+
- **Security Misconfigurations**: Dangerous default settings and configurations
|
|
435
|
+
- **Environment Inconsistencies**: Security settings that vary between environments
|
|
436
|
+
- **Secrets Management**: How API keys, passwords, and tokens are handled
|
|
437
|
+
- **Infrastructure Security**: Server, database, and service configurations
|
|
438
|
+
|
|
439
|
+
### 6. Architectural Security Review
|
|
440
|
+
- **Security Patterns in Use**: Well-implemented security patterns
|
|
441
|
+
- **Security Anti-Patterns**: Problematic code patterns across the codebase
|
|
442
|
+
- **Defense in Depth Analysis**: Multiple security layer effectiveness
|
|
443
|
+
- **Single Points of Failure**: Where security relies on single mechanisms
|
|
444
|
+
|
|
445
|
+
### 7. Risk-Prioritized Remediation Roadmap
|
|
446
|
+
**IMMEDIATE CRITICAL FIXES (24-48 hours):**
|
|
447
|
+
- [Issues that could lead to immediate system compromise]
|
|
448
|
+
|
|
449
|
+
**HIGH PRIORITY (1-2 weeks):**
|
|
450
|
+
- [Cross-file vulnerabilities and architectural flaws]
|
|
451
|
+
|
|
452
|
+
**MEDIUM PRIORITY (1 month):**
|
|
453
|
+
- [Configuration improvements and security hardening]
|
|
454
|
+
|
|
455
|
+
**STRATEGIC SECURITY IMPROVEMENTS (3-6 months):**
|
|
456
|
+
- [Architectural security enhancements and process improvements]
|
|
457
|
+
|
|
458
|
+
### 8. Implementation Guidance
|
|
459
|
+
- **Secure Development Standards**: Code standards to prevent similar issues
|
|
460
|
+
- **Security Testing Strategy**: How to test for these vulnerability classes
|
|
461
|
+
- **Monitoring and Detection**: Security monitoring for ongoing protection
|
|
462
|
+
- **Developer Training Needs**: Skills gaps identified during the audit
|
|
463
|
+
|
|
464
|
+
**ENTERPRISE AUDIT REQUIREMENTS:**
|
|
465
|
+
- Focus on business-critical attack scenarios
|
|
466
|
+
- Provide complete attack chains with proof-of-concept
|
|
467
|
+
- Include compliance mapping to relevant standards
|
|
468
|
+
- Emphasize systemic fixes over isolated patches
|
|
469
|
+
- Consider threat modeling and attacker motivations
|
|
470
|
+
- Address security at architectural and implementation levels`;
|
|
471
|
+
return { systemAndContext, dataPayload, outputInstructions };
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Implement for backwards compatibility
|
|
475
|
+
* The system still expects this method, so we intelligently route to the appropriate stages
|
|
476
|
+
*/
|
|
477
|
+
getPromptStages(params) {
|
|
478
|
+
const mode = this.detectAnalysisMode(params);
|
|
479
|
+
if (mode === 'single-file') {
|
|
480
|
+
return this.getSingleFilePromptStages(params);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
return this.getMultiFilePromptStages(params);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
// Multi-file helper methods
|
|
487
|
+
async discoverRelevantFiles(projectPath, maxDepth, projectType) {
|
|
488
|
+
const extensions = this.getFileExtensions(projectType);
|
|
489
|
+
return await this.multiFileAnalysis.discoverFiles(projectPath, extensions, maxDepth);
|
|
490
|
+
}
|
|
491
|
+
async performMultiFileAnalysis(files, params, model, contextLength) {
|
|
492
|
+
const cacheKey = this.analysisCache.generateKey('security_audit', params, files);
|
|
493
|
+
const cached = await this.analysisCache.get(cacheKey);
|
|
494
|
+
if (cached)
|
|
495
|
+
return cached;
|
|
496
|
+
const fileAnalysisResults = await this.multiFileAnalysis.analyzeBatch(files, (file) => this.analyzeIndividualFile(file, params, model), contextLength);
|
|
497
|
+
// Aggregate results into comprehensive security analysis
|
|
498
|
+
const aggregatedResult = {
|
|
499
|
+
summary: `Multi-file security audit of ${files.length} files`,
|
|
500
|
+
findings: fileAnalysisResults,
|
|
501
|
+
securityAssessment: {
|
|
502
|
+
fileCount: files.length,
|
|
503
|
+
totalSize: fileAnalysisResults.reduce((sum, result) => sum + (result.size || 0), 0),
|
|
504
|
+
riskDistribution: this.categorizeFilesByRisk(fileAnalysisResults),
|
|
505
|
+
criticalFiles: fileAnalysisResults.filter((result) => result.riskLevel === 'high'),
|
|
506
|
+
dataFlowAnalysis: this.analyzeDataFlows(fileAnalysisResults),
|
|
507
|
+
authenticationChain: this.analyzeAuthChain(fileAnalysisResults, params.projectType),
|
|
508
|
+
configurationSecurity: this.analyzeConfigurations(fileAnalysisResults)
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
await this.analysisCache.cacheAnalysis(cacheKey, aggregatedResult, {
|
|
512
|
+
modelUsed: model.identifier || 'unknown',
|
|
513
|
+
executionTime: Date.now() - Date.now(), // TODO: Track actual execution time
|
|
514
|
+
timestamp: new Date().toISOString()
|
|
515
|
+
});
|
|
516
|
+
return aggregatedResult;
|
|
517
|
+
}
|
|
518
|
+
async analyzeIndividualFile(file, params, model) {
|
|
519
|
+
const content = await import('fs/promises').then(fs => fs.readFile(file, 'utf-8'));
|
|
520
|
+
const stats = await import('fs/promises').then(fs => fs.stat(file));
|
|
521
|
+
return {
|
|
522
|
+
filePath: file,
|
|
523
|
+
size: content.length,
|
|
524
|
+
lines: content.split('\n').length,
|
|
525
|
+
extension: file.split('.').pop() || '',
|
|
526
|
+
riskLevel: this.assessFileRisk(content, file, params.projectType),
|
|
527
|
+
securityPatterns: this.identifySecurityPatterns(content, file),
|
|
528
|
+
vulnerabilityIndicators: this.scanForVulnerabilities(content),
|
|
529
|
+
modified: stats.mtime
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
getFileExtensions(projectType) {
|
|
533
|
+
const extensionMap = {
|
|
534
|
+
'wordpress-plugin': ['.php', '.js', '.json', '.css', '.html'],
|
|
535
|
+
'wordpress-theme': ['.php', '.js', '.css', '.html', '.json'],
|
|
536
|
+
'react-app': ['.js', '.jsx', '.ts', '.tsx', '.json', '.html', '.css'],
|
|
537
|
+
'react-component': ['.js', '.jsx', '.ts', '.tsx', '.css'],
|
|
538
|
+
'node-api': ['.js', '.ts', '.json', '.yaml', '.yml', '.env'],
|
|
539
|
+
'browser-extension': ['.js', '.json', '.html', '.css', '.xml'],
|
|
540
|
+
'cli-tool': ['.js', '.ts', '.py', '.sh', '.json'],
|
|
541
|
+
'n8n-node': ['.ts', '.js', '.json'],
|
|
542
|
+
'n8n-workflow': ['.json'],
|
|
543
|
+
'html-component': ['.html', '.js', '.css', '.json'],
|
|
544
|
+
'generic': ['.js', '.ts', '.jsx', '.tsx', '.php', '.py', '.java', '.cs', '.cpp', '.h', '.html', '.css', '.json', '.xml', '.yml', '.yaml', '.env', '.config', '.ini']
|
|
545
|
+
};
|
|
546
|
+
return extensionMap[projectType] || extensionMap.generic;
|
|
547
|
+
}
|
|
548
|
+
categorizeFilesByRisk(results) {
|
|
549
|
+
const riskCategories = { high: 0, medium: 0, low: 0 };
|
|
550
|
+
results.forEach(result => {
|
|
551
|
+
riskCategories[result.riskLevel] = (riskCategories[result.riskLevel] || 0) + 1;
|
|
552
|
+
});
|
|
553
|
+
return riskCategories;
|
|
554
|
+
}
|
|
555
|
+
analyzeDataFlows(results) {
|
|
556
|
+
// Analyze how data flows between files
|
|
557
|
+
return {
|
|
558
|
+
entryPoints: results.filter(r => r.securityPatterns?.includes('user-input')).length,
|
|
559
|
+
processingFiles: results.filter(r => r.securityPatterns?.includes('data-processing')).length,
|
|
560
|
+
outputFiles: results.filter(r => r.securityPatterns?.includes('output-generation')).length,
|
|
561
|
+
dataFlowRisks: 'Cross-file data flow analysis would be performed here'
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
analyzeAuthChain(results, projectType) {
|
|
565
|
+
// Analyze authentication and authorization chains
|
|
566
|
+
return {
|
|
567
|
+
authFiles: results.filter(r => r.filePath.toLowerCase().includes('auth')).length,
|
|
568
|
+
loginFiles: results.filter(r => r.filePath.toLowerCase().includes('login')).length,
|
|
569
|
+
adminFiles: results.filter(r => r.filePath.toLowerCase().includes('admin')).length,
|
|
570
|
+
authChainAnalysis: 'Authentication chain analysis would be performed here'
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
analyzeConfigurations(results) {
|
|
574
|
+
// Analyze configuration security
|
|
575
|
+
const configFiles = results.filter(r => r.extension === 'json' ||
|
|
576
|
+
r.extension === 'env' ||
|
|
577
|
+
r.filePath.includes('config'));
|
|
578
|
+
return {
|
|
579
|
+
configFileCount: configFiles.length,
|
|
580
|
+
configurationRisks: 'Configuration security analysis would be performed here',
|
|
581
|
+
configFiles: configFiles.map(f => f.filePath)
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
assessFileRisk(content, filePath, projectType) {
|
|
585
|
+
// Assess individual file risk based on content patterns
|
|
586
|
+
const riskPatterns = {
|
|
587
|
+
high: [/eval\s*\(/i, /exec\s*\(/i, /\$_GET\s*\[/i, /\$_POST\s*\[/i, /password.*=.*['"]/i],
|
|
588
|
+
medium: [/innerHTML\s*=/i, /document\.write/i, /api.*key/i, /secret/i],
|
|
589
|
+
low: [/console\.log/i, /debug/i]
|
|
590
|
+
};
|
|
591
|
+
for (const [level, patterns] of Object.entries(riskPatterns)) {
|
|
592
|
+
for (const pattern of patterns) {
|
|
593
|
+
if (pattern.test(content)) {
|
|
594
|
+
return level;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return 'low';
|
|
599
|
+
}
|
|
600
|
+
identifySecurityPatterns(content, filePath) {
|
|
601
|
+
const patterns = [];
|
|
602
|
+
if (/input|form|request/i.test(content))
|
|
603
|
+
patterns.push('user-input');
|
|
604
|
+
if (/validation|sanitize|filter/i.test(content))
|
|
605
|
+
patterns.push('input-validation');
|
|
606
|
+
if (/auth|login|session/i.test(content))
|
|
607
|
+
patterns.push('authentication');
|
|
608
|
+
if (/admin|role|permission/i.test(content))
|
|
609
|
+
patterns.push('authorization');
|
|
610
|
+
if (/encrypt|hash|crypto/i.test(content))
|
|
611
|
+
patterns.push('cryptography');
|
|
612
|
+
if (/output|echo|print|render/i.test(content))
|
|
613
|
+
patterns.push('output-generation');
|
|
614
|
+
return patterns;
|
|
615
|
+
}
|
|
616
|
+
scanForVulnerabilities(content) {
|
|
617
|
+
const vulnerabilities = [];
|
|
618
|
+
if (/eval\s*\(/i.test(content))
|
|
619
|
+
vulnerabilities.push('code-injection');
|
|
620
|
+
if (/\$_GET\s*\[.*\]\s*(?!.*htmlspecialchars)/i.test(content))
|
|
621
|
+
vulnerabilities.push('xss-risk');
|
|
622
|
+
if (/SELECT.*FROM.*WHERE.*\$_/i.test(content))
|
|
623
|
+
vulnerabilities.push('sql-injection-risk');
|
|
624
|
+
if (/password.*=.*['"]\w+['"]/i.test(content))
|
|
625
|
+
vulnerabilities.push('hardcoded-credentials');
|
|
626
|
+
if (/api.?key.*=.*['"]\w+['"]/i.test(content))
|
|
627
|
+
vulnerabilities.push('hardcoded-api-key');
|
|
628
|
+
return vulnerabilities;
|
|
629
|
+
}
|
|
630
|
+
generateCacheKey(files, params) {
|
|
631
|
+
const fileHash = files.join('|');
|
|
632
|
+
const paramHash = JSON.stringify(params);
|
|
633
|
+
return `${fileHash}_${paramHash}`.substring(0, 64);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
export default SecurityAuditor;
|
|
637
|
+
//# sourceMappingURL=security-audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-audit.js","sourceRoot":"","sources":["../../../src/prompts/analyze/security-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB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