@arcis/node 1.4.0 → 1.4.3

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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/core/constants.d.ts +2 -2
  3. package/dist/core/constants.d.ts.map +1 -1
  4. package/dist/core/index.js +11 -3
  5. package/dist/core/index.js.map +1 -1
  6. package/dist/core/index.mjs +11 -3
  7. package/dist/core/index.mjs.map +1 -1
  8. package/dist/core/types.d.ts +6 -0
  9. package/dist/core/types.d.ts.map +1 -1
  10. package/dist/index.d.ts +4 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +527 -63
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +525 -65
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/logging/index.js.map +1 -1
  17. package/dist/logging/index.mjs.map +1 -1
  18. package/dist/middleware/bot-detection.d.ts.map +1 -1
  19. package/dist/middleware/cookies.d.ts.map +1 -1
  20. package/dist/middleware/csrf.d.ts +10 -0
  21. package/dist/middleware/csrf.d.ts.map +1 -1
  22. package/dist/middleware/hpp.d.ts.map +1 -1
  23. package/dist/middleware/index.d.ts +2 -0
  24. package/dist/middleware/index.d.ts.map +1 -1
  25. package/dist/middleware/index.js +671 -39
  26. package/dist/middleware/index.js.map +1 -1
  27. package/dist/middleware/index.mjs +671 -41
  28. package/dist/middleware/index.mjs.map +1 -1
  29. package/dist/middleware/main.d.ts.map +1 -1
  30. package/dist/middleware/rate-limit.d.ts.map +1 -1
  31. package/dist/middleware/signup-protection.d.ts +65 -0
  32. package/dist/middleware/signup-protection.d.ts.map +1 -0
  33. package/dist/middleware/telemetry.d.ts +36 -0
  34. package/dist/middleware/telemetry.d.ts.map +1 -0
  35. package/dist/sanitizers/encode.d.ts.map +1 -1
  36. package/dist/sanitizers/index.d.ts +1 -0
  37. package/dist/sanitizers/index.d.ts.map +1 -1
  38. package/dist/sanitizers/index.js +113 -37
  39. package/dist/sanitizers/index.js.map +1 -1
  40. package/dist/sanitizers/index.mjs +111 -38
  41. package/dist/sanitizers/index.mjs.map +1 -1
  42. package/dist/sanitizers/ldap.d.ts +42 -0
  43. package/dist/sanitizers/ldap.d.ts.map +1 -0
  44. package/dist/sanitizers/path.d.ts.map +1 -1
  45. package/dist/sanitizers/pii.d.ts.map +1 -1
  46. package/dist/sanitizers/sanitize.d.ts.map +1 -1
  47. package/dist/sanitizers/ssti.d.ts.map +1 -1
  48. package/dist/sanitizers/xxe.d.ts.map +1 -1
  49. package/dist/stores/index.js +21 -1
  50. package/dist/stores/index.js.map +1 -1
  51. package/dist/stores/index.mjs +21 -1
  52. package/dist/stores/index.mjs.map +1 -1
  53. package/dist/stores/memory.d.ts +4 -10
  54. package/dist/stores/memory.d.ts.map +1 -1
  55. package/dist/telemetry/client.d.ts +60 -0
  56. package/dist/telemetry/client.d.ts.map +1 -0
  57. package/dist/telemetry/index.d.ts +3 -0
  58. package/dist/telemetry/index.d.ts.map +1 -0
  59. package/dist/telemetry/types.d.ts +59 -0
  60. package/dist/telemetry/types.d.ts.map +1 -0
  61. package/dist/validation/index.js +41 -21
  62. package/dist/validation/index.js.map +1 -1
  63. package/dist/validation/index.mjs +41 -21
  64. package/dist/validation/index.mjs.map +1 -1
  65. package/package.json +8 -2
@@ -11,6 +11,9 @@ var XSS_REMOVE_PATTERNS = [
11
11
  /<script[^>]*>[\s\S]*?<\/script>/gi,
12
12
  /** Standalone/unclosed script tags */
13
13
  /<script[^>]*>/gi,
14
+ /** style — CSS expression() and behavior: attacks (IE-era but still relevant) */
15
+ /<style[^>]*>[\s\S]*?<\/style>/gi,
16
+ /<style[^>]*/gi,
14
17
  /** iframe — full block and partial/unclosed */
15
18
  /<iframe[^>]*>[\s\S]*?<\/iframe>/gi,
16
19
  /<iframe[^>]*/gi,
@@ -31,7 +34,15 @@ var XSS_REMOVE_PATTERNS = [
31
34
  /javascript\s*:/gi,
32
35
  /vbscript\s*:/gi,
33
36
  /** data: URIs with HTML/script content */
34
- /data\s*:\s*text\/html[^>\s]*/gi
37
+ /data\s*:\s*text\/html[^>\s]*/gi,
38
+ /** form tag injection — phishing via action= redirection */
39
+ /<form[\s>][^>]*/gi,
40
+ /** meta tag injection — http-equiv refresh or CSP bypass */
41
+ /<meta[\s>][^>]*/gi,
42
+ /** base href hijacking */
43
+ /<base[\s>][^>]*/gi,
44
+ /** link tag injection — stylesheet or preload attacks */
45
+ /<link[\s>][^>]*/gi
35
46
  ];
36
47
  var SQL_PATTERNS = [
37
48
  /** SQL keywords */
@@ -95,8 +106,8 @@ var COMMAND_PATTERNS = [
95
106
  /[;&|`]/g,
96
107
  /** Command substitution: $( ... ) — matched as a pair to reduce false positives */
97
108
  /\$\(/g,
98
- /** URL-encoded newline/carriage-return injection (%0a, %0d) */
99
- /%0[ad]/gi
109
+ /** URL-encoded control characters (%00-%0F): null, tab, vtab, formfeed, LF, CR */
110
+ /%0[0-9a-f]/gi
100
111
  ];
101
112
  var VALIDATION = {
102
113
  /**
@@ -261,26 +272,31 @@ function sanitizePath(input, collectThreats = false) {
261
272
  const threats = [];
262
273
  let value = input;
263
274
  let wasSanitized = false;
264
- for (const pattern of PATH_PATTERNS) {
265
- pattern.lastIndex = 0;
266
- if (pattern.test(value)) {
275
+ value = value.normalize("NFKC");
276
+ let prev;
277
+ do {
278
+ prev = value;
279
+ for (const pattern of PATH_PATTERNS) {
267
280
  pattern.lastIndex = 0;
268
- if (collectThreats) {
269
- const matches = value.match(pattern);
270
- if (matches) {
271
- for (const match of matches) {
272
- threats.push({
273
- type: "path_traversal",
274
- pattern: pattern.source,
275
- original: match
276
- });
281
+ if (pattern.test(value)) {
282
+ pattern.lastIndex = 0;
283
+ if (collectThreats) {
284
+ const matches = value.match(pattern);
285
+ if (matches) {
286
+ for (const match of matches) {
287
+ threats.push({
288
+ type: "path_traversal",
289
+ pattern: pattern.source,
290
+ original: match
291
+ });
292
+ }
277
293
  }
278
294
  }
295
+ value = value.replace(pattern, "");
296
+ wasSanitized = true;
279
297
  }
280
- value = value.replace(pattern, "");
281
- wasSanitized = true;
282
298
  }
283
- }
299
+ } while (value !== prev);
284
300
  if (collectThreats) {
285
301
  return { value, wasSanitized, threats };
286
302
  }
@@ -338,7 +354,7 @@ function sanitizeString(value, options = {}) {
338
354
  if (value.length > maxSize) {
339
355
  throw new InputTooLargeError(maxSize, value.length);
340
356
  }
341
- const reject = options.mode !== "sanitize";
357
+ const reject = options.mode === "reject";
342
358
  let result = value;
343
359
  if (options.sql !== false) {
344
360
  if (reject) {
@@ -793,8 +809,12 @@ function checkPrivateIp(hostname) {
793
809
  if (hostname === "metadata.google.internal" || hostname === "metadata.internal" || hostname === "metadata.azure.internal") {
794
810
  return "cloud metadata endpoint";
795
811
  }
796
- const ipv6 = hostname.replace(/^\[|\]$/g, "");
797
- if (ipv6 === "::1" || ipv6 === "::" || ipv6.startsWith("fc") || ipv6.startsWith("fd") || ipv6.startsWith("fe80")) {
812
+ let ipv6 = hostname.replace(/^\[|\]$/g, "");
813
+ const zoneIdx = ipv6.indexOf("%");
814
+ if (zoneIdx !== -1) {
815
+ ipv6 = ipv6.slice(0, zoneIdx);
816
+ }
817
+ if (ipv6 === "::1" || ipv6 === "::" || /^fc[0-9a-f]{2}:/i.test(ipv6) || /^fd[0-9a-f]{2}:/i.test(ipv6) || /^fe80:/i.test(ipv6) || /^ff[0-9a-f]{2}:/i.test(ipv6)) {
798
818
  return "private IPv6 address";
799
819
  }
800
820
  const mappedDotted = ipv6.match(/^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i);