@zenstackhq/plugin-policy 3.0.0-beta.29 → 3.0.0-beta.31
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/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -935,6 +935,7 @@ var PolicyHandler = class extends import_kysely3.OperationNodeTransformer {
|
|
|
935
935
|
return proceed(this.transformNode(node));
|
|
936
936
|
}
|
|
937
937
|
const { mutationModel } = this.getMutationModel(node);
|
|
938
|
+
this.tryRejectNonexistentModel(mutationModel);
|
|
938
939
|
if (import_kysely3.InsertQueryNode.is(node)) {
|
|
939
940
|
const isManyToManyJoinTable = this.isManyToManyJoinTable(mutationModel);
|
|
940
941
|
let needCheckPreCreate = true;
|
|
@@ -1101,6 +1102,7 @@ var PolicyHandler = class extends import_kysely3.OperationNodeTransformer {
|
|
|
1101
1102
|
if (!table) {
|
|
1102
1103
|
return super.transformJoin(node);
|
|
1103
1104
|
}
|
|
1105
|
+
this.tryRejectNonexistentModel(table.model);
|
|
1104
1106
|
const filter = this.buildPolicyFilter(table.model, table.alias, "read");
|
|
1105
1107
|
const nestedSelect = {
|
|
1106
1108
|
kind: "SelectQueryNode",
|
|
@@ -1493,6 +1495,7 @@ var PolicyHandler = class extends import_kysely3.OperationNodeTransformer {
|
|
|
1493
1495
|
const extractResult = this.extractTableName(table);
|
|
1494
1496
|
if (extractResult) {
|
|
1495
1497
|
const { model, alias } = extractResult;
|
|
1498
|
+
this.tryRejectNonexistentModel(model);
|
|
1496
1499
|
const filter = this.buildPolicyFilter(model, alias, "read");
|
|
1497
1500
|
return acc ? conjunction(this.dialect, [
|
|
1498
1501
|
acc,
|
|
@@ -1580,6 +1583,11 @@ var PolicyHandler = class extends import_kysely3.OperationNodeTransformer {
|
|
|
1580
1583
|
bQuery
|
|
1581
1584
|
]).toOperationNode();
|
|
1582
1585
|
}
|
|
1586
|
+
tryRejectNonexistentModel(model) {
|
|
1587
|
+
if (!import_orm4.QueryUtils.hasModel(this.client.$schema, model) && !this.isManyToManyJoinTable(model)) {
|
|
1588
|
+
throw createRejectedByPolicyError(model, import_orm4.RejectedByPolicyReason.NO_ACCESS);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1583
1591
|
};
|
|
1584
1592
|
|
|
1585
1593
|
// src/functions.ts
|