@openinc/parse-server-opendash 4.38.1 → 4.38.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.
|
@@ -74,6 +74,22 @@ async function init() {
|
|
|
74
74
|
if (object.isNew()) {
|
|
75
75
|
await (0, index_js_2.requirePermission)(request, Permissions_js_1.Permissions.SERVICE.execution_perform, "perform a maintenance execution");
|
|
76
76
|
}
|
|
77
|
+
// The capability says *that* somebody may perform maintenance, not *which*
|
|
78
|
+
// plans. That is decided by the plan's ACL — creator and assignments — so
|
|
79
|
+
// the plan an execution points at has to be one the acting user can read.
|
|
80
|
+
//
|
|
81
|
+
// Without this, anyone holding `can-perform-execution` could record a run
|
|
82
|
+
// of a plan they were never assigned to, given its objectId (which every
|
|
83
|
+
// tenant-readable execution of that plan carries). It would count towards
|
|
84
|
+
// the plan's due dates, and `freezeSteps` above — which reads with the
|
|
85
|
+
// master key — would copy the private plan's steps into a record the whole
|
|
86
|
+
// tenant can read.
|
|
87
|
+
//
|
|
88
|
+
// Checked whenever `schedule` changes, not only on create: re-pointing an
|
|
89
|
+
// open execution at another plan is the same question.
|
|
90
|
+
if (object.dirty("schedule")) {
|
|
91
|
+
await requireReadableSchedule(object, request.sessionToken);
|
|
92
|
+
}
|
|
77
93
|
// Who performed it is established by the server from the session, not
|
|
78
94
|
// accepted from the client. A protocol that names somebody else is worth
|
|
79
95
|
// less than no protocol at all.
|
|
@@ -126,6 +142,25 @@ async function init() {
|
|
|
126
142
|
// already owns notification timing and recipients.
|
|
127
143
|
});
|
|
128
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Refuse an execution whose plan the acting user cannot read.
|
|
147
|
+
*
|
|
148
|
+
* Queried with the user's session token, so Parse applies the plan's ACL. A
|
|
149
|
+
* plan the user may not read and one that does not exist look the same here,
|
|
150
|
+
* and both are refused the same way — telling them apart would confirm that a
|
|
151
|
+
* guessed id belongs to somebody else's plan.
|
|
152
|
+
*/
|
|
153
|
+
async function requireReadableSchedule(execution, sessionToken) {
|
|
154
|
+
const schedule = execution.get("schedule");
|
|
155
|
+
if (!schedule?.id)
|
|
156
|
+
return;
|
|
157
|
+
const readable = await new node_1.default.Query(index_js_3.Service_Schedule)
|
|
158
|
+
.equalTo("objectId", schedule.id)
|
|
159
|
+
.first({ sessionToken: sessionToken ?? undefined });
|
|
160
|
+
if (!readable) {
|
|
161
|
+
throw new node_1.default.Error(node_1.default.Error.OPERATION_FORBIDDEN, "Maintenance plan not found, or not assigned to you.");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
129
164
|
/**
|
|
130
165
|
* Copy the plan's steps onto the execution.
|
|
131
166
|
*
|