agentic-qe 3.8.4 → 3.8.6
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/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/cli/bundle.js +694 -694
- package/dist/cli/commands/hooks-handlers/command-hooks.d.ts +12 -0
- package/dist/cli/commands/hooks-handlers/command-hooks.js +253 -0
- package/dist/cli/commands/hooks-handlers/editing-hooks.d.ts +12 -0
- package/dist/cli/commands/hooks-handlers/editing-hooks.js +161 -0
- package/dist/cli/commands/hooks-handlers/hooks-dream-learning.d.ts +57 -0
- package/dist/cli/commands/hooks-handlers/hooks-dream-learning.js +263 -0
- package/dist/cli/commands/hooks-handlers/hooks-shared.d.ts +52 -0
- package/dist/cli/commands/hooks-handlers/hooks-shared.js +223 -0
- package/dist/cli/commands/hooks-handlers/routing-hooks.d.ts +12 -0
- package/dist/cli/commands/hooks-handlers/routing-hooks.js +107 -0
- package/dist/cli/commands/hooks-handlers/session-hooks.d.ts +12 -0
- package/dist/cli/commands/hooks-handlers/session-hooks.js +171 -0
- package/dist/cli/commands/hooks-handlers/stats-hooks.d.ts +12 -0
- package/dist/cli/commands/hooks-handlers/stats-hooks.js +248 -0
- package/dist/cli/commands/hooks-handlers/task-hooks.d.ts +12 -0
- package/dist/cli/commands/hooks-handlers/task-hooks.js +152 -0
- package/dist/cli/commands/hooks.d.ts +3 -23
- package/dist/cli/commands/hooks.js +16 -1459
- package/dist/coordination/mincut/phase-executor.d.ts +27 -0
- package/dist/coordination/mincut/phase-executor.js +70 -0
- package/dist/coordination/mincut/time-crystal-analysis.d.ts +35 -0
- package/dist/coordination/mincut/time-crystal-analysis.js +237 -0
- package/dist/coordination/mincut/time-crystal-persistence.d.ts +35 -0
- package/dist/coordination/mincut/time-crystal-persistence.js +81 -0
- package/dist/coordination/mincut/time-crystal-scheduling.d.ts +34 -0
- package/dist/coordination/mincut/time-crystal-scheduling.js +213 -0
- package/dist/coordination/mincut/time-crystal-types.d.ts +278 -0
- package/dist/coordination/mincut/time-crystal-types.js +67 -0
- package/dist/coordination/mincut/time-crystal.d.ts +8 -438
- package/dist/coordination/mincut/time-crystal.js +87 -905
- package/dist/domains/base-domain-coordinator.d.ts +0 -15
- package/dist/domains/base-domain-coordinator.js +7 -5
- package/dist/domains/chaos-resilience/coordinator.d.ts +0 -4
- package/dist/domains/chaos-resilience/coordinator.js +24 -22
- package/dist/domains/chaos-resilience/services/chaos-engineer.d.ts +0 -4
- package/dist/domains/chaos-resilience/services/chaos-engineer.js +47 -45
- package/dist/domains/chaos-resilience/services/performance-profiler.d.ts +0 -4
- package/dist/domains/chaos-resilience/services/performance-profiler.js +10 -8
- package/dist/domains/code-intelligence/coordinator-consensus.d.ts +0 -3
- package/dist/domains/code-intelligence/coordinator-consensus.js +8 -6
- package/dist/domains/code-intelligence/coordinator-gnn.d.ts +0 -3
- package/dist/domains/code-intelligence/coordinator-gnn.js +8 -6
- package/dist/domains/code-intelligence/coordinator-hypergraph.d.ts +0 -3
- package/dist/domains/code-intelligence/coordinator-hypergraph.js +13 -11
- package/dist/domains/code-intelligence/coordinator.d.ts +0 -3
- package/dist/domains/code-intelligence/coordinator.js +21 -19
- package/dist/domains/code-intelligence/services/c4-model/index.d.ts +0 -3
- package/dist/domains/code-intelligence/services/c4-model/index.js +5 -3
- package/dist/domains/code-intelligence/services/knowledge-graph.d.ts +0 -6
- package/dist/domains/code-intelligence/services/knowledge-graph.js +4 -2
- package/dist/domains/code-intelligence/services/product-factors-bridge.d.ts +0 -5
- package/dist/domains/code-intelligence/services/product-factors-bridge.js +9 -7
- package/dist/domains/contract-testing/coordinator.d.ts +0 -6
- package/dist/domains/contract-testing/coordinator.js +25 -23
- package/dist/domains/contract-testing/services/contract-validator.d.ts +0 -4
- package/dist/domains/contract-testing/services/contract-validator.js +4 -2
- package/dist/domains/contract-testing/services/schema-validator.js +1 -1
- package/dist/domains/coverage-analysis/coordinator.js +13 -11
- package/dist/domains/coverage-analysis/services/coverage-analyzer.js +4 -2
- package/dist/domains/coverage-analysis/services/gap-detector.js +3 -1
- package/dist/domains/coverage-analysis/services/hnsw-index.d.ts +0 -15
- package/dist/domains/coverage-analysis/services/hnsw-index.js +3 -1
- package/dist/domains/coverage-analysis/services/sublinear-analyzer.d.ts +0 -26
- package/dist/domains/coverage-analysis/services/sublinear-analyzer.js +3 -1
- package/dist/domains/defect-intelligence/coordinator.d.ts +1 -10
- package/dist/domains/defect-intelligence/coordinator.js +5 -3
- package/dist/domains/defect-intelligence/services/causal-root-cause-analyzer.d.ts +0 -6
- package/dist/domains/defect-intelligence/services/causal-root-cause-analyzer.js +3 -1
- package/dist/domains/defect-intelligence/services/defect-predictor.d.ts +0 -6
- package/dist/domains/defect-intelligence/services/defect-predictor.js +5 -3
- package/dist/domains/defect-intelligence/services/pattern-learner.d.ts +0 -4
- package/dist/domains/defect-intelligence/services/pattern-learner.js +3 -1
- package/dist/domains/defect-intelligence/services/root-cause-analyzer.d.ts +0 -6
- package/dist/domains/defect-intelligence/services/root-cause-analyzer.js +3 -1
- package/dist/domains/enterprise-integration/coordinator.js +6 -4
- package/dist/domains/learning-optimization/coordinator-consensus.d.ts +0 -3
- package/dist/domains/learning-optimization/coordinator-consensus.js +8 -6
- package/dist/domains/learning-optimization/coordinator.d.ts +0 -3
- package/dist/domains/learning-optimization/coordinator.js +15 -13
- package/dist/domains/learning-optimization/services/learning-coordinator.d.ts +0 -4
- package/dist/domains/learning-optimization/services/learning-coordinator.js +4 -2
- package/dist/domains/quality-assessment/coordinator-claim-verifier.d.ts +0 -3
- package/dist/domains/quality-assessment/coordinator-claim-verifier.js +6 -4
- package/dist/domains/quality-assessment/coordinator-gate-evaluation.d.ts +0 -4
- package/dist/domains/quality-assessment/coordinator-gate-evaluation.js +9 -7
- package/dist/domains/quality-assessment/coordinator-rl-integration.d.ts +0 -3
- package/dist/domains/quality-assessment/coordinator-rl-integration.js +10 -8
- package/dist/domains/quality-assessment/coordinator.d.ts +0 -15
- package/dist/domains/quality-assessment/coordinator.js +14 -12
- package/dist/domains/quality-assessment/services/deployment-advisor.d.ts +0 -10
- package/dist/domains/quality-assessment/services/deployment-advisor.js +4 -2
- package/dist/domains/quality-assessment/services/quality-analyzer.d.ts +0 -6
- package/dist/domains/quality-assessment/services/quality-analyzer.js +4 -2
- package/dist/domains/requirements-validation/coordinator.d.ts +0 -3
- package/dist/domains/requirements-validation/coordinator.js +15 -13
- package/dist/domains/requirements-validation/services/product-factors-assessment/code-intelligence/codebase-analyzer.d.ts +0 -5
- package/dist/domains/requirements-validation/services/product-factors-assessment/code-intelligence/codebase-analyzer.js +15 -13
- package/dist/domains/requirements-validation/services/product-factors-assessment/product-factors-service.d.ts +0 -6
- package/dist/domains/requirements-validation/services/product-factors-assessment/product-factors-service.js +9 -7
- package/dist/domains/requirements-validation/services/requirements-validator.d.ts +0 -6
- package/dist/domains/requirements-validation/services/requirements-validator.js +4 -2
- package/dist/domains/security-compliance/coordinator.js +24 -22
- package/dist/domains/security-compliance/services/scanners/dast-scanner.d.ts +0 -21
- package/dist/domains/security-compliance/services/scanners/dast-scanner.js +4 -2
- package/dist/domains/security-compliance/services/scanners/sast-scanner.d.ts +0 -4
- package/dist/domains/security-compliance/services/scanners/sast-scanner.js +3 -1
- package/dist/domains/security-compliance/services/security-auditor-dast.d.ts +0 -4
- package/dist/domains/security-compliance/services/security-auditor-dast.js +3 -1
- package/dist/domains/security-compliance/services/security-auditor-sast.d.ts +0 -3
- package/dist/domains/security-compliance/services/security-auditor-sast.js +3 -1
- package/dist/domains/security-compliance/services/security-auditor-secrets.d.ts +0 -3
- package/dist/domains/security-compliance/services/security-auditor-secrets.js +3 -1
- package/dist/domains/security-compliance/services/security-auditor.js +11 -9
- package/dist/domains/test-execution/coordinator.js +11 -9
- package/dist/domains/test-execution/services/auth-state-manager.d.ts +0 -3
- package/dist/domains/test-execution/services/auth-state-manager.js +4 -2
- package/dist/domains/test-execution/services/e2e/e2e-coordinator.d.ts +0 -14
- package/dist/domains/test-execution/services/e2e/e2e-coordinator.js +3 -1
- package/dist/domains/test-execution/services/flaky-detector.js +4 -2
- package/dist/domains/test-execution/services/retry-handler.js +3 -1
- package/dist/domains/test-execution/services/test-executor.js +3 -1
- package/dist/domains/test-generation/coordinator.d.ts +0 -17
- package/dist/domains/test-generation/coordinator.js +33 -31
- package/dist/domains/test-generation/pattern-injection/edge-case-injector.d.ts +0 -5
- package/dist/domains/test-generation/pattern-injection/edge-case-injector.js +3 -1
- package/dist/domains/test-generation/services/code-transform-integration.d.ts +0 -7
- package/dist/domains/test-generation/services/code-transform-integration.js +3 -1
- package/dist/domains/test-generation/services/coherence-gate-service.d.ts +0 -3
- package/dist/domains/test-generation/services/coherence-gate-service.js +3 -1
- package/dist/domains/test-generation/services/test-generator.d.ts +0 -8
- package/dist/domains/test-generation/services/test-generator.js +5 -3
- package/dist/domains/visual-accessibility/coordinator.d.ts +0 -3
- package/dist/domains/visual-accessibility/coordinator.js +14 -12
- package/dist/domains/visual-accessibility/services/accessibility-tester-browser.d.ts +0 -3
- package/dist/domains/visual-accessibility/services/accessibility-tester-browser.js +52 -50
- package/dist/domains/visual-accessibility/services/accessibility-tester.d.ts +0 -4
- package/dist/domains/visual-accessibility/services/accessibility-tester.js +8 -6
- package/dist/domains/visual-accessibility/services/axe-core-integration.d.ts +0 -3
- package/dist/domains/visual-accessibility/services/axe-core-integration.js +20 -18
- package/dist/domains/visual-accessibility/services/browser-security-scanner.d.ts +0 -4
- package/dist/domains/visual-accessibility/services/browser-security-scanner.js +6 -4
- package/dist/domains/visual-accessibility/services/browser-swarm-coordinator.d.ts +0 -30
- package/dist/domains/visual-accessibility/services/browser-swarm-coordinator.js +5 -3
- package/dist/domains/visual-accessibility/services/viewport-capture.d.ts +0 -27
- package/dist/domains/visual-accessibility/services/viewport-capture.js +6 -4
- package/dist/domains/visual-accessibility/services/visual-regression.d.ts +0 -26
- package/dist/domains/visual-accessibility/services/visual-regression.js +4 -2
- package/dist/domains/visual-accessibility/services/visual-tester.d.ts +0 -4
- package/dist/domains/visual-accessibility/services/visual-tester.js +4 -2
- package/dist/governance/deterministic-gateway-integration.js +1 -1
- package/dist/learning/agent-routing.d.ts +53 -0
- package/dist/learning/agent-routing.js +142 -0
- package/dist/learning/embedding-utils.d.ts +34 -0
- package/dist/learning/embedding-utils.js +95 -0
- package/dist/learning/pattern-promotion.d.ts +63 -0
- package/dist/learning/pattern-promotion.js +187 -0
- package/dist/learning/pretrained-patterns.d.ts +14 -0
- package/dist/learning/pretrained-patterns.js +726 -0
- package/dist/learning/qe-reasoning-bank-types.d.ts +174 -0
- package/dist/learning/qe-reasoning-bank-types.js +24 -0
- package/dist/learning/qe-reasoning-bank.d.ts +9 -192
- package/dist/learning/qe-reasoning-bank.js +48 -1093
- package/dist/mcp/bundle.js +335 -335
- package/dist/mcp/security/validators/command-validator.d.ts +1 -40
- package/dist/mcp/security/validators/command-validator.js +2 -122
- package/dist/mcp/security/validators/crypto-validator.d.ts +1 -39
- package/dist/mcp/security/validators/crypto-validator.js +2 -71
- package/dist/mcp/security/validators/input-sanitizer.d.ts +1 -55
- package/dist/mcp/security/validators/input-sanitizer.js +2 -156
- package/dist/mcp/security/validators/interfaces.d.ts +1 -163
- package/dist/mcp/security/validators/interfaces.js +2 -5
- package/dist/mcp/security/validators/path-traversal-validator.d.ts +1 -49
- package/dist/mcp/security/validators/path-traversal-validator.js +2 -241
- package/dist/mcp/security/validators/regex-safety-validator.d.ts +1 -49
- package/dist/mcp/security/validators/regex-safety-validator.js +2 -182
- package/dist/mcp/security/validators/validation-orchestrator.d.ts +1 -65
- package/dist/mcp/security/validators/validation-orchestrator.js +2 -145
- package/dist/shared/io/file-reader.js +1 -1
- package/dist/shared/security/command-validator.d.ts +44 -0
- package/dist/shared/security/command-validator.js +126 -0
- package/dist/shared/security/crypto-validator.d.ts +43 -0
- package/dist/shared/security/crypto-validator.js +75 -0
- package/dist/shared/security/index.d.ts +7 -0
- package/dist/shared/security/index.js +15 -0
- package/dist/shared/security/input-sanitizer.d.ts +59 -0
- package/dist/shared/security/input-sanitizer.js +160 -0
- package/dist/shared/security/path-traversal-validator.d.ts +53 -0
- package/dist/shared/security/path-traversal-validator.js +245 -0
- package/dist/shared/security/regex-safety-validator.d.ts +53 -0
- package/dist/shared/security/regex-safety-validator.js +186 -0
- package/dist/shared/security/validation-orchestrator.d.ts +69 -0
- package/dist/shared/security/validation-orchestrator.js +149 -0
- package/dist/shared/security/validators-interfaces.d.ts +167 -0
- package/dist/shared/security/validators-interfaces.js +9 -0
- package/package.json +1 -1
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Agentic QE v3 - MCP Security: Path Traversal Validator
|
|
3
|
-
* Implements the Strategy Pattern for path traversal protection
|
|
4
|
-
*/
|
|
5
|
-
import { IPathValidationStrategy, PathValidationOptions, PathValidationResult, RiskLevel } from './interfaces';
|
|
6
|
-
/**
|
|
7
|
-
* Path traversal patterns to detect
|
|
8
|
-
*/
|
|
9
|
-
export declare const PATH_TRAVERSAL_PATTERNS: RegExp[];
|
|
10
|
-
/**
|
|
11
|
-
* Dangerous path components (system directories)
|
|
12
|
-
*/
|
|
13
|
-
export declare const DANGEROUS_PATH_COMPONENTS: RegExp[];
|
|
14
|
-
/**
|
|
15
|
-
* Path Traversal Validator Strategy
|
|
16
|
-
* Validates file paths to prevent directory traversal attacks
|
|
17
|
-
*/
|
|
18
|
-
export declare class PathTraversalValidator implements IPathValidationStrategy {
|
|
19
|
-
readonly name = "path-traversal";
|
|
20
|
-
/**
|
|
21
|
-
* Get the primary risk level this validator addresses
|
|
22
|
-
*/
|
|
23
|
-
getRiskLevel(): RiskLevel;
|
|
24
|
-
/**
|
|
25
|
-
* Validate a file path against traversal attacks
|
|
26
|
-
*/
|
|
27
|
-
validate(path: string, options?: PathValidationOptions): PathValidationResult;
|
|
28
|
-
/**
|
|
29
|
-
* Normalize a path by resolving . and .. components
|
|
30
|
-
*/
|
|
31
|
-
normalizePath(path: string): string;
|
|
32
|
-
/**
|
|
33
|
-
* Safely join path components (strips leading/trailing slashes from all parts)
|
|
34
|
-
*/
|
|
35
|
-
joinPaths(...paths: string[]): string;
|
|
36
|
-
/**
|
|
37
|
-
* Join paths preserving absolute path from first component
|
|
38
|
-
*/
|
|
39
|
-
joinPathsAbsolute(...paths: string[]): string;
|
|
40
|
-
/**
|
|
41
|
-
* Get file extension from path
|
|
42
|
-
*/
|
|
43
|
-
getExtension(path: string): string | null;
|
|
44
|
-
}
|
|
45
|
-
export declare const validatePath: (path: string, options?: PathValidationOptions) => PathValidationResult;
|
|
46
|
-
export declare const normalizePath: (path: string) => string;
|
|
47
|
-
export declare const joinPaths: (...paths: string[]) => string;
|
|
48
|
-
export declare const joinPathsAbsolute: (...paths: string[]) => string;
|
|
49
|
-
export declare const getExtension: (path: string) => string | null;
|
|
1
|
+
export * from '../../../shared/security/path-traversal-validator.js';
|
|
50
2
|
//# sourceMappingURL=path-traversal-validator.d.ts.map
|
|
@@ -1,242 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* Implements the Strategy Pattern for path traversal protection
|
|
4
|
-
*/
|
|
5
|
-
// ============================================================================
|
|
6
|
-
// Constants
|
|
7
|
-
// ============================================================================
|
|
8
|
-
/**
|
|
9
|
-
* Path traversal patterns to detect
|
|
10
|
-
*/
|
|
11
|
-
export const PATH_TRAVERSAL_PATTERNS = [
|
|
12
|
-
/\.\./, // Basic traversal
|
|
13
|
-
/%2e%2e/i, // URL encoded ..
|
|
14
|
-
/%252e%252e/i, // Double URL encoded
|
|
15
|
-
/\.\.%2f/i, // Mixed encoding
|
|
16
|
-
/%2f\.\./i, // Forward slash + ..
|
|
17
|
-
/\.\.%5c/i, // Backslash + ..
|
|
18
|
-
/\.\.\\/, // Windows backslash traversal
|
|
19
|
-
/%c0%ae/i, // UTF-8 overlong encoding
|
|
20
|
-
/%c0%2f/i, // UTF-8 overlong /
|
|
21
|
-
/%c1%9c/i, // UTF-8 overlong \
|
|
22
|
-
/\0/, // Null byte injection
|
|
23
|
-
/%00/i, // URL encoded null
|
|
24
|
-
];
|
|
25
|
-
/**
|
|
26
|
-
* Dangerous path components (system directories)
|
|
27
|
-
*/
|
|
28
|
-
export const DANGEROUS_PATH_COMPONENTS = [
|
|
29
|
-
/^\/etc\//i,
|
|
30
|
-
/^\/proc\//i,
|
|
31
|
-
/^\/sys\//i,
|
|
32
|
-
/^\/dev\//i,
|
|
33
|
-
/^\/root\//i,
|
|
34
|
-
/^\/home\/.+\/\./i,
|
|
35
|
-
/^[A-Z]:\\Windows/i,
|
|
36
|
-
/^[A-Z]:\\System/i,
|
|
37
|
-
/^[A-Z]:\\Users\\.+\\AppData/i,
|
|
38
|
-
];
|
|
39
|
-
// ============================================================================
|
|
40
|
-
// Path Traversal Validator Implementation
|
|
41
|
-
// ============================================================================
|
|
42
|
-
/**
|
|
43
|
-
* Path Traversal Validator Strategy
|
|
44
|
-
* Validates file paths to prevent directory traversal attacks
|
|
45
|
-
*/
|
|
46
|
-
export class PathTraversalValidator {
|
|
47
|
-
name = 'path-traversal';
|
|
48
|
-
/**
|
|
49
|
-
* Get the primary risk level this validator addresses
|
|
50
|
-
*/
|
|
51
|
-
getRiskLevel() {
|
|
52
|
-
return 'critical';
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Validate a file path against traversal attacks
|
|
56
|
-
*/
|
|
57
|
-
validate(path, options = {}) {
|
|
58
|
-
const { basePath = '', allowAbsolute = false, allowedExtensions = [], deniedExtensions = ['.exe', '.bat', '.cmd', '.sh', '.ps1', '.dll', '.so'], maxDepth = 10, maxLength = 4096, } = options;
|
|
59
|
-
// Check length
|
|
60
|
-
if (path.length > maxLength) {
|
|
61
|
-
return {
|
|
62
|
-
valid: false,
|
|
63
|
-
error: `Path exceeds maximum length of ${maxLength}`,
|
|
64
|
-
riskLevel: 'medium',
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
// Check for traversal patterns
|
|
68
|
-
for (const pattern of PATH_TRAVERSAL_PATTERNS) {
|
|
69
|
-
if (pattern.test(path)) {
|
|
70
|
-
return {
|
|
71
|
-
valid: false,
|
|
72
|
-
error: 'Path traversal attempt detected',
|
|
73
|
-
riskLevel: 'critical',
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Check for absolute paths
|
|
78
|
-
if (!allowAbsolute && (path.startsWith('/') || /^[A-Z]:/i.test(path))) {
|
|
79
|
-
return {
|
|
80
|
-
valid: false,
|
|
81
|
-
error: 'Absolute paths are not allowed',
|
|
82
|
-
riskLevel: 'high',
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
// Check for dangerous path components
|
|
86
|
-
for (const pattern of DANGEROUS_PATH_COMPONENTS) {
|
|
87
|
-
if (pattern.test(path)) {
|
|
88
|
-
return {
|
|
89
|
-
valid: false,
|
|
90
|
-
error: 'Access to system paths is not allowed',
|
|
91
|
-
riskLevel: 'critical',
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// Normalize the path
|
|
96
|
-
const normalizedPath = this.normalizePath(path);
|
|
97
|
-
// Re-check for traversal after normalization
|
|
98
|
-
if (normalizedPath.includes('..')) {
|
|
99
|
-
return {
|
|
100
|
-
valid: false,
|
|
101
|
-
error: 'Path traversal detected after normalization',
|
|
102
|
-
riskLevel: 'critical',
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
// Check depth
|
|
106
|
-
const depth = normalizedPath.split('/').filter(Boolean).length;
|
|
107
|
-
if (depth > maxDepth) {
|
|
108
|
-
return {
|
|
109
|
-
valid: false,
|
|
110
|
-
error: `Path depth exceeds maximum of ${maxDepth}`,
|
|
111
|
-
riskLevel: 'low',
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
// Check extension
|
|
115
|
-
const ext = this.getExtension(normalizedPath);
|
|
116
|
-
if (ext) {
|
|
117
|
-
const extWithDot = `.${ext.toLowerCase()}`;
|
|
118
|
-
const extWithoutDot = ext.toLowerCase();
|
|
119
|
-
// Check denied extensions (support both .exe and exe formats)
|
|
120
|
-
if (deniedExtensions.length > 0) {
|
|
121
|
-
const isDenied = deniedExtensions.some(denied => denied.toLowerCase() === extWithDot || denied.toLowerCase() === extWithoutDot);
|
|
122
|
-
if (isDenied) {
|
|
123
|
-
return {
|
|
124
|
-
valid: false,
|
|
125
|
-
error: `File extension '${ext}' is not allowed`,
|
|
126
|
-
riskLevel: 'high',
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
// Check allowed extensions (support both .ts and ts formats)
|
|
131
|
-
if (allowedExtensions.length > 0) {
|
|
132
|
-
const isAllowed = allowedExtensions.some(allowed => allowed.toLowerCase() === extWithDot || allowed.toLowerCase() === extWithoutDot);
|
|
133
|
-
if (!isAllowed) {
|
|
134
|
-
return {
|
|
135
|
-
valid: false,
|
|
136
|
-
error: `File extension '${ext}' is not in allowed list`,
|
|
137
|
-
riskLevel: 'medium',
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// Combine with base path if provided
|
|
143
|
-
const finalPath = basePath
|
|
144
|
-
? this.joinPathsAbsolute(basePath, normalizedPath)
|
|
145
|
-
: normalizedPath;
|
|
146
|
-
// Verify final path doesn't escape base (use normalized base for comparison)
|
|
147
|
-
const normalizedBase = basePath.startsWith('/')
|
|
148
|
-
? `/${this.normalizePath(basePath)}`
|
|
149
|
-
: this.normalizePath(basePath);
|
|
150
|
-
if (basePath && !finalPath.startsWith(normalizedBase)) {
|
|
151
|
-
return {
|
|
152
|
-
valid: false,
|
|
153
|
-
error: 'Path escapes base directory',
|
|
154
|
-
riskLevel: 'critical',
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
valid: true,
|
|
159
|
-
normalizedPath: finalPath,
|
|
160
|
-
riskLevel: 'none',
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Normalize a path by resolving . and .. components
|
|
165
|
-
*/
|
|
166
|
-
normalizePath(path) {
|
|
167
|
-
// Replace backslashes with forward slashes
|
|
168
|
-
let normalized = path.replace(/\\/g, '/');
|
|
169
|
-
// Remove multiple consecutive slashes
|
|
170
|
-
normalized = normalized.replace(/\/+/g, '/');
|
|
171
|
-
// Split and resolve
|
|
172
|
-
const parts = normalized.split('/');
|
|
173
|
-
const result = [];
|
|
174
|
-
for (const part of parts) {
|
|
175
|
-
if (part === '.' || part === '') {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (part === '..') {
|
|
179
|
-
// Don't allow going above root
|
|
180
|
-
if (result.length > 0 && result[result.length - 1] !== '..') {
|
|
181
|
-
result.pop();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
result.push(part);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return result.join('/');
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Safely join path components (strips leading/trailing slashes from all parts)
|
|
192
|
-
*/
|
|
193
|
-
joinPaths(...paths) {
|
|
194
|
-
if (paths.length === 0)
|
|
195
|
-
return '';
|
|
196
|
-
return paths
|
|
197
|
-
.map(p => p.replace(/^\/+|\/+$/g, ''))
|
|
198
|
-
.filter(Boolean)
|
|
199
|
-
.join('/');
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Join paths preserving absolute path from first component
|
|
203
|
-
*/
|
|
204
|
-
joinPathsAbsolute(...paths) {
|
|
205
|
-
if (paths.length === 0)
|
|
206
|
-
return '';
|
|
207
|
-
// Check if the first path is absolute
|
|
208
|
-
const isAbsolute = paths[0].startsWith('/');
|
|
209
|
-
const result = paths
|
|
210
|
-
// Use non-backtracking patterns with possessive-like behavior via split/join
|
|
211
|
-
.map(p => {
|
|
212
|
-
// Remove leading slashes by splitting and rejoining
|
|
213
|
-
while (p.startsWith('/'))
|
|
214
|
-
p = p.slice(1);
|
|
215
|
-
// Remove trailing slashes
|
|
216
|
-
while (p.endsWith('/'))
|
|
217
|
-
p = p.slice(0, -1);
|
|
218
|
-
return p;
|
|
219
|
-
})
|
|
220
|
-
.filter(Boolean)
|
|
221
|
-
.join('/');
|
|
222
|
-
// Preserve leading slash for absolute paths
|
|
223
|
-
return isAbsolute ? `/${result}` : result;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Get file extension from path
|
|
227
|
-
*/
|
|
228
|
-
getExtension(path) {
|
|
229
|
-
const match = path.match(/\.([^./\\]+)$/);
|
|
230
|
-
return match ? match[1] : null;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
// ============================================================================
|
|
234
|
-
// Standalone Functions (for backward compatibility)
|
|
235
|
-
// ============================================================================
|
|
236
|
-
const defaultValidator = new PathTraversalValidator();
|
|
237
|
-
export const validatePath = (path, options) => defaultValidator.validate(path, options);
|
|
238
|
-
export const normalizePath = (path) => defaultValidator.normalizePath(path);
|
|
239
|
-
export const joinPaths = (...paths) => defaultValidator.joinPaths(...paths);
|
|
240
|
-
export const joinPathsAbsolute = (...paths) => defaultValidator.joinPathsAbsolute(...paths);
|
|
241
|
-
export const getExtension = (path) => defaultValidator.getExtension(path);
|
|
1
|
+
// Re-export from shared/security for backward compatibility
|
|
2
|
+
export * from '../../../shared/security/path-traversal-validator.js';
|
|
242
3
|
//# sourceMappingURL=path-traversal-validator.js.map
|
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Agentic QE v3 - MCP Security: Regex Safety Validator
|
|
3
|
-
* Implements the Strategy Pattern for ReDoS prevention
|
|
4
|
-
*/
|
|
5
|
-
import { IRegexValidationStrategy, RegexSafetyResult, RegexValidationOptions, RiskLevel, ValidationResult } from './interfaces';
|
|
6
|
-
/**
|
|
7
|
-
* Patterns that can cause ReDoS (Regular Expression Denial of Service)
|
|
8
|
-
*/
|
|
9
|
-
export declare const REDOS_PATTERNS: RegExp[];
|
|
10
|
-
/**
|
|
11
|
-
* Count nested quantifier depth in a regex pattern
|
|
12
|
-
*/
|
|
13
|
-
export declare function countQuantifierNesting(pattern: string): number;
|
|
14
|
-
/**
|
|
15
|
-
* Check for exponential backtracking potential
|
|
16
|
-
*/
|
|
17
|
-
export declare function hasExponentialBacktracking(pattern: string): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Regex Safety Validator Strategy
|
|
20
|
-
* Validates regex patterns to prevent ReDoS attacks
|
|
21
|
-
*/
|
|
22
|
-
export declare class RegexSafetyValidator implements IRegexValidationStrategy {
|
|
23
|
-
readonly name = "regex-safety";
|
|
24
|
-
private maxComplexity;
|
|
25
|
-
constructor(maxComplexity?: number);
|
|
26
|
-
/**
|
|
27
|
-
* Get the primary risk level this validator addresses
|
|
28
|
-
*/
|
|
29
|
-
getRiskLevel(): RiskLevel;
|
|
30
|
-
/**
|
|
31
|
-
* Validate a regex pattern (IValidationStrategy interface)
|
|
32
|
-
*/
|
|
33
|
-
validate(pattern: string, options?: RegexValidationOptions): ValidationResult;
|
|
34
|
-
/**
|
|
35
|
-
* Check if a regex pattern is safe from ReDoS
|
|
36
|
-
*/
|
|
37
|
-
isRegexSafe(pattern: string, maxComplexity?: number): RegexSafetyResult;
|
|
38
|
-
/**
|
|
39
|
-
* Escape special regex characters in a string
|
|
40
|
-
*/
|
|
41
|
-
escapeRegex(str: string): string;
|
|
42
|
-
/**
|
|
43
|
-
* Create a safe regex with validation
|
|
44
|
-
*/
|
|
45
|
-
createSafeRegex(pattern: string, flags?: string, maxLength?: number): RegExp | null;
|
|
46
|
-
}
|
|
47
|
-
export declare const isRegexSafe: (pattern: string) => RegexSafetyResult;
|
|
48
|
-
export declare const escapeRegex: (str: string) => string;
|
|
49
|
-
export declare const createSafeRegex: (pattern: string, flags?: string, maxLength?: number) => RegExp | null;
|
|
1
|
+
export * from '../../../shared/security/regex-safety-validator.js';
|
|
50
2
|
//# sourceMappingURL=regex-safety-validator.d.ts.map
|
|
@@ -1,183 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* Implements the Strategy Pattern for ReDoS prevention
|
|
4
|
-
*/
|
|
5
|
-
// ============================================================================
|
|
6
|
-
// Constants
|
|
7
|
-
// ============================================================================
|
|
8
|
-
/**
|
|
9
|
-
* Patterns that can cause ReDoS (Regular Expression Denial of Service)
|
|
10
|
-
*/
|
|
11
|
-
export const REDOS_PATTERNS = [
|
|
12
|
-
/\(\.\*\)\+/, // (.*)+
|
|
13
|
-
/\(\.\+\)\+/, // (.+)+
|
|
14
|
-
/\([^)]*\?\)\+/, // (...?)+
|
|
15
|
-
/\([^)]*\*\)\+/, // (...*)+
|
|
16
|
-
/\([^)]*\+\)\+/, // (...+)+
|
|
17
|
-
/\(\[.*?\]\+\)\+/, // ([...]+)+
|
|
18
|
-
/\(\[.*?\]\*\)\+/, // ([...]*)+
|
|
19
|
-
/\(\[.*?\]\?\)\+/, // ([...]?)+
|
|
20
|
-
/\(\[.*?\]\*\)\*/, // ([...]*)*
|
|
21
|
-
/\.\*\.\*/, // .*.*
|
|
22
|
-
/\.\+\.\+/, // .+.+
|
|
23
|
-
/\(\.\|\.\)/, // (.|.)
|
|
24
|
-
];
|
|
25
|
-
/**
|
|
26
|
-
* Maximum allowed regex complexity (nested quantifiers)
|
|
27
|
-
*/
|
|
28
|
-
const MAX_REGEX_COMPLEXITY = 3;
|
|
29
|
-
// ============================================================================
|
|
30
|
-
// Helper Functions
|
|
31
|
-
// ============================================================================
|
|
32
|
-
/**
|
|
33
|
-
* Count nested quantifier depth in a regex pattern
|
|
34
|
-
*/
|
|
35
|
-
export function countQuantifierNesting(pattern) {
|
|
36
|
-
let maxDepth = 0;
|
|
37
|
-
let currentDepth = 0;
|
|
38
|
-
let inGroup = false;
|
|
39
|
-
let escaped = false;
|
|
40
|
-
for (let i = 0; i < pattern.length; i++) {
|
|
41
|
-
const char = pattern[i];
|
|
42
|
-
if (escaped) {
|
|
43
|
-
escaped = false;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (char === '\\') {
|
|
47
|
-
escaped = true;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (char === '(') {
|
|
51
|
-
inGroup = true;
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (char === ')') {
|
|
55
|
-
inGroup = false;
|
|
56
|
-
// Check if followed by quantifier
|
|
57
|
-
const next = pattern[i + 1];
|
|
58
|
-
if (next === '*' || next === '+' || next === '?' || next === '{') {
|
|
59
|
-
currentDepth++;
|
|
60
|
-
maxDepth = Math.max(maxDepth, currentDepth);
|
|
61
|
-
}
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if ((char === '*' || char === '+' || char === '?') && !inGroup) {
|
|
65
|
-
currentDepth = 1;
|
|
66
|
-
maxDepth = Math.max(maxDepth, currentDepth);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return maxDepth;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Check for exponential backtracking potential
|
|
73
|
-
*/
|
|
74
|
-
export function hasExponentialBacktracking(pattern) {
|
|
75
|
-
// Simplified check for common exponential patterns
|
|
76
|
-
const dangerous = [
|
|
77
|
-
/\(\[^\\]*\]\+\)\+/, // ([...]+)+
|
|
78
|
-
/\(\[^\\]*\]\*\)\*/, // ([...]*)*
|
|
79
|
-
/\([^)]+\|[^)]+\)\+/, // (a|b)+
|
|
80
|
-
/\(\.\*\)[*+]/, // (.*)+, (.*)*
|
|
81
|
-
/\(\.\+\)[*+]/, // (.+)+, (.+)*
|
|
82
|
-
];
|
|
83
|
-
return dangerous.some(d => d.test(pattern));
|
|
84
|
-
}
|
|
85
|
-
// ============================================================================
|
|
86
|
-
// Regex Safety Validator Implementation
|
|
87
|
-
// ============================================================================
|
|
88
|
-
/**
|
|
89
|
-
* Regex Safety Validator Strategy
|
|
90
|
-
* Validates regex patterns to prevent ReDoS attacks
|
|
91
|
-
*/
|
|
92
|
-
export class RegexSafetyValidator {
|
|
93
|
-
name = 'regex-safety';
|
|
94
|
-
maxComplexity;
|
|
95
|
-
constructor(maxComplexity = MAX_REGEX_COMPLEXITY) {
|
|
96
|
-
this.maxComplexity = maxComplexity;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Get the primary risk level this validator addresses
|
|
100
|
-
*/
|
|
101
|
-
getRiskLevel() {
|
|
102
|
-
return 'high';
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Validate a regex pattern (IValidationStrategy interface)
|
|
106
|
-
*/
|
|
107
|
-
validate(pattern, options = {}) {
|
|
108
|
-
const { maxLength = 10000, maxComplexity = this.maxComplexity } = options;
|
|
109
|
-
if (pattern.length > maxLength) {
|
|
110
|
-
return {
|
|
111
|
-
valid: false,
|
|
112
|
-
error: `Pattern exceeds maximum length of ${maxLength}`,
|
|
113
|
-
riskLevel: 'medium',
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
const result = this.isRegexSafe(pattern, maxComplexity);
|
|
117
|
-
return {
|
|
118
|
-
valid: result.safe,
|
|
119
|
-
error: result.error,
|
|
120
|
-
riskLevel: result.safe ? 'none' : 'high',
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Check if a regex pattern is safe from ReDoS
|
|
125
|
-
*/
|
|
126
|
-
isRegexSafe(pattern, maxComplexity = this.maxComplexity) {
|
|
127
|
-
const riskyPatterns = [];
|
|
128
|
-
// Check for known ReDoS patterns
|
|
129
|
-
for (const redosPattern of REDOS_PATTERNS) {
|
|
130
|
-
if (redosPattern.test(pattern)) {
|
|
131
|
-
riskyPatterns.push(redosPattern.source);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// Check nesting depth of quantifiers
|
|
135
|
-
const quantifierDepth = countQuantifierNesting(pattern);
|
|
136
|
-
if (quantifierDepth > maxComplexity) {
|
|
137
|
-
riskyPatterns.push(`Quantifier nesting depth: ${quantifierDepth} (max: ${maxComplexity})`);
|
|
138
|
-
}
|
|
139
|
-
// Check for exponential backtracking potential
|
|
140
|
-
if (hasExponentialBacktracking(pattern)) {
|
|
141
|
-
riskyPatterns.push('Exponential backtracking potential detected');
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
safe: riskyPatterns.length === 0,
|
|
145
|
-
pattern,
|
|
146
|
-
escapedPattern: this.escapeRegex(pattern),
|
|
147
|
-
riskyPatterns,
|
|
148
|
-
error: riskyPatterns.length > 0 ? 'Pattern may cause ReDoS' : undefined,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Escape special regex characters in a string
|
|
153
|
-
*/
|
|
154
|
-
escapeRegex(str) {
|
|
155
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Create a safe regex with validation
|
|
159
|
-
*/
|
|
160
|
-
createSafeRegex(pattern, flags, maxLength = 10000) {
|
|
161
|
-
const safety = this.isRegexSafe(pattern);
|
|
162
|
-
if (!safety.safe) {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
if (pattern.length > maxLength) {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
try {
|
|
169
|
-
return new RegExp(pattern, flags);
|
|
170
|
-
}
|
|
171
|
-
catch {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
// ============================================================================
|
|
177
|
-
// Standalone Functions (for backward compatibility)
|
|
178
|
-
// ============================================================================
|
|
179
|
-
const defaultValidator = new RegexSafetyValidator();
|
|
180
|
-
export const isRegexSafe = (pattern) => defaultValidator.isRegexSafe(pattern);
|
|
181
|
-
export const escapeRegex = (str) => defaultValidator.escapeRegex(str);
|
|
182
|
-
export const createSafeRegex = (pattern, flags, maxLength) => defaultValidator.createSafeRegex(pattern, flags, maxLength);
|
|
1
|
+
// Re-export from shared/security for backward compatibility
|
|
2
|
+
export * from '../../../shared/security/regex-safety-validator.js';
|
|
183
3
|
//# sourceMappingURL=regex-safety-validator.js.map
|
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Agentic QE v3 - MCP Security: Validation Orchestrator
|
|
3
|
-
* Coordinates all validation strategies using the Strategy Pattern
|
|
4
|
-
*/
|
|
5
|
-
import { IValidationOrchestrator, IValidationStrategy, ValidationResult, RiskLevel } from './interfaces';
|
|
6
|
-
/**
|
|
7
|
-
* Validation Orchestrator
|
|
8
|
-
* Coordinates multiple validation strategies and provides a unified interface
|
|
9
|
-
*/
|
|
10
|
-
export declare class ValidationOrchestrator implements IValidationOrchestrator {
|
|
11
|
-
private strategies;
|
|
12
|
-
/**
|
|
13
|
-
* Create a new orchestrator with default validators
|
|
14
|
-
*/
|
|
15
|
-
constructor(registerDefaults?: boolean);
|
|
16
|
-
/**
|
|
17
|
-
* Register the default validation strategies
|
|
18
|
-
*/
|
|
19
|
-
private registerDefaultStrategies;
|
|
20
|
-
/**
|
|
21
|
-
* Register a validation strategy
|
|
22
|
-
*/
|
|
23
|
-
registerStrategy(strategy: IValidationStrategy): void;
|
|
24
|
-
/**
|
|
25
|
-
* Get a registered strategy by name
|
|
26
|
-
*/
|
|
27
|
-
getStrategy(name: string): IValidationStrategy | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Get all registered strategy names
|
|
30
|
-
*/
|
|
31
|
-
getStrategyNames(): string[];
|
|
32
|
-
/**
|
|
33
|
-
* Validate using a specific strategy
|
|
34
|
-
*/
|
|
35
|
-
validateWith<TResult extends ValidationResult>(strategyName: string, input: unknown, options?: unknown): TResult;
|
|
36
|
-
/**
|
|
37
|
-
* Run all registered validators on an input
|
|
38
|
-
* Useful for comprehensive input validation
|
|
39
|
-
*/
|
|
40
|
-
validateAll(input: unknown): Map<string, ValidationResult>;
|
|
41
|
-
/**
|
|
42
|
-
* Check if any validator found issues
|
|
43
|
-
*/
|
|
44
|
-
hasIssues(results: Map<string, ValidationResult>): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Get the highest risk level from validation results
|
|
47
|
-
*/
|
|
48
|
-
getHighestRisk(results: Map<string, ValidationResult>): RiskLevel;
|
|
49
|
-
/**
|
|
50
|
-
* Get all issues from validation results
|
|
51
|
-
*/
|
|
52
|
-
getAllIssues(results: Map<string, ValidationResult>): Array<{
|
|
53
|
-
validator: string;
|
|
54
|
-
error: string;
|
|
55
|
-
riskLevel: RiskLevel;
|
|
56
|
-
}>;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Get the default validation orchestrator instance
|
|
60
|
-
*/
|
|
61
|
-
export declare function getOrchestrator(): ValidationOrchestrator;
|
|
62
|
-
/**
|
|
63
|
-
* Create a new validation orchestrator
|
|
64
|
-
*/
|
|
65
|
-
export declare function createOrchestrator(registerDefaults?: boolean): ValidationOrchestrator;
|
|
1
|
+
export * from '../../../shared/security/validation-orchestrator.js';
|
|
66
2
|
//# sourceMappingURL=validation-orchestrator.d.ts.map
|