@jjrawlins/cdk-diff-pr-github-action 1.9.13 → 1.9.14

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 (87) hide show
  1. package/.jsii +3 -3
  2. package/cdkdiffprgithubaction/jsii/jsii.go +2 -2
  3. package/cdkdiffprgithubaction/version +1 -1
  4. package/lib/CdkDiffIamTemplate.js +2 -2
  5. package/lib/CdkDiffIamTemplateStackSet.js +2 -2
  6. package/lib/CdkDiffStackWorkflow.js +1 -1
  7. package/lib/CdkDriftDetectionWorkflow.js +1 -1
  8. package/lib/CdkDriftIamTemplate.js +2 -2
  9. package/node_modules/@aws-sdk/client-cloudformation/package.json +13 -13
  10. package/node_modules/@aws-sdk/core/package.json +4 -4
  11. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  12. package/node_modules/@aws-sdk/credential-provider-http/package.json +5 -5
  13. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  14. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  15. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  16. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  17. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  18. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  19. package/node_modules/@aws-sdk/middleware-user-agent/package.json +3 -3
  20. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/CognitoIdentity.js +1 -1
  21. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/CognitoIdentity.d.ts +2 -2
  22. package/node_modules/@aws-sdk/nested-clients/package.json +12 -12
  23. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  24. package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
  25. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  26. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/CHANGELOG.md +33 -4
  27. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/README.md +8 -7
  28. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
  29. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
  30. package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
  31. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/lib/fxp.d.cts +73 -19
  32. package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
  33. package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
  34. package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
  35. package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
  36. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
  37. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/package.json +3 -2
  38. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/fxp.d.ts +73 -19
  39. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/util.js +18 -0
  40. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/xmlparser/DocTypeReader.js +12 -2
  41. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/xmlparser/OptionsBuilder.js +71 -0
  42. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/xmlparser/OrderedObjParser.js +291 -115
  43. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/xmlparser/XMLParser.js +1 -1
  44. package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/xmlparser/node2json.js +65 -14
  45. package/package.json +2 -2
  46. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js +0 -2
  47. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +0 -1
  48. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.cjs +0 -1
  49. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js +0 -2
  50. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js.map +0 -1
  51. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js +0 -2
  52. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js.map +0 -1
  53. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +0 -1
  54. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/LICENSE +0 -0
  55. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/lib/fxvalidator.min.js +0 -0
  56. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/cli/cli.js +0 -0
  57. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/cli/man.js +0 -0
  58. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/cli/read.js +0 -0
  59. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/fxp.js +0 -0
  60. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/ignoreAttributes.js +0 -0
  61. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/CharsSymbol.js +0 -0
  62. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/EntitiesParser.js +0 -0
  63. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/OptionsBuilder.js +0 -0
  64. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/OutputBuilders/BaseOutputBuilder.js +0 -0
  65. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/OutputBuilders/JsArrBuilder.js +0 -0
  66. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/OutputBuilders/JsMinArrBuilder.js +0 -0
  67. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/OutputBuilders/JsObjBuilder.js +0 -0
  68. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/OutputBuilders/ParserOptionsBuilder.js +0 -0
  69. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/Report.js +0 -0
  70. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/TagPath.js +0 -0
  71. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/TagPathMatcher.js +0 -0
  72. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/XMLParser.js +0 -0
  73. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/Xml2JsParser.js +0 -0
  74. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/XmlPartReader.js +0 -0
  75. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/XmlSpecialTagsReader.js +0 -0
  76. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/inputSource/BufferSource.js +0 -0
  77. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/inputSource/StringSource.js +0 -0
  78. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/valueParsers/EntitiesParser.js +0 -0
  79. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/valueParsers/booleanParser.js +0 -0
  80. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/valueParsers/booleanParserExt.js +0 -0
  81. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/valueParsers/currency.js +0 -0
  82. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/valueParsers/join.js +0 -0
  83. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/valueParsers/number.js +0 -0
  84. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/v6/valueParsers/trim.js +0 -0
  85. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/validator.js +0 -0
  86. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/xmlbuilder/json2xml.js +0 -0
  87. /package/node_modules/{@aws-sdk/xml-builder/node_modules/fast-xml-parser → fast-xml-parser}/src/xmlparser/xmlNode.js +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-xml-parser",
3
- "version": "5.4.1",
3
+ "version": "5.5.6",
4
4
  "description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
5
5
  "main": "./lib/fxp.cjs",
6
6
  "type": "module",
@@ -87,7 +87,8 @@
87
87
  }
88
88
  ],
89
89
  "dependencies": {
90
- "fast-xml-builder": "^1.0.0",
90
+ "fast-xml-builder": "^1.1.4",
91
+ "path-expression-matcher": "^1.1.3",
91
92
  "strnum": "^2.1.2"
92
93
  }
93
94
  }
@@ -1,3 +1,8 @@
1
+ //import type { Matcher, Expression } from 'path-expression-matcher';
2
+
3
+ type Matcher = unknown;
4
+ type Expression = unknown;
5
+
1
6
  export type ProcessEntitiesOptions = {
2
7
  /**
3
8
  * Whether to enable entity processing
@@ -34,6 +39,13 @@ export type ProcessEntitiesOptions = {
34
39
  */
35
40
  maxExpandedLength?: number;
36
41
 
42
+ /**
43
+ * Maximum number of entities allowed in the XML
44
+ *
45
+ * Defaults to `100`
46
+ */
47
+ maxEntityCount?: number;
48
+
37
49
  /**
38
50
  * Array of tag names where entity replacement is allowed.
39
51
  * If null, entities are replaced in all tags.
@@ -46,12 +58,12 @@ export type ProcessEntitiesOptions = {
46
58
  * Custom filter function to determine if entities should be replaced in a tag
47
59
  *
48
60
  * @param tagName - The name of the current tag
49
- * @param jPath - The jPath of the current tag
61
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
50
62
  * @returns `true` to allow entity replacement, `false` to skip
51
63
  *
52
64
  * Defaults to `null`
53
65
  */
54
- tagFilter?: ((tagName: string, jPath: string) => boolean) | null;
66
+ tagFilter?: ((tagName: string, jPathOrMatcher: string | Matcher) => boolean) | null;
55
67
  };
56
68
 
57
69
  export type X2jOptions = {
@@ -96,7 +108,7 @@ export type X2jOptions = {
96
108
  *
97
109
  * Defaults to `true`
98
110
  */
99
- ignoreAttributes?: boolean | (string | RegExp)[] | ((attrName: string, jPath: string) => boolean);
111
+ ignoreAttributes?: boolean | (string | RegExp)[] | ((attrName: string, jPathOrMatcher: string | Matcher) => boolean);
100
112
 
101
113
  /**
102
114
  * Whether to remove namespace string from tag and attribute names
@@ -150,28 +162,33 @@ export type X2jOptions = {
150
162
  /**
151
163
  * Control how tag value should be parsed. Called only if tag value is not empty
152
164
  *
165
+ * @param tagName - The name of the tag
166
+ * @param tagValue - The value of the tag
167
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
168
+ * @param hasAttributes - Whether the tag has attributes
169
+ * @param isLeafNode - Whether the tag is a leaf node
153
170
  * @returns {undefined|null} `undefined` or `null` to set original value.
154
171
  * @returns {unknown}
155
172
  *
156
173
  * 1. Different value or value with different data type to set new value.
157
174
  * 2. Same value to set parsed value if `parseTagValue: true`.
158
175
  *
159
- * Defaults to `(tagName, val, jPath, hasAttributes, isLeafNode) => val`
176
+ * Defaults to `(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode) => val`
160
177
  */
161
- tagValueProcessor?: (tagName: string, tagValue: string, jPath: string, hasAttributes: boolean, isLeafNode: boolean) => unknown;
178
+ tagValueProcessor?: (tagName: string, tagValue: string, jPathOrMatcher: string | Matcher, hasAttributes: boolean, isLeafNode: boolean) => unknown;
162
179
 
163
180
  /**
164
181
  * Control how attribute value should be parsed
165
182
  *
166
- * @param attrName
167
- * @param attrValue
168
- * @param jPath
183
+ * @param attrName - The name of the attribute
184
+ * @param attrValue - The value of the attribute
185
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
169
186
  * @returns {undefined|null} `undefined` or `null` to set original value
170
187
  * @returns {unknown}
171
188
  *
172
- * Defaults to `(attrName, val, jPath) => val`
189
+ * Defaults to `(attrName, val, jPathOrMatcher) => val`
173
190
  */
174
- attributeValueProcessor?: (attrName: string, attrValue: string, jPath: string) => unknown;
191
+ attributeValueProcessor?: (attrName: string, attrValue: string, jPathOrMatcher: string | Matcher) => unknown;
175
192
 
176
193
  /**
177
194
  * Options to pass to `strnum` for parsing numbers
@@ -183,9 +200,13 @@ export type X2jOptions = {
183
200
  /**
184
201
  * Nodes to stop parsing at
185
202
  *
203
+ * Accepts string patterns or Expression objects from path-expression-matcher
204
+ *
205
+ * String patterns starting with "*." are automatically converted to ".." for backward compatibility
206
+ *
186
207
  * Defaults to `[]`
187
208
  */
188
- stopNodes?: string[];
209
+ stopNodes?: (string | Expression)[];
189
210
 
190
211
  /**
191
212
  * List of tags without closing tags
@@ -204,15 +225,15 @@ export type X2jOptions = {
204
225
  /**
205
226
  * Determine whether a tag should be parsed as an array
206
227
  *
207
- * @param tagName
208
- * @param jPath
209
- * @param isLeafNode
210
- * @param isAttribute
228
+ * @param tagName - The name of the tag
229
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
230
+ * @param isLeafNode - Whether the tag is a leaf node
231
+ * @param isAttribute - Whether this is an attribute
211
232
  * @returns {boolean}
212
233
  *
213
234
  * Defaults to `() => false`
214
235
  */
215
- isArray?: (tagName: string, jPath: string, isLeafNode: boolean, isAttribute: boolean) => boolean;
236
+ isArray?: (tagName: string, jPathOrMatcher: string | Matcher, isLeafNode: boolean, isAttribute: boolean) => boolean;
216
237
 
217
238
  /**
218
239
  * Whether to process default and DOCTYPE entities
@@ -266,12 +287,15 @@ export type X2jOptions = {
266
287
  * Change the tag name when a different name is returned. Skip the tag from parsed result when false is returned.
267
288
  * Modify `attrs` object to control attributes for the given tag.
268
289
  *
290
+ * @param tagName - The name of the tag
291
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
292
+ * @param attrs - The attributes object
269
293
  * @returns {string} new tag name.
270
294
  * @returns false to skip the tag
271
295
  *
272
- * Defaults to `(tagName, jPath, attrs) => tagName`
296
+ * Defaults to `(tagName, jPathOrMatcher, attrs) => tagName`
273
297
  */
274
- updateTag?: (tagName: string, jPath: string, attrs: { [k: string]: string }) => string | boolean;
298
+ updateTag?: (tagName: string, jPathOrMatcher: string | Matcher, attrs: { [k: string]: string }) => string | boolean;
275
299
 
276
300
  /**
277
301
  * If true, adds a Symbol to all object nodes, accessible by {@link XMLParser.getMetaDataSymbol} with
@@ -292,6 +316,27 @@ export type X2jOptions = {
292
316
  * Defaults to `true`
293
317
  */
294
318
  strictReservedNames?: boolean;
319
+
320
+ /**
321
+ * Controls whether callbacks receive jPath as string or Matcher instance
322
+ *
323
+ * When `true` - callbacks receive jPath as string (backward compatible)
324
+ *
325
+ * When `false` - callbacks receive Matcher instance for advanced pattern matching
326
+ *
327
+ * Defaults to `true`
328
+ */
329
+ jPath?: boolean;
330
+
331
+ /**
332
+ * Function to sanitize dangerous property names
333
+ *
334
+ * @param name - The name of the property
335
+ * @returns {string} The sanitized name
336
+ *
337
+ * Defaults to `(name) => __name`
338
+ */
339
+ onDangerousProperty?: (name: string) => string;
295
340
  };
296
341
 
297
342
 
@@ -430,9 +475,11 @@ export type XmlBuilderOptions = {
430
475
  /**
431
476
  * Nodes to stop parsing at
432
477
  *
478
+ * Accepts string patterns or Expression objects from path-expression-matcher
479
+ *
433
480
  * Defaults to `[]`
434
481
  */
435
- stopNodes?: string[];
482
+ stopNodes?: (string | Expression)[];
436
483
 
437
484
  /**
438
485
  * Control how tag value should be parsed. Called only if tag value is not empty
@@ -469,6 +516,13 @@ export type XmlBuilderOptions = {
469
516
 
470
517
 
471
518
  oneListGroup?: boolean;
519
+
520
+ /**
521
+ * Maximum number of nested tags
522
+ *
523
+ * Defaults to `100`
524
+ */
525
+ maxNestedTags?: number;
472
526
  };
473
527
 
474
528
  type ESchema = string | object | Array<string | object>;
@@ -41,3 +41,21 @@ export function getValue(v) {
41
41
  return '';
42
42
  }
43
43
  }
44
+
45
+ /**
46
+ * Dangerous property names that could lead to prototype pollution or security issues
47
+ */
48
+ export const DANGEROUS_PROPERTY_NAMES = [
49
+ // '__proto__',
50
+ // 'constructor',
51
+ // 'prototype',
52
+ 'hasOwnProperty',
53
+ 'toString',
54
+ 'valueOf',
55
+ '__defineGetter__',
56
+ '__defineSetter__',
57
+ '__lookupGetter__',
58
+ '__lookupSetter__'
59
+ ];
60
+
61
+ export const criticalProperties = ["__proto__", "constructor", "prototype"];
@@ -7,8 +7,9 @@ export default class DocTypeReader {
7
7
  }
8
8
 
9
9
  readDocType(xmlData, i) {
10
-
11
10
  const entities = Object.create(null);
11
+ let entityCount = 0;
12
+
12
13
  if (xmlData[i + 3] === 'O' &&
13
14
  xmlData[i + 4] === 'C' &&
14
15
  xmlData[i + 5] === 'T' &&
@@ -26,11 +27,20 @@ export default class DocTypeReader {
26
27
  let entityName, val;
27
28
  [entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
28
29
  if (val.indexOf("&") === -1) { //Parameter entities are not supported
29
- const escaped = entityName.replace(/[.\-+*:]/g, '\\.');
30
+ if (this.options.enabled !== false &&
31
+ this.options.maxEntityCount &&
32
+ entityCount >= this.options.maxEntityCount) {
33
+ throw new Error(
34
+ `Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
35
+ );
36
+ }
37
+ //const escaped = entityName.replace(/[.\-+*:]/g, '\\.');
38
+ const escaped = entityName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
30
39
  entities[entityName] = {
31
40
  regx: RegExp(`&${escaped};`, "g"),
32
41
  val: val
33
42
  };
43
+ entityCount++;
34
44
  }
35
45
  }
36
46
  else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
@@ -1,3 +1,13 @@
1
+ import { DANGEROUS_PROPERTY_NAMES, criticalProperties } from "../util.js";
2
+
3
+ const defaultOnDangerousProperty = (name) => {
4
+ if (DANGEROUS_PROPERTY_NAMES.includes(name)) {
5
+ return "__" + name;
6
+ }
7
+ return name;
8
+ };
9
+
10
+
1
11
  export const defaultOptions = {
2
12
  preserveOrder: false,
3
13
  attributeNamePrefix: '@_',
@@ -40,8 +50,36 @@ export const defaultOptions = {
40
50
  captureMetaData: false,
41
51
  maxNestedTags: 100,
42
52
  strictReservedNames: true,
53
+ jPath: true, // if true, pass jPath string to callbacks; if false, pass matcher instance
54
+ onDangerousProperty: defaultOnDangerousProperty
43
55
  };
44
56
 
57
+
58
+ /**
59
+ * Validates that a property name is safe to use
60
+ * @param {string} propertyName - The property name to validate
61
+ * @param {string} optionName - The option field name (for error message)
62
+ * @throws {Error} If property name is dangerous
63
+ */
64
+ function validatePropertyName(propertyName, optionName) {
65
+ if (typeof propertyName !== 'string') {
66
+ return; // Only validate string property names
67
+ }
68
+
69
+ const normalized = propertyName.toLowerCase();
70
+ if (DANGEROUS_PROPERTY_NAMES.some(dangerous => normalized === dangerous.toLowerCase())) {
71
+ throw new Error(
72
+ `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
73
+ );
74
+ }
75
+
76
+ if (criticalProperties.some(dangerous => normalized === dangerous.toLowerCase())) {
77
+ throw new Error(
78
+ `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
79
+ );
80
+ }
81
+ }
82
+
45
83
  /**
46
84
  * Normalizes processEntities option for backward compatibility
47
85
  * @param {boolean|object} value
@@ -56,6 +94,7 @@ function normalizeProcessEntities(value) {
56
94
  maxExpansionDepth: 10,
57
95
  maxTotalExpansions: 1000,
58
96
  maxExpandedLength: 100000,
97
+ maxEntityCount: 100,
59
98
  allowedTags: null,
60
99
  tagFilter: null
61
100
  };
@@ -69,6 +108,7 @@ function normalizeProcessEntities(value) {
69
108
  maxExpansionDepth: value.maxExpansionDepth ?? 10,
70
109
  maxTotalExpansions: value.maxTotalExpansions ?? 1000,
71
110
  maxExpandedLength: value.maxExpandedLength ?? 100000,
111
+ maxEntityCount: value.maxEntityCount ?? 100,
72
112
  allowedTags: value.allowedTags ?? null,
73
113
  tagFilter: value.tagFilter ?? null
74
114
  };
@@ -81,8 +121,39 @@ function normalizeProcessEntities(value) {
81
121
  export const buildOptions = function (options) {
82
122
  const built = Object.assign({}, defaultOptions, options);
83
123
 
124
+ // Validate property names to prevent prototype pollution
125
+ const propertyNameOptions = [
126
+ { value: built.attributeNamePrefix, name: 'attributeNamePrefix' },
127
+ { value: built.attributesGroupName, name: 'attributesGroupName' },
128
+ { value: built.textNodeName, name: 'textNodeName' },
129
+ { value: built.cdataPropName, name: 'cdataPropName' },
130
+ { value: built.commentPropName, name: 'commentPropName' }
131
+ ];
132
+
133
+ for (const { value, name } of propertyNameOptions) {
134
+ if (value) {
135
+ validatePropertyName(value, name);
136
+ }
137
+ }
138
+
139
+ if (built.onDangerousProperty === null) {
140
+ built.onDangerousProperty = defaultOnDangerousProperty;
141
+ }
142
+
84
143
  // Always normalize processEntities for backward compatibility and validation
85
144
  built.processEntities = normalizeProcessEntities(built.processEntities);
145
+
146
+ // Convert old-style stopNodes for backward compatibility
147
+ if (built.stopNodes && Array.isArray(built.stopNodes)) {
148
+ built.stopNodes = built.stopNodes.map(node => {
149
+ if (typeof node === 'string' && node.startsWith('*.')) {
150
+ // Old syntax: *.tagname meant "tagname anywhere"
151
+ // Convert to new syntax: ..tagname
152
+ return '..' + node.substring(2);
153
+ }
154
+ return node;
155
+ });
156
+ }
86
157
  //console.debug(built.processEntities)
87
158
  return built;
88
159
  };