@mikro-orm/core 7.1.7-dev.8 → 7.1.7
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/entity/EntityAssigner.js +5 -1
- package/metadata/MetadataValidator.js +1 -13
- package/package.json +1 -1
- package/utils/Utils.d.ts +12 -0
- package/utils/Utils.js +14 -2
package/entity/EntityAssigner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collection } from './Collection.js';
|
|
2
|
-
import { Utils } from '../utils/Utils.js';
|
|
2
|
+
import { DANGEROUS_PROPERTY_NAMES, Utils } from '../utils/Utils.js';
|
|
3
3
|
import { Reference } from './Reference.js';
|
|
4
4
|
import { ReferenceKind, SCALAR_TYPES } from '../enums.js';
|
|
5
5
|
import { validateProperty } from './validators.js';
|
|
@@ -35,6 +35,10 @@ export class EntityAssigner {
|
|
|
35
35
|
return entity;
|
|
36
36
|
}
|
|
37
37
|
static assignProperty(entity, propName, props, data, options) {
|
|
38
|
+
// needs to happen before the `props` lookup, as those keys resolve to inherited accessors
|
|
39
|
+
if (DANGEROUS_PROPERTY_NAMES.includes(propName)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
38
42
|
let value = data[propName];
|
|
39
43
|
const onlyProperties = options.onlyProperties && !(propName in props);
|
|
40
44
|
const ignoreUndefined = options.ignoreUndefined === true && value === undefined;
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { Utils } from '../utils/Utils.js';
|
|
1
|
+
import { DANGEROUS_PROPERTY_NAMES, Utils } from '../utils/Utils.js';
|
|
2
2
|
import { normalizePartitionNameForComparison, splitCommaSeparatedIdentifiers } from '../utils/partition-utils.js';
|
|
3
3
|
import { MetadataError } from '../errors.js';
|
|
4
4
|
import { ReferenceKind } from '../enums.js';
|
|
5
|
-
/**
|
|
6
|
-
* List of property names that could lead to prototype pollution vulnerabilities.
|
|
7
|
-
* These names should never be used as entity property names because they could
|
|
8
|
-
* allow malicious code to modify object prototypes when property values are assigned.
|
|
9
|
-
*
|
|
10
|
-
* - `__proto__`: Could modify the prototype chain
|
|
11
|
-
* - `constructor`: Could modify the constructor property
|
|
12
|
-
* - `prototype`: Could modify the prototype object
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
const DANGEROUS_PROPERTY_NAMES = ['__proto__', 'constructor', 'prototype'];
|
|
17
5
|
/**
|
|
18
6
|
* @internal
|
|
19
7
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.1.7
|
|
3
|
+
"version": "7.1.7",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
package/utils/Utils.d.ts
CHANGED
|
@@ -3,6 +3,18 @@ import type { Platform } from '../platforms/Platform.js';
|
|
|
3
3
|
import { ScalarReference } from '../entity/Reference.js';
|
|
4
4
|
import { Collection } from '../entity/Collection.js';
|
|
5
5
|
import { type RawQueryFragmentSymbol } from './RawQueryFragment.js';
|
|
6
|
+
/**
|
|
7
|
+
* List of property names that could lead to prototype pollution vulnerabilities.
|
|
8
|
+
* These names should never be used as entity property names because they could
|
|
9
|
+
* allow malicious code to modify object prototypes when property values are assigned.
|
|
10
|
+
*
|
|
11
|
+
* - `__proto__`: Could modify the prototype chain
|
|
12
|
+
* - `constructor`: Could modify the constructor property
|
|
13
|
+
* - `prototype`: Could modify the prototype object
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare const DANGEROUS_PROPERTY_NAMES: readonly string[];
|
|
6
18
|
/** Deeply compares two objects for equality, handling dates, regexes, and raw fragments. */
|
|
7
19
|
export declare function compareObjects(a: any, b: any): boolean;
|
|
8
20
|
/** Compares two arrays element-by-element for deep equality. */
|
package/utils/Utils.js
CHANGED
|
@@ -5,6 +5,18 @@ import { Reference, ScalarReference } from '../entity/Reference.js';
|
|
|
5
5
|
import { Collection } from '../entity/Collection.js';
|
|
6
6
|
import { EntityHelper } from '../entity/EntityHelper.js';
|
|
7
7
|
import { Raw, isRaw } from './RawQueryFragment.js';
|
|
8
|
+
/**
|
|
9
|
+
* List of property names that could lead to prototype pollution vulnerabilities.
|
|
10
|
+
* These names should never be used as entity property names because they could
|
|
11
|
+
* allow malicious code to modify object prototypes when property values are assigned.
|
|
12
|
+
*
|
|
13
|
+
* - `__proto__`: Could modify the prototype chain
|
|
14
|
+
* - `constructor`: Could modify the constructor property
|
|
15
|
+
* - `prototype`: Could modify the prototype object
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export const DANGEROUS_PROPERTY_NAMES = ['__proto__', 'constructor', 'prototype'];
|
|
8
20
|
function compareConstructors(a, b) {
|
|
9
21
|
if (a.constructor === b.constructor) {
|
|
10
22
|
return true;
|
|
@@ -141,7 +153,7 @@ export function parseJsonSafe(value) {
|
|
|
141
153
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
142
154
|
export class Utils {
|
|
143
155
|
static PK_SEPARATOR = '~~~';
|
|
144
|
-
static #ORM_VERSION = '7.1.7
|
|
156
|
+
static #ORM_VERSION = '7.1.7';
|
|
145
157
|
/**
|
|
146
158
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
159
|
*/
|
|
@@ -232,7 +244,7 @@ export class Utils {
|
|
|
232
244
|
const source = sources.shift();
|
|
233
245
|
if (Utils.isObject(target) && Utils.isPlainObject(source)) {
|
|
234
246
|
for (const [key, value] of Object.entries(source)) {
|
|
235
|
-
if (
|
|
247
|
+
if (DANGEROUS_PROPERTY_NAMES.includes(key)) {
|
|
236
248
|
continue;
|
|
237
249
|
}
|
|
238
250
|
if (ignoreUndefined && typeof value === 'undefined') {
|