agentic-qe 3.8.4 → 3.8.5
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/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/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,146 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* Coordinates all validation strategies using the Strategy Pattern
|
|
4
|
-
*/
|
|
5
|
-
import { PathTraversalValidator } from './path-traversal-validator';
|
|
6
|
-
import { RegexSafetyValidator } from './regex-safety-validator';
|
|
7
|
-
import { CommandValidator } from './command-validator';
|
|
8
|
-
// ============================================================================
|
|
9
|
-
// Validation Orchestrator Implementation
|
|
10
|
-
// ============================================================================
|
|
11
|
-
/**
|
|
12
|
-
* Validation Orchestrator
|
|
13
|
-
* Coordinates multiple validation strategies and provides a unified interface
|
|
14
|
-
*/
|
|
15
|
-
export class ValidationOrchestrator {
|
|
16
|
-
strategies = new Map();
|
|
17
|
-
/**
|
|
18
|
-
* Create a new orchestrator with default validators
|
|
19
|
-
*/
|
|
20
|
-
constructor(registerDefaults = true) {
|
|
21
|
-
if (registerDefaults) {
|
|
22
|
-
this.registerDefaultStrategies();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Register the default validation strategies
|
|
27
|
-
*/
|
|
28
|
-
registerDefaultStrategies() {
|
|
29
|
-
this.registerStrategy(new PathTraversalValidator());
|
|
30
|
-
this.registerStrategy(new RegexSafetyValidator());
|
|
31
|
-
this.registerStrategy(new CommandValidator());
|
|
32
|
-
// Note: InputSanitizer and CryptoValidator don't implement IValidationStrategy
|
|
33
|
-
// They have their own interfaces (IInputSanitizationStrategy, ICryptoValidationStrategy)
|
|
34
|
-
// They can be accessed directly through the facade
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Register a validation strategy
|
|
38
|
-
*/
|
|
39
|
-
registerStrategy(strategy) {
|
|
40
|
-
this.strategies.set(strategy.name, strategy);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get a registered strategy by name
|
|
44
|
-
*/
|
|
45
|
-
getStrategy(name) {
|
|
46
|
-
return this.strategies.get(name);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Get all registered strategy names
|
|
50
|
-
*/
|
|
51
|
-
getStrategyNames() {
|
|
52
|
-
return Array.from(this.strategies.keys());
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Validate using a specific strategy
|
|
56
|
-
*/
|
|
57
|
-
validateWith(strategyName, input, options) {
|
|
58
|
-
const strategy = this.strategies.get(strategyName);
|
|
59
|
-
if (!strategy) {
|
|
60
|
-
throw new Error(`Strategy '${strategyName}' not found`);
|
|
61
|
-
}
|
|
62
|
-
return strategy.validate(input, options);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Run all registered validators on an input
|
|
66
|
-
* Useful for comprehensive input validation
|
|
67
|
-
*/
|
|
68
|
-
validateAll(input) {
|
|
69
|
-
const results = new Map();
|
|
70
|
-
for (const [name, strategy] of this.strategies) {
|
|
71
|
-
try {
|
|
72
|
-
results.set(name, strategy.validate(input));
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
results.set(name, {
|
|
76
|
-
valid: false,
|
|
77
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
78
|
-
riskLevel: 'high',
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return results;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Check if any validator found issues
|
|
86
|
-
*/
|
|
87
|
-
hasIssues(results) {
|
|
88
|
-
for (const result of results.values()) {
|
|
89
|
-
if (!result.valid) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Get the highest risk level from validation results
|
|
97
|
-
*/
|
|
98
|
-
getHighestRisk(results) {
|
|
99
|
-
const riskOrder = ['none', 'low', 'medium', 'high', 'critical'];
|
|
100
|
-
let highest = 'none';
|
|
101
|
-
for (const result of results.values()) {
|
|
102
|
-
const currentIndex = riskOrder.indexOf(result.riskLevel);
|
|
103
|
-
const highestIndex = riskOrder.indexOf(highest);
|
|
104
|
-
if (currentIndex > highestIndex) {
|
|
105
|
-
highest = result.riskLevel;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return highest;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Get all issues from validation results
|
|
112
|
-
*/
|
|
113
|
-
getAllIssues(results) {
|
|
114
|
-
const issues = [];
|
|
115
|
-
for (const [name, result] of results) {
|
|
116
|
-
if (!result.valid && result.error) {
|
|
117
|
-
issues.push({
|
|
118
|
-
validator: name,
|
|
119
|
-
error: result.error,
|
|
120
|
-
riskLevel: result.riskLevel,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return issues;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// ============================================================================
|
|
128
|
-
// Singleton Instance
|
|
129
|
-
// ============================================================================
|
|
130
|
-
let defaultOrchestrator = null;
|
|
131
|
-
/**
|
|
132
|
-
* Get the default validation orchestrator instance
|
|
133
|
-
*/
|
|
134
|
-
export function getOrchestrator() {
|
|
135
|
-
if (!defaultOrchestrator) {
|
|
136
|
-
defaultOrchestrator = new ValidationOrchestrator();
|
|
137
|
-
}
|
|
138
|
-
return defaultOrchestrator;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Create a new validation orchestrator
|
|
142
|
-
*/
|
|
143
|
-
export function createOrchestrator(registerDefaults = true) {
|
|
144
|
-
return new ValidationOrchestrator(registerDefaults);
|
|
145
|
-
}
|
|
1
|
+
// Re-export from shared/security for backward compatibility
|
|
2
|
+
export * from '../../../shared/security/validation-orchestrator.js';
|
|
146
3
|
//# sourceMappingURL=validation-orchestrator.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as fs from 'node:fs/promises';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
import { ok, err } from '../types';
|
|
8
|
-
import { validatePath } from '
|
|
8
|
+
import { validatePath } from '../security/path-traversal-validator.js';
|
|
9
9
|
import { safeJsonParse } from '../safe-json.js';
|
|
10
10
|
export class FileReadError extends Error {
|
|
11
11
|
filePath;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Command Validator
|
|
3
|
+
* Implements the Strategy Pattern for command injection prevention
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/command-validator.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
import { ICommandValidationStrategy, CommandValidationOptions, CommandValidationResult, RiskLevel } from './validators-interfaces.js';
|
|
9
|
+
/**
|
|
10
|
+
* Allowed commands whitelist (default safe commands)
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_ALLOWED_COMMANDS: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Blocked command patterns (injection vectors)
|
|
15
|
+
*/
|
|
16
|
+
export declare const BLOCKED_COMMAND_PATTERNS: RegExp[];
|
|
17
|
+
/**
|
|
18
|
+
* Command Validator Strategy
|
|
19
|
+
* Validates and sanitizes shell commands to prevent injection attacks
|
|
20
|
+
*/
|
|
21
|
+
export declare class CommandValidator implements ICommandValidationStrategy {
|
|
22
|
+
readonly name = "command-injection";
|
|
23
|
+
private defaultAllowedCommands;
|
|
24
|
+
constructor(defaultAllowedCommands?: string[]);
|
|
25
|
+
/**
|
|
26
|
+
* Get the primary risk level this validator addresses
|
|
27
|
+
*/
|
|
28
|
+
getRiskLevel(): RiskLevel;
|
|
29
|
+
/**
|
|
30
|
+
* Validate a command (IValidationStrategy interface)
|
|
31
|
+
*/
|
|
32
|
+
validate(command: string, options?: CommandValidationOptions): CommandValidationResult;
|
|
33
|
+
/**
|
|
34
|
+
* Validate and sanitize a command
|
|
35
|
+
*/
|
|
36
|
+
validateCommand(command: string, allowedCommands?: string[]): CommandValidationResult;
|
|
37
|
+
/**
|
|
38
|
+
* Escape a string for safe shell usage
|
|
39
|
+
*/
|
|
40
|
+
escapeShellArg(arg: string): string;
|
|
41
|
+
}
|
|
42
|
+
export declare const validateCommand: (command: string, allowedCommands?: string[]) => CommandValidationResult;
|
|
43
|
+
export declare const escapeShellArg: (arg: string) => string;
|
|
44
|
+
//# sourceMappingURL=command-validator.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Command Validator
|
|
3
|
+
* Implements the Strategy Pattern for command injection prevention
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/command-validator.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Constants
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Allowed commands whitelist (default safe commands)
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_ALLOWED_COMMANDS = [
|
|
15
|
+
'ls', 'cat', 'echo', 'grep', 'find', 'head', 'tail', 'wc',
|
|
16
|
+
'npm', 'node', 'yarn', 'pnpm',
|
|
17
|
+
'git', 'jest', 'vitest', 'playwright',
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Blocked command patterns (injection vectors)
|
|
21
|
+
*/
|
|
22
|
+
export const BLOCKED_COMMAND_PATTERNS = [
|
|
23
|
+
/;/, // Command chaining with semicolon
|
|
24
|
+
/&&/, // Command chaining with AND
|
|
25
|
+
/\|\|/, // Command chaining with OR
|
|
26
|
+
/\|/, // Piping
|
|
27
|
+
/`.*`/, // Backtick command substitution
|
|
28
|
+
/\$\(.*\)/, // $() command substitution
|
|
29
|
+
/>\s*\/dev\/sd/i, // Writing to block devices
|
|
30
|
+
/>\s*\/etc\//i, // Writing to /etc
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Shell metacharacters (excludes parentheses which are common in normal text)
|
|
34
|
+
*/
|
|
35
|
+
const SHELL_METACHARACTERS = /[|;&$`<>{}[\]!#*?~]/g;
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Command Validator Implementation
|
|
38
|
+
// ============================================================================
|
|
39
|
+
/**
|
|
40
|
+
* Command Validator Strategy
|
|
41
|
+
* Validates and sanitizes shell commands to prevent injection attacks
|
|
42
|
+
*/
|
|
43
|
+
export class CommandValidator {
|
|
44
|
+
name = 'command-injection';
|
|
45
|
+
defaultAllowedCommands;
|
|
46
|
+
constructor(defaultAllowedCommands = DEFAULT_ALLOWED_COMMANDS) {
|
|
47
|
+
this.defaultAllowedCommands = defaultAllowedCommands;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the primary risk level this validator addresses
|
|
51
|
+
*/
|
|
52
|
+
getRiskLevel() {
|
|
53
|
+
return 'critical';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Validate a command (IValidationStrategy interface)
|
|
57
|
+
*/
|
|
58
|
+
validate(command, options = {}) {
|
|
59
|
+
const allowedCommands = options.allowedCommands ?? this.defaultAllowedCommands;
|
|
60
|
+
return this.validateCommand(command, allowedCommands);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Validate and sanitize a command
|
|
64
|
+
*/
|
|
65
|
+
validateCommand(command, allowedCommands = this.defaultAllowedCommands) {
|
|
66
|
+
const blockedPatterns = [];
|
|
67
|
+
// Check for blocked patterns
|
|
68
|
+
for (const pattern of BLOCKED_COMMAND_PATTERNS) {
|
|
69
|
+
if (pattern.test(command)) {
|
|
70
|
+
blockedPatterns.push(pattern.source);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (blockedPatterns.length > 0) {
|
|
74
|
+
return {
|
|
75
|
+
valid: false,
|
|
76
|
+
error: 'Command contains blocked patterns',
|
|
77
|
+
blockedPatterns,
|
|
78
|
+
riskLevel: 'critical',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// Extract base command
|
|
82
|
+
const parts = command.trim().split(/\s+/);
|
|
83
|
+
const baseCommand = parts[0].split('/').pop() || '';
|
|
84
|
+
// Check against whitelist
|
|
85
|
+
if (!allowedCommands.includes(baseCommand)) {
|
|
86
|
+
return {
|
|
87
|
+
valid: false,
|
|
88
|
+
error: `Command '${baseCommand}' is not in the allowed list`,
|
|
89
|
+
blockedPatterns: [],
|
|
90
|
+
riskLevel: 'high',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// Sanitize arguments
|
|
94
|
+
const sanitizedParts = parts.map((part, i) => {
|
|
95
|
+
if (i === 0)
|
|
96
|
+
return part;
|
|
97
|
+
// Remove shell metacharacters from arguments
|
|
98
|
+
return part.replace(SHELL_METACHARACTERS, '');
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
valid: true,
|
|
102
|
+
sanitizedCommand: sanitizedParts.join(' '),
|
|
103
|
+
blockedPatterns: [],
|
|
104
|
+
riskLevel: 'none',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Escape a string for safe shell usage
|
|
109
|
+
*/
|
|
110
|
+
escapeShellArg(arg) {
|
|
111
|
+
// Wrap in single quotes and escape any internal single quotes
|
|
112
|
+
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// Standalone Functions (for backward compatibility)
|
|
117
|
+
// ============================================================================
|
|
118
|
+
const defaultValidator = new CommandValidator();
|
|
119
|
+
export const validateCommand = (command, allowedCommands) => {
|
|
120
|
+
if (allowedCommands) {
|
|
121
|
+
return defaultValidator.validateCommand(command, allowedCommands);
|
|
122
|
+
}
|
|
123
|
+
return defaultValidator.validate(command);
|
|
124
|
+
};
|
|
125
|
+
export const escapeShellArg = (arg) => defaultValidator.escapeShellArg(arg);
|
|
126
|
+
//# sourceMappingURL=command-validator.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Crypto Validator
|
|
3
|
+
* Implements the Strategy Pattern for cryptographic security operations
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/crypto-validator.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
import { ICryptoValidationStrategy, RiskLevel } from './validators-interfaces.js';
|
|
9
|
+
/**
|
|
10
|
+
* Crypto Validator Strategy
|
|
11
|
+
* Provides timing-safe comparisons and secure cryptographic operations
|
|
12
|
+
*/
|
|
13
|
+
export declare class CryptoValidator implements ICryptoValidationStrategy {
|
|
14
|
+
readonly name = "crypto-security";
|
|
15
|
+
/**
|
|
16
|
+
* Get the primary risk level this validator addresses
|
|
17
|
+
*/
|
|
18
|
+
getRiskLevel(): RiskLevel;
|
|
19
|
+
/**
|
|
20
|
+
* Perform a timing-safe string comparison
|
|
21
|
+
* Prevents timing attacks by ensuring constant-time comparison
|
|
22
|
+
*/
|
|
23
|
+
timingSafeCompare(a: string, b: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Timing-safe comparison for hashed values
|
|
26
|
+
* Hashes the input value and compares against expected hash
|
|
27
|
+
*/
|
|
28
|
+
timingSafeHashCompare(value: string, expectedHash: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a secure random token
|
|
31
|
+
* Uses cryptographically secure random bytes
|
|
32
|
+
*/
|
|
33
|
+
generateSecureToken(length?: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Hash a value securely using SHA-256
|
|
36
|
+
*/
|
|
37
|
+
secureHash(value: string, salt?: string): string;
|
|
38
|
+
}
|
|
39
|
+
export declare const timingSafeCompare: (a: string, b: string) => boolean;
|
|
40
|
+
export declare const timingSafeHashCompare: (value: string, expectedHash: string) => boolean;
|
|
41
|
+
export declare const generateSecureToken: (length?: number) => string;
|
|
42
|
+
export declare const secureHash: (value: string, salt?: string) => string;
|
|
43
|
+
//# sourceMappingURL=crypto-validator.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Crypto Validator
|
|
3
|
+
* Implements the Strategy Pattern for cryptographic security operations
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/crypto-validator.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
import { createHash, timingSafeEqual, randomBytes } from 'crypto';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Crypto Validator Implementation
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Crypto Validator Strategy
|
|
14
|
+
* Provides timing-safe comparisons and secure cryptographic operations
|
|
15
|
+
*/
|
|
16
|
+
export class CryptoValidator {
|
|
17
|
+
name = 'crypto-security';
|
|
18
|
+
/**
|
|
19
|
+
* Get the primary risk level this validator addresses
|
|
20
|
+
*/
|
|
21
|
+
getRiskLevel() {
|
|
22
|
+
return 'critical';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Perform a timing-safe string comparison
|
|
26
|
+
* Prevents timing attacks by ensuring constant-time comparison
|
|
27
|
+
*/
|
|
28
|
+
timingSafeCompare(a, b) {
|
|
29
|
+
// Pad shorter string to prevent length-based timing attacks
|
|
30
|
+
const maxLen = Math.max(a.length, b.length);
|
|
31
|
+
const paddedA = a.padEnd(maxLen, '\0');
|
|
32
|
+
const paddedB = b.padEnd(maxLen, '\0');
|
|
33
|
+
try {
|
|
34
|
+
return timingSafeEqual(Buffer.from(paddedA), Buffer.from(paddedB));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Timing-safe comparison for hashed values
|
|
42
|
+
* Hashes the input value and compares against expected hash
|
|
43
|
+
*/
|
|
44
|
+
timingSafeHashCompare(value, expectedHash) {
|
|
45
|
+
const hash = createHash('sha256').update(value).digest('hex');
|
|
46
|
+
return this.timingSafeCompare(hash, expectedHash);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Generate a secure random token
|
|
50
|
+
* Uses cryptographically secure random bytes
|
|
51
|
+
*/
|
|
52
|
+
generateSecureToken(length = 32) {
|
|
53
|
+
return randomBytes(length)
|
|
54
|
+
.toString('base64')
|
|
55
|
+
.replace(/\+/g, '-')
|
|
56
|
+
.replace(/\//g, '_')
|
|
57
|
+
.replace(/=/g, '');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Hash a value securely using SHA-256
|
|
61
|
+
*/
|
|
62
|
+
secureHash(value, salt) {
|
|
63
|
+
const data = salt ? `${salt}:${value}` : value;
|
|
64
|
+
return createHash('sha256').update(data).digest('hex');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Standalone Functions (for backward compatibility)
|
|
69
|
+
// ============================================================================
|
|
70
|
+
const defaultValidator = new CryptoValidator();
|
|
71
|
+
export const timingSafeCompare = (a, b) => defaultValidator.timingSafeCompare(a, b);
|
|
72
|
+
export const timingSafeHashCompare = (value, expectedHash) => defaultValidator.timingSafeHashCompare(value, expectedHash);
|
|
73
|
+
export const generateSecureToken = (length) => defaultValidator.generateSecureToken(length);
|
|
74
|
+
export const secureHash = (value, salt) => defaultValidator.secureHash(value, salt);
|
|
75
|
+
//# sourceMappingURL=crypto-validator.js.map
|
|
@@ -5,4 +5,11 @@ export { OSVClient } from './osv-client';
|
|
|
5
5
|
export type { OSVClientConfig, OSVQueryRequest, OSVEcosystem, OSVVulnerability, OSVSeverity, OSVAffected, OSVRange, OSVReference, OSVQueryResponse, OSVBatchQueryRequest, OSVBatchQueryResponse, ParsedVulnerability, } from './osv-client';
|
|
6
6
|
export { CompliancePatternAnalyzer, getCompliancePatternAnalyzer } from './compliance-patterns';
|
|
7
7
|
export type { PatternMatch, CompliancePatternResult, EncryptionAnalysis, AccessControlAnalysis, LoggingAnalysis, DataProtectionAnalysis, SecurityControlsAnalysis, } from './compliance-patterns';
|
|
8
|
+
export type { RiskLevel, ValidationResult, PathValidationResult, RegexSafetyResult, CommandValidationResult, SanitizationOptions, PathValidationOptions, RegexValidationOptions, CommandValidationOptions, IValidationStrategy, IPathValidationStrategy, IRegexValidationStrategy, ICommandValidationStrategy, IInputSanitizationStrategy, ICryptoValidationStrategy, IValidationOrchestrator, } from './validators-interfaces';
|
|
9
|
+
export { PathTraversalValidator, PATH_TRAVERSAL_PATTERNS, DANGEROUS_PATH_COMPONENTS, validatePath, normalizePath, joinPaths, joinPathsAbsolute, getExtension, } from './path-traversal-validator';
|
|
10
|
+
export { RegexSafetyValidator, REDOS_PATTERNS, countQuantifierNesting, hasExponentialBacktracking, isRegexSafe, escapeRegex, createSafeRegex, } from './regex-safety-validator';
|
|
11
|
+
export { CommandValidator, DEFAULT_ALLOWED_COMMANDS, BLOCKED_COMMAND_PATTERNS, validateCommand, escapeShellArg, } from './command-validator';
|
|
12
|
+
export { InputSanitizer, HTML_ESCAPE_MAP, SQL_INJECTION_PATTERNS, SHELL_METACHARACTERS, DANGEROUS_CONTROL_CHARS, sanitizeInput, escapeHtml, stripHtmlTags, } from './input-sanitizer';
|
|
13
|
+
export { CryptoValidator, timingSafeCompare, timingSafeHashCompare, generateSecureToken, secureHash, } from './crypto-validator';
|
|
14
|
+
export { ValidationOrchestrator, getOrchestrator, createOrchestrator, } from './validation-orchestrator';
|
|
8
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,4 +3,19 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { OSVClient } from './osv-client';
|
|
5
5
|
export { CompliancePatternAnalyzer, getCompliancePatternAnalyzer } from './compliance-patterns';
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Validators (moved from mcp/security/validators/)
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Path Traversal
|
|
10
|
+
export { PathTraversalValidator, PATH_TRAVERSAL_PATTERNS, DANGEROUS_PATH_COMPONENTS, validatePath, normalizePath, joinPaths, joinPathsAbsolute, getExtension, } from './path-traversal-validator';
|
|
11
|
+
// Regex Safety
|
|
12
|
+
export { RegexSafetyValidator, REDOS_PATTERNS, countQuantifierNesting, hasExponentialBacktracking, isRegexSafe, escapeRegex, createSafeRegex, } from './regex-safety-validator';
|
|
13
|
+
// Command Validator
|
|
14
|
+
export { CommandValidator, DEFAULT_ALLOWED_COMMANDS, BLOCKED_COMMAND_PATTERNS, validateCommand, escapeShellArg, } from './command-validator';
|
|
15
|
+
// Input Sanitizer
|
|
16
|
+
export { InputSanitizer, HTML_ESCAPE_MAP, SQL_INJECTION_PATTERNS, SHELL_METACHARACTERS, DANGEROUS_CONTROL_CHARS, sanitizeInput, escapeHtml, stripHtmlTags, } from './input-sanitizer';
|
|
17
|
+
// Crypto Validator
|
|
18
|
+
export { CryptoValidator, timingSafeCompare, timingSafeHashCompare, generateSecureToken, secureHash, } from './crypto-validator';
|
|
19
|
+
// Orchestrator
|
|
20
|
+
export { ValidationOrchestrator, getOrchestrator, createOrchestrator, } from './validation-orchestrator';
|
|
6
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - MCP Security: Input Sanitizer
|
|
3
|
+
* Implements the Strategy Pattern for input sanitization
|
|
4
|
+
*
|
|
5
|
+
* Moved from src/mcp/security/validators/input-sanitizer.ts to shared/security
|
|
6
|
+
* for cross-domain reuse without DDD boundary violations.
|
|
7
|
+
*/
|
|
8
|
+
import { IInputSanitizationStrategy, SanitizationOptions, RiskLevel } from './validators-interfaces.js';
|
|
9
|
+
/**
|
|
10
|
+
* HTML escape characters mapping
|
|
11
|
+
*/
|
|
12
|
+
export declare const HTML_ESCAPE_MAP: Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* SQL injection patterns to detect and remove
|
|
15
|
+
*/
|
|
16
|
+
export declare const SQL_INJECTION_PATTERNS: RegExp[];
|
|
17
|
+
/**
|
|
18
|
+
* Shell metacharacters (excludes parentheses which are common in normal text)
|
|
19
|
+
*/
|
|
20
|
+
export declare const SHELL_METACHARACTERS: RegExp;
|
|
21
|
+
/**
|
|
22
|
+
* Dangerous control characters that should be stripped:
|
|
23
|
+
* - Null byte (\x00): String termination attacks, filter bypass
|
|
24
|
+
* - Backspace (\x08): Log manipulation
|
|
25
|
+
* - Bell (\x07): Terminal escape attacks
|
|
26
|
+
* - Vertical tab (\x0B): Filter bypass
|
|
27
|
+
* - Form feed (\x0C): Filter bypass
|
|
28
|
+
* - Escape (\x1B): Terminal escape sequences (ANSI attacks)
|
|
29
|
+
* - Delete (\x7F): Buffer manipulation
|
|
30
|
+
*/
|
|
31
|
+
export declare const DANGEROUS_CONTROL_CHARS: RegExp;
|
|
32
|
+
/**
|
|
33
|
+
* Input Sanitizer Strategy
|
|
34
|
+
* Sanitizes user input to prevent XSS, SQL injection, and command injection
|
|
35
|
+
*/
|
|
36
|
+
export declare class InputSanitizer implements IInputSanitizationStrategy {
|
|
37
|
+
readonly name = "input-sanitization";
|
|
38
|
+
/**
|
|
39
|
+
* Get the primary risk level this sanitizer addresses
|
|
40
|
+
*/
|
|
41
|
+
getRiskLevel(): RiskLevel;
|
|
42
|
+
/**
|
|
43
|
+
* Sanitize input string with configurable options
|
|
44
|
+
*/
|
|
45
|
+
sanitize(input: string, options?: SanitizationOptions): string;
|
|
46
|
+
/**
|
|
47
|
+
* Escape HTML special characters
|
|
48
|
+
*/
|
|
49
|
+
escapeHtml(str: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Strip HTML tags from a string
|
|
52
|
+
* Handles both complete tags and incomplete/malformed tags to prevent XSS
|
|
53
|
+
*/
|
|
54
|
+
stripHtmlTags(str: string): string;
|
|
55
|
+
}
|
|
56
|
+
export declare const sanitizeInput: (input: string, options?: SanitizationOptions) => string;
|
|
57
|
+
export declare const escapeHtml: (str: string) => string;
|
|
58
|
+
export declare const stripHtmlTags: (str: string) => string;
|
|
59
|
+
//# sourceMappingURL=input-sanitizer.d.ts.map
|