xypriss 9.14.27 → 9.14.28
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 +45 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +45 -14
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -4661,15 +4661,7 @@ function isImmediateInternalEngineCall() {
|
|
|
4661
4661
|
fnName === "call" ||
|
|
4662
4662
|
fnName === "callSync" ||
|
|
4663
4663
|
fnName === "callSyncSubprocess" ||
|
|
4664
|
-
fnName === "executeEnvCall"
|
|
4665
|
-
// Issue #52 (https://github.com/Nehonix-Team/XyPriss/issues/52)
|
|
4666
|
-
// When code accesses `process.env[prop]`, the proxy trap handler executes inside `EnvApi.ts`.
|
|
4667
|
-
// If EnvApi frames are not skipped, `isImmediateInternalEngineCall()` would treat the Proxy
|
|
4668
|
-
// handler itself as the "caller", erroneously considering every process.env access as an
|
|
4669
|
-
// internal engine call and bypassing the shield. Skipping EnvApi frames ensures we inspect
|
|
4670
|
-
// the real consumer (project code, plugins, or third-party dependencies).
|
|
4671
|
-
norm.endsWith("/EnvApi.ts") ||
|
|
4672
|
-
norm.endsWith("/EnvApi.js")) {
|
|
4664
|
+
fnName === "executeEnvCall") {
|
|
4673
4665
|
continue;
|
|
4674
4666
|
}
|
|
4675
4667
|
}
|
|
@@ -9456,6 +9448,37 @@ class EnvApi {
|
|
|
9456
9448
|
"DYLD_LIBRARY_PATH",
|
|
9457
9449
|
]);
|
|
9458
9450
|
let isInsideShieldCheck = false;
|
|
9451
|
+
/**
|
|
9452
|
+
* Verifies whether the caller that directly triggered a process.env Proxy trap
|
|
9453
|
+
* belongs to the internal XyPriss engine core or to external user/plugin code.
|
|
9454
|
+
*/
|
|
9455
|
+
function isProxyCallerEngineCore() {
|
|
9456
|
+
const frames = captureNativeFrames();
|
|
9457
|
+
let seenTrap = false;
|
|
9458
|
+
for (let i = 0; i < frames.length; i++) {
|
|
9459
|
+
const { filePath, fnName } = frames[i];
|
|
9460
|
+
if (!filePath)
|
|
9461
|
+
continue;
|
|
9462
|
+
if (filePath.startsWith("node:") ||
|
|
9463
|
+
filePath.startsWith("bun:") ||
|
|
9464
|
+
filePath === "native" ||
|
|
9465
|
+
filePath.includes("[eval]")) {
|
|
9466
|
+
continue;
|
|
9467
|
+
}
|
|
9468
|
+
if (fnName === "captureNativeFrames" ||
|
|
9469
|
+
fnName === "isProxyCallerEngineCore") {
|
|
9470
|
+
continue;
|
|
9471
|
+
}
|
|
9472
|
+
// The first frame after capture plumbing is the Proxy trap itself
|
|
9473
|
+
if (!seenTrap) {
|
|
9474
|
+
seenTrap = true;
|
|
9475
|
+
continue;
|
|
9476
|
+
}
|
|
9477
|
+
// The very first frame after the Proxy trap is the consumer that accessed process.env!
|
|
9478
|
+
return isEngineCorePath(filePath.replace(/\\/g, "/"));
|
|
9479
|
+
}
|
|
9480
|
+
return false;
|
|
9481
|
+
}
|
|
9459
9482
|
const envShield = new Proxy(process.env, {
|
|
9460
9483
|
get(target, prop, receiver) {
|
|
9461
9484
|
if (prop === SHIELD_MARKER) {
|
|
@@ -9469,13 +9492,21 @@ class EnvApi {
|
|
|
9469
9492
|
}
|
|
9470
9493
|
// Pass through whitelisted keys.
|
|
9471
9494
|
if (self.whitelistedFields.has(prop)) {
|
|
9495
|
+
// If this key is declared in the application's secure Vault (e.g. from .env via $env.whitelist),
|
|
9496
|
+
// return the authentic configuration value rather than the honeypot canary decoy.
|
|
9497
|
+
if (!self.defaultWhitelist.has(prop) || prop === "PORT") {
|
|
9498
|
+
const vaultVal = self.get(prop);
|
|
9499
|
+
if (vaultVal !== undefined) {
|
|
9500
|
+
return vaultVal;
|
|
9501
|
+
}
|
|
9502
|
+
}
|
|
9472
9503
|
return Reflect.get(target, prop, receiver);
|
|
9473
9504
|
}
|
|
9474
9505
|
// Internal framework operations: allow verified engine callers to read environment safely
|
|
9475
9506
|
isInsideShieldCheck = true;
|
|
9476
9507
|
try {
|
|
9477
9508
|
const caller = getVerifiedCallerInfo();
|
|
9478
|
-
if (!caller.isUntrusted &&
|
|
9509
|
+
if (!caller.isUntrusted && isProxyCallerEngineCore()) {
|
|
9479
9510
|
return Reflect.get(target, prop, receiver);
|
|
9480
9511
|
}
|
|
9481
9512
|
}
|
|
@@ -9524,7 +9555,7 @@ class EnvApi {
|
|
|
9524
9555
|
try {
|
|
9525
9556
|
const caller = getVerifiedCallerInfo();
|
|
9526
9557
|
if (!caller.isUntrusted &&
|
|
9527
|
-
|
|
9558
|
+
isProxyCallerEngineCore()) {
|
|
9528
9559
|
try {
|
|
9529
9560
|
target[key] = String(value);
|
|
9530
9561
|
}
|
|
@@ -9584,7 +9615,7 @@ class EnvApi {
|
|
|
9584
9615
|
isInsideShieldCheck = true;
|
|
9585
9616
|
try {
|
|
9586
9617
|
const caller = getVerifiedCallerInfo();
|
|
9587
|
-
if (!caller.isUntrusted &&
|
|
9618
|
+
if (!caller.isUntrusted && isProxyCallerEngineCore()) {
|
|
9588
9619
|
try {
|
|
9589
9620
|
delete target[prop];
|
|
9590
9621
|
}
|
|
@@ -9616,7 +9647,7 @@ class EnvApi {
|
|
|
9616
9647
|
isInsideShieldCheck = true;
|
|
9617
9648
|
try {
|
|
9618
9649
|
const caller = getVerifiedCallerInfo();
|
|
9619
|
-
if (!caller.isUntrusted &&
|
|
9650
|
+
if (!caller.isUntrusted && isProxyCallerEngineCore()) {
|
|
9620
9651
|
return Reflect.ownKeys(target);
|
|
9621
9652
|
}
|
|
9622
9653
|
}
|
|
@@ -9644,7 +9675,7 @@ class EnvApi {
|
|
|
9644
9675
|
isInsideShieldCheck = true;
|
|
9645
9676
|
try {
|
|
9646
9677
|
const caller = getVerifiedCallerInfo();
|
|
9647
|
-
return !caller.isUntrusted &&
|
|
9678
|
+
return !caller.isUntrusted && isProxyCallerEngineCore();
|
|
9648
9679
|
}
|
|
9649
9680
|
catch {
|
|
9650
9681
|
return false;
|