@capybara-hq/kernel 0.1.0-rc.145 → 0.1.0-rc.147
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/admin/extensions.controller.d.ts +0 -11
- package/dist/admin/extensions.controller.js +0 -28
- package/dist/admin/health.service.d.ts +25 -1
- package/dist/admin/health.service.js +50 -18
- package/dist/audit/full-access.d.ts +78 -0
- package/dist/audit/full-access.js +283 -0
- package/dist/automations/automations.service.d.ts +1 -0
- package/dist/automations/automations.service.js +3 -1
- package/dist/automations/calendar.js +3 -1
- package/dist/automations/grant-rules.d.ts +2 -1
- package/dist/automations/grant-rules.js +8 -1
- package/dist/automations/unattended.d.ts +13 -1
- package/dist/automations/unattended.js +13 -1
- package/dist/catalog/admin-catalog.controller.d.ts +8 -0
- package/dist/catalog/admin-catalog.controller.js +8 -2
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +8 -1
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-scope.service.d.ts +22 -2
- package/dist/catalog/catalog-scope.service.js +27 -3
- package/dist/catalog/catalog.service.js +19 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +8 -1
- package/dist/catalog/org-catalog.service.js +36 -3
- package/dist/catalog/platform-components.js +3 -2
- package/dist/catalog/platform-import-update.d.ts +2 -0
- package/dist/catalog/platform-import-update.js +8 -1
- package/dist/catalog/plugin-connectors.d.ts +11 -0
- package/dist/catalog/plugin-connectors.js +33 -0
- package/dist/catalog/plugin-import.d.ts +35 -15
- package/dist/catalog/plugin-import.js +110 -35
- package/dist/catalog/plugin-install.js +6 -0
- package/dist/catalog/provenance.d.ts +71 -0
- package/dist/catalog/provenance.js +112 -0
- package/dist/config/auto-approve.d.ts +16 -0
- package/dist/config/auto-approve.js +24 -0
- package/dist/config/capacity-presets.d.ts +243 -0
- package/dist/config/capacity-presets.js +195 -0
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +6 -1
- package/dist/config/load.js +15 -0
- package/dist/config/schema.d.ts +46 -9
- package/dist/config/schema.js +154 -30
- package/dist/ctx/create-ctx.d.ts +16 -0
- package/dist/ctx/create-ctx.js +269 -34
- package/dist/ctx/net.d.ts +5 -1
- package/dist/ctx/net.js +62 -12
- package/dist/db/kernel-schema.d.ts +31 -0
- package/dist/db/migrator.js +0 -36
- package/dist/dial-in/routes.js +1 -1
- package/dist/erasure/org-batches.js +1 -6
- package/dist/erasure/org-catalog.js +6 -2
- package/dist/erasure/org-rules.js +1 -0
- package/dist/erasure/org-worker.js +0 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/admin-ops.d.ts +14 -1
- package/dist/extensions/admin-ops.js +30 -3
- package/dist/extensions/admin-view.d.ts +21 -1
- package/dist/extensions/admin-view.js +43 -0
- package/dist/extensions/bootstrap-packages.d.ts +5 -0
- package/dist/extensions/bootstrap-packages.js +1 -1
- package/dist/extensions/bootstrap-review.d.ts +251 -0
- package/dist/extensions/bootstrap-review.js +676 -0
- package/dist/extensions/bootstrap.d.ts +21 -1
- package/dist/extensions/bootstrap.js +72 -2
- package/dist/extensions/cli.d.ts +6 -0
- package/dist/extensions/cli.js +4 -0
- package/dist/extensions/enabled.d.ts +3 -0
- package/dist/extensions/execution-realm.d.ts +96 -0
- package/dist/extensions/execution-realm.js +141 -0
- package/dist/extensions/extensions.module.js +12 -0
- package/dist/extensions/full-access-disclosure.d.ts +15 -0
- package/dist/extensions/full-access-disclosure.js +57 -0
- package/dist/extensions/grant-epoch.d.ts +9 -2
- package/dist/extensions/grant-epoch.js +13 -2
- package/dist/extensions/host.d.ts +96 -4
- package/dist/extensions/host.js +411 -33
- package/dist/extensions/installs.d.ts +18 -0
- package/dist/extensions/installs.js +28 -0
- package/dist/extensions/instance.d.ts +2 -0
- package/dist/extensions/instance.js +1 -0
- package/dist/extensions/isolated/admission.d.ts +23 -2
- package/dist/extensions/isolated/admission.js +32 -7
- package/dist/extensions/isolated/authorization.d.ts +8 -2
- package/dist/extensions/isolated/authorization.js +11 -3
- package/dist/extensions/isolated/broker.d.ts +3 -0
- package/dist/extensions/isolated/broker.js +50 -14
- package/dist/extensions/isolated/configured-package.d.ts +5 -0
- package/dist/extensions/isolated/configured-package.js +2 -0
- package/dist/extensions/isolated/lanes.d.ts +44 -3
- package/dist/extensions/isolated/lanes.js +263 -80
- package/dist/extensions/isolated/metrics.d.ts +146 -0
- package/dist/extensions/isolated/metrics.js +304 -0
- package/dist/extensions/isolated/revision.d.ts +7 -1
- package/dist/extensions/isolated/revision.js +26 -5
- package/dist/extensions/isolated/rpc.d.ts +5 -0
- package/dist/extensions/isolated/rpc.js +7 -2
- package/dist/extensions/isolated/sandbox.d.ts +23 -0
- package/dist/extensions/isolated/sandbox.js +50 -0
- package/dist/extensions/isolated/status.d.ts +79 -0
- package/dist/extensions/isolated/status.js +216 -0
- package/dist/extensions/isolated/tier.d.ts +127 -2
- package/dist/extensions/isolated/tier.js +266 -7
- package/dist/extensions/isolated/usage.d.ts +134 -0
- package/dist/extensions/isolated/usage.js +322 -0
- package/dist/extensions/ledger.d.ts +5 -0
- package/dist/extensions/ledger.js +16 -0
- package/dist/extensions/lifecycle.d.ts +42 -2
- package/dist/extensions/lifecycle.js +100 -4
- package/dist/extensions/org-config.js +11 -0
- package/dist/extensions/package.d.ts +14 -0
- package/dist/extensions/package.js +23 -0
- package/dist/extensions/permission-view.d.ts +2 -2
- package/dist/extensions/permissions.controller.d.ts +35 -0
- package/dist/extensions/permissions.controller.js +98 -0
- package/dist/extensions/permissions.schemas.d.ts +288 -0
- package/dist/extensions/permissions.schemas.js +96 -0
- package/dist/extensions/permissions.service.d.ts +116 -0
- package/dist/extensions/permissions.service.js +428 -0
- package/dist/extensions/realm-retirement.d.ts +65 -0
- package/dist/extensions/realm-retirement.js +150 -0
- package/dist/extensions/registry.d.ts +6 -0
- package/dist/extensions/registry.js +8 -0
- package/dist/extensions/review-hash.d.ts +114 -0
- package/dist/extensions/review-hash.js +145 -0
- package/dist/extensions/revision-approvals.d.ts +58 -3
- package/dist/extensions/revision-approvals.js +135 -14
- package/dist/extensions/revision-grants.d.ts +10 -0
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation-leases.d.ts +273 -0
- package/dist/extensions/revocation-leases.js +533 -0
- package/dist/extensions/revocation.d.ts +78 -0
- package/dist/extensions/revocation.js +205 -0
- package/dist/extensions/state.module.js +12 -0
- package/dist/git/run-end.d.ts +35 -7
- package/dist/git/run-end.js +87 -38
- package/dist/http/api.module.js +2 -0
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/audit.js +4 -17
- package/dist/index.d.ts +10 -2
- package/dist/index.js +10 -2
- package/dist/infra/config/kernel-config.service.d.ts +6 -0
- package/dist/infra/config/kernel-config.service.js +21 -0
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +27 -1
- package/dist/lifecycle/kernel-lifecycle.js +83 -22
- package/dist/net/private-endpoint-preflight.d.ts +159 -0
- package/dist/net/private-endpoint-preflight.js +417 -0
- package/dist/net/private-endpoints.d.ts +68 -0
- package/dist/net/private-endpoints.js +164 -0
- package/dist/net/public-address.d.ts +14 -0
- package/dist/net/public-address.js +15 -1
- package/dist/net/safe-fetch.d.ts +2 -1
- package/dist/net/safe-fetch.js +10 -3
- package/dist/overrides.d.ts +9 -1
- package/dist/overrides.js +4 -0
- package/dist/packages/official-publisher.d.ts +65 -1
- package/dist/packages/official-publisher.js +171 -46
- package/dist/packages/provenance.d.ts +11 -0
- package/dist/packages/provenance.js +24 -0
- package/dist/platform/exclusions.js +4 -4
- package/dist/platform/ops/automations.ops.js +1 -1
- package/dist/platform/ops/catalog-admin.ops.js +25 -4
- package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
- package/dist/platform/ops/extension-permissions.ops.js +159 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +2 -0
- package/dist/platform/route-schemas.js +2 -0
- package/dist/retention/purge-batch.js +10 -14
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -3
- package/dist/runtime/run-finish.d.ts +3 -3
- package/dist/runtime/run-finish.js +7 -3
- package/dist/sandbox/permission-availability.d.ts +17 -2
- package/dist/sandbox/permission-availability.js +22 -1
- package/dist/sandbox/permission-facts.js +7 -1
- package/dist/tools/builtins/sandbox/common.js +2 -0
- package/dist/tools/pipeline.d.ts +2 -1
- package/dist/tools/pipeline.js +7 -2
- package/package.json +4 -3
- package/src/migrations/0238_extension_usage.sql +40 -0
- package/src/migrations/0239_extension_replica_isolation.sql +28 -0
|
@@ -9,14 +9,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { SDK_VERSION } from "@capybara-hq/plugin-sdk";
|
|
12
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
12
|
+
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
13
13
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
14
14
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
15
|
+
import { asPlatform } from "../infra/database/org-scope.js";
|
|
15
16
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
16
17
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
17
18
|
import { canonicalJson } from "../tools/canonical-json.js";
|
|
18
19
|
import { ExtensionApprovals } from "./approvals.js";
|
|
19
20
|
import { ExtensionBlobs } from "./blobs.js";
|
|
21
|
+
import { executionDecision } from "./execution-realm.js";
|
|
22
|
+
import { deploymentConfigIsolatable } from "./isolated/admission.js";
|
|
23
|
+
import { IsolationStatusReader } from "./isolated/status.js";
|
|
24
|
+
import { uncoveredForcing } from "./isolated/tier.js";
|
|
20
25
|
import { permissionSetOfPackage, readExtensionPackage } from "./package.js";
|
|
21
26
|
import { blockingKeys, diffPermissions, permissionKeys, WARNINGS_KEY_PREFIX, } from "./permission-set.js";
|
|
22
27
|
import { reviewPermissionRows } from "./permission-view.js";
|
|
@@ -98,7 +103,17 @@ export function resolveRevisionGrant(input) {
|
|
|
98
103
|
const keys = permissionKeys(set).filter((key) => !serving.has(key));
|
|
99
104
|
const refusedKeys = keys.filter((key) => granted.has(key));
|
|
100
105
|
const ungrantedKeys = keys.filter((key) => !granted.has(key));
|
|
101
|
-
|
|
106
|
+
const widened = input.itemScope !== undefined && scopeWider(input.itemScope, own.approvalScope);
|
|
107
|
+
const uncovered = Object.fromEntries(Object.entries(input.uncovered ?? {}).filter(([, forcing]) => (forcing ?? []).length > 0));
|
|
108
|
+
if (Object.keys(uncovered).length > 0) {
|
|
109
|
+
return decide("realm_uncovered", false, {
|
|
110
|
+
generation: own.generation,
|
|
111
|
+
refusedKeys,
|
|
112
|
+
ungrantedKeys,
|
|
113
|
+
uncoveredForcing: uncovered,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return decide(keys.length > 0 ? "partially_revoked" : widened ? "scope_exceeds_grant" : "granted", true, {
|
|
102
117
|
generation: own.generation,
|
|
103
118
|
refusedKeys,
|
|
104
119
|
ungrantedKeys,
|
|
@@ -112,10 +127,32 @@ export function resolveRevisionGrant(input) {
|
|
|
112
127
|
publisher: { evidence: "none" },
|
|
113
128
|
}) ?? "continuity is recorded when the revision is promoted")
|
|
114
129
|
: undefined;
|
|
115
|
-
|
|
130
|
+
const status = missing.length > 0
|
|
131
|
+
? "missing_purposes"
|
|
132
|
+
: input.fullAccess === true
|
|
133
|
+
? "awaiting_acknowledgement"
|
|
134
|
+
: "missing_grant";
|
|
135
|
+
return decide(status, false, {
|
|
116
136
|
...(continuity !== undefined && { continuity }),
|
|
117
137
|
});
|
|
118
138
|
}
|
|
139
|
+
const SCOPE_BREADTH = { named: 0, optional: 1, all: 2 };
|
|
140
|
+
/** Whether `scope` reaches orgs `granted` does not (`all` ⊇ `optional` ⊇ `named`, named subsets). */
|
|
141
|
+
export function scopeWider(scope, granted) {
|
|
142
|
+
if (SCOPE_BREADTH[scope.mode] !== SCOPE_BREADTH[granted.mode]) {
|
|
143
|
+
return SCOPE_BREADTH[scope.mode] > SCOPE_BREADTH[granted.mode];
|
|
144
|
+
}
|
|
145
|
+
if (scope.mode !== "named" || granted.mode !== "named")
|
|
146
|
+
return false;
|
|
147
|
+
const allowed = new Set(granted.orgs);
|
|
148
|
+
return scope.orgs.some((org) => !allowed.has(org));
|
|
149
|
+
}
|
|
150
|
+
/** Grant sources made by a person's review: they lift the official pin-only refusal (#1368). */
|
|
151
|
+
const REVIEWED_SOURCES = new Set([
|
|
152
|
+
"review",
|
|
153
|
+
"operator_cli",
|
|
154
|
+
"operator_config",
|
|
155
|
+
]);
|
|
119
156
|
const SET_CACHE_ENTRIES = 512;
|
|
120
157
|
/** The installed revisions' shadow decisions, and promotion with continuity. */
|
|
121
158
|
let ExtensionRevisionApprovals = class ExtensionRevisionApprovals {
|
|
@@ -125,15 +162,19 @@ let ExtensionRevisionApprovals = class ExtensionRevisionApprovals {
|
|
|
125
162
|
approvals;
|
|
126
163
|
blobs;
|
|
127
164
|
config;
|
|
165
|
+
isolation;
|
|
128
166
|
/** Permission sets by package sha256: content-addressed, so a cached set never goes stale. */
|
|
129
167
|
sets = new Map();
|
|
130
|
-
constructor(kdb, txHost, grants, approvals, blobs, config
|
|
168
|
+
constructor(kdb, txHost, grants, approvals, blobs, config,
|
|
169
|
+
/** The deployment-wide isolation state the shadow decisions are computed for (1.4j). */
|
|
170
|
+
isolation) {
|
|
131
171
|
this.kdb = kdb;
|
|
132
172
|
this.txHost = txHost;
|
|
133
173
|
this.grants = grants;
|
|
134
174
|
this.approvals = approvals;
|
|
135
175
|
this.blobs = blobs;
|
|
136
176
|
this.config = config;
|
|
177
|
+
this.isolation = isolation;
|
|
137
178
|
}
|
|
138
179
|
/**
|
|
139
180
|
* The shadow decision of every install record. A package that cannot be read is reported as
|
|
@@ -150,6 +191,7 @@ let ExtensionRevisionApprovals = class ExtensionRevisionApprovals {
|
|
|
150
191
|
"i.required",
|
|
151
192
|
"i.approved_version",
|
|
152
193
|
"i.approved_sha512",
|
|
194
|
+
"i.catalog_item_id",
|
|
153
195
|
"p.sha512",
|
|
154
196
|
])
|
|
155
197
|
.orderBy("i.name")
|
|
@@ -157,11 +199,14 @@ let ExtensionRevisionApprovals = class ExtensionRevisionApprovals {
|
|
|
157
199
|
const snapshots = await this.approvals.all();
|
|
158
200
|
const autoApprove = this.config.get().extensionPermissions.autoApprove === true;
|
|
159
201
|
const out = [];
|
|
202
|
+
const host = (await this.isolation?.hostIsolation()) ??
|
|
203
|
+
(this.config.get().extensionHost.isolation ? "failing" : "not_configured");
|
|
160
204
|
for (const row of installs) {
|
|
161
205
|
const revision = { plugin: row.name, version: row.version, sha512: row.sha512 };
|
|
162
206
|
let set;
|
|
207
|
+
let section;
|
|
163
208
|
try {
|
|
164
|
-
set = await this.
|
|
209
|
+
({ set, section } = await this.packageOf(row.sha256));
|
|
165
210
|
}
|
|
166
211
|
catch {
|
|
167
212
|
out.push({
|
|
@@ -190,6 +235,17 @@ let ExtensionRevisionApprovals = class ExtensionRevisionApprovals {
|
|
|
190
235
|
sha512: row.approved_sha512,
|
|
191
236
|
})
|
|
192
237
|
: undefined;
|
|
238
|
+
const decision = executionDecision({
|
|
239
|
+
keys: permissionKeys(set),
|
|
240
|
+
server: true,
|
|
241
|
+
client: section.client !== undefined ? {} : undefined,
|
|
242
|
+
host,
|
|
243
|
+
configSchemaIsolatable: deploymentConfigIsolatable(section),
|
|
244
|
+
});
|
|
245
|
+
// awaiting_acknowledgement only where a person's catalog review grants it: a required
|
|
246
|
+
// (bootstrap) install is granted by the bootstrap approval (1.3c), and unknown keys block
|
|
247
|
+
// any review
|
|
248
|
+
const fullAccess = Object.keys(decision.fullAccess).length > 0 && decision.confirmable && !row.required;
|
|
193
249
|
out.push(resolveRevisionGrant({
|
|
194
250
|
revision,
|
|
195
251
|
set,
|
|
@@ -197,10 +253,34 @@ let ExtensionRevisionApprovals = class ExtensionRevisionApprovals {
|
|
|
197
253
|
own,
|
|
198
254
|
approved,
|
|
199
255
|
legacy: legacyDecision(set, snapshots.get(row.name), autoApprove),
|
|
256
|
+
fullAccess,
|
|
257
|
+
// 1.3b's one realm coverage rule: a realm whose forcing keys the grant does not cover
|
|
258
|
+
// would not serve
|
|
259
|
+
uncovered: own ? uncoveredForcing(decision, own) : undefined,
|
|
260
|
+
itemScope: own ? await this.itemScope(row.catalog_item_id) : undefined,
|
|
200
261
|
}));
|
|
201
262
|
}
|
|
202
263
|
return out;
|
|
203
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* The live grant (approved or partially_revoked) of exactly this revision when a person made it:
|
|
267
|
+
* source review, operator_cli or operator_config, whatever its publisher evidence (pin_only and
|
|
268
|
+
* none included). Undefined otherwise: no grant, a revoked or retired one, a continuity or auto
|
|
269
|
+
* grant. Admission (plan task 1.3b, `isolated/tier.ts`) accepts an official revision without a
|
|
270
|
+
* publisher proof when this returns a grant (#1368). A plain read; safe on every replica.
|
|
271
|
+
*/
|
|
272
|
+
async reviewedGrant(revision) {
|
|
273
|
+
const grant = await this.grants.live(revision);
|
|
274
|
+
return grant && REVIEWED_SOURCES.has(grant.source) ? grant : undefined;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* {@link promote} for an install that has just moved to `candidate` in the caller's transaction
|
|
278
|
+
* (`ExtensionAdminOps.install`): the package was read before it, so its permission set is given
|
|
279
|
+
* and no object storage call holds the transaction. A downgrade is a rollback.
|
|
280
|
+
*/
|
|
281
|
+
async promoteInstalled(candidate, set, kind) {
|
|
282
|
+
return this.promoteIn(candidate, { publisher: { evidence: "none" } }, kind, purposeRowsOf(set));
|
|
283
|
+
}
|
|
204
284
|
/** The facts the enforcing start gate would act on; computed and reported, never refused. */
|
|
205
285
|
async startGate() {
|
|
206
286
|
const all = await this.decisions();
|
|
@@ -239,15 +319,26 @@ let ExtensionRevisionApprovals = class ExtensionRevisionApprovals {
|
|
|
239
319
|
return this.promoteIn(candidate, evidence, kind, purposes);
|
|
240
320
|
}
|
|
241
321
|
async promoteIn(candidate, evidence, kind, purposes) {
|
|
242
|
-
const own = await this.grants.live(candidate);
|
|
243
|
-
if (own) {
|
|
244
|
-
await this.grants.promote(candidate);
|
|
245
|
-
return { status: "promoted", grant: own, continued: false };
|
|
246
|
-
}
|
|
247
322
|
const pending = async (reason) => {
|
|
248
323
|
await this.grants.setCandidate(candidate.plugin, candidate);
|
|
249
324
|
return { status: "pending", reason };
|
|
250
325
|
};
|
|
326
|
+
const own = await this.grants.live(candidate);
|
|
327
|
+
if (own) {
|
|
328
|
+
try {
|
|
329
|
+
// rechecked under the grant's row lock: a revocation committed since the read leaves the
|
|
330
|
+
// revision a candidate, it never fails the install that called (shadow mode)
|
|
331
|
+
await this.grants.promote(candidate);
|
|
332
|
+
}
|
|
333
|
+
catch (err) {
|
|
334
|
+
if (err instanceof RevisionGrantError &&
|
|
335
|
+
(err.code === "not_found" || err.code === "terminal")) {
|
|
336
|
+
return pending(err.message);
|
|
337
|
+
}
|
|
338
|
+
throw err;
|
|
339
|
+
}
|
|
340
|
+
return { status: "promoted", grant: own, continued: false };
|
|
341
|
+
}
|
|
251
342
|
const newest = await this.grants.get(candidate);
|
|
252
343
|
if (newest)
|
|
253
344
|
return pending(`its grant is ${newest.state}; it needs a new review`);
|
|
@@ -309,6 +400,10 @@ let ExtensionRevisionApprovals = class ExtensionRevisionApprovals {
|
|
|
309
400
|
return row?.sha256;
|
|
310
401
|
}
|
|
311
402
|
async setOf(sha256) {
|
|
403
|
+
return (await this.packageOf(sha256)).set;
|
|
404
|
+
}
|
|
405
|
+
/** A package's permission set and section, cached by sha256 (content-addressed, never stale). */
|
|
406
|
+
async packageOf(sha256) {
|
|
312
407
|
const cached = this.sets.get(sha256);
|
|
313
408
|
if (cached)
|
|
314
409
|
return cached;
|
|
@@ -316,14 +411,38 @@ let ExtensionRevisionApprovals = class ExtensionRevisionApprovals {
|
|
|
316
411
|
maxBytes: this.config.get().packages.maxBytes,
|
|
317
412
|
hostSdkVersion: SDK_VERSION,
|
|
318
413
|
});
|
|
319
|
-
const
|
|
414
|
+
const entry = { set: permissionSetOfPackage(pkg), section: pkg.section };
|
|
320
415
|
// a bound on memory only: a dropped entry is read again from the package store
|
|
321
416
|
if (this.sets.size >= SET_CACHE_ENTRIES)
|
|
322
417
|
this.sets.clear();
|
|
323
|
-
this.sets.set(sha256,
|
|
324
|
-
return
|
|
418
|
+
this.sets.set(sha256, entry);
|
|
419
|
+
return entry;
|
|
420
|
+
}
|
|
421
|
+
/** The current org scope of the catalog item an install comes from, if any. */
|
|
422
|
+
async itemScope(itemId) {
|
|
423
|
+
if (itemId === null)
|
|
424
|
+
return undefined;
|
|
425
|
+
const item = await this.kdb.db
|
|
426
|
+
.selectFrom("catalog_items")
|
|
427
|
+
.select("scope")
|
|
428
|
+
.where("id", "=", itemId)
|
|
429
|
+
.executeTakeFirst();
|
|
430
|
+
if (item === undefined)
|
|
431
|
+
return undefined;
|
|
432
|
+
if (item.scope !== "named")
|
|
433
|
+
return { mode: item.scope };
|
|
434
|
+
// org-filter: deployment-wide: the item's whole named list (spans orgs), keyed by its item id
|
|
435
|
+
const orgs = await asPlatform("read the named scope of the catalog item of an install", () => this.kdb.db
|
|
436
|
+
.selectFrom("catalog_item_scope_orgs")
|
|
437
|
+
.select("org_id")
|
|
438
|
+
.where("item_id", "=", itemId)
|
|
439
|
+
.execute());
|
|
440
|
+
return { mode: "named", orgs: orgs.map((r) => r.org_id) };
|
|
325
441
|
}
|
|
326
442
|
};
|
|
443
|
+
__decorate([
|
|
444
|
+
Transactional({ propagation: "mandatory" })
|
|
445
|
+
], ExtensionRevisionApprovals.prototype, "promoteInstalled", null);
|
|
327
446
|
__decorate([
|
|
328
447
|
Transactional()
|
|
329
448
|
], ExtensionRevisionApprovals.prototype, "promoteIn", null);
|
|
@@ -334,7 +453,9 @@ ExtensionRevisionApprovals = __decorate([
|
|
|
334
453
|
__param(2, Inject(ExtensionRevisionGrants)),
|
|
335
454
|
__param(3, Inject(ExtensionApprovals)),
|
|
336
455
|
__param(4, Inject(ExtensionBlobs)),
|
|
337
|
-
__param(5, Inject(KernelConfigService))
|
|
456
|
+
__param(5, Inject(KernelConfigService)),
|
|
457
|
+
__param(6, Optional()),
|
|
458
|
+
__param(6, Inject(IsolationStatusReader))
|
|
338
459
|
], ExtensionRevisionApprovals);
|
|
339
460
|
export { ExtensionRevisionApprovals };
|
|
340
461
|
/**
|
|
@@ -41,11 +41,21 @@ export interface PurposeRow {
|
|
|
41
41
|
zh: string;
|
|
42
42
|
en: string;
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* A verified publisher identity, normalized by `catalog/provenance.ts`. Continuity compares it
|
|
46
|
+
* exactly: a changed repository, its ids, the workflow or the ref class needs a new review.
|
|
47
|
+
*/
|
|
44
48
|
export interface PublisherIdentity {
|
|
45
49
|
issuer: string;
|
|
50
|
+
/** `<repository>/<workflow>`: who builds, without the ref (that is `refClass`). */
|
|
46
51
|
identity: string;
|
|
47
52
|
repository?: string;
|
|
53
|
+
/** The repository's and owner's numeric ids: a repository recreated under the same name differs. */
|
|
54
|
+
repositoryId?: string;
|
|
55
|
+
ownerId?: string;
|
|
48
56
|
workflow?: string;
|
|
57
|
+
/** A branch ref exactly (`refs/heads/main`), or `refs/tags/*` for any release tag. */
|
|
58
|
+
refClass?: string;
|
|
49
59
|
}
|
|
50
60
|
export interface NewRevisionGrant {
|
|
51
61
|
revision: RevisionIdentity;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { PublisherEvidence } from "../catalog/provenance.js";
|
|
2
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
4
|
+
import { type HostIsolation } from "./execution-realm.js";
|
|
5
|
+
import { IsolationStatusReader } from "./isolated/status.js";
|
|
6
|
+
import type { ExtensionPackage } from "./package.js";
|
|
7
|
+
import { type PermissionSet } from "./permission-set.js";
|
|
8
|
+
import { type ReviewDisplay } from "./review-hash.js";
|
|
9
|
+
import { type ApprovalScope, type ExecutionRealm, ExtensionRevisionGrants, type RevisionGrant, type RevisionIdentity } from "./revision-grants.js";
|
|
10
|
+
/**
|
|
11
|
+
* The permission review of one extension revision at catalog prepare and confirm (extension
|
|
12
|
+
* permission model spec, "Review, updates and provenance"; plan tasks 1.3a and 1.3d).
|
|
13
|
+
*
|
|
14
|
+
* Prepare binds the 1.2e display and its `review:v1:` hash: identity, every permission and purpose
|
|
15
|
+
* row, the previous approval and the diff against it, the org scope, the approver authority, the
|
|
16
|
+
* risk contract version, the publisher evidence and the execution realms. It also decides whether
|
|
17
|
+
* a confirmation re-consents (a `review` grant, `super_admin`) or continues the install's approved
|
|
18
|
+
* grant (a `continuity` grant carrying its authority): re-consent is exactly "not a continuation"
|
|
19
|
+
* (the store's `continuityProblem`): a new or broadened key, informational rows included, a
|
|
20
|
+
* changed purpose in either language, a widened org scope, full access not covered by the
|
|
21
|
+
* approved grant, or a publisher that is not the same verified one (pin-only and unverified
|
|
22
|
+
* evidence never continue, #1368: they get the same review and decision with no continuity).
|
|
23
|
+
*
|
|
24
|
+
* Confirm recomputes the display with the prepared scope: any drift (the approved grant revoked
|
|
25
|
+
* or replaced, the host's isolation, the evidence) makes the review stale. The grant binds the
|
|
26
|
+
* display with the scope actually chosen.
|
|
27
|
+
*
|
|
28
|
+
* Shadow mode until plan task 1.5a: the grant is minted and the decisions computed while the
|
|
29
|
+
* legacy snapshot keeps governing admission, so a confirmation that cannot mint a grant still
|
|
30
|
+
* completes the import; the result says why. A full-access review grant needs one explicit
|
|
31
|
+
* acknowledgement per affected realm bound to the review hash (1.3d): a missing one only skips the
|
|
32
|
+
* grant until 1.5a, a wrong one (another hash, a missing or extra realm) refuses the confirm.
|
|
33
|
+
*/
|
|
34
|
+
export interface RevisionReview {
|
|
35
|
+
revision: RevisionIdentity;
|
|
36
|
+
publisher: PublisherEvidence;
|
|
37
|
+
evidenceDigest: string | null;
|
|
38
|
+
/** The org scope the display was prepared with; confirm rechecks against it. */
|
|
39
|
+
preparedScope: ApprovalScope;
|
|
40
|
+
display: ReviewDisplay;
|
|
41
|
+
/** `review:v1:<sha256>` of {@link display}: what a full-access acknowledgement binds. */
|
|
42
|
+
hash: string;
|
|
43
|
+
/**
|
|
44
|
+
* `granted`: this exact revision has a live grant already, which a confirmation keeps;
|
|
45
|
+
* `continuity`: a confirmation continues the install's approved grant, with no re-consent;
|
|
46
|
+
* `review`: it records a new review grant, `reason` says why it is not a continuation.
|
|
47
|
+
*/
|
|
48
|
+
consent: {
|
|
49
|
+
kind: "granted";
|
|
50
|
+
generation: number;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "continuity";
|
|
53
|
+
} | {
|
|
54
|
+
kind: "review";
|
|
55
|
+
reason: string;
|
|
56
|
+
};
|
|
57
|
+
/** The realms whose full access a review grant needs acknowledged, sorted ([] for continuity). */
|
|
58
|
+
acknowledge: ExecutionRealm[];
|
|
59
|
+
/** Why no grant can be minted from this review (missing purposes, unknown keys). */
|
|
60
|
+
blocked?: string;
|
|
61
|
+
}
|
|
62
|
+
/** The per-realm acknowledgement a confirm sends (1.3d). */
|
|
63
|
+
export interface FullAccessAcknowledgement {
|
|
64
|
+
/** The {@link RevisionReview.hash} the approver confirmed. */
|
|
65
|
+
reviewHash: string;
|
|
66
|
+
realms: ExecutionRealm[];
|
|
67
|
+
}
|
|
68
|
+
/** What a confirmation did with the grant. */
|
|
69
|
+
export type RevisionGrantOutcome = {
|
|
70
|
+
status: "granted";
|
|
71
|
+
generation: number;
|
|
72
|
+
} | {
|
|
73
|
+
status: "kept";
|
|
74
|
+
generation: number;
|
|
75
|
+
} | {
|
|
76
|
+
status: "continued";
|
|
77
|
+
generation: number;
|
|
78
|
+
fullAccess: ExecutionRealm[];
|
|
79
|
+
} | {
|
|
80
|
+
status: "skipped";
|
|
81
|
+
reason: string;
|
|
82
|
+
};
|
|
83
|
+
export interface RevisionReviewInput {
|
|
84
|
+
revision: RevisionIdentity;
|
|
85
|
+
pkg: Pick<ExtensionPackage, "section">;
|
|
86
|
+
set: PermissionSet;
|
|
87
|
+
host: HostIsolation;
|
|
88
|
+
approvalScope: ApprovalScope;
|
|
89
|
+
publisher: PublisherEvidence;
|
|
90
|
+
evidenceDigest?: string | undefined;
|
|
91
|
+
/** The live grant of the install's approved revision, if any. */
|
|
92
|
+
previous?: RevisionGrant | undefined;
|
|
93
|
+
/** The newest grant of this exact revision in any state, if any. */
|
|
94
|
+
own?: RevisionGrant | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* The authority a review grant would exercise: `super_admin` (a person on the web, default) or
|
|
97
|
+
* `operator` (`capybara extensions approve`). The display binds it.
|
|
98
|
+
*/
|
|
99
|
+
authority?: "super_admin" | "operator" | undefined;
|
|
100
|
+
}
|
|
101
|
+
/** The review of one revision. Pure. */
|
|
102
|
+
export declare function buildRevisionReview(input: RevisionReviewInput): RevisionReview;
|
|
103
|
+
/**
|
|
104
|
+
* Checks a full-access acknowledgement sent with a confirm against the prepared review (1.3d).
|
|
105
|
+
* Absent is allowed until plan task 1.5a (the grant is skipped); present, it must name the
|
|
106
|
+
* review's hash and exactly the realms the review needs acknowledged, else 409
|
|
107
|
+
* `plugin.full_access_ack_invalid`.
|
|
108
|
+
*/
|
|
109
|
+
export declare function checkAcknowledgement(review: RevisionReview, ack: FullAccessAcknowledgement | undefined): void;
|
|
110
|
+
/** Prepare and confirm of revision reviews, and the grant a confirmation records. */
|
|
111
|
+
export declare class RevisionReviews {
|
|
112
|
+
private readonly kdb;
|
|
113
|
+
readonly txHost: TransactionHost;
|
|
114
|
+
private readonly grants;
|
|
115
|
+
/** The host profile a review binds (plan task 1.4j): configured or not. */
|
|
116
|
+
private readonly isolation;
|
|
117
|
+
constructor(kdb: KernelDb, txHost: TransactionHost, grants: ExtensionRevisionGrants,
|
|
118
|
+
/** The host profile a review binds (plan task 1.4j): configured or not. */
|
|
119
|
+
isolation: Pick<IsolationStatusReader, "reviewProfile">);
|
|
120
|
+
/** The live grant of the install's approved revision, if any. */
|
|
121
|
+
previousGrant(plugin: string): Promise<RevisionGrant | undefined>;
|
|
122
|
+
/** The review of a revision as prepare shows it. */
|
|
123
|
+
prepare(input: Omit<RevisionReviewInput, "host" | "previous">): Promise<RevisionReview>;
|
|
124
|
+
/**
|
|
125
|
+
* At confirm, in the confirm's transaction (under the extension's install lock): rechecks the
|
|
126
|
+
* prepared review against the current previous grant and host, then records the grant for the
|
|
127
|
+
* chosen scope. Returns `stale` when the review no longer holds; never throws for a grant that
|
|
128
|
+
* cannot be recorded in shadow mode (the outcome says why).
|
|
129
|
+
*/
|
|
130
|
+
confirm(input: {
|
|
131
|
+
actor: string | null;
|
|
132
|
+
actorTokenId?: string | undefined;
|
|
133
|
+
prepared: RevisionReview;
|
|
134
|
+
pkg: Pick<ExtensionPackage, "section">;
|
|
135
|
+
set: PermissionSet;
|
|
136
|
+
approvalScope: ApprovalScope;
|
|
137
|
+
ack: FullAccessAcknowledgement | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* The operator approves from the CLI (`actor` null): an `operator_cli` grant, prepared with the
|
|
140
|
+
* `operator` authority. Without it a confirm without a person records none.
|
|
141
|
+
*/
|
|
142
|
+
operator?: boolean | undefined;
|
|
143
|
+
}): Promise<RevisionGrantOutcome | "stale">;
|
|
144
|
+
}
|