@defai.digital/ax-cli 3.5.4 → 3.6.1
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/.ax-cli/checkpoints/2025-11-20/checkpoint-11e9e0ba-c39d-4fd2-aa77-bc818811c921.json +69 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-2b260b98-b418-4c7c-9694-e2b94967e662.json +24 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-7e03601e-e8ab-4cd7-9841-a74b66adf78f.json +69 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-7f9c6562-771f-4fd0-adcf-9e7e9ac34ae8.json +44 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-e1ebe666-4c3a-4367-ba5c-27fe512a9c70.json +24 -0
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-15743e7d-430c-4d76-b6fc-955d7a5c250c.json +44 -0
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-25cf7679-0b3f-4988-83d7-704548fbba91.json +69 -0
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-54aedbac-6db0-464e-8ebb-dbb3979e6dca.json +24 -0
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-7658aed8-fe5d-4222-903f-1a7c63717ea7.json +24 -0
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-c9c13497-40dc-4294-a327-6a5fc854eaa1.json +69 -0
- package/.ax-cli/memory.json +15 -8
- package/README.md +423 -82
- package/ax.config.json +333 -0
- package/config-defaults/messages.yaml +75 -0
- package/config-defaults/models.yaml +66 -0
- package/config-defaults/prompts.yaml +156 -0
- package/config-defaults/settings.yaml +86 -0
- package/dist/agent/chat-history-manager.d.ts +56 -0
- package/dist/agent/chat-history-manager.js +150 -0
- package/dist/agent/chat-history-manager.js.map +1 -0
- package/dist/agent/llm-agent.js +1 -1
- package/dist/agent/llm-agent.js.map +1 -1
- package/dist/agent/tool-manager.d.ts +39 -0
- package/dist/agent/tool-manager.js +76 -0
- package/dist/agent/tool-manager.js.map +1 -0
- package/dist/analyzers/code-smells/detectors/data-clumps-detector.js +7 -9
- package/dist/analyzers/code-smells/detectors/data-clumps-detector.js.map +1 -1
- package/dist/analyzers/code-smells/detectors/dead-code-detector.js +1 -1
- package/dist/analyzers/code-smells/detectors/dead-code-detector.js.map +1 -1
- package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js +22 -10
- package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js.map +1 -1
- package/dist/analyzers/code-smells/detectors/feature-envy-detector.js +1 -1
- package/dist/analyzers/code-smells/detectors/feature-envy-detector.js.map +1 -1
- package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js +1 -1
- package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js.map +1 -1
- package/dist/analyzers/code-smells/detectors/large-class-detector.js +4 -1
- package/dist/analyzers/code-smells/detectors/large-class-detector.js.map +1 -1
- package/dist/analyzers/code-smells/detectors/long-method-detector.js +4 -1
- package/dist/analyzers/code-smells/detectors/long-method-detector.js.map +1 -1
- package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js +4 -1
- package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js.map +1 -1
- package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js +4 -5
- package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js.map +1 -1
- package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js +4 -1
- package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js.map +1 -1
- package/dist/commands/memory.js +1 -1
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/setup.js +19 -6
- package/dist/commands/setup.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.bak +664 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/client.d.ts +1 -0
- package/dist/llm/client.js +44 -0
- package/dist/llm/client.js.map +1 -1
- package/dist/mcp/health.js +4 -2
- package/dist/mcp/health.js.map +1 -1
- package/dist/mcp/ssrf-protection.d.ts +86 -0
- package/dist/mcp/ssrf-protection.js +313 -0
- package/dist/mcp/ssrf-protection.js.map +1 -0
- package/dist/mcp/validation.d.ts +4 -0
- package/dist/mcp/validation.js +122 -11
- package/dist/mcp/validation.js.map +1 -1
- package/dist/schemas/settings-schemas.d.ts +53 -0
- package/dist/schemas/settings-schemas.js +47 -0
- package/dist/schemas/settings-schemas.js.map +1 -1
- package/dist/tools/bash.d.ts +3 -2
- package/dist/tools/bash.js +31 -2
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/search.d.ts +1 -1
- package/dist/tools/search.js +121 -128
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/text-editor.js +52 -15
- package/dist/tools/text-editor.js.map +1 -1
- package/dist/tools/web-search/index.d.ts +0 -2
- package/dist/tools/web-search/index.js +0 -2
- package/dist/tools/web-search/index.js.map +1 -1
- package/dist/tools/web-search/router.d.ts +0 -2
- package/dist/tools/web-search/router.js +2 -37
- package/dist/tools/web-search/router.js.map +1 -1
- package/dist/tools/web-search/web-search-tool.js +2 -12
- package/dist/tools/web-search/web-search-tool.js.map +1 -1
- package/dist/ui/components/chat-history.js +1 -1
- package/dist/ui/components/chat-history.js.map +1 -1
- package/dist/ui/components/chat-input.d.ts +4 -1
- package/dist/ui/components/chat-input.js +133 -52
- package/dist/ui/components/chat-input.js.map +1 -1
- package/dist/ui/components/chat-interface.js +5 -4
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/confirmation-dialog.js +1 -1
- package/dist/ui/components/confirmation-dialog.js.map +1 -1
- package/dist/ui/components/keyboard-hints.js +2 -0
- package/dist/ui/components/keyboard-hints.js.map +1 -1
- package/dist/ui/components/status-bar.js +3 -13
- package/dist/ui/components/status-bar.js.map +1 -1
- package/dist/ui/components/welcome-panel.js +4 -0
- package/dist/ui/components/welcome-panel.js.map +1 -1
- package/dist/ui/hooks/use-chat-reducer.d.ts +61 -0
- package/dist/ui/hooks/use-chat-reducer.js +118 -0
- package/dist/ui/hooks/use-chat-reducer.js.map +1 -0
- package/dist/ui/hooks/use-enhanced-input.d.ts +44 -0
- package/dist/ui/hooks/use-enhanced-input.js +364 -0
- package/dist/ui/hooks/use-enhanced-input.js.map +1 -0
- package/dist/ui/hooks/use-input-handler.d.ts +48 -0
- package/dist/ui/hooks/use-input-handler.js +1446 -0
- package/dist/ui/hooks/use-input-handler.js.map +1 -0
- package/dist/utils/audit-logger.d.ts +205 -0
- package/dist/utils/audit-logger.js +269 -0
- package/dist/utils/audit-logger.js.map +1 -0
- package/dist/utils/command-security.d.ts +85 -0
- package/dist/utils/command-security.js +200 -0
- package/dist/utils/command-security.js.map +1 -0
- package/dist/utils/config-loader.js +3 -3
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/encryption.d.ts +78 -0
- package/dist/utils/encryption.js +216 -0
- package/dist/utils/encryption.js.map +1 -0
- package/dist/utils/error-sanitizer.d.ts +119 -0
- package/dist/utils/error-sanitizer.js +253 -0
- package/dist/utils/error-sanitizer.js.map +1 -0
- package/dist/utils/input-sanitizer.d.ts +210 -0
- package/dist/utils/input-sanitizer.js +362 -0
- package/dist/utils/input-sanitizer.js.map +1 -0
- package/dist/utils/json-utils.d.ts +13 -0
- package/dist/utils/json-utils.js +55 -1
- package/dist/utils/json-utils.js.map +1 -1
- package/dist/utils/paste-collapse.d.ts +46 -0
- package/dist/utils/paste-collapse.js +77 -0
- package/dist/utils/paste-collapse.js.map +1 -0
- package/dist/utils/paste-utils.d.ts +99 -0
- package/dist/utils/paste-utils.js +239 -0
- package/dist/utils/paste-utils.js.map +1 -0
- package/dist/utils/path-security.d.ts +90 -0
- package/dist/utils/path-security.js +328 -0
- package/dist/utils/path-security.js.map +1 -0
- package/dist/utils/process-pool.d.ts +105 -0
- package/dist/utils/process-pool.js +326 -0
- package/dist/utils/process-pool.js.map +1 -0
- package/dist/utils/rate-limiter.d.ts +221 -0
- package/dist/utils/rate-limiter.js +317 -0
- package/dist/utils/rate-limiter.js.map +1 -0
- package/dist/utils/settings-manager.js +99 -6
- package/dist/utils/settings-manager.js.map +1 -1
- package/dist/utils/streaming-analyzer.js +9 -21
- package/dist/utils/streaming-analyzer.js.map +1 -1
- package/package.json +3 -7
- package/packages/schemas/dist/index.d.ts +14 -0
- package/packages/schemas/dist/index.d.ts.map +1 -0
- package/packages/schemas/dist/index.js +19 -0
- package/packages/schemas/dist/index.js.map +1 -0
- package/packages/schemas/dist/public/core/brand-types.d.ts +308 -0
- package/packages/schemas/dist/public/core/brand-types.d.ts.map +1 -0
- package/packages/schemas/dist/public/core/brand-types.js +243 -0
- package/packages/schemas/dist/public/core/brand-types.js.map +1 -0
- package/packages/schemas/dist/public/core/enums.d.ts +227 -0
- package/packages/schemas/dist/public/core/enums.d.ts.map +1 -0
- package/packages/schemas/dist/public/core/enums.js +222 -0
- package/packages/schemas/dist/public/core/enums.js.map +1 -0
- package/packages/schemas/dist/public/core/id-types.d.ts +286 -0
- package/packages/schemas/dist/public/core/id-types.d.ts.map +1 -0
- package/packages/schemas/dist/public/core/id-types.js +136 -0
- package/packages/schemas/dist/public/core/id-types.js.map +1 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Message Sanitization (REQ-SEC-010)
|
|
3
|
+
*
|
|
4
|
+
* Sanitizes error messages to prevent information disclosure
|
|
5
|
+
* Removes:
|
|
6
|
+
* - File system paths
|
|
7
|
+
* - API keys and secrets
|
|
8
|
+
* - Stack traces (for user-facing errors)
|
|
9
|
+
* - Internal implementation details
|
|
10
|
+
*
|
|
11
|
+
* Security: CVSS 6.5 (Medium Priority)
|
|
12
|
+
*/
|
|
13
|
+
import { homedir } from 'os';
|
|
14
|
+
import { getAuditLogger, AuditCategory } from './audit-logger.js';
|
|
15
|
+
/**
|
|
16
|
+
* Patterns to detect and sanitize in error messages
|
|
17
|
+
*/
|
|
18
|
+
const SENSITIVE_PATTERNS = {
|
|
19
|
+
// File paths (Windows and Unix)
|
|
20
|
+
FILE_PATH: /([A-Za-z]:\\|\/)[^\s"'<>|]+/g,
|
|
21
|
+
// API keys and tokens (common formats)
|
|
22
|
+
// Matches patterns like "api_key=XXX", "secret: XXX", "API key: XXX", "bearer XXX"
|
|
23
|
+
API_KEY: /\b(?:api[_ -]?key|token|secret|password|bearer)[\s:=]+['"]?[a-zA-Z0-9_\-]{16,}['"]?/gi,
|
|
24
|
+
// Environment variables
|
|
25
|
+
ENV_VAR: /\$\{?[A-Z_][A-Z0-9_]*\}?/g,
|
|
26
|
+
// IP addresses (for SSRF protection)
|
|
27
|
+
IP_ADDRESS: /\b(?:\d{1,3}\.){3}\d{1,3}\b/g,
|
|
28
|
+
// URLs with credentials
|
|
29
|
+
URL_WITH_CREDS: /https?:\/\/[^:]+:[^@]+@[^\s]+/g,
|
|
30
|
+
// Stack trace lines
|
|
31
|
+
STACK_TRACE_LINE: /^\s*at\s+.+\(.+:\d+:\d+\)$/gm,
|
|
32
|
+
// Home directory references
|
|
33
|
+
HOME_DIR: new RegExp(homedir().replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'),
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Replacement strings for sanitized content
|
|
37
|
+
*/
|
|
38
|
+
const REPLACEMENTS = {
|
|
39
|
+
FILE_PATH: '[REDACTED_PATH]',
|
|
40
|
+
API_KEY: '[REDACTED_KEY]',
|
|
41
|
+
ENV_VAR: '[REDACTED_ENV]',
|
|
42
|
+
IP_ADDRESS: '[REDACTED_IP]',
|
|
43
|
+
URL_WITH_CREDS: '[REDACTED_URL]',
|
|
44
|
+
STACK_TRACE_LINE: '',
|
|
45
|
+
HOME_DIR: '[USER_HOME]',
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Error categories for user-friendly messages
|
|
49
|
+
*/
|
|
50
|
+
export var ErrorCategory;
|
|
51
|
+
(function (ErrorCategory) {
|
|
52
|
+
ErrorCategory["NETWORK"] = "NETWORK";
|
|
53
|
+
ErrorCategory["FILE_SYSTEM"] = "FILE_SYSTEM";
|
|
54
|
+
ErrorCategory["VALIDATION"] = "VALIDATION";
|
|
55
|
+
ErrorCategory["AUTHENTICATION"] = "AUTHENTICATION";
|
|
56
|
+
ErrorCategory["RATE_LIMIT"] = "RATE_LIMIT";
|
|
57
|
+
ErrorCategory["API_ERROR"] = "API_ERROR";
|
|
58
|
+
ErrorCategory["INTERNAL"] = "INTERNAL";
|
|
59
|
+
ErrorCategory["USER_INPUT"] = "USER_INPUT";
|
|
60
|
+
})(ErrorCategory || (ErrorCategory = {}));
|
|
61
|
+
/**
|
|
62
|
+
* Sanitize error message by removing sensitive information
|
|
63
|
+
*
|
|
64
|
+
* @param message - Raw error message
|
|
65
|
+
* @returns Sanitized message safe for user display
|
|
66
|
+
*/
|
|
67
|
+
export function sanitizeErrorMessage(message) {
|
|
68
|
+
let sanitized = message;
|
|
69
|
+
// Remove URLs with credentials first (before FILE_PATH catches them)
|
|
70
|
+
sanitized = sanitized.replace(SENSITIVE_PATTERNS.URL_WITH_CREDS, REPLACEMENTS.URL_WITH_CREDS);
|
|
71
|
+
// Remove home directory references (before FILE_PATH catches them)
|
|
72
|
+
sanitized = sanitized.replace(SENSITIVE_PATTERNS.HOME_DIR, REPLACEMENTS.HOME_DIR);
|
|
73
|
+
// Remove file paths
|
|
74
|
+
sanitized = sanitized.replace(SENSITIVE_PATTERNS.FILE_PATH, REPLACEMENTS.FILE_PATH);
|
|
75
|
+
// Remove API keys and secrets
|
|
76
|
+
sanitized = sanitized.replace(SENSITIVE_PATTERNS.API_KEY, REPLACEMENTS.API_KEY);
|
|
77
|
+
// Remove environment variables
|
|
78
|
+
sanitized = sanitized.replace(SENSITIVE_PATTERNS.ENV_VAR, REPLACEMENTS.ENV_VAR);
|
|
79
|
+
// Remove IP addresses
|
|
80
|
+
sanitized = sanitized.replace(SENSITIVE_PATTERNS.IP_ADDRESS, REPLACEMENTS.IP_ADDRESS);
|
|
81
|
+
return sanitized;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Sanitize stack trace by removing sensitive paths
|
|
85
|
+
*
|
|
86
|
+
* @param stack - Raw stack trace
|
|
87
|
+
* @returns Sanitized stack trace
|
|
88
|
+
*/
|
|
89
|
+
export function sanitizeStackTrace(stack) {
|
|
90
|
+
let sanitized = stack;
|
|
91
|
+
// Remove home directory references first
|
|
92
|
+
sanitized = sanitized.replace(SENSITIVE_PATTERNS.HOME_DIR, REPLACEMENTS.HOME_DIR);
|
|
93
|
+
// Remove file paths from stack frames
|
|
94
|
+
sanitized = sanitized.replace(SENSITIVE_PATTERNS.FILE_PATH, REPLACEMENTS.FILE_PATH);
|
|
95
|
+
return sanitized;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Remove stack trace entirely (for user-facing errors)
|
|
99
|
+
*
|
|
100
|
+
* @param message - Error message with potential stack trace
|
|
101
|
+
* @returns Message without stack trace
|
|
102
|
+
*/
|
|
103
|
+
export function removeStackTrace(message) {
|
|
104
|
+
// Split at first "at " (stack trace start)
|
|
105
|
+
const parts = message.split(/\n\s*at\s+/);
|
|
106
|
+
return parts[0].trim();
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Categorize error and create user-friendly message
|
|
110
|
+
*
|
|
111
|
+
* @param error - Error object
|
|
112
|
+
* @returns Sanitized error with category and suggestion
|
|
113
|
+
*/
|
|
114
|
+
export function sanitizeError(error) {
|
|
115
|
+
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
116
|
+
const message = errorObj.message;
|
|
117
|
+
// Sanitize the message
|
|
118
|
+
const sanitizedMessage = sanitizeErrorMessage(removeStackTrace(message));
|
|
119
|
+
// Determine category and suggestion
|
|
120
|
+
let category = ErrorCategory.INTERNAL;
|
|
121
|
+
let suggestion;
|
|
122
|
+
let code;
|
|
123
|
+
// Network errors
|
|
124
|
+
if (message.includes('ENOTFOUND') || message.includes('ECONNREFUSED') || message.includes('fetch failed')) {
|
|
125
|
+
category = ErrorCategory.NETWORK;
|
|
126
|
+
suggestion = 'Check your network connection and try again.';
|
|
127
|
+
code = 'ERR_NETWORK';
|
|
128
|
+
}
|
|
129
|
+
// File system errors
|
|
130
|
+
else if (message.includes('ENOENT') || message.includes('EACCES') || message.includes('EPERM')) {
|
|
131
|
+
category = ErrorCategory.FILE_SYSTEM;
|
|
132
|
+
suggestion = 'Check that the file exists and you have permission to access it.';
|
|
133
|
+
code = 'ERR_FILE_SYSTEM';
|
|
134
|
+
}
|
|
135
|
+
// Validation errors
|
|
136
|
+
else if (message.includes('validation') || message.includes('invalid') || message.includes('required')) {
|
|
137
|
+
category = ErrorCategory.VALIDATION;
|
|
138
|
+
suggestion = 'Check your input and try again.';
|
|
139
|
+
code = 'ERR_VALIDATION';
|
|
140
|
+
}
|
|
141
|
+
// Authentication errors
|
|
142
|
+
else if (message.includes('unauthorized') || message.includes('authentication') || message.includes('API key')) {
|
|
143
|
+
category = ErrorCategory.AUTHENTICATION;
|
|
144
|
+
suggestion = 'Check your API key configuration.';
|
|
145
|
+
code = 'ERR_AUTH';
|
|
146
|
+
}
|
|
147
|
+
// Rate limit errors
|
|
148
|
+
else if (message.includes('rate limit') || message.includes('too many requests')) {
|
|
149
|
+
category = ErrorCategory.RATE_LIMIT;
|
|
150
|
+
suggestion = 'Please wait a moment before trying again.';
|
|
151
|
+
code = 'ERR_RATE_LIMIT';
|
|
152
|
+
}
|
|
153
|
+
// API errors
|
|
154
|
+
else if (message.includes('API') || message.includes('status code')) {
|
|
155
|
+
category = ErrorCategory.API_ERROR;
|
|
156
|
+
suggestion = 'The API returned an error. Please try again later.';
|
|
157
|
+
code = 'ERR_API';
|
|
158
|
+
}
|
|
159
|
+
// REQ-SEC-008: Audit log errors with sensitive info detection
|
|
160
|
+
if (message !== sanitizedMessage) {
|
|
161
|
+
const auditLogger = getAuditLogger();
|
|
162
|
+
auditLogger.logWarning({
|
|
163
|
+
category: AuditCategory.SYSTEM_EVENT,
|
|
164
|
+
action: 'sensitive_data_in_error',
|
|
165
|
+
outcome: 'success',
|
|
166
|
+
details: {
|
|
167
|
+
category,
|
|
168
|
+
sanitized: true,
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
message: sanitizedMessage,
|
|
174
|
+
code,
|
|
175
|
+
category,
|
|
176
|
+
suggestion,
|
|
177
|
+
originalError: errorObj,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Format sanitized error for user display
|
|
182
|
+
*
|
|
183
|
+
* @param sanitizedError - Sanitized error object
|
|
184
|
+
* @returns Formatted error message
|
|
185
|
+
*/
|
|
186
|
+
export function formatUserError(sanitizedError) {
|
|
187
|
+
const parts = [];
|
|
188
|
+
if (sanitizedError.code) {
|
|
189
|
+
parts.push(`[${sanitizedError.code}]`);
|
|
190
|
+
}
|
|
191
|
+
parts.push(sanitizedError.message);
|
|
192
|
+
if (sanitizedError.suggestion) {
|
|
193
|
+
parts.push(`\nℹ️ ${sanitizedError.suggestion}`);
|
|
194
|
+
}
|
|
195
|
+
return parts.join(' ');
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Create internal log message with full details (not sanitized)
|
|
199
|
+
*
|
|
200
|
+
* @param error - Original error
|
|
201
|
+
* @param context - Additional context
|
|
202
|
+
* @returns Detailed log message
|
|
203
|
+
*/
|
|
204
|
+
export function createInternalLogMessage(error, context) {
|
|
205
|
+
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
206
|
+
const parts = [
|
|
207
|
+
`Error: ${errorObj.message}`,
|
|
208
|
+
];
|
|
209
|
+
if (errorObj.stack) {
|
|
210
|
+
parts.push(`Stack: ${sanitizeStackTrace(errorObj.stack)}`);
|
|
211
|
+
}
|
|
212
|
+
if (context) {
|
|
213
|
+
parts.push(`Context: ${JSON.stringify(context, null, 2)}`);
|
|
214
|
+
}
|
|
215
|
+
return parts.join('\n');
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Safe error wrapper for user-facing operations
|
|
219
|
+
*
|
|
220
|
+
* @param operation - Async operation to execute
|
|
221
|
+
* @param errorHandler - Optional custom error handler
|
|
222
|
+
* @returns Result or sanitized error
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const result = await safeExecute(
|
|
227
|
+
* () => riskyOperation(),
|
|
228
|
+
* (error) => console.error('Internal error:', error)
|
|
229
|
+
* );
|
|
230
|
+
*
|
|
231
|
+
* if (!result.success) {
|
|
232
|
+
* console.log(formatUserError(result.error));
|
|
233
|
+
* }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
export async function safeExecute(operation, errorHandler) {
|
|
237
|
+
try {
|
|
238
|
+
const data = await operation();
|
|
239
|
+
return { success: true, data };
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
const sanitized = sanitizeError(error);
|
|
243
|
+
// Log internal error details
|
|
244
|
+
if (errorHandler) {
|
|
245
|
+
errorHandler(sanitized.originalError, sanitized);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
console.error(createInternalLogMessage(error));
|
|
249
|
+
}
|
|
250
|
+
return { success: false, error: sanitized };
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=error-sanitizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-sanitizer.js","sourceRoot":"","sources":["../../src/utils/error-sanitizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElE;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB,gCAAgC;IAChC,SAAS,EAAE,8BAA8B;IAEzC,uCAAuC;IACvC,mFAAmF;IACnF,OAAO,EAAE,uFAAuF;IAEhG,wBAAwB;IACxB,OAAO,EAAE,2BAA2B;IAEpC,qCAA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SAAS,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAC9C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input Sanitization Framework (REQ-SEC-007)
|
|
3
|
+
*
|
|
4
|
+
* Provides comprehensive input validation and sanitization to prevent:
|
|
5
|
+
* - ReDoS (Regular Expression Denial of Service)
|
|
6
|
+
* - Command injection
|
|
7
|
+
* - Path traversal
|
|
8
|
+
* - Unicode attacks
|
|
9
|
+
* - Buffer overflow
|
|
10
|
+
*
|
|
11
|
+
* Security: CVSS 7.3 (High Priority)
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Sanitization result with validation and cleaned value
|
|
15
|
+
*/
|
|
16
|
+
export interface SanitizationResult {
|
|
17
|
+
/**
|
|
18
|
+
* Whether the input passed validation
|
|
19
|
+
*/
|
|
20
|
+
valid: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Sanitized/cleaned value (only if valid)
|
|
23
|
+
*/
|
|
24
|
+
value?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Error message if validation failed
|
|
27
|
+
*/
|
|
28
|
+
error?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Warning messages (non-fatal issues)
|
|
31
|
+
*/
|
|
32
|
+
warnings?: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for input sanitization
|
|
36
|
+
*/
|
|
37
|
+
export interface SanitizerOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Maximum allowed length (default: 10,000 characters)
|
|
40
|
+
*/
|
|
41
|
+
maxLength?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to normalize Unicode (default: true)
|
|
44
|
+
*/
|
|
45
|
+
normalizeUnicode?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Character whitelist pattern (regex)
|
|
48
|
+
*/
|
|
49
|
+
allowedPattern?: RegExp;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to trim whitespace (default: true)
|
|
52
|
+
*/
|
|
53
|
+
trim?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether to allow empty strings (default: false)
|
|
56
|
+
*/
|
|
57
|
+
allowEmpty?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Default maximum input lengths for different contexts
|
|
61
|
+
*/
|
|
62
|
+
export declare const MAX_INPUT_LENGTHS: {
|
|
63
|
+
readonly COMMAND: 10000;
|
|
64
|
+
readonly FILE_PATH: 4096;
|
|
65
|
+
readonly USER_INPUT: 50000;
|
|
66
|
+
readonly SEARCH_QUERY: 1000;
|
|
67
|
+
readonly ENV_VALUE: 10000;
|
|
68
|
+
readonly CONFIG_VALUE: 10000;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Safe characters for different contexts
|
|
72
|
+
*/
|
|
73
|
+
export declare const SAFE_PATTERNS: {
|
|
74
|
+
/**
|
|
75
|
+
* Alphanumeric, spaces, and common punctuation
|
|
76
|
+
*/
|
|
77
|
+
readonly BASIC: RegExp;
|
|
78
|
+
/**
|
|
79
|
+
* Safe for file paths (no directory traversal)
|
|
80
|
+
*/
|
|
81
|
+
readonly FILE_PATH: RegExp;
|
|
82
|
+
/**
|
|
83
|
+
* Safe for environment variable values
|
|
84
|
+
*/
|
|
85
|
+
readonly ENV_VALUE: RegExp;
|
|
86
|
+
/**
|
|
87
|
+
* Printable ASCII only (most restrictive)
|
|
88
|
+
*/
|
|
89
|
+
readonly ASCII_PRINTABLE: RegExp;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Normalize Unicode string to prevent homograph attacks
|
|
93
|
+
*
|
|
94
|
+
* Uses NFC (Canonical Decomposition, followed by Canonical Composition)
|
|
95
|
+
* which is the recommended normalization form for most use cases
|
|
96
|
+
*
|
|
97
|
+
* @param input - String to normalize
|
|
98
|
+
* @returns Normalized string
|
|
99
|
+
*/
|
|
100
|
+
export declare function normalizeUnicode(input: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* Check for dangerous patterns in input
|
|
103
|
+
*
|
|
104
|
+
* @param input - String to check
|
|
105
|
+
* @returns Array of detected dangerous patterns
|
|
106
|
+
*/
|
|
107
|
+
export declare function detectDangerousPatterns(input: string): string[];
|
|
108
|
+
/**
|
|
109
|
+
* Sanitize general user input with configurable options
|
|
110
|
+
*
|
|
111
|
+
* @param input - Raw input string
|
|
112
|
+
* @param options - Sanitization options
|
|
113
|
+
* @returns Sanitization result
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const result = sanitizeInput('User input here', {
|
|
118
|
+
* maxLength: 1000,
|
|
119
|
+
* normalizeUnicode: true,
|
|
120
|
+
* allowedPattern: SAFE_PATTERNS.BASIC,
|
|
121
|
+
* });
|
|
122
|
+
*
|
|
123
|
+
* if (result.valid) {
|
|
124
|
+
* // Use result.value safely
|
|
125
|
+
* } else {
|
|
126
|
+
* console.error(result.error);
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare function sanitizeInput(input: string, options?: SanitizerOptions): SanitizationResult;
|
|
131
|
+
/**
|
|
132
|
+
* Sanitize file path input to prevent path traversal
|
|
133
|
+
*
|
|
134
|
+
* @param path - File path to sanitize
|
|
135
|
+
* @returns Sanitization result
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const result = sanitizeFilePath('../../../etc/passwd');
|
|
140
|
+
* if (!result.valid) {
|
|
141
|
+
* console.error('Invalid path:', result.error);
|
|
142
|
+
* }
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export declare function sanitizeFilePath(path: string): SanitizationResult;
|
|
146
|
+
/**
|
|
147
|
+
* Sanitize shell command input
|
|
148
|
+
*
|
|
149
|
+
* NOTE: This is a last line of defense. Prefer execFile over exec
|
|
150
|
+
* and use argument arrays instead of concatenating commands.
|
|
151
|
+
*
|
|
152
|
+
* @param command - Command string to sanitize
|
|
153
|
+
* @returns Sanitization result
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const result = sanitizeCommand('ls -la');
|
|
158
|
+
* if (result.valid) {
|
|
159
|
+
* // Still prefer execFile with args array
|
|
160
|
+
* execFile(result.value.split(' ')[0], result.value.split(' ').slice(1));
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export declare function sanitizeCommand(command: string): SanitizationResult;
|
|
165
|
+
/**
|
|
166
|
+
* Sanitize search query input
|
|
167
|
+
*
|
|
168
|
+
* @param query - Search query to sanitize
|
|
169
|
+
* @returns Sanitization result
|
|
170
|
+
*/
|
|
171
|
+
export declare function sanitizeSearchQuery(query: string): SanitizationResult;
|
|
172
|
+
/**
|
|
173
|
+
* Sanitize environment variable value
|
|
174
|
+
*
|
|
175
|
+
* @param value - Environment variable value to sanitize
|
|
176
|
+
* @returns Sanitization result
|
|
177
|
+
*/
|
|
178
|
+
export declare function sanitizeEnvValue(value: string): SanitizationResult;
|
|
179
|
+
/**
|
|
180
|
+
* Escape shell arguments for safe execution
|
|
181
|
+
*
|
|
182
|
+
* NOTE: This is a defense-in-depth measure. Always prefer:
|
|
183
|
+
* 1. execFile with argument array over exec
|
|
184
|
+
* 2. Argument validation/whitelisting
|
|
185
|
+
* 3. This escaping function as a last resort
|
|
186
|
+
*
|
|
187
|
+
* @param arg - Argument to escape
|
|
188
|
+
* @returns Safely escaped argument
|
|
189
|
+
*/
|
|
190
|
+
export declare function escapeShellArg(arg: string): string;
|
|
191
|
+
/**
|
|
192
|
+
* Validate regex pattern for ReDoS protection
|
|
193
|
+
*
|
|
194
|
+
* Checks for common ReDoS patterns:
|
|
195
|
+
* - Nested quantifiers (e.g., (a+)+)
|
|
196
|
+
* - Alternation with overlapping patterns
|
|
197
|
+
* - Excessive backtracking potential
|
|
198
|
+
*
|
|
199
|
+
* @param pattern - Regex pattern to validate
|
|
200
|
+
* @returns Validation result
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* const result = validateRegexPattern('(a+)+b');
|
|
205
|
+
* if (!result.valid) {
|
|
206
|
+
* console.error('Unsafe regex:', result.error);
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export declare function validateRegexPattern(pattern: string): SanitizationResult;
|