@posiwise/common-services 0.1.93 → 0.1.97
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.
|
@@ -1477,8 +1477,57 @@ class PermissionService {
|
|
|
1477
1477
|
}
|
|
1478
1478
|
expr = this.handleNonBooleanPermissions(permission, expr, productKey, permission_key, productSlug);
|
|
1479
1479
|
// Now expr is made of true/false values with &&, ||, ()
|
|
1480
|
-
//
|
|
1481
|
-
return
|
|
1480
|
+
// Safe parser: no eval() - CSP 'unsafe-eval' not required
|
|
1481
|
+
return this.evaluateBooleanExpression(expr);
|
|
1482
|
+
}
|
|
1483
|
+
/** Safe boolean expression parser - replaces eval() for CSP compliance. */
|
|
1484
|
+
evaluateBooleanExpression(expr) {
|
|
1485
|
+
expr = expr.replace(/\s+/g, ' ').trim();
|
|
1486
|
+
if (!expr)
|
|
1487
|
+
return false;
|
|
1488
|
+
if (expr === 'true')
|
|
1489
|
+
return true;
|
|
1490
|
+
if (expr === 'false')
|
|
1491
|
+
return false;
|
|
1492
|
+
let depth = 0;
|
|
1493
|
+
for (let i = 0; i < expr.length - 1; i++) {
|
|
1494
|
+
const c = expr[i];
|
|
1495
|
+
if (c === '(')
|
|
1496
|
+
depth++;
|
|
1497
|
+
else if (c === ')')
|
|
1498
|
+
depth--;
|
|
1499
|
+
else if (depth === 0 && expr.substring(i, i + 2) === '||') {
|
|
1500
|
+
const left = expr.substring(0, i).trim();
|
|
1501
|
+
const right = expr.substring(i + 2).trim();
|
|
1502
|
+
return (this.evaluateBooleanExpression(left) || this.evaluateBooleanExpression(right));
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
depth = 0;
|
|
1506
|
+
for (let i = 0; i < expr.length - 1; i++) {
|
|
1507
|
+
const c = expr[i];
|
|
1508
|
+
if (c === '(')
|
|
1509
|
+
depth++;
|
|
1510
|
+
else if (c === ')')
|
|
1511
|
+
depth--;
|
|
1512
|
+
else if (depth === 0 && expr.substring(i, i + 2) === '&&') {
|
|
1513
|
+
const left = expr.substring(0, i).trim();
|
|
1514
|
+
const right = expr.substring(i + 2).trim();
|
|
1515
|
+
return (this.evaluateBooleanExpression(left) && this.evaluateBooleanExpression(right));
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
if (expr.startsWith('(') && expr.endsWith(')')) {
|
|
1519
|
+
let d = 0;
|
|
1520
|
+
for (let j = 1; j < expr.length - 1; j++) {
|
|
1521
|
+
if (expr[j] === '(')
|
|
1522
|
+
d++;
|
|
1523
|
+
if (expr[j] === ')')
|
|
1524
|
+
d--;
|
|
1525
|
+
if (d < 0)
|
|
1526
|
+
return false;
|
|
1527
|
+
}
|
|
1528
|
+
return this.evaluateBooleanExpression(expr.substring(1, expr.length - 1));
|
|
1529
|
+
}
|
|
1530
|
+
return false;
|
|
1482
1531
|
}
|
|
1483
1532
|
handleNonBooleanPermissions(permission, expr, productKey, permission_key, productSlug) {
|
|
1484
1533
|
if (typeof permission !== 'boolean') {
|
|
@@ -2851,6 +2900,9 @@ class SentryErrorHandler {
|
|
|
2851
2900
|
: 'production';
|
|
2852
2901
|
const config = {
|
|
2853
2902
|
dsn: null,
|
|
2903
|
+
// Disable Session Replay (uses eval internally) for CSP 'unsafe-eval' compliance
|
|
2904
|
+
replaysSessionSampleRate: 0,
|
|
2905
|
+
replaysOnErrorSampleRate: 0,
|
|
2854
2906
|
// NOTE: We intentionally do not enable Performance Tracing here.
|
|
2855
2907
|
// The previous integration (`BrowserTracing` + `routingInstrumentation`) was part of
|
|
2856
2908
|
// the legacy `@sentry/angular-ivy` API and isn't available in `@sentry/angular` v10.
|