xypriss 9.15.1 → 9.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/dist/cjs/index.js +21 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +21 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -18428,10 +18428,12 @@ class ProtoShield {
|
|
|
18428
18428
|
throw new Error(`[XyPriss Validation Error] Invalid '$protoShield.mode': ${JSON.stringify(raw.mode)}. Accepted values are: 'block', 'warn', 'freeze'.`);
|
|
18429
18429
|
}
|
|
18430
18430
|
}
|
|
18431
|
-
if (raw.neutralizeProto !== undefined &&
|
|
18431
|
+
if (raw.neutralizeProto !== undefined &&
|
|
18432
|
+
typeof raw.neutralizeProto !== "boolean") {
|
|
18432
18433
|
throw new Error(`[XyPriss Validation Error] '$protoShield.neutralizeProto' must be a boolean. Received: ${typeof raw.neutralizeProto}`);
|
|
18433
18434
|
}
|
|
18434
|
-
if (raw.freezePrototypes !== undefined &&
|
|
18435
|
+
if (raw.freezePrototypes !== undefined &&
|
|
18436
|
+
typeof raw.freezePrototypes !== "boolean") {
|
|
18435
18437
|
throw new Error(`[XyPriss Validation Error] '$protoShield.freezePrototypes' must be a boolean. Received: ${typeof raw.freezePrototypes}`);
|
|
18436
18438
|
}
|
|
18437
18439
|
if (raw.allowedProperties !== undefined) {
|
|
@@ -18449,8 +18451,12 @@ class ProtoShield {
|
|
|
18449
18451
|
enabled: raw.enabled !== undefined ? raw.enabled : true,
|
|
18450
18452
|
mode: raw.mode || "block",
|
|
18451
18453
|
neutralizeProto: raw.neutralizeProto !== undefined ? raw.neutralizeProto : true,
|
|
18452
|
-
freezePrototypes: raw.freezePrototypes !== undefined
|
|
18453
|
-
|
|
18454
|
+
freezePrototypes: raw.freezePrototypes !== undefined
|
|
18455
|
+
? raw.freezePrototypes
|
|
18456
|
+
: false,
|
|
18457
|
+
allowedProperties: Array.isArray(raw.allowedProperties)
|
|
18458
|
+
? [...raw.allowedProperties]
|
|
18459
|
+
: [],
|
|
18454
18460
|
};
|
|
18455
18461
|
}
|
|
18456
18462
|
/**
|
|
@@ -18494,14 +18500,19 @@ class ProtoShield {
|
|
|
18494
18500
|
*/
|
|
18495
18501
|
static applyPropertyInterception(allowed, mode) {
|
|
18496
18502
|
const origDefineProperty = Object.defineProperty;
|
|
18497
|
-
const targetPrototypes = [
|
|
18503
|
+
const targetPrototypes = [
|
|
18504
|
+
Object.prototype,
|
|
18505
|
+
Array.prototype,
|
|
18506
|
+
Function.prototype,
|
|
18507
|
+
];
|
|
18498
18508
|
Object.defineProperty = function (target, propertyKey, attributes) {
|
|
18499
18509
|
if (targetPrototypes.includes(target)) {
|
|
18500
18510
|
const propStr = String(propertyKey);
|
|
18501
18511
|
if (!allowed.has(propStr)) {
|
|
18502
18512
|
const message = `[XyPriss ProtoShield] Blocked Prototype Pollution attempt! Unauthorized property '${propStr}' on ${target?.constructor?.name || "Object"}.prototype`;
|
|
18503
18513
|
if (mode === "warn") {
|
|
18504
|
-
console.warn(`\x1b[33m${message}\x1b[0m\n` +
|
|
18514
|
+
console.warn(`\x1b[33m${message}\x1b[0m\n` +
|
|
18515
|
+
(new Error().stack || ""));
|
|
18505
18516
|
}
|
|
18506
18517
|
else {
|
|
18507
18518
|
const err = new TypeError(message);
|
|
@@ -18527,11 +18538,13 @@ class ProtoShield {
|
|
|
18527
18538
|
set(_newProto) {
|
|
18528
18539
|
const message = `[XyPriss ProtoShield] Blocked Prototype Mutation attempt via '__proto__'!`;
|
|
18529
18540
|
if (mode === "warn") {
|
|
18530
|
-
console.warn(`\x1b[33m${message}\x1b[0m\n` +
|
|
18541
|
+
console.warn(`\x1b[33m${message}\x1b[0m\n` +
|
|
18542
|
+
(new Error().stack || ""));
|
|
18531
18543
|
}
|
|
18532
18544
|
else {
|
|
18533
18545
|
const err = new TypeError(message);
|
|
18534
|
-
console.error(`\x1b[31m${message}\x1b[0m\n` +
|
|
18546
|
+
console.error(`\x1b[31m${message}\x1b[0m\n` +
|
|
18547
|
+
(err.stack || ""));
|
|
18535
18548
|
throw err;
|
|
18536
18549
|
}
|
|
18537
18550
|
},
|