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
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Regex Safety Validator
|
|
3
|
+
* Implements the Strategy Pattern for ReDoS prevention
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/regex-safety-validator.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Constants
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Patterns that can cause ReDoS (Regular Expression Denial of Service)
|
|
13
|
+
*/
|
|
14
|
+
export const REDOS_PATTERNS = [
|
|
15
|
+
/\(\.\*\)\+/, // (.*)+
|
|
16
|
+
/\(\.\+\)\+/, // (.+)+
|
|
17
|
+
/\([^)]*?\?\)\+/, // (...?)+
|
|
18
|
+
/\([^)]*?\*\)\+/, // (...*)+
|
|
19
|
+
/\([^)]*?\+\)\+/, // (...+)+
|
|
20
|
+
/\(\[[^\]]*\]\+\)\+/, // ([...]+)+
|
|
21
|
+
/\(\[[^\]]*\]\*\)\+/, // ([...]*)+
|
|
22
|
+
/\(\[[^\]]*\]\?\)\+/, // ([...]?)+
|
|
23
|
+
/\(\[[^\]]*\]\*\)\*/, // ([...]*)*
|
|
24
|
+
/\.\*\.\*/, // .*.*
|
|
25
|
+
/\.\+\.\+/, // .+.+
|
|
26
|
+
/\(\.\|\.\)/, // (.|.)
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Maximum allowed regex complexity (nested quantifiers)
|
|
30
|
+
*/
|
|
31
|
+
const MAX_REGEX_COMPLEXITY = 3;
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Helper Functions
|
|
34
|
+
// ============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* Count nested quantifier depth in a regex pattern
|
|
37
|
+
*/
|
|
38
|
+
export function countQuantifierNesting(pattern) {
|
|
39
|
+
let maxDepth = 0;
|
|
40
|
+
let currentDepth = 0;
|
|
41
|
+
let inGroup = false;
|
|
42
|
+
let escaped = false;
|
|
43
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
44
|
+
const char = pattern[i];
|
|
45
|
+
if (escaped) {
|
|
46
|
+
escaped = false;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (char === '\\') {
|
|
50
|
+
escaped = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (char === '(') {
|
|
54
|
+
inGroup = true;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (char === ')') {
|
|
58
|
+
inGroup = false;
|
|
59
|
+
// Check if followed by quantifier
|
|
60
|
+
const next = pattern[i + 1];
|
|
61
|
+
if (next === '*' || next === '+' || next === '?' || next === '{') {
|
|
62
|
+
currentDepth++;
|
|
63
|
+
maxDepth = Math.max(maxDepth, currentDepth);
|
|
64
|
+
}
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if ((char === '*' || char === '+' || char === '?') && !inGroup) {
|
|
68
|
+
currentDepth = 1;
|
|
69
|
+
maxDepth = Math.max(maxDepth, currentDepth);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return maxDepth;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check for exponential backtracking potential
|
|
76
|
+
*/
|
|
77
|
+
export function hasExponentialBacktracking(pattern) {
|
|
78
|
+
// Simplified check for common exponential patterns
|
|
79
|
+
const dangerous = [
|
|
80
|
+
/\(\[^\\]*\]\+\)\+/, // ([...]+)+
|
|
81
|
+
/\(\[^\\]*\]\*\)\*/, // ([...]*)*
|
|
82
|
+
/\([^)]+\|[^)]+\)\+/, // (a|b)+
|
|
83
|
+
/\(\.\*\)[*+]/, // (.*)+, (.*)*
|
|
84
|
+
/\(\.\+\)[*+]/, // (.+)+, (.+)*
|
|
85
|
+
];
|
|
86
|
+
return dangerous.some(d => d.test(pattern));
|
|
87
|
+
}
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// Regex Safety Validator Implementation
|
|
90
|
+
// ============================================================================
|
|
91
|
+
/**
|
|
92
|
+
* Regex Safety Validator Strategy
|
|
93
|
+
* Validates regex patterns to prevent ReDoS attacks
|
|
94
|
+
*/
|
|
95
|
+
export class RegexSafetyValidator {
|
|
96
|
+
name = 'regex-safety';
|
|
97
|
+
maxComplexity;
|
|
98
|
+
constructor(maxComplexity = MAX_REGEX_COMPLEXITY) {
|
|
99
|
+
this.maxComplexity = maxComplexity;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get the primary risk level this validator addresses
|
|
103
|
+
*/
|
|
104
|
+
getRiskLevel() {
|
|
105
|
+
return 'high';
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Validate a regex pattern (IValidationStrategy interface)
|
|
109
|
+
*/
|
|
110
|
+
validate(pattern, options = {}) {
|
|
111
|
+
const { maxLength = 10000, maxComplexity = this.maxComplexity } = options;
|
|
112
|
+
if (pattern.length > maxLength) {
|
|
113
|
+
return {
|
|
114
|
+
valid: false,
|
|
115
|
+
error: `Pattern exceeds maximum length of ${maxLength}`,
|
|
116
|
+
riskLevel: 'medium',
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const result = this.isRegexSafe(pattern, maxComplexity);
|
|
120
|
+
return {
|
|
121
|
+
valid: result.safe,
|
|
122
|
+
error: result.error,
|
|
123
|
+
riskLevel: result.safe ? 'none' : 'high',
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Check if a regex pattern is safe from ReDoS
|
|
128
|
+
*/
|
|
129
|
+
isRegexSafe(pattern, maxComplexity = this.maxComplexity) {
|
|
130
|
+
const riskyPatterns = [];
|
|
131
|
+
// Check for known ReDoS patterns
|
|
132
|
+
for (const redosPattern of REDOS_PATTERNS) {
|
|
133
|
+
if (redosPattern.test(pattern)) {
|
|
134
|
+
riskyPatterns.push(redosPattern.source);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Check nesting depth of quantifiers
|
|
138
|
+
const quantifierDepth = countQuantifierNesting(pattern);
|
|
139
|
+
if (quantifierDepth > maxComplexity) {
|
|
140
|
+
riskyPatterns.push(`Quantifier nesting depth: ${quantifierDepth} (max: ${maxComplexity})`);
|
|
141
|
+
}
|
|
142
|
+
// Check for exponential backtracking potential
|
|
143
|
+
if (hasExponentialBacktracking(pattern)) {
|
|
144
|
+
riskyPatterns.push('Exponential backtracking potential detected');
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
safe: riskyPatterns.length === 0,
|
|
148
|
+
pattern,
|
|
149
|
+
escapedPattern: this.escapeRegex(pattern),
|
|
150
|
+
riskyPatterns,
|
|
151
|
+
error: riskyPatterns.length > 0 ? 'Pattern may cause ReDoS' : undefined,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Escape special regex characters in a string
|
|
156
|
+
*/
|
|
157
|
+
escapeRegex(str) {
|
|
158
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Create a safe regex with validation
|
|
162
|
+
*/
|
|
163
|
+
createSafeRegex(pattern, flags, maxLength = 10000) {
|
|
164
|
+
const safety = this.isRegexSafe(pattern);
|
|
165
|
+
if (!safety.safe) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
if (pattern.length > maxLength) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
return new RegExp(pattern, flags);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// Standalone Functions (for backward compatibility)
|
|
181
|
+
// ============================================================================
|
|
182
|
+
const defaultValidator = new RegexSafetyValidator();
|
|
183
|
+
export const isRegexSafe = (pattern) => defaultValidator.isRegexSafe(pattern);
|
|
184
|
+
export const escapeRegex = (str) => defaultValidator.escapeRegex(str);
|
|
185
|
+
export const createSafeRegex = (pattern, flags, maxLength) => defaultValidator.createSafeRegex(pattern, flags, maxLength);
|
|
186
|
+
//# sourceMappingURL=regex-safety-validator.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Validation Orchestrator
|
|
3
|
+
* Coordinates all validation strategies using the Strategy Pattern
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/validation-orchestrator.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
import { IValidationOrchestrator, IValidationStrategy, ValidationResult, RiskLevel } from './validators-interfaces.js';
|
|
9
|
+
/**
|
|
10
|
+
* Validation Orchestrator
|
|
11
|
+
* Coordinates multiple validation strategies and provides a unified interface
|
|
12
|
+
*/
|
|
13
|
+
export declare class ValidationOrchestrator implements IValidationOrchestrator {
|
|
14
|
+
private strategies;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new orchestrator with default validators
|
|
17
|
+
*/
|
|
18
|
+
constructor(registerDefaults?: boolean);
|
|
19
|
+
/**
|
|
20
|
+
* Register the default validation strategies
|
|
21
|
+
*/
|
|
22
|
+
private registerDefaultStrategies;
|
|
23
|
+
/**
|
|
24
|
+
* Register a validation strategy
|
|
25
|
+
*/
|
|
26
|
+
registerStrategy(strategy: IValidationStrategy): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get a registered strategy by name
|
|
29
|
+
*/
|
|
30
|
+
getStrategy(name: string): IValidationStrategy | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Get all registered strategy names
|
|
33
|
+
*/
|
|
34
|
+
getStrategyNames(): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Validate using a specific strategy
|
|
37
|
+
*/
|
|
38
|
+
validateWith<TResult extends ValidationResult>(strategyName: string, input: unknown, options?: unknown): TResult;
|
|
39
|
+
/**
|
|
40
|
+
* Run all registered validators on an input
|
|
41
|
+
* Useful for comprehensive input validation
|
|
42
|
+
*/
|
|
43
|
+
validateAll(input: unknown): Map<string, ValidationResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Check if any validator found issues
|
|
46
|
+
*/
|
|
47
|
+
hasIssues(results: Map<string, ValidationResult>): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Get the highest risk level from validation results
|
|
50
|
+
*/
|
|
51
|
+
getHighestRisk(results: Map<string, ValidationResult>): RiskLevel;
|
|
52
|
+
/**
|
|
53
|
+
* Get all issues from validation results
|
|
54
|
+
*/
|
|
55
|
+
getAllIssues(results: Map<string, ValidationResult>): Array<{
|
|
56
|
+
validator: string;
|
|
57
|
+
error: string;
|
|
58
|
+
riskLevel: RiskLevel;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the default validation orchestrator instance
|
|
63
|
+
*/
|
|
64
|
+
export declare function getOrchestrator(): ValidationOrchestrator;
|
|
65
|
+
/**
|
|
66
|
+
* Create a new validation orchestrator
|
|
67
|
+
*/
|
|
68
|
+
export declare function createOrchestrator(registerDefaults?: boolean): ValidationOrchestrator;
|
|
69
|
+
//# sourceMappingURL=validation-orchestrator.d.ts.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Validation Orchestrator
|
|
3
|
+
* Coordinates all validation strategies using the Strategy Pattern
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/validation-orchestrator.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
import { PathTraversalValidator } from './path-traversal-validator.js';
|
|
9
|
+
import { RegexSafetyValidator } from './regex-safety-validator.js';
|
|
10
|
+
import { CommandValidator } from './command-validator.js';
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Validation Orchestrator Implementation
|
|
13
|
+
// ============================================================================
|
|
14
|
+
/**
|
|
15
|
+
* Validation Orchestrator
|
|
16
|
+
* Coordinates multiple validation strategies and provides a unified interface
|
|
17
|
+
*/
|
|
18
|
+
export class ValidationOrchestrator {
|
|
19
|
+
strategies = new Map();
|
|
20
|
+
/**
|
|
21
|
+
* Create a new orchestrator with default validators
|
|
22
|
+
*/
|
|
23
|
+
constructor(registerDefaults = true) {
|
|
24
|
+
if (registerDefaults) {
|
|
25
|
+
this.registerDefaultStrategies();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Register the default validation strategies
|
|
30
|
+
*/
|
|
31
|
+
registerDefaultStrategies() {
|
|
32
|
+
this.registerStrategy(new PathTraversalValidator());
|
|
33
|
+
this.registerStrategy(new RegexSafetyValidator());
|
|
34
|
+
this.registerStrategy(new CommandValidator());
|
|
35
|
+
// Note: InputSanitizer and CryptoValidator don't implement IValidationStrategy
|
|
36
|
+
// They have their own interfaces (IInputSanitizationStrategy, ICryptoValidationStrategy)
|
|
37
|
+
// They can be accessed directly through the facade
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Register a validation strategy
|
|
41
|
+
*/
|
|
42
|
+
registerStrategy(strategy) {
|
|
43
|
+
this.strategies.set(strategy.name, strategy);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a registered strategy by name
|
|
47
|
+
*/
|
|
48
|
+
getStrategy(name) {
|
|
49
|
+
return this.strategies.get(name);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get all registered strategy names
|
|
53
|
+
*/
|
|
54
|
+
getStrategyNames() {
|
|
55
|
+
return Array.from(this.strategies.keys());
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Validate using a specific strategy
|
|
59
|
+
*/
|
|
60
|
+
validateWith(strategyName, input, options) {
|
|
61
|
+
const strategy = this.strategies.get(strategyName);
|
|
62
|
+
if (!strategy) {
|
|
63
|
+
throw new Error(`Strategy '${strategyName}' not found`);
|
|
64
|
+
}
|
|
65
|
+
return strategy.validate(input, options);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Run all registered validators on an input
|
|
69
|
+
* Useful for comprehensive input validation
|
|
70
|
+
*/
|
|
71
|
+
validateAll(input) {
|
|
72
|
+
const results = new Map();
|
|
73
|
+
for (const [name, strategy] of this.strategies) {
|
|
74
|
+
try {
|
|
75
|
+
results.set(name, strategy.validate(input));
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
results.set(name, {
|
|
79
|
+
valid: false,
|
|
80
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
81
|
+
riskLevel: 'high',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return results;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if any validator found issues
|
|
89
|
+
*/
|
|
90
|
+
hasIssues(results) {
|
|
91
|
+
for (const result of results.values()) {
|
|
92
|
+
if (!result.valid) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get the highest risk level from validation results
|
|
100
|
+
*/
|
|
101
|
+
getHighestRisk(results) {
|
|
102
|
+
const riskOrder = ['none', 'low', 'medium', 'high', 'critical'];
|
|
103
|
+
let highest = 'none';
|
|
104
|
+
for (const result of results.values()) {
|
|
105
|
+
const currentIndex = riskOrder.indexOf(result.riskLevel);
|
|
106
|
+
const highestIndex = riskOrder.indexOf(highest);
|
|
107
|
+
if (currentIndex > highestIndex) {
|
|
108
|
+
highest = result.riskLevel;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return highest;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get all issues from validation results
|
|
115
|
+
*/
|
|
116
|
+
getAllIssues(results) {
|
|
117
|
+
const issues = [];
|
|
118
|
+
for (const [name, result] of results) {
|
|
119
|
+
if (!result.valid && result.error) {
|
|
120
|
+
issues.push({
|
|
121
|
+
validator: name,
|
|
122
|
+
error: result.error,
|
|
123
|
+
riskLevel: result.riskLevel,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return issues;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// ============================================================================
|
|
131
|
+
// Singleton Instance
|
|
132
|
+
// ============================================================================
|
|
133
|
+
let defaultOrchestrator = null;
|
|
134
|
+
/**
|
|
135
|
+
* Get the default validation orchestrator instance
|
|
136
|
+
*/
|
|
137
|
+
export function getOrchestrator() {
|
|
138
|
+
if (!defaultOrchestrator) {
|
|
139
|
+
defaultOrchestrator = new ValidationOrchestrator();
|
|
140
|
+
}
|
|
141
|
+
return defaultOrchestrator;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Create a new validation orchestrator
|
|
145
|
+
*/
|
|
146
|
+
export function createOrchestrator(registerDefaults = true) {
|
|
147
|
+
return new ValidationOrchestrator(registerDefaults);
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=validation-orchestrator.js.map
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Validation Strategy Interfaces
|
|
3
|
+
* Defines the Strategy Pattern interfaces for security validators
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/interfaces.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Risk level classification for security validation
|
|
10
|
+
*/
|
|
11
|
+
export type RiskLevel = 'none' | 'low' | 'medium' | 'high' | 'critical';
|
|
12
|
+
/**
|
|
13
|
+
* Base validation result returned by all validators
|
|
14
|
+
*/
|
|
15
|
+
export interface ValidationResult {
|
|
16
|
+
valid: boolean;
|
|
17
|
+
error?: string;
|
|
18
|
+
riskLevel: RiskLevel;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Path validation result with normalized path
|
|
22
|
+
*/
|
|
23
|
+
export interface PathValidationResult extends ValidationResult {
|
|
24
|
+
normalizedPath?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Regex safety result with pattern analysis
|
|
28
|
+
*/
|
|
29
|
+
export interface RegexSafetyResult {
|
|
30
|
+
safe: boolean;
|
|
31
|
+
pattern?: string;
|
|
32
|
+
escapedPattern?: string;
|
|
33
|
+
error?: string;
|
|
34
|
+
riskyPatterns: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Command validation result with sanitized command
|
|
38
|
+
*/
|
|
39
|
+
export interface CommandValidationResult extends ValidationResult {
|
|
40
|
+
sanitizedCommand?: string;
|
|
41
|
+
blockedPatterns: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Input sanitization options
|
|
45
|
+
*/
|
|
46
|
+
export interface SanitizationOptions {
|
|
47
|
+
maxLength?: number;
|
|
48
|
+
allowedChars?: RegExp;
|
|
49
|
+
stripHtml?: boolean;
|
|
50
|
+
stripSql?: boolean;
|
|
51
|
+
escapeShell?: boolean;
|
|
52
|
+
trim?: boolean;
|
|
53
|
+
/** Strip dangerous control characters (null bytes, escape sequences, etc.) - default: true */
|
|
54
|
+
stripControlChars?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Path validation options
|
|
58
|
+
*/
|
|
59
|
+
export interface PathValidationOptions {
|
|
60
|
+
basePath?: string;
|
|
61
|
+
allowAbsolute?: boolean;
|
|
62
|
+
allowedExtensions?: string[];
|
|
63
|
+
deniedExtensions?: string[];
|
|
64
|
+
maxDepth?: number;
|
|
65
|
+
maxLength?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Regex validation options
|
|
69
|
+
*/
|
|
70
|
+
export interface RegexValidationOptions {
|
|
71
|
+
maxLength?: number;
|
|
72
|
+
maxComplexity?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Command validation options
|
|
76
|
+
*/
|
|
77
|
+
export interface CommandValidationOptions {
|
|
78
|
+
allowedCommands?: string[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Base interface for all validation strategies
|
|
82
|
+
* Implements the Strategy Pattern for modular security validation
|
|
83
|
+
*/
|
|
84
|
+
export interface IValidationStrategy<TInput = unknown, TOptions = unknown, TResult extends ValidationResult = ValidationResult> {
|
|
85
|
+
/**
|
|
86
|
+
* Unique name identifier for this validator
|
|
87
|
+
*/
|
|
88
|
+
readonly name: string;
|
|
89
|
+
/**
|
|
90
|
+
* Validate the input according to this strategy
|
|
91
|
+
* @param input - The input to validate
|
|
92
|
+
* @param options - Optional validation options
|
|
93
|
+
* @returns The validation result
|
|
94
|
+
*/
|
|
95
|
+
validate(input: TInput, options?: TOptions): TResult;
|
|
96
|
+
/**
|
|
97
|
+
* Get the risk level this validator typically addresses
|
|
98
|
+
* @returns The primary risk level category
|
|
99
|
+
*/
|
|
100
|
+
getRiskLevel(): RiskLevel;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Path traversal validation strategy interface
|
|
104
|
+
*/
|
|
105
|
+
export interface IPathValidationStrategy extends IValidationStrategy<string, PathValidationOptions, PathValidationResult> {
|
|
106
|
+
normalizePath(path: string): string;
|
|
107
|
+
joinPaths(...paths: string[]): string;
|
|
108
|
+
joinPathsAbsolute(...paths: string[]): string;
|
|
109
|
+
getExtension(path: string): string | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Regex safety validation strategy interface
|
|
113
|
+
*/
|
|
114
|
+
export interface IRegexValidationStrategy extends IValidationStrategy<string, RegexValidationOptions, ValidationResult> {
|
|
115
|
+
isRegexSafe(pattern: string): RegexSafetyResult;
|
|
116
|
+
escapeRegex(str: string): string;
|
|
117
|
+
createSafeRegex(pattern: string, flags?: string, maxLength?: number): RegExp | null;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Command validation strategy interface
|
|
121
|
+
*/
|
|
122
|
+
export interface ICommandValidationStrategy extends IValidationStrategy<string, CommandValidationOptions, CommandValidationResult> {
|
|
123
|
+
escapeShellArg(arg: string): string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Input sanitization strategy interface
|
|
127
|
+
*/
|
|
128
|
+
export interface IInputSanitizationStrategy {
|
|
129
|
+
readonly name: string;
|
|
130
|
+
sanitize(input: string, options?: SanitizationOptions): string;
|
|
131
|
+
escapeHtml(str: string): string;
|
|
132
|
+
stripHtmlTags(str: string): string;
|
|
133
|
+
getRiskLevel(): RiskLevel;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Crypto validation strategy interface
|
|
137
|
+
*/
|
|
138
|
+
export interface ICryptoValidationStrategy {
|
|
139
|
+
readonly name: string;
|
|
140
|
+
timingSafeCompare(a: string, b: string): boolean;
|
|
141
|
+
timingSafeHashCompare(value: string, expectedHash: string): boolean;
|
|
142
|
+
generateSecureToken(length?: number): string;
|
|
143
|
+
secureHash(value: string, salt?: string): string;
|
|
144
|
+
getRiskLevel(): RiskLevel;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Validation orchestrator interface for coordinating multiple validators
|
|
148
|
+
*/
|
|
149
|
+
export interface IValidationOrchestrator {
|
|
150
|
+
/**
|
|
151
|
+
* Register a validation strategy
|
|
152
|
+
*/
|
|
153
|
+
registerStrategy(strategy: IValidationStrategy): void;
|
|
154
|
+
/**
|
|
155
|
+
* Get a registered strategy by name
|
|
156
|
+
*/
|
|
157
|
+
getStrategy(name: string): IValidationStrategy | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* Validate using a specific strategy
|
|
160
|
+
*/
|
|
161
|
+
validateWith<TResult extends ValidationResult>(strategyName: string, input: unknown, options?: unknown): TResult;
|
|
162
|
+
/**
|
|
163
|
+
* Run all registered validators on an input
|
|
164
|
+
*/
|
|
165
|
+
validateAll(input: unknown): Map<string, ValidationResult>;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=validators-interfaces.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Validation Strategy Interfaces
|
|
3
|
+
* Defines the Strategy Pattern interfaces for security validators
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/interfaces.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=validators-interfaces.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-qe",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.6",
|
|
4
4
|
"description": "Agentic Quality Engineering V3 - Domain-Driven Design Architecture with 13 Bounded Contexts, O(log n) coverage analysis, ReasoningBank learning, 60 specialized QE agents, mathematical Coherence verification, deep Claude Flow integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|