@arcis/node 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/{index.d.mts → constants.d.ts} +21 -70
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/errors.d.ts +53 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/index.d.ts +6 -168
- package/dist/core/index.d.ts.map +1 -0
- package/dist/{types-CsOFHoD9.d.mts → core/types.d.ts} +38 -31
- package/dist/core/types.d.ts.map +1 -0
- package/dist/index.d.ts +71 -166
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +151 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -5
- package/dist/index.mjs.map +1 -1
- package/dist/logging/index.d.ts +4 -36
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/{index.d.mts → redactor.d.ts} +5 -9
- package/dist/logging/redactor.d.ts.map +1 -0
- package/dist/middleware/bot-detection.d.ts +86 -0
- package/dist/middleware/bot-detection.d.ts.map +1 -0
- package/dist/middleware/cookies.d.ts +48 -0
- package/dist/middleware/cookies.d.ts.map +1 -0
- package/dist/middleware/cors.d.ts +65 -0
- package/dist/middleware/cors.d.ts.map +1 -0
- package/dist/middleware/csrf.d.ts +109 -0
- package/dist/middleware/csrf.d.ts.map +1 -0
- package/dist/middleware/error-handler.d.ts +43 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/headers.d.ts +29 -0
- package/dist/middleware/headers.d.ts.map +1 -0
- package/dist/middleware/hpp.d.ts +56 -0
- package/dist/middleware/hpp.d.ts.map +1 -0
- package/dist/middleware/index.d.ts +16 -3
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +28 -3
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/index.mjs +28 -3
- package/dist/middleware/index.mjs.map +1 -1
- package/dist/middleware/main.d.ts +40 -0
- package/dist/middleware/main.d.ts.map +1 -0
- package/dist/middleware/rate-limit-sliding.d.ts +46 -0
- package/dist/middleware/rate-limit-sliding.d.ts.map +1 -0
- package/dist/middleware/rate-limit-token.d.ts +51 -0
- package/dist/middleware/rate-limit-token.d.ts.map +1 -0
- package/dist/middleware/rate-limit.d.ts +34 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/sanitizers/command.d.ts +28 -0
- package/dist/sanitizers/command.d.ts.map +1 -0
- package/dist/sanitizers/encode.d.ts +46 -0
- package/dist/sanitizers/encode.d.ts.map +1 -0
- package/dist/sanitizers/headers.d.ts +46 -0
- package/dist/sanitizers/headers.d.ts.map +1 -0
- package/dist/sanitizers/index.d.ts +17 -22
- package/dist/sanitizers/index.d.ts.map +1 -0
- package/dist/sanitizers/index.js +72 -0
- package/dist/sanitizers/index.js.map +1 -1
- package/dist/sanitizers/index.mjs +68 -1
- package/dist/sanitizers/index.mjs.map +1 -1
- package/dist/sanitizers/jsonp.d.ts +34 -0
- package/dist/sanitizers/jsonp.d.ts.map +1 -0
- package/dist/sanitizers/nosql.d.ts +31 -0
- package/dist/sanitizers/nosql.d.ts.map +1 -0
- package/dist/sanitizers/path.d.ts +28 -0
- package/dist/sanitizers/path.d.ts.map +1 -0
- package/dist/sanitizers/pii.d.ts +80 -0
- package/dist/sanitizers/pii.d.ts.map +1 -0
- package/dist/sanitizers/prototype.d.ts +34 -0
- package/dist/sanitizers/prototype.d.ts.map +1 -0
- package/dist/sanitizers/sanitize.d.ts +51 -0
- package/dist/sanitizers/sanitize.d.ts.map +1 -0
- package/dist/sanitizers/sql.d.ts +28 -0
- package/dist/sanitizers/sql.d.ts.map +1 -0
- package/dist/sanitizers/ssti.d.ts +20 -0
- package/dist/sanitizers/ssti.d.ts.map +1 -0
- package/dist/sanitizers/utils.d.ts +19 -0
- package/dist/sanitizers/utils.d.ts.map +1 -0
- package/dist/sanitizers/xss.d.ts +35 -0
- package/dist/sanitizers/xss.d.ts.map +1 -0
- package/dist/sanitizers/xxe.d.ts +20 -0
- package/dist/sanitizers/xxe.d.ts.map +1 -0
- package/dist/stores/index.d.ts +6 -104
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/memory.d.ts +35 -0
- package/dist/stores/memory.d.ts.map +1 -0
- package/dist/stores/{index.d.mts → redis.d.ts} +6 -45
- package/dist/stores/redis.d.ts.map +1 -0
- package/dist/utils/duration.d.ts +34 -0
- package/dist/utils/duration.d.ts.map +1 -0
- package/dist/utils/fingerprint.d.ts +64 -0
- package/dist/utils/fingerprint.d.ts.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +188 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +182 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/ip.d.ts +70 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/validation/email.d.ts +82 -0
- package/dist/validation/email.d.ts.map +1 -0
- package/dist/validation/file.d.ts +90 -0
- package/dist/validation/file.d.ts.map +1 -0
- package/dist/validation/index.d.ts +10 -3
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/redirect.d.ts +64 -0
- package/dist/validation/redirect.d.ts.map +1 -0
- package/dist/validation/schema.d.ts +36 -0
- package/dist/validation/schema.d.ts.map +1 -0
- package/dist/validation/url.d.ts +65 -0
- package/dist/validation/url.d.ts.map +1 -0
- package/package.json +8 -6
- package/dist/index-A-m-pPeW.d.mts +0 -340
- package/dist/index-CgK94hY_.d.mts +0 -532
- package/dist/index-Co5kPRZz.d.ts +0 -340
- package/dist/index-D_bdJcF0.d.ts +0 -532
- package/dist/index.d.mts +0 -175
- package/dist/middleware/index.d.mts +0 -3
- package/dist/pii-CXcHMlnX.d.mts +0 -438
- package/dist/pii-DhNpl7M3.d.ts +0 -438
- package/dist/sanitizers/index.d.mts +0 -24
- package/dist/types-CsOFHoD9.d.ts +0 -269
- package/dist/validation/index.d.mts +0 -3
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { g as arcis, h as arcisFunction, i as botProtection, j as createCors, k as createCsrf, l as createErrorHandler, m as createHeaders, n as createRateLimiter, o as createSecureCookies, p as createSlidingWindowLimiter, q as createTokenBucketLimiter, r as csrfProtection, h as default, s as detectBot, t as enforceSecureCookie, u as errorHandler, v as generateCsrfToken, w as rateLimit, x as safeCors, y as secureCookieDefaults, z as securityHeaders, A as validateCsrfToken } from '../index-CgK94hY_.mjs';
|
|
2
|
-
import '../types-CsOFHoD9.mjs';
|
|
3
|
-
import 'express';
|
package/dist/pii-CXcHMlnX.d.mts
DELETED
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
import { RequestHandler } from 'express';
|
|
2
|
-
import { i as SanitizeOptions, j as SanitizeResult } from './types-CsOFHoD9.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @module @arcis/node/sanitizers/sanitize
|
|
6
|
-
* Main sanitization functions that combine all sanitizers
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Sanitize a string value against multiple attack vectors.
|
|
11
|
-
*
|
|
12
|
-
* Order matters: We do XSS encoding LAST because:
|
|
13
|
-
* 1. Other sanitizers need to see the original patterns (e.g., SQL keywords)
|
|
14
|
-
* 2. HTML encoding is the final safe output transformation
|
|
15
|
-
* 3. Encoded entities like < shouldn't be treated as SQL/command threats
|
|
16
|
-
*
|
|
17
|
-
* @param value - The string to sanitize
|
|
18
|
-
* @param options - Sanitization options
|
|
19
|
-
* @returns The sanitized string
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* sanitizeString("<script>alert('xss')</script>")
|
|
23
|
-
* // Returns: "<script>alert('xss')</script>"
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* sanitizeString("../../etc/passwd")
|
|
27
|
-
* // Returns: "etc/passwd"
|
|
28
|
-
*/
|
|
29
|
-
declare function sanitizeString(value: string, options?: SanitizeOptions): string;
|
|
30
|
-
/**
|
|
31
|
-
* Sanitize an object recursively, including nested objects and arrays.
|
|
32
|
-
* Also removes prototype pollution and NoSQL injection keys.
|
|
33
|
-
*
|
|
34
|
-
* @param obj - The object to sanitize
|
|
35
|
-
* @param options - Sanitization options
|
|
36
|
-
* @returns The sanitized object
|
|
37
|
-
*/
|
|
38
|
-
declare function sanitizeObject(obj: unknown, options?: SanitizeOptions): unknown;
|
|
39
|
-
/**
|
|
40
|
-
* Create Express middleware for request sanitization.
|
|
41
|
-
* Sanitizes req.body, req.query, and req.params.
|
|
42
|
-
*
|
|
43
|
-
* @param options - Sanitization options
|
|
44
|
-
* @returns Express middleware
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* app.use(createSanitizer());
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* app.use(createSanitizer({ xss: true, sql: true, nosql: true }));
|
|
51
|
-
*/
|
|
52
|
-
declare function createSanitizer(options?: SanitizeOptions): RequestHandler;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @module @arcis/node/sanitizers/xss
|
|
56
|
-
* XSS (Cross-Site Scripting) prevention
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Sanitizes a string to prevent XSS attacks.
|
|
61
|
-
*
|
|
62
|
-
* Strategy:
|
|
63
|
-
* 1. Remove dangerous patterns (script tags, event handlers, etc.)
|
|
64
|
-
* 2. HTML-encode the remaining content
|
|
65
|
-
*
|
|
66
|
-
* @param input - The string to sanitize
|
|
67
|
-
* @param collectThreats - Whether to collect threat information (default: false for performance)
|
|
68
|
-
* @returns Sanitized string or SanitizeResult if collectThreats is true
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* sanitizeXss("<script>alert('xss')</script>")
|
|
72
|
-
* // Returns: "<script>alert('xss')</script>"
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* sanitizeXss("<img onerror='alert(1)'>")
|
|
76
|
-
* // Returns: "<img>" (event handler removed)
|
|
77
|
-
*/
|
|
78
|
-
declare function sanitizeXss(input: string, collectThreats?: false, htmlEncode?: boolean): string;
|
|
79
|
-
declare function sanitizeXss(input: string, collectThreats: true, htmlEncode?: boolean): SanitizeResult;
|
|
80
|
-
/**
|
|
81
|
-
* Checks if a string contains potential XSS patterns.
|
|
82
|
-
* Does not sanitize — use sanitizeXss() for that.
|
|
83
|
-
*
|
|
84
|
-
* @param input - The string to check
|
|
85
|
-
* @returns True if XSS patterns detected
|
|
86
|
-
*/
|
|
87
|
-
declare function detectXss(input: string): boolean;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @module @arcis/node/sanitizers/sql
|
|
91
|
-
* SQL injection prevention
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Sanitizes a string to prevent SQL injection attacks.
|
|
96
|
-
* Replaces dangerous SQL patterns with [BLOCKED].
|
|
97
|
-
*
|
|
98
|
-
* @param input - The string to sanitize
|
|
99
|
-
* @param collectThreats - Whether to collect threat information (default: false for performance)
|
|
100
|
-
* @returns Sanitized string or SanitizeResult if collectThreats is true
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* sanitizeSql("'; DROP TABLE users; --")
|
|
104
|
-
* // Returns: "'; TABLE users "
|
|
105
|
-
*/
|
|
106
|
-
declare function sanitizeSql(input: string, collectThreats?: false): string;
|
|
107
|
-
declare function sanitizeSql(input: string, collectThreats: true): SanitizeResult;
|
|
108
|
-
/**
|
|
109
|
-
* Checks if a string contains potential SQL injection patterns.
|
|
110
|
-
* Does not sanitize — use sanitizeSql() for that.
|
|
111
|
-
*
|
|
112
|
-
* @param input - The string to check
|
|
113
|
-
* @returns True if SQL injection patterns detected
|
|
114
|
-
*/
|
|
115
|
-
declare function detectSql(input: string): boolean;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* @module @arcis/node/sanitizers/path
|
|
119
|
-
* Path traversal prevention
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Sanitizes a string to prevent path traversal attacks.
|
|
124
|
-
* Removes ../ and ..\ patterns (including URL-encoded variants).
|
|
125
|
-
*
|
|
126
|
-
* @param input - The string to sanitize
|
|
127
|
-
* @param collectThreats - Whether to collect threat information (default: false for performance)
|
|
128
|
-
* @returns Sanitized string or SanitizeResult if collectThreats is true
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* sanitizePath("../../etc/passwd")
|
|
132
|
-
* // Returns: "etc/passwd"
|
|
133
|
-
*/
|
|
134
|
-
declare function sanitizePath(input: string, collectThreats?: false): string;
|
|
135
|
-
declare function sanitizePath(input: string, collectThreats: true): SanitizeResult;
|
|
136
|
-
/**
|
|
137
|
-
* Checks if a string contains path traversal patterns.
|
|
138
|
-
* Does not sanitize — use sanitizePath() for that.
|
|
139
|
-
*
|
|
140
|
-
* @param input - The string to check
|
|
141
|
-
* @returns True if path traversal patterns detected
|
|
142
|
-
*/
|
|
143
|
-
declare function detectPathTraversal(input: string): boolean;
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @module @arcis/node/sanitizers/command
|
|
147
|
-
* Command injection prevention
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Sanitizes a string to prevent command injection attacks.
|
|
152
|
-
* Replaces shell metacharacters and dangerous commands with [BLOCKED].
|
|
153
|
-
*
|
|
154
|
-
* @param input - The string to sanitize
|
|
155
|
-
* @param collectThreats - Whether to collect threat information (default: false for performance)
|
|
156
|
-
* @returns Sanitized string or SanitizeResult if collectThreats is true
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* sanitizeCommand("file.txt; rm -rf /")
|
|
160
|
-
* // Returns: "file.txt rm -rf /"
|
|
161
|
-
*/
|
|
162
|
-
declare function sanitizeCommand(input: string, collectThreats?: false): string;
|
|
163
|
-
declare function sanitizeCommand(input: string, collectThreats: true): SanitizeResult;
|
|
164
|
-
/**
|
|
165
|
-
* Checks if a string contains command injection patterns.
|
|
166
|
-
* Does not sanitize — use sanitizeCommand() for that.
|
|
167
|
-
*
|
|
168
|
-
* @param input - The string to check
|
|
169
|
-
* @returns True if command injection patterns detected
|
|
170
|
-
*/
|
|
171
|
-
declare function detectCommandInjection(input: string): boolean;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @module @arcis/node/sanitizers/ssti
|
|
175
|
-
* Server-Side Template Injection (SSTI) prevention
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Sanitizes a string to prevent SSTI attacks.
|
|
180
|
-
* Removes template expression syntax.
|
|
181
|
-
*/
|
|
182
|
-
declare function sanitizeSsti(input: string, collectThreats?: false): string;
|
|
183
|
-
declare function sanitizeSsti(input: string, collectThreats: true): SanitizeResult;
|
|
184
|
-
/**
|
|
185
|
-
* Checks if a string contains SSTI patterns.
|
|
186
|
-
* Does not sanitize — use sanitizeSsti() for that.
|
|
187
|
-
*
|
|
188
|
-
* @param input - The string to check
|
|
189
|
-
* @returns True if SSTI patterns detected
|
|
190
|
-
*/
|
|
191
|
-
declare function detectSsti(input: string): boolean;
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* @module @arcis/node/sanitizers/xxe
|
|
195
|
-
* XML External Entity (XXE) injection prevention
|
|
196
|
-
*/
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Sanitizes a string to prevent XXE attacks.
|
|
200
|
-
* Removes DOCTYPE, ENTITY, and CDATA constructs.
|
|
201
|
-
*/
|
|
202
|
-
declare function sanitizeXxe(input: string, collectThreats?: false): string;
|
|
203
|
-
declare function sanitizeXxe(input: string, collectThreats: true): SanitizeResult;
|
|
204
|
-
/**
|
|
205
|
-
* Checks if a string contains XXE patterns.
|
|
206
|
-
* Does not sanitize — use sanitizeXxe() for that.
|
|
207
|
-
*
|
|
208
|
-
* @param input - The string to check
|
|
209
|
-
* @returns True if XXE patterns detected
|
|
210
|
-
*/
|
|
211
|
-
declare function detectXxe(input: string): boolean;
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* @module @arcis/node/sanitizers/jsonp
|
|
215
|
-
* JSONP callback sanitization to prevent XSS via callback parameters
|
|
216
|
-
*/
|
|
217
|
-
/**
|
|
218
|
-
* Validates and sanitizes a JSONP callback parameter.
|
|
219
|
-
*
|
|
220
|
-
* Returns the callback name if safe, or null if the callback is dangerous.
|
|
221
|
-
* Use this to validate `?callback=` query parameters before wrapping responses.
|
|
222
|
-
*
|
|
223
|
-
* @param callback - The callback parameter value
|
|
224
|
-
* @param maxLength - Maximum allowed length (default: 128)
|
|
225
|
-
* @returns The safe callback name, or null if invalid
|
|
226
|
-
*
|
|
227
|
-
* @example
|
|
228
|
-
* ```ts
|
|
229
|
-
* const cb = sanitizeJsonpCallback(req.query.callback);
|
|
230
|
-
* if (cb) {
|
|
231
|
-
* res.set('Content-Type', 'application/javascript');
|
|
232
|
-
* res.send(`${cb}(${JSON.stringify(data)})`);
|
|
233
|
-
* } else {
|
|
234
|
-
* res.status(400).json({ error: 'Invalid callback' });
|
|
235
|
-
* }
|
|
236
|
-
* ```
|
|
237
|
-
*/
|
|
238
|
-
declare function sanitizeJsonpCallback(callback: string, maxLength?: number): string | null;
|
|
239
|
-
/**
|
|
240
|
-
* Checks if a JSONP callback parameter contains potentially dangerous content.
|
|
241
|
-
*
|
|
242
|
-
* @param callback - The callback parameter value
|
|
243
|
-
* @returns True if the callback is dangerous / invalid
|
|
244
|
-
*/
|
|
245
|
-
declare function detectJsonpInjection(callback: string): boolean;
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* @module @arcis/node/sanitizers/nosql
|
|
249
|
-
* NoSQL injection prevention (MongoDB operators)
|
|
250
|
-
*/
|
|
251
|
-
/**
|
|
252
|
-
* Checks if a key is a dangerous MongoDB operator.
|
|
253
|
-
*
|
|
254
|
-
* @param key - The key to check
|
|
255
|
-
* @returns True if the key is a MongoDB operator
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* isDangerousNoSqlKey('$gt') // true
|
|
259
|
-
* isDangerousNoSqlKey('name') // false
|
|
260
|
-
*/
|
|
261
|
-
declare function isDangerousNoSqlKey(key: string): boolean;
|
|
262
|
-
/**
|
|
263
|
-
* Recursively checks if an object contains dangerous MongoDB operators.
|
|
264
|
-
*
|
|
265
|
-
* @param obj - The object to check
|
|
266
|
-
* @param maxDepth - Maximum recursion depth (default: 10)
|
|
267
|
-
* @returns True if dangerous operators found
|
|
268
|
-
*/
|
|
269
|
-
declare function detectNoSqlInjection(obj: unknown, maxDepth?: number): boolean;
|
|
270
|
-
/**
|
|
271
|
-
* Get list of all MongoDB operators considered dangerous.
|
|
272
|
-
* Useful for documentation or custom validation.
|
|
273
|
-
*
|
|
274
|
-
* @returns Array of dangerous operator strings
|
|
275
|
-
*/
|
|
276
|
-
declare function getDangerousOperators(): string[];
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* @module @arcis/node/sanitizers/prototype
|
|
280
|
-
* Prototype pollution prevention
|
|
281
|
-
*/
|
|
282
|
-
/**
|
|
283
|
-
* Checks if a key is dangerous for prototype pollution.
|
|
284
|
-
* Case-insensitive — catches __PROTO__, Constructor, etc.
|
|
285
|
-
*
|
|
286
|
-
* @param key - The key to check
|
|
287
|
-
* @returns True if the key could cause prototype pollution
|
|
288
|
-
*
|
|
289
|
-
* @example
|
|
290
|
-
* isDangerousProtoKey('__proto__') // true
|
|
291
|
-
* isDangerousProtoKey('__PROTO__') // true
|
|
292
|
-
* isDangerousProtoKey('Constructor') // true
|
|
293
|
-
* isDangerousProtoKey('name') // false
|
|
294
|
-
*/
|
|
295
|
-
declare function isDangerousProtoKey(key: string): boolean;
|
|
296
|
-
/**
|
|
297
|
-
* Recursively checks if an object contains prototype pollution keys.
|
|
298
|
-
*
|
|
299
|
-
* @param obj - The object to check
|
|
300
|
-
* @param maxDepth - Maximum recursion depth (default: 10)
|
|
301
|
-
* @returns True if dangerous keys found
|
|
302
|
-
*/
|
|
303
|
-
declare function detectPrototypePollution(obj: unknown, maxDepth?: number): boolean;
|
|
304
|
-
/**
|
|
305
|
-
* Get list of all keys considered dangerous for prototype pollution.
|
|
306
|
-
* Useful for documentation or custom validation.
|
|
307
|
-
*
|
|
308
|
-
* @returns Array of dangerous key strings
|
|
309
|
-
*/
|
|
310
|
-
declare function getDangerousProtoKeys(): string[];
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* @module @arcis/node/sanitizers/headers
|
|
314
|
-
* HTTP Header Injection & CRLF Injection prevention
|
|
315
|
-
*
|
|
316
|
-
* Prevents attackers from injecting newline characters (\r\n) into HTTP header
|
|
317
|
-
* values, which can lead to response splitting, session fixation, XSS via
|
|
318
|
-
* injected headers, and cache poisoning.
|
|
319
|
-
*/
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Sanitizes a header value by stripping CRLF sequences, bare CR/LF, and null bytes.
|
|
323
|
-
*
|
|
324
|
-
* @param input - The header value to sanitize
|
|
325
|
-
* @param collectThreats - Whether to collect threat information (default: false)
|
|
326
|
-
* @returns Sanitized string or SanitizeResult if collectThreats is true
|
|
327
|
-
*
|
|
328
|
-
* @example
|
|
329
|
-
* sanitizeHeaderValue("safe-value")
|
|
330
|
-
* // Returns: "safe-value"
|
|
331
|
-
*
|
|
332
|
-
* sanitizeHeaderValue("value\r\nX-Injected: evil")
|
|
333
|
-
* // Returns: "valueX-Injected: evil"
|
|
334
|
-
*/
|
|
335
|
-
declare function sanitizeHeaderValue(input: string, collectThreats?: false): string;
|
|
336
|
-
declare function sanitizeHeaderValue(input: string, collectThreats: true): SanitizeResult;
|
|
337
|
-
/**
|
|
338
|
-
* Sanitizes an object of header key-value pairs.
|
|
339
|
-
* Strips CRLF/null bytes from both keys and values.
|
|
340
|
-
*
|
|
341
|
-
* @param headers - Object with header names as keys and header values as values
|
|
342
|
-
* @returns New object with sanitized header names and values
|
|
343
|
-
*
|
|
344
|
-
* @example
|
|
345
|
-
* sanitizeHeaders({ "X-Custom": "safe", "X-Bad\r\n": "value\r\ninjected" })
|
|
346
|
-
* // Returns: { "X-Custom": "safe", "X-Bad": "valueinjected" }
|
|
347
|
-
*/
|
|
348
|
-
declare function sanitizeHeaders(headers: Record<string, string>): Record<string, string>;
|
|
349
|
-
/**
|
|
350
|
-
* Checks if a string contains HTTP header injection patterns (CRLF, null bytes).
|
|
351
|
-
* Does not sanitize — use sanitizeHeaderValue() for that.
|
|
352
|
-
*
|
|
353
|
-
* @param input - The string to check
|
|
354
|
-
* @returns True if header injection patterns detected
|
|
355
|
-
*/
|
|
356
|
-
declare function detectHeaderInjection(input: string): boolean;
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* @module @arcis/node/sanitizers/pii
|
|
360
|
-
* PII (Personally Identifiable Information) detection and redaction
|
|
361
|
-
*
|
|
362
|
-
* Detects: email addresses, phone numbers, credit card numbers, SSNs, IP addresses
|
|
363
|
-
*/
|
|
364
|
-
type PiiType = 'email' | 'phone' | 'credit_card' | 'ssn' | 'ip_address';
|
|
365
|
-
interface PiiMatch {
|
|
366
|
-
type: PiiType;
|
|
367
|
-
value: string;
|
|
368
|
-
start: number;
|
|
369
|
-
end: number;
|
|
370
|
-
}
|
|
371
|
-
interface PiiScanOptions {
|
|
372
|
-
/** PII types to scan for. Default: all types */
|
|
373
|
-
types?: PiiType[];
|
|
374
|
-
}
|
|
375
|
-
interface PiiRedactOptions extends PiiScanOptions {
|
|
376
|
-
/** Replacement for redacted values. Default: '[REDACTED]' */
|
|
377
|
-
replacement?: string;
|
|
378
|
-
/** Use type-specific replacements like '[EMAIL]', '[SSN]'. Default: false */
|
|
379
|
-
typeLabels?: boolean;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Scan a string for PII and return all matches.
|
|
383
|
-
*
|
|
384
|
-
* @param input - String to scan
|
|
385
|
-
* @param options - Optional scan configuration
|
|
386
|
-
* @returns Array of PII matches with type, value, and position
|
|
387
|
-
*
|
|
388
|
-
* @example
|
|
389
|
-
* scanPii('Call me at 555-123-4567 or email john@example.com')
|
|
390
|
-
* // [
|
|
391
|
-
* // { type: 'phone', value: '555-123-4567', start: 11, end: 23 },
|
|
392
|
-
* // { type: 'email', value: 'john@example.com', start: 33, end: 49 }
|
|
393
|
-
* // ]
|
|
394
|
-
*/
|
|
395
|
-
declare function scanPii(input: string, options?: PiiScanOptions): PiiMatch[];
|
|
396
|
-
/**
|
|
397
|
-
* Check if a string contains any PII.
|
|
398
|
-
*
|
|
399
|
-
* @param input - String to check
|
|
400
|
-
* @param options - Optional scan configuration
|
|
401
|
-
* @returns true if PII is detected
|
|
402
|
-
*/
|
|
403
|
-
declare function detectPii(input: string, options?: PiiScanOptions): boolean;
|
|
404
|
-
/**
|
|
405
|
-
* Redact PII from a string, replacing matches with a placeholder.
|
|
406
|
-
*
|
|
407
|
-
* @param input - String to redact
|
|
408
|
-
* @param options - Redaction options
|
|
409
|
-
* @returns String with PII replaced
|
|
410
|
-
*
|
|
411
|
-
* @example
|
|
412
|
-
* redactPii('Email: john@example.com, SSN: 123-45-6789')
|
|
413
|
-
* // 'Email: [REDACTED], SSN: [REDACTED]'
|
|
414
|
-
*
|
|
415
|
-
* redactPii('Email: john@example.com', { typeLabels: true })
|
|
416
|
-
* // 'Email: [EMAIL]'
|
|
417
|
-
*/
|
|
418
|
-
declare function redactPii(input: string, options?: PiiRedactOptions): string;
|
|
419
|
-
/**
|
|
420
|
-
* Scan an object's string values for PII recursively.
|
|
421
|
-
*
|
|
422
|
-
* @param obj - Object to scan
|
|
423
|
-
* @param options - Optional scan configuration
|
|
424
|
-
* @returns Array of PII matches with the field path prepended
|
|
425
|
-
*/
|
|
426
|
-
declare function scanObjectPii(obj: Record<string, unknown>, options?: PiiScanOptions, path?: string): (PiiMatch & {
|
|
427
|
-
field: string;
|
|
428
|
-
})[];
|
|
429
|
-
/**
|
|
430
|
-
* Redact PII from all string values in an object recursively.
|
|
431
|
-
*
|
|
432
|
-
* @param obj - Object to redact
|
|
433
|
-
* @param options - Redaction options
|
|
434
|
-
* @returns New object with PII redacted
|
|
435
|
-
*/
|
|
436
|
-
declare function redactObjectPii<T extends Record<string, unknown>>(obj: T, options?: PiiRedactOptions): T;
|
|
437
|
-
|
|
438
|
-
export { sanitizeString as A, sanitizeXss as B, sanitizeXxe as C, scanObjectPii as D, scanPii as E, type PiiRedactOptions as F, type PiiScanOptions as G, type PiiType as H, type PiiMatch as P, detectHeaderInjection as a, detectJsonpInjection as b, createSanitizer as c, detectCommandInjection as d, detectNoSqlInjection as e, detectPathTraversal as f, detectPii as g, detectPrototypePollution as h, detectSql as i, detectSsti as j, detectXss as k, detectXxe as l, getDangerousOperators as m, getDangerousProtoKeys as n, isDangerousNoSqlKey as o, isDangerousProtoKey as p, redactPii as q, redactObjectPii as r, sanitizeCommand as s, sanitizeHeaderValue as t, sanitizeHeaders as u, sanitizeJsonpCallback as v, sanitizeObject as w, sanitizePath as x, sanitizeSql as y, sanitizeSsti as z };
|