@scalar/json-magic 0.15.1 → 0.15.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @scalar/json-magic
2
2
 
3
+ ## 0.15.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#10342](https://github.com/scalar/scalar/pull/10342): Prevent prototype pollution when merging documents and writing nested values or JSON references, while preserving prototype-named JSON data properties.
8
+
9
+ Dot-separated mutations now reject new `constructor` and `prototype` keys, as well as `__proto__`, instead of creating these keys through inherited properties.
10
+
11
+ - [#10345](https://github.com/scalar/scalar/pull/10345): Update undici to 7.29.0 to address security vulnerabilities in HTTP requests, proxies, WebSockets, cookies, and caching.
12
+
3
13
  ## 0.15.1
4
14
 
5
15
  ## 0.15.0
@@ -25,7 +25,7 @@ export function getValueByPath(target, segments) {
25
25
  return { context: '', value: undefined };
26
26
  }
27
27
  // If the accumulator is not an object or is null, stop traversal
28
- if (typeof acc.value !== 'object' || acc.value === null) {
28
+ if (typeof acc.value !== 'object' || acc.value === null || !Object.hasOwn(acc.value, key)) {
29
29
  return { context: '', value: undefined };
30
30
  }
31
31
  // Attempt to get the id from the current value for context tracking
@@ -1 +1 @@
1
- {"version":3,"file":"json-path-utils.d.ts","sourceRoot":"","sources":["../../src/helpers/json-path-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAWlE"}
1
+ {"version":3,"file":"json-path-utils.d.ts","sourceRoot":"","sources":["../../src/helpers/json-path-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAalE"}
@@ -18,12 +18,14 @@
18
18
  */
19
19
  export function createPathFromSegments(obj, segments) {
20
20
  return segments.reduce((acc, part) => {
21
- if (acc[part] === undefined) {
22
- if (isNaN(Number(part))) {
23
- acc[part] = {};
21
+ if (!Object.hasOwn(acc, part) || acc[part] === undefined) {
22
+ const value = isNaN(Number(part)) ? {} : [];
23
+ if (part === '__proto__') {
24
+ // Avoid the prototype setter while preserving ordinary proxy set notifications.
25
+ Object.defineProperty(acc, part, { value, enumerable: true, configurable: true, writable: true });
24
26
  }
25
27
  else {
26
- acc[part] = [];
28
+ acc[part] = value;
27
29
  }
28
30
  }
29
31
  return acc[part];
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/magic-proxy/proxy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAQ5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,aAAa,EACnG,QAAQ,CAAC,EACT,UAAU,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAA;IACrB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAA;CACpB,CAAC,EACF,OAAM;IACJ;;OAEG;IACH,IAAI,EAAE,CAAC,GAAG,CAAC,CAAA;IACX;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC9B;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3B;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAA;CAOvB,KACA,CAkNF,CAAA;AAMD;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAUnC"}
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/magic-proxy/proxy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAQ5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,aAAa,EACnG,QAAQ,CAAC,EACT,UAAU,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAA;IACrB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAA;CACpB,CAAC,EACF,OAAM;IACJ;;OAEG;IACH,IAAI,EAAE,CAAC,GAAG,CAAC,CAAA;IACX;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC9B;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3B;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAA;CAOvB,KACA,CAwNF,CAAA;AAMD;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAUnC"}
@@ -150,7 +150,14 @@ export const createMagicProxy = (target, options, args = {
150
150
  console.warn(`Trying to set $ref-value for invalid reference: ${ref}\n\nPlease fix your input file to fix this issue.`);
151
151
  }
152
152
  // Set the value on the parent node
153
- getParentNode()[segments.at(-1)] = newValue;
153
+ const parent = getParentNode();
154
+ const key = segments.at(-1);
155
+ if (key === '__proto__') {
156
+ Object.defineProperty(parent, key, { value: newValue, enumerable: true, configurable: true, writable: true });
157
+ }
158
+ else {
159
+ parent[key] = newValue;
160
+ }
154
161
  return true;
155
162
  }
156
163
  return Reflect.set(target, prop, newValue, receiver);
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/scalar/scalar.git",
11
11
  "directory": "packages/json-magic"
12
12
  },
13
- "version": "0.15.1",
13
+ "version": "0.15.2",
14
14
  "engines": {
15
15
  "node": ">=22"
16
16
  },
@@ -122,9 +122,9 @@
122
122
  "CHANGELOG.md"
123
123
  ],
124
124
  "dependencies": {
125
- "@scalar/helpers": "0.14.0",
125
+ "@scalar/helpers": "0.15.0",
126
126
  "pathe": "^2.0.3",
127
- "undici": "7.24.4",
127
+ "undici": "7.29.0",
128
128
  "yaml": "^2.9.0"
129
129
  },
130
130
  "devDependencies": {