@capybara-hq/kernel 0.1.0-rc.53 → 0.1.0-rc.55
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/admin.schemas.d.ts +11 -1
- package/dist/catalog/catalog.module.js +1 -1
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/requests.service.d.ts +5 -5
- package/dist/catalog/requests.service.js +9 -9
- package/dist/channels/cards.d.ts +4 -3
- package/dist/channels/cards.js +25 -16
- package/dist/channels/phrases.d.ts +15 -4
- package/dist/channels/phrases.js +15 -1
- package/dist/config/load.d.ts +26 -7
- package/dist/config/load.js +60 -9
- package/dist/config/permission-migration.d.ts +17 -9
- package/dist/config/permission-migration.js +60 -9
- package/dist/config/schema.d.ts +15 -1
- package/dist/config/schema.js +66 -11
- package/dist/conversations/events.d.ts +247 -5
- package/dist/conversations/events.js +127 -16
- package/dist/conversations/permission-profiles.controller.d.ts +12 -2
- package/dist/conversations/permission-profiles.service.d.ts +12 -2
- package/dist/conversations/permission-profiles.service.js +11 -4
- package/dist/db/kernel-schema.d.ts +18 -2
- package/dist/devices/device-projects.service.d.ts +1 -1
- package/dist/devices/device-projects.service.js +6 -6
- package/dist/devices/devices.controller.d.ts +10 -8
- package/dist/devices/devices.controller.js +14 -18
- package/dist/devices/devices.schemas.d.ts +5 -5
- package/dist/devices/devices.schemas.js +5 -5
- package/dist/devices/devices.service.d.ts +188 -175
- package/dist/devices/devices.service.js +284 -292
- package/dist/devices/dto.d.ts +43 -23
- package/dist/devices/dto.js +45 -49
- package/dist/devices/project-rules.d.ts +0 -10
- package/dist/devices/project-rules.js +0 -5
- package/dist/errors.d.ts +43 -19
- package/dist/errors.js +43 -19
- package/dist/evals/reconstruct.d.ts +12 -3
- package/dist/evals/reconstruct.js +10 -6
- package/dist/evals/recorded-permission-context.d.ts +6 -4
- package/dist/evals/recorded-permission-context.js +15 -9
- package/dist/evals/run-replay.d.ts +6 -1
- package/dist/evals/run-replay.js +7 -2
- package/dist/evals/worker.js +3 -1
- package/dist/http/api.module.js +8 -0
- package/dist/http/app.js +9 -0
- package/dist/http/meta.controller.d.ts +33 -0
- package/dist/http/meta.controller.js +72 -0
- package/dist/identity/app-auth.controller.d.ts +25 -0
- package/dist/identity/app-auth.controller.js +64 -0
- package/dist/identity/app-auth.d.ts +66 -0
- package/dist/identity/app-auth.js +203 -0
- package/dist/identity/app-auth.schemas.d.ts +47 -0
- package/dist/identity/app-auth.schemas.js +43 -0
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -1
- package/dist/identity/settings.d.ts +45 -18
- package/dist/identity/settings.js +151 -51
- package/dist/infra/config/kernel-config.service.d.ts +1 -1
- package/dist/infra/config/kernel-config.service.js +19 -5
- package/dist/infra/outbox/registry.d.ts +14 -0
- package/dist/infra/outbox/registry.js +15 -0
- package/dist/infra/throttler/named-throttlers.d.ts +3 -2
- package/dist/infra/throttler/named-throttlers.js +14 -2
- package/dist/local-devices/device-auth.controller.d.ts +1 -1
- package/dist/local-devices/device-auth.controller.js +1 -1
- package/dist/local-devices/device-auth.d.ts +4 -4
- package/dist/local-devices/device-auth.js +1 -1
- package/dist/local-devices/device-policy.service.d.ts +18 -9
- package/dist/local-devices/device-policy.service.js +21 -61
- package/dist/local-devices/device-routes.d.ts +3 -1
- package/dist/local-devices/device-routes.js +15 -4
- package/dist/local-devices/instance-bindings.js +5 -2
- package/dist/local-devices/local-device-gateway.d.ts +2 -2
- package/dist/local-devices/local-device-gateway.js +3 -3
- package/dist/local-devices/local-device-provider.d.ts +4 -4
- package/dist/local-devices/local-device-provider.js +23 -9
- package/dist/local-devices/local-devices.module.d.ts +1 -1
- package/dist/local-devices/local-devices.module.js +1 -1
- package/dist/local-devices/machines.d.ts +40 -16
- package/dist/local-devices/machines.js +89 -61
- package/dist/local-devices/owner-report.d.ts +16 -14
- package/dist/local-devices/owner-report.js +24 -30
- package/dist/local-devices/owner-reports.js +26 -8
- package/dist/local-devices/policy-summary.d.ts +25 -44
- package/dist/local-devices/policy-summary.js +26 -71
- package/dist/local-devices/relay.d.ts +6 -6
- package/dist/local-devices/relay.js +10 -8
- package/dist/net/public-address.d.ts +1 -1
- package/dist/net/public-address.js +5 -2
- package/dist/orgs/device-network-setting.d.ts +82 -0
- package/dist/orgs/device-network-setting.js +142 -0
- package/dist/orgs/settings.service.d.ts +103 -66
- package/dist/orgs/settings.service.js +201 -137
- package/dist/overrides.d.ts +5 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +24 -1
- package/dist/platform/operation.js +2 -2
- package/dist/platform/ops/admin.ops.js +20 -11
- package/dist/platform/ops/devices.ops.js +70 -5
- package/dist/platform/ops/org-settings.ops.js +10 -6
- package/dist/platform/ops/orgs.ops.js +2 -1
- package/dist/platform/ops/platform-icons.ops.d.ts +14 -0
- package/dist/platform/ops/platform-icons.ops.js +117 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +3 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/runtime/context/permission-profile.d.ts +17 -8
- package/dist/runtime/context/permission-profile.js +126 -45
- package/dist/runtime/maintenance.d.ts +5 -2
- package/dist/runtime/maintenance.js +15 -4
- package/dist/runtime/permission-context.service.d.ts +1 -1
- package/dist/runtime/permission-context.service.js +5 -3
- package/dist/runtime/project/knowledge.d.ts +5 -4
- package/dist/runtime/project/knowledge.js +2 -1
- package/dist/runtime/project/knowledge.service.js +16 -13
- package/dist/sandbox/cloud-permission-snapshot.js +22 -3
- package/dist/sandbox/device-sandbox-settings.d.ts +230 -0
- package/dist/sandbox/device-sandbox-settings.js +470 -0
- package/dist/sandbox/device-sandbox.d.ts +187 -0
- package/dist/sandbox/device-sandbox.js +236 -0
- package/dist/sandbox/held-operations.js +15 -7
- package/dist/sandbox/modes.d.ts +49 -24
- package/dist/sandbox/modes.js +27 -19
- package/dist/sandbox/operation-authority-types.d.ts +6 -5
- package/dist/sandbox/operation-authority-types.js +7 -8
- package/dist/sandbox/operation-authority.d.ts +23 -9
- package/dist/sandbox/operation-authority.js +179 -97
- package/dist/sandbox/permission-auto-grants.d.ts +42 -0
- package/dist/sandbox/permission-auto-grants.js +145 -0
- package/dist/sandbox/permission-call-grants.d.ts +12 -4
- package/dist/sandbox/permission-call-grants.js +84 -35
- package/dist/sandbox/permission-call-grants.module.js +10 -3
- package/dist/sandbox/permission-call-types.d.ts +39 -5
- package/dist/sandbox/permission-ceiling-writes.d.ts +29 -3
- package/dist/sandbox/permission-ceiling-writes.js +38 -4
- package/dist/sandbox/permission-config-publication.d.ts +44 -2
- package/dist/sandbox/permission-config-publication.js +230 -59
- package/dist/sandbox/permission-context-types.d.ts +2 -2
- package/dist/sandbox/permission-facts.d.ts +144 -15
- package/dist/sandbox/permission-facts.js +258 -70
- package/dist/sandbox/permission-runtime-reports.d.ts +5 -4
- package/dist/sandbox/permission-runtime-reports.js +19 -29
- package/dist/sandbox/review/classifier.d.ts +8 -0
- package/dist/sandbox/review/classifier.js +10 -0
- package/dist/sandbox/review/permission-candidate.d.ts +69 -5
- package/dist/sandbox/review/permission-candidate.js +153 -30
- package/dist/sandbox/review/review.service.d.ts +19 -3
- package/dist/sandbox/review/review.service.js +59 -11
- package/dist/sandbox/review/rules.js +23 -3
- package/dist/sandbox/sandbox.service.d.ts +29 -11
- package/dist/sandbox/sandbox.service.js +51 -26
- package/dist/skills/invoke.js +3 -2
- package/dist/themes/platform-icon-objects.d.ts +51 -0
- package/dist/themes/platform-icon-objects.js +113 -0
- package/dist/themes/platform-icon-public.controller.d.ts +17 -0
- package/dist/themes/platform-icon-public.controller.js +58 -0
- package/dist/themes/platform-icon.controller.d.ts +22 -0
- package/dist/themes/platform-icon.controller.js +65 -0
- package/dist/themes/platform-icon.schemas.d.ts +48 -0
- package/dist/themes/platform-icon.schemas.js +53 -0
- package/dist/themes/platform-icon.service.d.ts +83 -0
- package/dist/themes/platform-icon.service.js +301 -0
- package/dist/themes/themes.module.d.ts +4 -1
- package/dist/themes/themes.module.js +9 -4
- package/dist/tools/approvals.service.d.ts +26 -116
- package/dist/tools/approvals.service.js +42 -346
- package/dist/tools/builtins/sandbox/bash.d.ts +16 -3
- package/dist/tools/builtins/sandbox/bash.js +80 -28
- package/dist/tools/builtins/sandbox/common.d.ts +39 -14
- package/dist/tools/builtins/sandbox/common.js +47 -24
- package/dist/tools/builtins/sandbox/deliver.js +7 -4
- package/dist/tools/builtins/skill-load.d.ts +2 -2
- package/dist/tools/builtins/skill-load.js +4 -3
- package/dist/tools/device-op-resolver.d.ts +4 -10
- package/dist/tools/device-op-resolver.js +8 -19
- package/dist/tools/network-asks.d.ts +52 -15
- package/dist/tools/network-asks.js +55 -25
- package/dist/tools/pipeline.d.ts +26 -14
- package/dist/tools/pipeline.js +144 -61
- package/dist/tools/registry.d.ts +6 -0
- package/dist/tools/tools.module.js +1 -1
- package/package.json +4 -4
- package/src/migrations/0164_platform_icons.sql +10 -0
- package/src/migrations/0165_device_network_columns.sql +50 -0
- package/src/migrations/0166_permission_grant_full_access.sql +17 -0
- package/src/migrations/0167_device_network_backfill.sql +32 -0
- package/src/migrations/0168_binding_installed_connection.sql +6 -0
- package/dist/orgs/cloud-network-setting.d.ts +0 -33
- package/dist/orgs/cloud-network-setting.js +0 -47
- package/dist/sandbox/platform-full-access.d.ts +0 -110
- package/dist/sandbox/platform-full-access.js +0 -198
|
@@ -94,14 +94,14 @@ export declare class MachinesService {
|
|
|
94
94
|
* never said hello has no known roots: nothing to compare. The reported features (known ones
|
|
95
95
|
* only) and local policy summary (null when absent or malformed) replace the stored ones, so a
|
|
96
96
|
* program downgraded to one without them is no longer sent what it cannot do. The summary is the
|
|
97
|
-
* device's
|
|
98
|
-
*
|
|
97
|
+
* device's sandbox allowlist; a change of what the owner sets, made on the machine while it was
|
|
98
|
+
* away, is audited `device.policy_changed` (the owner ceiling's, `device.owner_ceiling_changed`)
|
|
99
99
|
* ({@link reportedPolicy}). The outcomes of its recent policy ops (`recentOps`) backfill the
|
|
100
100
|
* platform's ops still pending on the row ({@link backfillOps}). The owner's home directory
|
|
101
101
|
* (`home`) replaces the stored one too (null when the hello has none).
|
|
102
102
|
*/
|
|
103
|
-
recordHello(machineId: string, hello: LegacyDeviceHello,
|
|
104
|
-
/** A
|
|
103
|
+
recordHello(machineId: string, hello: LegacyDeviceHello,
|
|
104
|
+
/** A protocol 4 hello's authenticated owner report (B2): it, not the summary, decides publication. */
|
|
105
105
|
owner?: {
|
|
106
106
|
report: DeviceOwnerCeiling;
|
|
107
107
|
connectionId: string | null;
|
|
@@ -118,26 +118,50 @@ export declare class MachinesService {
|
|
|
118
118
|
* transaction, with the machine's row locked; an op already reported is not owed again.
|
|
119
119
|
*/
|
|
120
120
|
private backfillOps;
|
|
121
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* A protocol 4 hello on an authenticated connection: validated as a frame, then recorded like
|
|
123
|
+
* {@link recordHello} with its owner report and the connection it arrived on.
|
|
124
|
+
*/
|
|
122
125
|
recordHelloV3(machineId: string, hello: DeviceHello, connectionId?: string | null): Promise<void>;
|
|
123
126
|
/**
|
|
124
127
|
* The runtime identity a v3 hello may attest (B4): only a bound hello re-reporting exactly the
|
|
125
128
|
* identity of the current instance generation's installed binding. An unbound hello, another
|
|
126
129
|
* generation or a binding still awaiting the device attests nothing (unprobed; it never finishes
|
|
127
|
-
* an installation, which only the bindInstance answer does).
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
+
* an installation, which only the bindInstance answer does).
|
|
131
|
+
*
|
|
132
|
+
* The machine the current generation was installed for no longer attesting it means its program
|
|
133
|
+
* can never serve that generation again: a restarted program whose verified runtime differs from
|
|
134
|
+
* the one its stored binding attested (every capybara-device upgrade changes the runtime bytes)
|
|
135
|
+
* starts unbound, and the device refuses to rebind a generation under a changed runtime. The
|
|
136
|
+
* instance is then replaced ({@link replaceUnattestedLocked}), so the next use creates and binds
|
|
137
|
+
* a new generation under the new evidence instead of staying unprobed until a new login.
|
|
138
|
+
*
|
|
139
|
+
* A connection answers bindInstance before its own hello is recorded (the hello is recorded
|
|
140
|
+
* after `ready`), so a binding installed on the hello's own connection is newer than the hello:
|
|
141
|
+
* it is left as it is (`installed-here`), never replaced by the evidence the hello predates.
|
|
130
142
|
*/
|
|
131
143
|
private boundIdentityLocked;
|
|
144
|
+
/**
|
|
145
|
+
* Replaces a local instance whose installed binding its machine no longer attests (under the
|
|
146
|
+
* device authority writer): the row forgets its instance (status `none`, no handle) and its
|
|
147
|
+
* fence moves on, so a lifecycle holder of the old instance fails its next write; the device's
|
|
148
|
+
* admission epoch advances, revoking every admitted or started operation of the old generation.
|
|
149
|
+
* The files stay (the same machine and directory): the next use creates a new instance on them,
|
|
150
|
+
* which the kernel binds under the program's new runtime evidence. Full consent is left to that
|
|
151
|
+
* install, which resets it when the proven environment fingerprint changed: a fingerprint a
|
|
152
|
+
* hello merely names proves nothing, and nothing is admitted before the install records a
|
|
153
|
+
* report, so resetting here too would reset twice.
|
|
154
|
+
*/
|
|
155
|
+
private replaceUnattestedLocked;
|
|
132
156
|
/**
|
|
133
157
|
* Stores the local policy summary a connected program pushed after its hello (a `policy` frame:
|
|
134
|
-
* its policy file changed on the machine: its
|
|
135
|
-
*
|
|
136
|
-
*
|
|
158
|
+
* its policy file changed on the machine: its sandbox allowlist), read and audited as the hello's
|
|
159
|
+
* ({@link recordHello}). A change the owner made on the machine is audited
|
|
160
|
+
* `device.policy_changed`. The next sandbox call then records a
|
|
137
161
|
* new `device_paths` event when the facts the model is told changed. A revoked machine is left
|
|
138
162
|
* alone.
|
|
139
163
|
*/
|
|
140
|
-
recordPolicy(machineId: string, summary: DeviceLocalPolicySummary | undefined
|
|
164
|
+
recordPolicy(machineId: string, summary: DeviceLocalPolicySummary | undefined): Promise<void>;
|
|
141
165
|
/**
|
|
142
166
|
* A staged (v3) `policy` frame (B2): the summary is kept for the device page like protocol 2's,
|
|
143
167
|
* while the authenticated owner report alone decides what changed ({@link OwnerReports}).
|
|
@@ -148,10 +172,10 @@ export declare class MachinesService {
|
|
|
148
172
|
* null. When both the stored and the reported summary are readable and what the owner sets
|
|
149
173
|
* changed ({@link localPolicyDiff}) by no `policy` op the platform sent ({@link opExplains}: its
|
|
150
174
|
* answer may come after the machine's own report), the owner changed it on the machine
|
|
151
|
-
* (`capybara-device
|
|
152
|
-
* `device.policy_changed
|
|
153
|
-
*
|
|
154
|
-
* (the op's answer is). A summary reported again is no change. Runs in the caller's transaction,
|
|
175
|
+
* (`capybara-device policy add|remove allowedDomains ...`): the host changes are audited
|
|
176
|
+
* `device.policy_changed`, `via: "device"`, so the device page lists them beside the platform's
|
|
177
|
+
* changes (an owner ceiling change is the owner report writer's, `device.owner_ceiling_changed`);
|
|
178
|
+
* one an op explains is not audited here (the op's answer is). A summary reported again is no change. Runs in the caller's transaction,
|
|
155
179
|
* with the machine's row locked.
|
|
156
180
|
*/
|
|
157
181
|
private reportedPolicy;
|
|
@@ -28,7 +28,7 @@ import { deviceNotFound } from "../sandbox/sandbox.service.js";
|
|
|
28
28
|
import { deviceRevokedTopic } from "./keys.js";
|
|
29
29
|
import { OwnerReports } from "./owner-reports.js";
|
|
30
30
|
import { DEVICE_OP_RESOLVE_JOB, deviceOpReportedJobId } from "./policy-op-jobs.js";
|
|
31
|
-
import { deviceFeaturesOf,
|
|
31
|
+
import { deviceFeaturesOf, localPolicyDiff, localPolicyOf, opExplains, opVisibleIn, ownerPolicyRevokes, pendingPolicyOpsOf, } from "./policy-summary.js";
|
|
32
32
|
import { LocalDeviceRelay } from "./relay.js";
|
|
33
33
|
/** The machine credential's prefix (`cap_dev_` plus 32 random bytes, base64url). */
|
|
34
34
|
export const MACHINE_CREDENTIAL_PREFIX = "cap_dev_";
|
|
@@ -187,14 +187,14 @@ let MachinesService = class MachinesService {
|
|
|
187
187
|
* never said hello has no known roots: nothing to compare. The reported features (known ones
|
|
188
188
|
* only) and local policy summary (null when absent or malformed) replace the stored ones, so a
|
|
189
189
|
* program downgraded to one without them is no longer sent what it cannot do. The summary is the
|
|
190
|
-
* device's
|
|
191
|
-
*
|
|
190
|
+
* device's sandbox allowlist; a change of what the owner sets, made on the machine while it was
|
|
191
|
+
* away, is audited `device.policy_changed` (the owner ceiling's, `device.owner_ceiling_changed`)
|
|
192
192
|
* ({@link reportedPolicy}). The outcomes of its recent policy ops (`recentOps`) backfill the
|
|
193
193
|
* platform's ops still pending on the row ({@link backfillOps}). The owner's home directory
|
|
194
194
|
* (`home`) replaces the stored one too (null when the hello has none).
|
|
195
195
|
*/
|
|
196
|
-
async recordHello(machineId, hello,
|
|
197
|
-
/** A
|
|
196
|
+
async recordHello(machineId, hello,
|
|
197
|
+
/** A protocol 4 hello's authenticated owner report (B2): it, not the summary, decides publication. */
|
|
198
198
|
owner) {
|
|
199
199
|
const subject = await this.db
|
|
200
200
|
.selectFrom("device_machines")
|
|
@@ -250,7 +250,7 @@ let MachinesService = class MachinesService {
|
|
|
250
250
|
.execute();
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
const policy = await this.reportedPolicy(machineId, self, hello.policy
|
|
253
|
+
const policy = await this.reportedPolicy(machineId, self, hello.policy);
|
|
254
254
|
// jsonb returns keys in its own order: compare roots canonically, or every reconnect would
|
|
255
255
|
// look like a changed reach and reset Full consent (B4 consent stability)
|
|
256
256
|
const rootsChanged = canonicalRoots(self.roots) !== canonicalRoots(hello.roots);
|
|
@@ -263,7 +263,7 @@ let MachinesService = class MachinesService {
|
|
|
263
263
|
else if (rootsChanged ||
|
|
264
264
|
JSON.stringify(localPolicyOf(self.local_policy)) !== JSON.stringify(policy))
|
|
265
265
|
await this.ceilings.publishLocked({ orgId: self.org_id, deviceId: self.device_id }, "device", (scope, row) => rootsChanged ||
|
|
266
|
-
ownerPolicyRevokes(localPolicyOf(policy), scope, row.method, row.granted_hosts),
|
|
266
|
+
ownerPolicyRevokes(localPolicyOf(policy), scope, row.method, row.granted_hosts), rootsChanged);
|
|
267
267
|
await this.db
|
|
268
268
|
.updateTable("device_machines")
|
|
269
269
|
.set({
|
|
@@ -345,12 +345,15 @@ let MachinesService = class MachinesService {
|
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
|
-
/**
|
|
348
|
+
/**
|
|
349
|
+
* A protocol 4 hello on an authenticated connection: validated as a frame, then recorded like
|
|
350
|
+
* {@link recordHello} with its owner report and the connection it arrived on.
|
|
351
|
+
*/
|
|
349
352
|
async recordHelloV3(machineId, hello, connectionId = null) {
|
|
350
353
|
const parsed = parseDeviceFrame(JSON.stringify(hello), "device");
|
|
351
354
|
if (parsed.type !== "hello")
|
|
352
355
|
throw new Error("Expected a validated operation hello");
|
|
353
|
-
await this.recordHello(machineId, parsed,
|
|
356
|
+
await this.recordHello(machineId, parsed, {
|
|
354
357
|
report: parsed.ownerCeiling,
|
|
355
358
|
connectionId,
|
|
356
359
|
});
|
|
@@ -364,53 +367,100 @@ let MachinesService = class MachinesService {
|
|
|
364
367
|
return;
|
|
365
368
|
const subject = { orgId: machine.org_id, deviceId: machine.device_id };
|
|
366
369
|
await this.ceilings.lock(subject, "device");
|
|
367
|
-
|
|
370
|
+
const attested = await this.boundIdentityLocked(subject, machineId, parsed, connectionId);
|
|
371
|
+
// the hello predates the binding its own connection installed: that install recorded the
|
|
372
|
+
// report, which this hello's must not overwrite
|
|
373
|
+
if (attested === "installed-here")
|
|
374
|
+
return;
|
|
375
|
+
await this.reports.record(machine.device_id, LOCAL_PROVIDER, parsed.programVersion, attested, parsed.permissionSupport);
|
|
368
376
|
}
|
|
369
377
|
/**
|
|
370
378
|
* The runtime identity a v3 hello may attest (B4): only a bound hello re-reporting exactly the
|
|
371
379
|
* identity of the current instance generation's installed binding. An unbound hello, another
|
|
372
380
|
* generation or a binding still awaiting the device attests nothing (unprobed; it never finishes
|
|
373
|
-
* an installation, which only the bindInstance answer does).
|
|
374
|
-
*
|
|
375
|
-
*
|
|
381
|
+
* an installation, which only the bindInstance answer does).
|
|
382
|
+
*
|
|
383
|
+
* The machine the current generation was installed for no longer attesting it means its program
|
|
384
|
+
* can never serve that generation again: a restarted program whose verified runtime differs from
|
|
385
|
+
* the one its stored binding attested (every capybara-device upgrade changes the runtime bytes)
|
|
386
|
+
* starts unbound, and the device refuses to rebind a generation under a changed runtime. The
|
|
387
|
+
* instance is then replaced ({@link replaceUnattestedLocked}), so the next use creates and binds
|
|
388
|
+
* a new generation under the new evidence instead of staying unprobed until a new login.
|
|
389
|
+
*
|
|
390
|
+
* A connection answers bindInstance before its own hello is recorded (the hello is recorded
|
|
391
|
+
* after `ready`), so a binding installed on the hello's own connection is newer than the hello:
|
|
392
|
+
* it is left as it is (`installed-here`), never replaced by the evidence the hello predates.
|
|
376
393
|
*/
|
|
377
|
-
async boundIdentityLocked(subject, hello) {
|
|
378
|
-
const reported = hello.runtimeIdentity;
|
|
379
|
-
if (hello.instanceGeneration === null || !reported)
|
|
380
|
-
return undefined;
|
|
394
|
+
async boundIdentityLocked(subject, machineId, hello, connectionId) {
|
|
381
395
|
const instance = await this.db
|
|
382
396
|
.selectFrom("device_instances")
|
|
383
|
-
.select(["provider", "created_at", "permission_runtime_identity"])
|
|
397
|
+
.select(["provider", "status", "handle", "created_at", "permission_runtime_identity"])
|
|
384
398
|
.where("device_id", "=", subject.deviceId)
|
|
385
399
|
.executeTakeFirst();
|
|
386
400
|
if (!instance ||
|
|
387
401
|
instance.provider !== LOCAL_PROVIDER ||
|
|
388
|
-
|
|
402
|
+
!instance.handle ||
|
|
403
|
+
(instance.status !== "running" && instance.status !== "suspended"))
|
|
389
404
|
return undefined;
|
|
405
|
+
const generation = String(instance.created_at.getTime());
|
|
390
406
|
const binding = await this.db
|
|
391
407
|
.selectFrom("device_instance_bindings")
|
|
392
|
-
.select(["status", "runtime_identity"])
|
|
408
|
+
.select(["status", "runtime_identity", "machine_id", "installed_connection_id"])
|
|
393
409
|
.where("device_id", "=", subject.deviceId)
|
|
394
|
-
.where("instance_generation", "=",
|
|
410
|
+
.where("instance_generation", "=", generation)
|
|
395
411
|
.executeTakeFirst();
|
|
412
|
+
// not installed yet (the kernel's bindInstance finishes it), or installed for another machine
|
|
413
|
+
// (a login replaced the instance already): nothing to attest, nothing to replace
|
|
396
414
|
if (binding?.status !== "installed" || !binding.runtime_identity)
|
|
397
415
|
return undefined;
|
|
398
|
-
if (
|
|
416
|
+
if (binding.machine_id !== machineId)
|
|
417
|
+
return undefined;
|
|
418
|
+
if (connectionId !== null && binding.installed_connection_id === connectionId)
|
|
419
|
+
return "installed-here";
|
|
420
|
+
const reported = hello.runtimeIdentity;
|
|
421
|
+
if (hello.instanceGeneration === generation &&
|
|
422
|
+
reported?.instanceGeneration === generation &&
|
|
423
|
+
sameRuntimeIdentity(binding.runtime_identity, reported))
|
|
399
424
|
return reported;
|
|
400
|
-
|
|
401
|
-
if (previous)
|
|
402
|
-
await this.ceilings.publishLocked(subject, "device", true, previous.imageFingerprint !== reported.imageFingerprint);
|
|
425
|
+
await this.replaceUnattestedLocked(subject);
|
|
403
426
|
return undefined;
|
|
404
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Replaces a local instance whose installed binding its machine no longer attests (under the
|
|
430
|
+
* device authority writer): the row forgets its instance (status `none`, no handle) and its
|
|
431
|
+
* fence moves on, so a lifecycle holder of the old instance fails its next write; the device's
|
|
432
|
+
* admission epoch advances, revoking every admitted or started operation of the old generation.
|
|
433
|
+
* The files stay (the same machine and directory): the next use creates a new instance on them,
|
|
434
|
+
* which the kernel binds under the program's new runtime evidence. Full consent is left to that
|
|
435
|
+
* install, which resets it when the proven environment fingerprint changed: a fingerprint a
|
|
436
|
+
* hello merely names proves nothing, and nothing is admitted before the install records a
|
|
437
|
+
* report, so resetting here too would reset twice.
|
|
438
|
+
*/
|
|
439
|
+
async replaceUnattestedLocked(subject) {
|
|
440
|
+
await this.ceilings.publishLocked(subject, "device", true, false);
|
|
441
|
+
await this.db
|
|
442
|
+
.updateTable("device_instances")
|
|
443
|
+
.set((eb) => ({
|
|
444
|
+
status: "none",
|
|
445
|
+
handle: null,
|
|
446
|
+
running_since: null,
|
|
447
|
+
suspended_at: null,
|
|
448
|
+
destroyed_at: sql `now()`,
|
|
449
|
+
generation: eb("generation", "+", 1),
|
|
450
|
+
permission_runtime_identity: null,
|
|
451
|
+
}))
|
|
452
|
+
.where("device_id", "=", subject.deviceId)
|
|
453
|
+
.execute();
|
|
454
|
+
}
|
|
405
455
|
/**
|
|
406
456
|
* Stores the local policy summary a connected program pushed after its hello (a `policy` frame:
|
|
407
|
-
* its policy file changed on the machine: its
|
|
408
|
-
*
|
|
409
|
-
*
|
|
457
|
+
* its policy file changed on the machine: its sandbox allowlist), read and audited as the hello's
|
|
458
|
+
* ({@link recordHello}). A change the owner made on the machine is audited
|
|
459
|
+
* `device.policy_changed`. The next sandbox call then records a
|
|
410
460
|
* new `device_paths` event when the facts the model is told changed. A revoked machine is left
|
|
411
461
|
* alone.
|
|
412
462
|
*/
|
|
413
|
-
async recordPolicy(machineId, summary
|
|
463
|
+
async recordPolicy(machineId, summary) {
|
|
414
464
|
const subject = await this.db
|
|
415
465
|
.selectFrom("device_machines")
|
|
416
466
|
.select(["org_id", "device_id"])
|
|
@@ -431,9 +481,9 @@ let MachinesService = class MachinesService {
|
|
|
431
481
|
.executeTakeFirst();
|
|
432
482
|
if (self === undefined)
|
|
433
483
|
return;
|
|
434
|
-
const policy = await this.reportedPolicy(machineId, self, summary
|
|
484
|
+
const policy = await this.reportedPolicy(machineId, self, summary);
|
|
435
485
|
if (JSON.stringify(localPolicyOf(self.local_policy)) !== JSON.stringify(policy))
|
|
436
|
-
await this.ceilings.publishLocked({ orgId: self.org_id, deviceId: self.device_id }, "device", (scope, row) => ownerPolicyRevokes(localPolicyOf(policy), scope, row.method, row.granted_hosts),
|
|
486
|
+
await this.ceilings.publishLocked({ orgId: self.org_id, deviceId: self.device_id }, "device", (scope, row) => ownerPolicyRevokes(localPolicyOf(policy), scope, row.method, row.granted_hosts), false);
|
|
437
487
|
await this.db
|
|
438
488
|
.updateTable("device_machines")
|
|
439
489
|
.set({ local_policy: jsonOrNull(policy), last_seen_at: sql `now()` })
|
|
@@ -458,7 +508,7 @@ let MachinesService = class MachinesService {
|
|
|
458
508
|
if (!subject)
|
|
459
509
|
return;
|
|
460
510
|
await this.ceilings.lock({ orgId: subject.org_id, deviceId: subject.device_id }, "device");
|
|
461
|
-
const policy = await this.reportedPolicy(machineId, { ...subject, device_id: subject.device_id }, parsed.policy
|
|
511
|
+
const policy = await this.reportedPolicy(machineId, { ...subject, device_id: subject.device_id }, parsed.policy);
|
|
462
512
|
await this.db
|
|
463
513
|
.updateTable("device_machines")
|
|
464
514
|
.set({ local_policy: jsonOrNull(policy), last_seen_at: sql `now()` })
|
|
@@ -475,19 +525,13 @@ let MachinesService = class MachinesService {
|
|
|
475
525
|
* null. When both the stored and the reported summary are readable and what the owner sets
|
|
476
526
|
* changed ({@link localPolicyDiff}) by no `policy` op the platform sent ({@link opExplains}: its
|
|
477
527
|
* answer may come after the machine's own report), the owner changed it on the machine
|
|
478
|
-
* (`capybara-device
|
|
479
|
-
* `device.policy_changed
|
|
480
|
-
*
|
|
481
|
-
* (the op's answer is). A summary reported again is no change. Runs in the caller's transaction,
|
|
528
|
+
* (`capybara-device policy add|remove allowedDomains ...`): the host changes are audited
|
|
529
|
+
* `device.policy_changed`, `via: "device"`, so the device page lists them beside the platform's
|
|
530
|
+
* changes (an owner ceiling change is the owner report writer's, `device.owner_ceiling_changed`);
|
|
531
|
+
* one an op explains is not audited here (the op's answer is). A summary reported again is no change. Runs in the caller's transaction,
|
|
482
532
|
* with the machine's row locked.
|
|
483
533
|
*/
|
|
484
|
-
async reportedPolicy(machineId, self, reported
|
|
485
|
-
/**
|
|
486
|
-
* A staged (v3) report: the authenticated owner report carries the Full change and is audited
|
|
487
|
-
* once, `device.owner_ceiling_changed` ({@link OwnerReports}); the summary's derived mode is
|
|
488
|
-
* not audited a second time as `device.mode_changed`.
|
|
489
|
-
*/
|
|
490
|
-
ownerReported = false) {
|
|
534
|
+
async reportedPolicy(machineId, self, reported) {
|
|
491
535
|
const summary = localPolicyOf(reported);
|
|
492
536
|
const prev = localPolicyOf(self.local_policy);
|
|
493
537
|
const diff = summary !== null && prev !== null ? localPolicyDiff(prev, summary) : null;
|
|
@@ -511,28 +555,12 @@ let MachinesService = class MachinesService {
|
|
|
511
555
|
by: self.account_id,
|
|
512
556
|
via: "device",
|
|
513
557
|
machineId,
|
|
514
|
-
approvalId: null,
|
|
515
|
-
},
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
if (diff.mode !== undefined && !ownerReported) {
|
|
519
|
-
await audit(this.db.db, {
|
|
520
|
-
...base,
|
|
521
|
-
action: "device.mode_changed",
|
|
522
|
-
detail: {
|
|
523
|
-
from: diff.mode.from,
|
|
524
|
-
to: diff.mode.to,
|
|
525
|
-
by: self.account_id,
|
|
526
|
-
via: "device",
|
|
527
|
-
machineId,
|
|
528
558
|
},
|
|
529
559
|
});
|
|
530
560
|
}
|
|
531
561
|
return summary;
|
|
532
562
|
}
|
|
533
|
-
|
|
534
|
-
// program is still recognized (and refused where auto mode is not allowed)
|
|
535
|
-
return summary ?? legacyPolicyOf(rawPolicy);
|
|
563
|
+
return summary;
|
|
536
564
|
}
|
|
537
565
|
/** Marks the machine seen (a ping); writes at most once every 60 seconds. */
|
|
538
566
|
async touch(machineId) {
|
|
@@ -678,7 +706,7 @@ let MachinesService = class MachinesService {
|
|
|
678
706
|
async disconnect(deviceId, machineId, reason) {
|
|
679
707
|
try {
|
|
680
708
|
if (reason !== null && (await this.relay.holderLive(deviceId))) {
|
|
681
|
-
// fenced to this machine: on a staged connection it goes out as a protocol
|
|
709
|
+
// fenced to this machine: on a staged connection it goes out as a protocol 4 `stop`
|
|
682
710
|
await this.relay.send(deviceId, "stop", { reason }, STOP_DEADLINE_MS, machineId);
|
|
683
711
|
}
|
|
684
712
|
}
|
|
@@ -29,27 +29,31 @@ export declare function storedOwnerReportOf(v: unknown): StoredOwnerReport | nul
|
|
|
29
29
|
export declare function decideOwnerReport(stored: StoredOwnerReport | null, incoming: DeviceOwnerCeiling): "record" | "same" | "stale" | "conflict";
|
|
30
30
|
/**
|
|
31
31
|
* The owner facts the kernel decides with (B2), never inferred wider than reported:
|
|
32
|
-
* - `report`: an authenticated version
|
|
32
|
+
* - `report`: an authenticated version 3 report (protocol 4);
|
|
33
33
|
* - `blocked`: a stale or conflicting report arrived: fail closed, admission refused;
|
|
34
|
-
* - `
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* - `missing`: nothing readable (no report, or one of an older protocol): fail closed.
|
|
35
|
+
*
|
|
36
|
+
* The facts carry the report's fields under its own names: `outsideSandbox`, `network` and
|
|
37
|
+
* `allowedDomains` (the owner's sandbox allowlist, a ceiling while its network is `allowlist`).
|
|
37
38
|
*/
|
|
38
39
|
export interface OwnerFacts {
|
|
39
|
-
state: "report" | "blocked" | "
|
|
40
|
-
|
|
40
|
+
state: "report" | "blocked" | "missing";
|
|
41
|
+
/** The owner allows running outside the sandbox (an escalated call). */
|
|
42
|
+
outsideSandbox: boolean;
|
|
41
43
|
restrictedProjectReach: RestrictedProjectReach;
|
|
42
|
-
|
|
44
|
+
/** The owner's sandbox allowlist: the machine's host ceiling while its network is `allowlist`. */
|
|
45
|
+
allowedDomains: string[];
|
|
46
|
+
/** The owner's sandbox network (`allowlist` when failing closed). */
|
|
47
|
+
network: "open" | "allowlist";
|
|
43
48
|
revision: string | null;
|
|
44
49
|
sequence: number | null;
|
|
45
50
|
observedAt: string | null;
|
|
46
51
|
}
|
|
47
52
|
/** The facts of a stored report alone (a successful record). */
|
|
48
53
|
export declare function ownerFactsOfReport(stored: StoredOwnerReport): OwnerFacts;
|
|
49
|
-
/** A machine row's owner facts: its authenticated report, else
|
|
54
|
+
/** A machine row's owner facts: its authenticated report, else missing (fail closed). */
|
|
50
55
|
export declare function ownerFactsOf(row: {
|
|
51
56
|
owner_report?: unknown;
|
|
52
|
-
local_policy?: unknown;
|
|
53
57
|
}): OwnerFacts;
|
|
54
58
|
/**
|
|
55
59
|
* The owner writer's selector (B2): what an owner-ceiling change takes from a running admission.
|
|
@@ -68,12 +72,10 @@ export declare function outsideMachineRoots(scope: SandboxOperationScope | Sandb
|
|
|
68
72
|
/** The machine's reported roots as a list (workspace, tmp, skills ...), or none. */
|
|
69
73
|
export declare function machineRootList(roots: unknown): string[];
|
|
70
74
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
75
|
+
* A machine's owner outside-sandbox permission in the kernel-internal tier encoding (`SandboxMode`
|
|
76
|
+
* in `sandbox/modes.ts`; never re-encodes reach): `auto` only for an authenticated report that
|
|
77
|
+
* allows running outside the sandbox; a blocked, missing or older report fails closed.
|
|
74
78
|
*/
|
|
75
79
|
export declare function ownerModeOf(row: {
|
|
76
|
-
features: unknown;
|
|
77
|
-
local_policy: unknown;
|
|
78
80
|
owner_report?: unknown;
|
|
79
81
|
}): "auto" | "sandbox";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { parseOwnerCeilingReport, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { coversHost } from "../sandbox/modes.js";
|
|
3
3
|
import { isExecutionMethod, isFullExecutionScope } from "../sandbox/operation-authority-types.js";
|
|
4
|
-
import { localModeOf, localPolicyOf } from "./policy-summary.js";
|
|
5
4
|
/** The stored report in `v`, or null (absent or malformed: never trusted). */
|
|
6
5
|
export function storedOwnerReportOf(v) {
|
|
7
6
|
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
@@ -55,14 +54,16 @@ const canonicalReport = (r) => ({
|
|
|
55
54
|
version: r.version,
|
|
56
55
|
revision: r.revision,
|
|
57
56
|
sequence: r.sequence,
|
|
58
|
-
|
|
57
|
+
outsideSandbox: r.outsideSandbox,
|
|
58
|
+
network: r.network,
|
|
59
|
+
allowedDomains: [...r.allowedDomains],
|
|
59
60
|
restrictedProjectReach: r.restrictedProjectReach,
|
|
60
|
-
restrictedAllowedDomains: [...r.restrictedAllowedDomains],
|
|
61
61
|
});
|
|
62
62
|
const FAIL_CLOSED = {
|
|
63
|
-
|
|
63
|
+
outsideSandbox: false,
|
|
64
64
|
restrictedProjectReach: "workspace",
|
|
65
|
-
|
|
65
|
+
allowedDomains: [],
|
|
66
|
+
network: "allowlist",
|
|
66
67
|
};
|
|
67
68
|
/** The facts of a stored report alone (a successful record). */
|
|
68
69
|
export function ownerFactsOfReport(stored) {
|
|
@@ -76,31 +77,21 @@ export function ownerFactsOfReport(stored) {
|
|
|
76
77
|
};
|
|
77
78
|
return {
|
|
78
79
|
state: "report",
|
|
79
|
-
|
|
80
|
+
outsideSandbox: stored.report.outsideSandbox,
|
|
80
81
|
restrictedProjectReach: stored.report.restrictedProjectReach,
|
|
81
|
-
|
|
82
|
+
allowedDomains: [...stored.report.allowedDomains],
|
|
83
|
+
network: stored.report.network,
|
|
82
84
|
revision: stored.report.revision,
|
|
83
85
|
sequence: stored.report.sequence,
|
|
84
86
|
observedAt: stored.observedAt,
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
|
-
/** A machine row's owner facts: its authenticated report, else
|
|
89
|
+
/** A machine row's owner facts: its authenticated report, else missing (fail closed). */
|
|
88
90
|
export function ownerFactsOf(row) {
|
|
89
91
|
const stored = storedOwnerReportOf(row.owner_report);
|
|
90
92
|
if (stored !== null)
|
|
91
93
|
return ownerFactsOfReport(stored);
|
|
92
|
-
|
|
93
|
-
if (summary === null)
|
|
94
|
-
return { state: "missing", ...FAIL_CLOSED, revision: null, sequence: null, observedAt: null };
|
|
95
|
-
return {
|
|
96
|
-
state: "legacy",
|
|
97
|
-
fullAccess: summary.mode === "auto",
|
|
98
|
-
restrictedProjectReach: summary.mode === "auto" ? "os-user" : "workspace",
|
|
99
|
-
restrictedAllowedDomains: [...summary.allowedDomains],
|
|
100
|
-
revision: null,
|
|
101
|
-
sequence: null,
|
|
102
|
-
observedAt: null,
|
|
103
|
-
};
|
|
94
|
+
return { state: "missing", ...FAIL_CLOSED, revision: null, sequence: null, observedAt: null };
|
|
104
95
|
}
|
|
105
96
|
/** True when `path` lies in one of `roots` (absolute, normalized). */
|
|
106
97
|
const within = (path, root) => root === "/" || path === root || path.startsWith(`${root}/`);
|
|
@@ -118,12 +109,18 @@ export function ownerReportRevokes(next, scope, method, grantedHosts, machineRoo
|
|
|
118
109
|
if (!("profile" in scope))
|
|
119
110
|
return (next.restrictedProjectReach === "workspace" && scope.readRoots.some((r) => !inMachine(r)));
|
|
120
111
|
if (isFullExecutionScope(scope))
|
|
121
|
-
return !next.
|
|
112
|
+
return !next.outsideSandbox;
|
|
122
113
|
if (next.restrictedProjectReach === "workspace" && outsideMachineRoots(scope, machineRoots))
|
|
123
114
|
return true;
|
|
124
|
-
if (!isExecutionMethod(method)
|
|
115
|
+
if (!isExecutionMethod(method))
|
|
116
|
+
return false;
|
|
117
|
+
// the open public network goes when the owner narrows the sandbox network to the allowlist
|
|
118
|
+
if (scope.network.kind === "open-public")
|
|
119
|
+
return next.network === "allowlist";
|
|
120
|
+
// the owner's list bounds hosts only while its network is the allowlist
|
|
121
|
+
if (scope.network.kind !== "allowlist" || next.network !== "allowlist")
|
|
125
122
|
return false;
|
|
126
|
-
return scope.network.hosts.some((host) => !next.
|
|
123
|
+
return scope.network.hosts.some((host) => !next.allowedDomains.some((pattern) => coversHost(pattern, host)) &&
|
|
127
124
|
!grantedHosts.includes(host));
|
|
128
125
|
}
|
|
129
126
|
/**
|
|
@@ -143,13 +140,10 @@ export function machineRootList(roots) {
|
|
|
143
140
|
return Object.values(roots).filter((r) => typeof r === "string" && r.startsWith("/"));
|
|
144
141
|
}
|
|
145
142
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
143
|
+
* A machine's owner outside-sandbox permission in the kernel-internal tier encoding (`SandboxMode`
|
|
144
|
+
* in `sandbox/modes.ts`; never re-encodes reach): `auto` only for an authenticated report that
|
|
145
|
+
* allows running outside the sandbox; a blocked, missing or older report fails closed.
|
|
149
146
|
*/
|
|
150
147
|
export function ownerModeOf(row) {
|
|
151
|
-
|
|
152
|
-
if (stored === null)
|
|
153
|
-
return localModeOf(row.features, row.local_policy);
|
|
154
|
-
return ownerFactsOfReport(stored).fullAccess ? "auto" : "sandbox";
|
|
148
|
+
return ownerFactsOf(row).outsideSandbox ? "auto" : "sandbox";
|
|
155
149
|
}
|
|
@@ -13,6 +13,7 @@ import { audit } from "../identity/audit.js";
|
|
|
13
13
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
14
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
15
15
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
16
|
+
import { coversHost } from "../sandbox/modes.js";
|
|
16
17
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
17
18
|
import { decideOwnerReport, machineRootList, ownerFactsOf, ownerFactsOfReport, ownerReportRevokes, storedOwnerReportOf, } from "./owner-report.js";
|
|
18
19
|
import { opExplainsOwnerChange, pendingPolicyOpsOf } from "./policy-summary.js";
|
|
@@ -119,15 +120,29 @@ let OwnerReports = class OwnerReports {
|
|
|
119
120
|
};
|
|
120
121
|
const after = ownerFactsOfReport(next);
|
|
121
122
|
await this.write(machineId, next);
|
|
122
|
-
const fullChanged = before.
|
|
123
|
+
const fullChanged = before.outsideSandbox !== after.outsideSandbox;
|
|
123
124
|
const reachChanged = before.restrictedProjectReach !== after.restrictedProjectReach;
|
|
124
|
-
const domainsChanged = JSON.stringify([...before.
|
|
125
|
-
JSON.stringify([...after.
|
|
125
|
+
const domainsChanged = JSON.stringify([...before.allowedDomains].sort()) !==
|
|
126
|
+
JSON.stringify([...after.allowedDomains].sort());
|
|
127
|
+
// the owner's sandbox network: narrowing it to the allowlist takes open-network work
|
|
128
|
+
const networkChanged = before.network !== after.network;
|
|
129
|
+
// only a widening resets Full consent (Full access would auto-approve more): running outside
|
|
130
|
+
// allowed again, the open network, the os-user reach, or a host added to an allowlist the
|
|
131
|
+
// owner keeps; a narrowing keeps what the consent covered. A machine's first report is no
|
|
132
|
+
// network widening (the missing state's allowlist is only failing closed)
|
|
133
|
+
const reported = before.state !== "missing";
|
|
134
|
+
const widened = (!before.outsideSandbox && after.outsideSandbox) ||
|
|
135
|
+
(before.restrictedProjectReach === "workspace" &&
|
|
136
|
+
after.restrictedProjectReach === "os-user") ||
|
|
137
|
+
(reported && before.network === "allowlist" && after.network === "open") ||
|
|
138
|
+
(reported &&
|
|
139
|
+
after.network === "allowlist" &&
|
|
140
|
+
after.allowedDomains.some((h) => !before.allowedDomains.some((p) => coversHost(p, h))));
|
|
126
141
|
const roots = machineRootList(row.roots);
|
|
127
142
|
// a new revision with the same visible facts is no new authority: nothing is published
|
|
128
|
-
if (fullChanged || reachChanged || domainsChanged || meta.rootsChanged)
|
|
143
|
+
if (fullChanged || reachChanged || domainsChanged || networkChanged || meta.rootsChanged)
|
|
129
144
|
await this.ceilings.publishLocked(subject, "device", (scope, intent) => meta.rootsChanged === true ||
|
|
130
|
-
ownerReportRevokes(after, scope, intent.method, intent.granted_hosts, roots),
|
|
145
|
+
ownerReportRevokes(after, scope, intent.method, intent.granted_hosts, roots), widened || meta.rootsChanged === true);
|
|
131
146
|
// the op whose change this is: its answer names it, else (the machine's own report of it, a
|
|
132
147
|
// policy frame or a reconnect hello, landing first) a live pending op of the platform's that
|
|
133
148
|
// asked for exactly this narrowing; the answer then finds the same report and audits nothing
|
|
@@ -142,7 +157,7 @@ let OwnerReports = class OwnerReports {
|
|
|
142
157
|
opId: pending.id,
|
|
143
158
|
...(pending.actorTokenId !== undefined && { actorTokenId: pending.actorTokenId }),
|
|
144
159
|
});
|
|
145
|
-
if (before.state !== "missing" && (fullChanged || reachChanged))
|
|
160
|
+
if (before.state !== "missing" && (fullChanged || reachChanged || networkChanged))
|
|
146
161
|
await audit(this.db.db, {
|
|
147
162
|
actorAccountId: by?.accountId ?? row.account_id,
|
|
148
163
|
...(by?.actorTokenId !== undefined && { actorTokenId: by.actorTokenId }),
|
|
@@ -150,13 +165,16 @@ let OwnerReports = class OwnerReports {
|
|
|
150
165
|
action: "device.owner_ceiling_changed",
|
|
151
166
|
target: row.device_id,
|
|
152
167
|
detail: {
|
|
168
|
+
// the network appears when it changed (the rows of other changes keep their shape)
|
|
153
169
|
from: {
|
|
154
|
-
|
|
170
|
+
outsideSandbox: before.outsideSandbox,
|
|
155
171
|
restrictedProjectReach: before.restrictedProjectReach,
|
|
172
|
+
...(networkChanged && { network: before.network }),
|
|
156
173
|
},
|
|
157
174
|
to: {
|
|
158
|
-
|
|
175
|
+
outsideSandbox: after.outsideSandbox,
|
|
159
176
|
restrictedProjectReach: after.restrictedProjectReach,
|
|
177
|
+
...(networkChanged && { network: after.network }),
|
|
160
178
|
},
|
|
161
179
|
sequence: report.sequence,
|
|
162
180
|
by: by?.accountId ?? row.account_id,
|