@coffre/conformance 0.2.0 → 0.4.0
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/{idp-BeOsuZ3p.js → idp-Dyaj6k5N.js} +2 -2
- package/dist/idp.d.ts +2 -2
- package/dist/idp.js +1 -1
- package/dist/main.js +1548 -127
- package/package.json +4 -4
- package/src/bundle.ts +5 -0
- package/src/checks/access.ts +53 -1
- package/src/checks/canaries.ts +5 -4
- package/src/checks/cli.ts +86 -16
- package/src/checks/deletion.ts +98 -0
- package/src/checks/environments.ts +193 -0
- package/src/checks/mcp.ts +475 -0
- package/src/checks/pages.ts +172 -11
- package/src/checks/people.ts +17 -13
- package/src/checks/workloads.ts +19 -21
- package/src/chrome.ts +48 -10
- package/src/draining.ts +4 -3
- package/src/harness.ts +10 -6
- package/src/idp/workloads.ts +2 -2
- package/src/suite.ts +19 -3
package/dist/main.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as DevIdp, o as defaultGitHubAccount, r as GITHUB_RUN } from "./idp-
|
|
1
|
+
import { n as DevIdp, o as defaultGitHubAccount, r as GITHUB_RUN } from "./idp-Dyaj6k5N.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { delimiter, dirname, join, relative, resolve } from "node:path";
|
|
4
4
|
import { inspect, parseArgs } from "node:util";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
6
|
import { createHash, createHmac, createPrivateKey, hkdfSync, randomBytes, randomUUID, sign } from "node:crypto";
|
|
7
|
-
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { homedir, tmpdir } from "node:os";
|
|
9
9
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
10
10
|
import { DatabaseSync } from "node:sqlite";
|
|
@@ -52,9 +52,10 @@ const KEYS = {
|
|
|
52
52
|
* The built app as `wrangler dev` can run it: its own build, behind an entry
|
|
53
53
|
* that, once the app has answered, reads whatever the request still sends
|
|
54
54
|
* before passing the answer on. Locally, and only there, a Worker built
|
|
55
|
-
* unbundled with static assets
|
|
56
|
-
* left unread, which every refusal does
|
|
57
|
-
*
|
|
55
|
+
* unbundled with static assets may fail the request after one whose body it
|
|
56
|
+
* left unread, which every refusal does: wrangler retries a GET, not a POST
|
|
57
|
+
* (cloudflare/workers-sdk#15203). Reading it later, after the answer, is too
|
|
58
|
+
* late; deployed, Cloudflare discards such a body, as
|
|
58
59
|
* `vite dev` and `vite preview` do. The app itself must never wait so on what
|
|
59
60
|
* a caller sends; this harness sends only bodies that end. The entry and its
|
|
60
61
|
* config are written beside the build, which the next `vite build`
|
|
@@ -152,11 +153,29 @@ function createClient(options) {
|
|
|
152
153
|
/** With their environments. */
|
|
153
154
|
list: () => call("GET /projects", {}),
|
|
154
155
|
create: (project, input) => call("PUT /projects/:project", { project }, input),
|
|
155
|
-
update: (project, patch) => call("PATCH /projects/:project", { project }, patch)
|
|
156
|
+
update: (project, patch) => call("PATCH /projects/:project", { project }, patch),
|
|
157
|
+
/** What deleting an archived project would erase and revoke; changes nothing. */
|
|
158
|
+
previewDelete: (project) => {
|
|
159
|
+
const [method, route] = address("DELETE /projects/:project", { project });
|
|
160
|
+
return send(method, `${route}?dryRun=1`, void 0);
|
|
161
|
+
},
|
|
162
|
+
/** Delete an archived project for good: its values erased, its grants revoked, its slug free. Owners only. */
|
|
163
|
+
delete: (project) => call("DELETE /projects/:project", { project })
|
|
156
164
|
},
|
|
157
165
|
environments: {
|
|
158
166
|
create: (path, input) => call("PUT /projects/:project/:environment", place(path), input),
|
|
159
|
-
update: (path, patch) => call("PATCH /projects/:project/:environment", place(path), patch)
|
|
167
|
+
update: (path, patch) => call("PATCH /projects/:project/:environment", place(path), patch),
|
|
168
|
+
/** What deleting an archived environment would erase and revoke; changes nothing. */
|
|
169
|
+
previewDelete: (path) => {
|
|
170
|
+
const [method, route] = address("DELETE /projects/:project/:environment", place(path));
|
|
171
|
+
return send(method, `${route}?dryRun=1`, void 0);
|
|
172
|
+
},
|
|
173
|
+
/** Delete an archived environment for good, as a project is. Owners only. */
|
|
174
|
+
delete: (path) => call("DELETE /projects/:project/:environment", place(path)),
|
|
175
|
+
/** The keys its sibling environments have and it lacks, those you can see, and those its team dismissed. */
|
|
176
|
+
missing: (path) => call("GET /projects/:project/:environment/missing", place(path)),
|
|
177
|
+
/** Dismiss missing keys (`true`) or restore them (`null`). */
|
|
178
|
+
dismiss: (path, patch) => call("PATCH /projects/:project/:environment/dismissals", place(path), patch)
|
|
160
179
|
},
|
|
161
180
|
secrets: {
|
|
162
181
|
/** Keys, versions and who changed what; never values. */
|
|
@@ -180,6 +199,16 @@ function createClient(options) {
|
|
|
180
199
|
rename: (path, key) => call("PATCH /secrets/:project/:environment/:key", place(path), { key }),
|
|
181
200
|
update: (path, patch) => call("PATCH /secrets/:project/:environment/:key", place(path), patch)
|
|
182
201
|
},
|
|
202
|
+
/**
|
|
203
|
+
* References: secrets read through others (docs/design/environments.md).
|
|
204
|
+
* A key becomes one with `secrets.set(path, { KEY: { ref: 'market/prod/KEY' } })`.
|
|
205
|
+
*/
|
|
206
|
+
references: {
|
|
207
|
+
/** The live references into and out of a place, `market`, `market/prod` or `market/prod/KEY`, and who reads through them. */
|
|
208
|
+
list: (path) => call("GET /references", {}, { path }),
|
|
209
|
+
/** Break the reference a secret is: its readers stop reading the source through it. */
|
|
210
|
+
break: (path) => call("DELETE /secrets/:project/:environment/:key/reference", place(path))
|
|
211
|
+
},
|
|
183
212
|
members: {
|
|
184
213
|
/** People and tokens, their role and their access; at a place, those who reach it. */
|
|
185
214
|
list: (path) => call("GET /members", {}, { path }),
|
|
@@ -232,6 +261,55 @@ set: (member, access) => call("PATCH /access/:member", { member }, access) },
|
|
|
232
261
|
get: (code) => call("GET /device-logins/:code", { code }),
|
|
233
262
|
decide: (code, approve) => call("POST /device-logins/:code", { code }, { approve })
|
|
234
263
|
},
|
|
264
|
+
/**
|
|
265
|
+
* Folders, which arrange lists and do nothing else: a folder exists while
|
|
266
|
+
* something is filed in it. Renaming one re-files all of it, onto a folder
|
|
267
|
+
* that exists merges the two; removing one takes all of it out, each item
|
|
268
|
+
* staying where it is, in no folder. Moving one item is `projects.update`
|
|
269
|
+
* or `secrets.update` with a `folder`.
|
|
270
|
+
*/
|
|
271
|
+
folders: {
|
|
272
|
+
/** A folder of projects, renamed. Takes managing every project in it. */
|
|
273
|
+
rename: (folder, name) => call("PATCH /folders/:folder", { folder }, { name }),
|
|
274
|
+
/** Every project out of a folder. */
|
|
275
|
+
remove: (folder) => call("DELETE /folders/:folder", { folder }),
|
|
276
|
+
/** One of an environment's key folders, `market/prod`, renamed. Takes writing there. */
|
|
277
|
+
renameKeys: (environment, folder, name) => {
|
|
278
|
+
const { project, environment: slug } = place(environment);
|
|
279
|
+
return call("PATCH /folders/:project/:environment/:folder", {
|
|
280
|
+
project,
|
|
281
|
+
environment: slug,
|
|
282
|
+
folder
|
|
283
|
+
}, { name });
|
|
284
|
+
},
|
|
285
|
+
/** Every key out of one of an environment's folders. */
|
|
286
|
+
removeKeys: (environment, folder) => {
|
|
287
|
+
const { project, environment: slug } = place(environment);
|
|
288
|
+
return call("DELETE /folders/:project/:environment/:folder", {
|
|
289
|
+
project,
|
|
290
|
+
environment: slug,
|
|
291
|
+
folder
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
/**
|
|
296
|
+
* An MCP client asking to connect, by its authorization request, and the
|
|
297
|
+
* person's answer: where to send the browser next.
|
|
298
|
+
*/
|
|
299
|
+
oauth: {
|
|
300
|
+
describe: (request) => call("GET /oauth/authorizations", {}, request),
|
|
301
|
+
decide: (input) => call("POST /oauth/authorizations", {}, input)
|
|
302
|
+
},
|
|
303
|
+
/** The MCP clients I connected. */
|
|
304
|
+
/** A change an MCP client asked for: what it would do, and the person's decision, which makes it. */
|
|
305
|
+
approvals: {
|
|
306
|
+
get: (id) => call("GET /approvals/:id", { id }),
|
|
307
|
+
decide: (id, input) => call("POST /approvals/:id", { id }, input)
|
|
308
|
+
},
|
|
309
|
+
apps: {
|
|
310
|
+
list: () => call("GET /apps", {}),
|
|
311
|
+
disconnect: (id) => call("DELETE /apps/:id", { id })
|
|
312
|
+
},
|
|
235
313
|
audit: {
|
|
236
314
|
list: (query = {}) => call("GET /audit", {}, query),
|
|
237
315
|
verify: () => call("GET /audit/verification", {}),
|
|
@@ -259,7 +337,7 @@ function expect(condition, message, detail) {
|
|
|
259
337
|
* The status coffre turned a call away with. A call that went through
|
|
260
338
|
* fails the check: `what` says what it should not have done.
|
|
261
339
|
*/
|
|
262
|
-
async function refused(what, call) {
|
|
340
|
+
async function refused$1(what, call) {
|
|
263
341
|
const outcome = await call.then((value) => ({ value }), (error) => ({ error }));
|
|
264
342
|
if ("value" in outcome) throw new Failure(`${what}, and was let`, outcome.value);
|
|
265
343
|
if (!(outcome.error instanceof CoffreError)) throw outcome.error;
|
|
@@ -364,7 +442,7 @@ async function boot(kind, at, options) {
|
|
|
364
442
|
const output = (tail = Infinity) => children.map((entry) => `--- ${entry.name}\n${Buffer.concat(entry.output).toString("utf8").slice(-tail)}`).join("\n");
|
|
365
443
|
const logs = () => output(4e3);
|
|
366
444
|
const alive = () => !children.some((entry) => entry.daemon && entry.exited);
|
|
367
|
-
function start(name, command, args, env, daemon = true) {
|
|
445
|
+
function start(name, command, args, env, daemon = true, input) {
|
|
368
446
|
const child = spawn(command, args, {
|
|
369
447
|
cwd: dir,
|
|
370
448
|
env: {
|
|
@@ -373,11 +451,15 @@ async function boot(kind, at, options) {
|
|
|
373
451
|
},
|
|
374
452
|
detached: true,
|
|
375
453
|
stdio: [
|
|
376
|
-
"ignore",
|
|
454
|
+
input === void 0 ? "ignore" : "pipe",
|
|
377
455
|
"pipe",
|
|
378
456
|
"pipe"
|
|
379
457
|
]
|
|
380
458
|
});
|
|
459
|
+
if (input !== void 0) {
|
|
460
|
+
child.stdin.on("error", () => {});
|
|
461
|
+
child.stdin.end(input);
|
|
462
|
+
}
|
|
381
463
|
const entry = {
|
|
382
464
|
name,
|
|
383
465
|
child,
|
|
@@ -395,8 +477,8 @@ async function boot(kind, at, options) {
|
|
|
395
477
|
children.push(entry);
|
|
396
478
|
return entry;
|
|
397
479
|
}
|
|
398
|
-
async function run(command, args, env = {}) {
|
|
399
|
-
const entry = start(args[0] ?? command, command, args, env, false);
|
|
480
|
+
async function run(command, args, env = {}, input) {
|
|
481
|
+
const entry = start(args[0] ?? command, command, args, env, false, input);
|
|
400
482
|
if (await new Promise((done) => {
|
|
401
483
|
entry.child.once("exit", done);
|
|
402
484
|
entry.child.once("error", done);
|
|
@@ -452,7 +534,7 @@ async function boot(kind, at, options) {
|
|
|
452
534
|
deploymentCli(dir),
|
|
453
535
|
"migrate",
|
|
454
536
|
"--yes"
|
|
455
|
-
], {
|
|
537
|
+
], {}, `${owner}\n`);
|
|
456
538
|
await run(bin("vite"), ["build", "app"]);
|
|
457
539
|
const state = join(scratch, "state");
|
|
458
540
|
start("wrangler", bin("wrangler"), [
|
|
@@ -638,13 +720,13 @@ function bearer(origin, token) {
|
|
|
638
720
|
}
|
|
639
721
|
//#endregion
|
|
640
722
|
//#region src/checks/people.ts
|
|
641
|
-
const PROJECT = "conformance";
|
|
642
|
-
const DEV = `${PROJECT}/dev`;
|
|
643
|
-
const PROD = `${PROJECT}/prod`;
|
|
644
|
-
const BULK = `${PROJECT}/bulk`;
|
|
645
|
-
const SERVICE = "token:conformance-ci";
|
|
723
|
+
const PROJECT$1 = "conformance";
|
|
724
|
+
const DEV = `${PROJECT$1}/dev`;
|
|
725
|
+
const PROD = `${PROJECT$1}/prod`;
|
|
726
|
+
const BULK = `${PROJECT$1}/bulk`;
|
|
727
|
+
const SERVICE$2 = "token:conformance-ci";
|
|
646
728
|
/** Where the live checks' token reads, as an operator would set it up. */
|
|
647
|
-
const LIVE = `${PROJECT}/live`;
|
|
729
|
+
const LIVE = `${PROJECT$1}/live`;
|
|
648
730
|
const LIVE_SERVICE = "token:conformance-live";
|
|
649
731
|
function canary() {
|
|
650
732
|
return `coffre-canary-${randomBytes(12).toString("hex")}`;
|
|
@@ -669,10 +751,12 @@ async function signIn(deployment, browser, email) {
|
|
|
669
751
|
expect(approve.status === 302 && callback.startsWith(`${deployment.origin}/auth/callback/github?`), "GitHub did not send the browser back", callback);
|
|
670
752
|
const back = await browser.fetch(callback);
|
|
671
753
|
expect(back.status === 302 || back.status === 303, `the callback answered ${back.status}`, await back.text());
|
|
672
|
-
const
|
|
754
|
+
const location = new URL(back.headers.get("location") ?? "/", deployment.origin);
|
|
755
|
+
const error = location.searchParams.get("error");
|
|
673
756
|
return error === null ? { ok: true } : {
|
|
674
757
|
ok: false,
|
|
675
|
-
error
|
|
758
|
+
error,
|
|
759
|
+
location: `${location.pathname}${location.search}`
|
|
676
760
|
};
|
|
677
761
|
}
|
|
678
762
|
async function signInAdmin(deployment) {
|
|
@@ -694,7 +778,7 @@ async function signInAdmin(deployment) {
|
|
|
694
778
|
};
|
|
695
779
|
}
|
|
696
780
|
async function setUp(admin) {
|
|
697
|
-
await admin.api.projects.create(PROJECT, { name: "Conformance" });
|
|
781
|
+
await admin.api.projects.create(PROJECT$1, { name: "Conformance" });
|
|
698
782
|
for (const [path, name] of [
|
|
699
783
|
[DEV, "Development"],
|
|
700
784
|
[PROD, "Production"],
|
|
@@ -707,7 +791,7 @@ async function setUp(admin) {
|
|
|
707
791
|
};
|
|
708
792
|
for (const path of [DEV, PROD]) await admin.api.secrets.set(path, valuesIn(canaries, path));
|
|
709
793
|
return {
|
|
710
|
-
detail: `${PROJECT}: dev and prod, ${Object.keys(canaries).length} values, and bulk`,
|
|
794
|
+
detail: `${PROJECT$1}: dev and prod, ${Object.keys(canaries).length} values, and bulk`,
|
|
711
795
|
value: canaries
|
|
712
796
|
};
|
|
713
797
|
}
|
|
@@ -724,18 +808,18 @@ async function setUpLive(admin, canaries) {
|
|
|
724
808
|
await admin.api.members.add(LIVE_SERVICE);
|
|
725
809
|
await admin.api.access.set(LIVE_SERVICE, {
|
|
726
810
|
[LIVE]: "viewer",
|
|
727
|
-
[PROJECT]: "auditor"
|
|
811
|
+
[PROJECT$1]: "auditor"
|
|
728
812
|
});
|
|
729
813
|
const { token } = await admin.api.tokens.issue(LIVE_SERVICE, {
|
|
730
814
|
label: "conformance live",
|
|
731
815
|
expiresInDays: 1
|
|
732
816
|
});
|
|
733
817
|
return {
|
|
734
|
-
detail: `${LIVE}/CANARY, and ${LIVE_SERVICE}: viewer there, auditor on ${PROJECT}`,
|
|
818
|
+
detail: `${LIVE}/CANARY, and ${LIVE_SERVICE}: viewer there, auditor on ${PROJECT$1}`,
|
|
735
819
|
value: {
|
|
736
820
|
token,
|
|
737
821
|
canary: {
|
|
738
|
-
project: PROJECT,
|
|
822
|
+
project: PROJECT$1,
|
|
739
823
|
environment: "live",
|
|
740
824
|
key: "CANARY",
|
|
741
825
|
value
|
|
@@ -747,28 +831,30 @@ async function setUpLive(admin, canaries) {
|
|
|
747
831
|
function valuesIn(canaries, environment) {
|
|
748
832
|
return Object.fromEntries(Object.entries(canaries).filter(([path]) => path.startsWith(`${environment}/`)).map(([path, value]) => [path.slice(environment.length + 1), value]));
|
|
749
833
|
}
|
|
834
|
+
/** A person the admin admits with this access, signed in in a browser of their own. */
|
|
835
|
+
async function personaOn(deployment, admin, name, access) {
|
|
836
|
+
const email = `${name}@conformance.example`;
|
|
837
|
+
const member = `user:${email}`;
|
|
838
|
+
await admin.api.members.add(member);
|
|
839
|
+
await admin.api.access.set(member, access);
|
|
840
|
+
const browser = new Browser(deployment.origin);
|
|
841
|
+
const signed = await signIn(deployment, browser, email);
|
|
842
|
+
expect(signed.ok, `${email} was refused: ${"error" in signed ? signed.error : ""}`);
|
|
843
|
+
return {
|
|
844
|
+
email,
|
|
845
|
+
member,
|
|
846
|
+
browser,
|
|
847
|
+
api: browser.client()
|
|
848
|
+
};
|
|
849
|
+
}
|
|
750
850
|
async function personas(deployment, admin) {
|
|
751
|
-
|
|
752
|
-
const email = `${name}@conformance.example`;
|
|
753
|
-
const member = `user:${email}`;
|
|
754
|
-
await admin.api.members.add(member);
|
|
755
|
-
await admin.api.access.set(member, access);
|
|
756
|
-
const browser = new Browser(deployment.origin);
|
|
757
|
-
const signed = await signIn(deployment, browser, email);
|
|
758
|
-
expect(signed.ok, `${email} was refused: ${"error" in signed ? signed.error : ""}`);
|
|
759
|
-
return {
|
|
760
|
-
email,
|
|
761
|
-
member,
|
|
762
|
-
browser,
|
|
763
|
-
api: browser.client()
|
|
764
|
-
};
|
|
765
|
-
}
|
|
851
|
+
const person = (name, access) => personaOn(deployment, admin, name, access);
|
|
766
852
|
const reader = await person("reader", { [DEV]: "viewer" });
|
|
767
853
|
const leaver = await person("leaver", { [DEV]: "developer" });
|
|
768
854
|
const bulk = await person("bulk", { [BULK]: "viewer" });
|
|
769
|
-
await admin.api.members.add(SERVICE);
|
|
770
|
-
await admin.api.access.set(SERVICE, { [DEV]: "viewer" });
|
|
771
|
-
const issued = await admin.api.tokens.issue(SERVICE, {
|
|
855
|
+
await admin.api.members.add(SERVICE$2);
|
|
856
|
+
await admin.api.access.set(SERVICE$2, { [DEV]: "viewer" });
|
|
857
|
+
const issued = await admin.api.tokens.issue(SERVICE$2, {
|
|
772
858
|
label: "conformance",
|
|
773
859
|
expiresInDays: 1
|
|
774
860
|
});
|
|
@@ -784,7 +870,7 @@ async function personas(deployment, admin) {
|
|
|
784
870
|
cliToken
|
|
785
871
|
},
|
|
786
872
|
service: {
|
|
787
|
-
member: SERVICE,
|
|
873
|
+
member: SERVICE$2,
|
|
788
874
|
token: issued.token,
|
|
789
875
|
api: bearer(deployment.origin, issued.token)
|
|
790
876
|
},
|
|
@@ -1280,7 +1366,7 @@ async function membersOnly(deployment, { stranger }) {
|
|
|
1280
1366
|
expect(!attempt.ok, "someone never admitted signed in");
|
|
1281
1367
|
expect(!stranger.browser.hasCookies, "the refused sign-in left the browser a cookie");
|
|
1282
1368
|
expect((await stranger.browser.fetch("/api/me")).status === 401, "the refused sign-in left a session");
|
|
1283
|
-
await refused("a made-up token read secrets", bearer(deployment.origin, "coffre_cli_conformanceforgedtokenconformanceforged").secrets.list(DEV));
|
|
1369
|
+
await refused$1("a made-up token read secrets", bearer(deployment.origin, "coffre_cli_conformanceforgedtokenconformanceforged").secrets.list(DEV));
|
|
1284
1370
|
for (const [method, path, body] of [
|
|
1285
1371
|
[
|
|
1286
1372
|
"GET",
|
|
@@ -1318,18 +1404,18 @@ async function membersOnly(deployment, { stranger }) {
|
|
|
1318
1404
|
async function grantScoping({ reader, service, bulk }, canaries) {
|
|
1319
1405
|
const read = await reader.api.secrets.reveal(DEV);
|
|
1320
1406
|
expect(same(read.values, valuesIn(canaries, DEV)), "a viewer on dev did not get dev's values", read.values);
|
|
1321
|
-
await refused("a viewer on dev revealed prod", reader.api.secrets.reveal(PROD));
|
|
1322
|
-
await refused("a viewer on dev listed prod", reader.api.secrets.list(PROD));
|
|
1323
|
-
await refused("a viewer wrote a value", reader.api.secrets.set(DEV, { API_KEY: "from the reader" }));
|
|
1324
|
-
await refused("a viewer granted themselves more", reader.api.access.set(reader.member, { [PROD]: "owner" }));
|
|
1325
|
-
await refused("a viewer added a member", reader.api.members.add("user:friend@conformance.example"));
|
|
1326
|
-
await refused("a viewer issued a service token", reader.api.tokens.issue(service.member, { expiresInDays: 1 }));
|
|
1407
|
+
await refused$1("a viewer on dev revealed prod", reader.api.secrets.reveal(PROD));
|
|
1408
|
+
await refused$1("a viewer on dev listed prod", reader.api.secrets.list(PROD));
|
|
1409
|
+
await refused$1("a viewer wrote a value", reader.api.secrets.set(DEV, { API_KEY: "from the reader" }));
|
|
1410
|
+
await refused$1("a viewer granted themselves more", reader.api.access.set(reader.member, { [PROD]: "owner" }));
|
|
1411
|
+
await refused$1("a viewer added a member", reader.api.members.add("user:friend@conformance.example"));
|
|
1412
|
+
await refused$1("a viewer issued a service token", reader.api.tokens.issue(service.member, { expiresInDays: 1 }));
|
|
1327
1413
|
const places = (await reader.api.me()).environments.map((place) => `${place.project}/${place.environment}`);
|
|
1328
1414
|
expect(places.length === 1 && places[0] === DEV, "a viewer on dev is told of other places", places);
|
|
1329
1415
|
const served = await service.api.secrets.reveal(DEV);
|
|
1330
1416
|
expect(same(served.values, valuesIn(canaries, DEV)), "a service viewer on dev did not get dev's values", served.values);
|
|
1331
|
-
await refused("a service viewer on dev revealed prod", service.api.secrets.reveal(PROD));
|
|
1332
|
-
await refused("a viewer on bulk revealed dev", bulk.api.secrets.reveal(DEV));
|
|
1417
|
+
await refused$1("a service viewer on dev revealed prod", service.api.secrets.reveal(PROD));
|
|
1418
|
+
await refused$1("a viewer on bulk revealed dev", bulk.api.secrets.reveal(DEV));
|
|
1333
1419
|
return "a viewer on dev reads dev and nothing else, in a browser or with a token, and changes nothing";
|
|
1334
1420
|
}
|
|
1335
1421
|
/**
|
|
@@ -1392,29 +1478,81 @@ async function offboarding(deployment, { admin, leaver, service }, canaries) {
|
|
|
1392
1478
|
const exposed = report.exposed.map((entry) => `${entry.project}/${entry.environment}/${entry.key}`).sort();
|
|
1393
1479
|
expect(same(exposed, Object.keys(valuesIn(canaries, DEV)).map((key) => `${DEV}/${key}`).sort()), "the offboarding report does not name what they read", report.exposed);
|
|
1394
1480
|
expect((await leaver.browser.fetch("/api/me")).status === 401, "a removed member's browser session still works");
|
|
1395
|
-
await refused("a removed member's CLI session read secrets", leaver.cli.secrets.list(DEV));
|
|
1481
|
+
await refused$1("a removed member's CLI session read secrets", leaver.cli.secrets.list(DEV));
|
|
1396
1482
|
expect(!(await signIn(deployment, leaver.browser, leaver.email)).ok, "a removed member signed in again");
|
|
1397
1483
|
await admin.api.members.remove(service.member);
|
|
1398
|
-
await refused("a removed service's token read secrets", service.api.secrets.reveal(DEV));
|
|
1484
|
+
await refused$1("a removed service's token read secrets", service.api.secrets.reveal(DEV));
|
|
1399
1485
|
await admin.api.members.add(leaver.member);
|
|
1400
1486
|
await admin.api.access.set(leaver.member, { [DEV]: "developer" });
|
|
1401
1487
|
await admin.api.members.add(service.member);
|
|
1402
1488
|
await admin.api.access.set(service.member, { [DEV]: "viewer" });
|
|
1403
1489
|
expect((await leaver.browser.fetch("/api/me")).status === 401, "re-admission revived the browser session");
|
|
1404
|
-
await refused("re-admission revived the CLI session", leaver.cli.secrets.reveal(DEV));
|
|
1405
|
-
await refused("re-admission revived the service token", service.api.secrets.reveal(DEV));
|
|
1490
|
+
await refused$1("re-admission revived the CLI session", leaver.cli.secrets.reveal(DEV));
|
|
1491
|
+
await refused$1("re-admission revived the service token", service.api.secrets.reveal(DEV));
|
|
1406
1492
|
expect(!(await pollDevice(deployment, device.device_code)).ok, "re-admission revived the old device approval");
|
|
1407
1493
|
expect((await signIn(deployment, leaver.browser, leaver.email)).ok, "a fresh provider callback could not sign the re-admitted member in");
|
|
1408
1494
|
await admin.api.members.remove(leaver.member);
|
|
1409
1495
|
await admin.api.members.remove(service.member);
|
|
1410
1496
|
return `the report names ${exposed.length} values; re-admission revives no old session, token or approval; a fresh provider callback works`;
|
|
1411
1497
|
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Grants on every project: one on `*` reaches a project made after it; one
|
|
1500
|
+
* on `*` and a slug reaches that environment in every project and never
|
|
1501
|
+
* another; nobody but an owner gives one; and removing a member takes
|
|
1502
|
+
* them. Its services are removed, and its project archived, as it ends.
|
|
1503
|
+
*/
|
|
1504
|
+
async function everyProject(deployment, { admin, reader }, canaries) {
|
|
1505
|
+
const services = {
|
|
1506
|
+
everything: "token:conformance-everywhere",
|
|
1507
|
+
dev: "token:conformance-every-dev",
|
|
1508
|
+
manager: "token:conformance-manager"
|
|
1509
|
+
};
|
|
1510
|
+
const client = async (member) => bearer(deployment.origin, (await admin.api.tokens.issue(member, { expiresInDays: 1 })).token);
|
|
1511
|
+
for (const member of Object.values(services)) await admin.api.members.add(member);
|
|
1512
|
+
await admin.api.access.set(services.manager, { [PROJECT$1]: "access-manager" });
|
|
1513
|
+
await refused$1("a project's access manager granted on every project", (await client(services.manager)).access.set(services.everything, { "*": "viewer" }));
|
|
1514
|
+
await refused$1("a viewer granted themselves every project", reader.api.access.set(reader.member, { "*/prod": "viewer" }));
|
|
1515
|
+
await admin.api.access.set(services.everything, { "*": "viewer" });
|
|
1516
|
+
await admin.api.access.set(services.dev, { "*/dev": "viewer" });
|
|
1517
|
+
const [everything, dev] = [await client(services.everything), await client(services.dev)];
|
|
1518
|
+
const later = `${PROJECT$1}-later`;
|
|
1519
|
+
const made = await admin.api.projects.create(later, { name: "Made later" });
|
|
1520
|
+
expect(made.inherited.some((grant) => grant.member === services.everything && grant.place === "*"), "making a project did not say who reaches it", made.inherited);
|
|
1521
|
+
for (const environment of ["dev", "prod"]) {
|
|
1522
|
+
const path = `${later}/${environment}`;
|
|
1523
|
+
const { inherited } = await admin.api.environments.create(path, { name: environment });
|
|
1524
|
+
const reaches = inherited.filter((grant) => grant.member === services.dev).length;
|
|
1525
|
+
expect(reaches === (environment === "dev" ? 1 : 0), `making ${path} misnamed who reaches it through dev in every project`, inherited);
|
|
1526
|
+
canaries[`${path}/API_KEY`] = canary();
|
|
1527
|
+
await admin.api.secrets.set(path, valuesIn(canaries, path));
|
|
1528
|
+
}
|
|
1529
|
+
for (const path of [
|
|
1530
|
+
`${later}/prod`,
|
|
1531
|
+
`${later}/dev`,
|
|
1532
|
+
PROD
|
|
1533
|
+
]) {
|
|
1534
|
+
const read = await everything.secrets.reveal(path);
|
|
1535
|
+
expect(read.values.API_KEY === canaries[`${path}/API_KEY`], `viewer on every project could not read ${path}`, read.values);
|
|
1536
|
+
}
|
|
1537
|
+
await refused$1("viewer on every project wrote a value", everything.secrets.set(`${later}/prod`, { API_KEY: "from everywhere" }));
|
|
1538
|
+
const devRead = await dev.secrets.reveal(`${later}/dev`);
|
|
1539
|
+
expect(devRead.values.API_KEY === canaries[`${later}/dev/API_KEY`], "viewer on dev in every project could not read a dev made later", devRead.values);
|
|
1540
|
+
await refused$1("viewer on dev in every project read a prod made later", dev.secrets.reveal(`${later}/prod`));
|
|
1541
|
+
await refused$1("viewer on dev in every project read prod", dev.secrets.reveal(PROD));
|
|
1542
|
+
for (const member of Object.values(services)) await admin.api.members.remove(member);
|
|
1543
|
+
await refused$1("a removed member read through a grant on every project", everything.secrets.reveal(`${later}/prod`));
|
|
1544
|
+
await refused$1("a removed member read through a grant on dev in every project", dev.secrets.reveal(`${later}/dev`));
|
|
1545
|
+
const left = (await admin.api.members.list("*")).members.filter((member) => Object.values(services).includes(member.member));
|
|
1546
|
+
expect(left.length === 0, "grants on every project outlived their members", left);
|
|
1547
|
+
await admin.api.projects.update(later, { archived: true });
|
|
1548
|
+
return "a grant on every project reaches a project made after it; one on dev, every dev and nothing else; refused to non-owners; gone with its member";
|
|
1549
|
+
}
|
|
1412
1550
|
/** Reading more values at once than the vault allows in its window is refused. */
|
|
1413
1551
|
async function bulkLimit$1({ admin, bulk }, limit) {
|
|
1414
1552
|
const values = {};
|
|
1415
1553
|
for (let i = 0; i <= limit; i++) values[`BULK_${i}`] = `bulk-${i}`;
|
|
1416
1554
|
await admin.api.secrets.set(BULK, values);
|
|
1417
|
-
const refusal = await refused(`${limit + 1} values were revealed at once`, bulk.api.secrets.reveal(BULK));
|
|
1555
|
+
const refusal = await refused$1(`${limit + 1} values were revealed at once`, bulk.api.secrets.reveal(BULK));
|
|
1418
1556
|
expect(refusal.status === 403 && refusal.code === "bulk_limit" && refusal.reason === "bulk_limit", "the bulk read was not refused as bulk_limit", refusal);
|
|
1419
1557
|
const one = await bulk.api.secrets.reveal(`${BULK}/BULK_0`);
|
|
1420
1558
|
expect(one.values.BULK_0 === "bulk-0", "a viewer on bulk could not read one of its values", one.values);
|
|
@@ -1543,7 +1681,7 @@ async function writesAgree(deployment) {
|
|
|
1543
1681
|
});
|
|
1544
1682
|
}
|
|
1545
1683
|
const versions = await query(sql, `SELECT v.secret_id, v.version FROM secret_versions v JOIN secrets s ON s.id = v.secret_id
|
|
1546
|
-
JOIN projects p ON p.id = s.project_id WHERE p.slug = $1`, [PROJECT]);
|
|
1684
|
+
JOIN projects p ON p.id = s.project_id WHERE p.slug = $1`, [PROJECT$1]);
|
|
1547
1685
|
expect(versions.length > 0, "no stored versions were inspected");
|
|
1548
1686
|
for (const version of versions) {
|
|
1549
1687
|
const matching = writes.filter((entry) => entry.secret_id === version.secret_id && JSON.parse(entry.metadata).version === version.version);
|
|
@@ -1759,6 +1897,285 @@ async function earlierCheckpoint(deployment, { admin }) {
|
|
|
1759
1897
|
return "an invalid earlier checkpoint was caught despite valid MACs and a valid later checkpoint";
|
|
1760
1898
|
}
|
|
1761
1899
|
//#endregion
|
|
1900
|
+
//#region src/checks/deletion.ts
|
|
1901
|
+
const PROJECT = "conformance-gone";
|
|
1902
|
+
const SERVICE$1 = "token:conformance-gone-ci";
|
|
1903
|
+
/** Each version under a project, by whether it still holds a ciphertext or a wrapped key. */
|
|
1904
|
+
async function sealed(deployment, projectId) {
|
|
1905
|
+
const rows = await using(deployment.database(), (sql) => query(sql, `SELECT length(v.ciphertext) AS ciphertext, length(v.wrapped_dek) AS wrapped
|
|
1906
|
+
FROM secret_versions v JOIN secrets s ON s.id = v.secret_id WHERE s.project_id = $1`, [projectId]));
|
|
1907
|
+
return {
|
|
1908
|
+
versions: rows.length,
|
|
1909
|
+
sealed: rows.filter((row) => Number(row.ciphertext) > 0 || Number(row.wrapped) > 0).length
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
async function projectId(deployment, slug) {
|
|
1913
|
+
const [row] = await using(deployment.database(), (sql) => query(sql, "SELECT id FROM projects WHERE slug = $1", [slug]));
|
|
1914
|
+
return row?.id;
|
|
1915
|
+
}
|
|
1916
|
+
async function deletion(deployment, cli, admin) {
|
|
1917
|
+
const run = async (args, code = 0) => {
|
|
1918
|
+
const result = await cli.run(args);
|
|
1919
|
+
expect(result.code === code, `coffre ${args.join(" ")} exited ${result.code}, not ${code}`, result.output);
|
|
1920
|
+
return result.output;
|
|
1921
|
+
};
|
|
1922
|
+
const value = () => `deleted-value-${randomBytes(8).toString("hex")}`;
|
|
1923
|
+
await admin.api.projects.create(PROJECT, { name: "Gone" });
|
|
1924
|
+
for (const environment of ["prod", "dev"]) {
|
|
1925
|
+
await admin.api.environments.create(`${PROJECT}/${environment}`, { name: environment });
|
|
1926
|
+
await admin.api.secrets.set(`${PROJECT}/${environment}`, {
|
|
1927
|
+
API_KEY: value(),
|
|
1928
|
+
DATABASE_URL: value()
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
await admin.api.secrets.set(`${PROJECT}/prod`, { API_KEY: value() });
|
|
1932
|
+
await admin.api.members.add(SERVICE$1);
|
|
1933
|
+
await admin.api.access.set(SERVICE$1, { [`${PROJECT}/prod`]: "viewer" });
|
|
1934
|
+
const id = await projectId(deployment, PROJECT);
|
|
1935
|
+
const live = await run([
|
|
1936
|
+
"projects",
|
|
1937
|
+
"delete",
|
|
1938
|
+
PROJECT,
|
|
1939
|
+
"--apply"
|
|
1940
|
+
], 1);
|
|
1941
|
+
expect(/not archived/.test(live), "deleting a live project was not refused as not archived", live);
|
|
1942
|
+
await run([
|
|
1943
|
+
"projects",
|
|
1944
|
+
"archive",
|
|
1945
|
+
PROJECT
|
|
1946
|
+
]);
|
|
1947
|
+
const preview = await run([
|
|
1948
|
+
"projects",
|
|
1949
|
+
"delete",
|
|
1950
|
+
PROJECT
|
|
1951
|
+
]);
|
|
1952
|
+
expect(/erased: 5 versions/.test(preview) && /revoked: 1 grant/.test(preview) && preview.includes("service:conformance-gone-ci would hold nothing anywhere"), "the preview does not say what the deletion takes", preview);
|
|
1953
|
+
expect(/Backups taken before the deletion still hold the encrypted values/.test(preview) && /Nothing changed/.test(preview), "the preview does not warn of backups, or changed something", preview);
|
|
1954
|
+
expect((await sealed(deployment, id)).sealed === 5, "the preview erased something");
|
|
1955
|
+
const done = await run([
|
|
1956
|
+
"projects",
|
|
1957
|
+
"delete",
|
|
1958
|
+
PROJECT,
|
|
1959
|
+
"--apply"
|
|
1960
|
+
]);
|
|
1961
|
+
expect(/^deleted conformance-gone, for good/.test(done), "the deletion did not say it was done", done);
|
|
1962
|
+
const after = await sealed(deployment, id);
|
|
1963
|
+
expect(after.versions === 5 && after.sealed === 0, "a deleted project still holds a ciphertext or a wrapped key", after);
|
|
1964
|
+
const [tombstone] = await using(deployment.database(), (sql) => query(sql, "SELECT slug FROM projects WHERE id = $1", [id]));
|
|
1965
|
+
expect(/^conformance-gone~deleted-\d{4}-\d{2}-\d{2}$/.test(tombstone?.slug ?? ""), "the tombstone is not named for the day", tombstone);
|
|
1966
|
+
expect((await admin.api.projects.list()).projects.every((project) => !project.slug.startsWith(PROJECT)), "a deleted project is still listed");
|
|
1967
|
+
expect((await admin.api.members.get(SERVICE$1)).live.grants === 0, "a grant on the deleted project is still live");
|
|
1968
|
+
const revealed = await admin.api.secrets.reveal(`${tombstone.slug}/prod`).then(() => null, (error) => error);
|
|
1969
|
+
expect(revealed instanceof CoffreError && revealed.status === 404, "a deleted project is still revealed by its tombstone", revealed);
|
|
1970
|
+
const fresh = value();
|
|
1971
|
+
await admin.api.projects.create(PROJECT, { name: "Gone, again" });
|
|
1972
|
+
await admin.api.environments.create(`${PROJECT}/prod`, { name: "prod" });
|
|
1973
|
+
await admin.api.secrets.set(`${PROJECT}/prod`, { API_KEY: fresh });
|
|
1974
|
+
expect(await projectId(deployment, PROJECT) !== id, "the new project took the deleted one's row");
|
|
1975
|
+
expect((await admin.api.secrets.reveal(`${PROJECT}/prod/API_KEY`)).values.API_KEY === fresh, "the new project does not read its own value");
|
|
1976
|
+
const { entries } = await admin.api.audit.list({
|
|
1977
|
+
path: tombstone.slug,
|
|
1978
|
+
limit: 500
|
|
1979
|
+
});
|
|
1980
|
+
expect(entries.some((entry) => entry.action === "project.delete" && entry.decision === "allow"), "the deletion is not in the log under its tombstone", entries.slice(0, 5));
|
|
1981
|
+
await admin.api.environments.update(`${PROJECT}/prod`, { archived: true });
|
|
1982
|
+
await run([
|
|
1983
|
+
"environments",
|
|
1984
|
+
"delete",
|
|
1985
|
+
`${PROJECT}/prod`,
|
|
1986
|
+
"--apply"
|
|
1987
|
+
]);
|
|
1988
|
+
await admin.api.environments.create(`${PROJECT}/prod`, { name: "prod, again" });
|
|
1989
|
+
const environments = (await admin.api.projects.list()).projects.find((project) => project.slug === PROJECT)?.environments ?? [];
|
|
1990
|
+
expect(environments.length === 1 && environments[0].name === "prod, again", "a deleted environment is still listed, or its slug is not free", environments);
|
|
1991
|
+
expect((await sealed(deployment, await projectId(deployment, PROJECT))).sealed === 0, "a deleted environment still holds a value");
|
|
1992
|
+
const verified = await admin.api.audit.verify();
|
|
1993
|
+
expect(verified.ok, "the log does not verify after the deletions", verified);
|
|
1994
|
+
return `${PROJECT} and ${PROJECT}/prod deleted by the CLI: 5 versions erased, a grant revoked, both unlisted and their slugs reused; ${verified.entries} entries verify`;
|
|
1995
|
+
}
|
|
1996
|
+
//#endregion
|
|
1997
|
+
//#region src/checks/environments.ts
|
|
1998
|
+
/** Where the fork check copies dev to; archived once checked. */
|
|
1999
|
+
const FORKED = `${PROJECT$1}/forked`;
|
|
2000
|
+
/**
|
|
2001
|
+
* A folder grants, hides and renames nothing: a secret filed in one is
|
|
2002
|
+
* still read, run and exported by its own name, by the same people, and
|
|
2003
|
+
* only those who may write may file it.
|
|
2004
|
+
*/
|
|
2005
|
+
async function folders({ admin, reader }, canaries) {
|
|
2006
|
+
const keys = Object.keys(valuesIn(canaries, DEV));
|
|
2007
|
+
const key = keys[0];
|
|
2008
|
+
expect(key !== void 0, "dev holds no secret to file");
|
|
2009
|
+
await admin.api.projects.update(PROJECT$1, { folder: "Conformance" });
|
|
2010
|
+
await admin.api.secrets.update(`${DEV}/${key}`, { folder: "filed" });
|
|
2011
|
+
try {
|
|
2012
|
+
const project = (await reader.api.projects.list()).projects.find((each) => each.slug === PROJECT$1);
|
|
2013
|
+
expect(project?.folder === "Conformance", "a project filed in a folder is not listed in it", project);
|
|
2014
|
+
const listed = (await reader.api.secrets.list(DEV)).keys.find((each) => each.key === key);
|
|
2015
|
+
expect(listed?.folder === "filed", "a secret filed in a folder is not listed in it", listed);
|
|
2016
|
+
const read = await reader.api.secrets.reveal(DEV);
|
|
2017
|
+
expect(JSON.stringify(Object.keys(read.values).sort()) === JSON.stringify([...keys].sort()), "filing a secret changed the names a run injects", Object.keys(read.values));
|
|
2018
|
+
expect(read.values[key] === canaries[`${DEV}/${key}`], "filing a secret changed its value");
|
|
2019
|
+
await refused$1("a viewer filed a secret", reader.api.secrets.update(`${DEV}/${key}`, { folder: "elsewhere" }));
|
|
2020
|
+
await refused$1("a viewer filed a project", reader.api.projects.update(PROJECT$1, { folder: "Elsewhere" }));
|
|
2021
|
+
await refused$1("a folder name with a slash was taken", admin.api.secrets.update(`${DEV}/${key}`, { folder: "a/b" }));
|
|
2022
|
+
} finally {
|
|
2023
|
+
await admin.api.secrets.update(`${DEV}/${key}`, { folder: null });
|
|
2024
|
+
await admin.api.projects.update(PROJECT$1, { folder: null });
|
|
2025
|
+
}
|
|
2026
|
+
return "a filed secret is read and run by its own name, by the same people; only writers file it";
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* A fork copies dev's values into a new environment, and nothing of who
|
|
2030
|
+
* may read dev: a viewer on dev reads neither the fork nor makes one.
|
|
2031
|
+
*/
|
|
2032
|
+
async function forks({ admin, reader }, canaries) {
|
|
2033
|
+
const dev = valuesIn(canaries, DEV);
|
|
2034
|
+
await refused$1("a viewer forked an environment", reader.api.environments.create(FORKED, {
|
|
2035
|
+
name: "Forked",
|
|
2036
|
+
from: DEV.split("/")[1]
|
|
2037
|
+
}));
|
|
2038
|
+
const made = await admin.api.environments.create(FORKED, {
|
|
2039
|
+
name: "Forked",
|
|
2040
|
+
from: DEV.split("/")[1]
|
|
2041
|
+
});
|
|
2042
|
+
try {
|
|
2043
|
+
expect(made.forked?.keys === Object.keys(dev).length, "the fork did not copy each of dev's keys", made);
|
|
2044
|
+
const read = await admin.api.secrets.reveal(FORKED);
|
|
2045
|
+
expect(JSON.stringify(Object.entries(read.values).sort()) === JSON.stringify(Object.entries(dev).sort()), "the fork's values are not dev's");
|
|
2046
|
+
const history = await admin.api.secrets.history(`${FORKED}/${Object.keys(dev)[0]}`);
|
|
2047
|
+
expect(history.versions.length === 1, "the fork carried history", history.versions);
|
|
2048
|
+
await refused$1("a viewer on dev read dev's fork", reader.api.secrets.reveal(FORKED));
|
|
2049
|
+
} finally {
|
|
2050
|
+
await admin.api.environments.update(FORKED, { archived: true });
|
|
2051
|
+
}
|
|
2052
|
+
return "a fork holds dev's values and no history, and a viewer on dev neither makes one nor reads it";
|
|
2053
|
+
}
|
|
2054
|
+
/** The key in dev the reference check makes, archived once checked. */
|
|
2055
|
+
const HELD = "CONFORMANCE_REFERENCE";
|
|
2056
|
+
const FORGED = "CONFORMANCE_FORGED";
|
|
2057
|
+
/** The status a call failed with and its reason, the vault's or the app's, or that it went through. */
|
|
2058
|
+
async function outcome(call) {
|
|
2059
|
+
try {
|
|
2060
|
+
await call;
|
|
2061
|
+
return "let through";
|
|
2062
|
+
} catch (error) {
|
|
2063
|
+
if (!(error instanceof CoffreError)) throw error;
|
|
2064
|
+
return `${error.status} ${error.reason ?? error.code}`;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* A reference lets whoever reads its holder read its source, so only the
|
|
2069
|
+
* vault makes one, and a read through one is checked against the vault's
|
|
2070
|
+
* own entry: the reader, a viewer on dev with no grant on prod, reads
|
|
2071
|
+
* prod's value through dev's reference, and the read is in prod's log and
|
|
2072
|
+
* dev's; a reference row the vault never made, written straight into the
|
|
2073
|
+
* database, reads nothing; a developer on dev who cannot read prod makes
|
|
2074
|
+
* none; and once broken, it reads no more.
|
|
2075
|
+
*/
|
|
2076
|
+
async function references(deployment, { admin, reader, leaver }, canaries) {
|
|
2077
|
+
const [sourceKey] = Object.keys(valuesIn(canaries, PROD));
|
|
2078
|
+
expect(sourceKey !== void 0, "prod holds no secret to refer to");
|
|
2079
|
+
const source = `${PROD}/${sourceKey}`;
|
|
2080
|
+
await refused$1("a viewer on dev read prod directly", reader.api.secrets.reveal(source));
|
|
2081
|
+
expect(await outcome(leaver.api.secrets.set(DEV, { [HELD]: { ref: source } })) === "403 missing_secret_read", "a developer on dev who cannot read prod made a reference to prod's secret");
|
|
2082
|
+
await admin.api.secrets.set(DEV, { [HELD]: { ref: source } });
|
|
2083
|
+
try {
|
|
2084
|
+
expect((await reader.api.secrets.reveal(`${DEV}/${HELD}`)).values[HELD] === canaries[source], "a viewer on dev did not read prod's value through dev's reference");
|
|
2085
|
+
const logged = async (path) => (await admin.api.audit.list({
|
|
2086
|
+
path,
|
|
2087
|
+
limit: 200
|
|
2088
|
+
})).entries.filter((entry) => entry.action === "secret.read" && entry.actorId === reader.email && entry.metadata.via !== void 0).length;
|
|
2089
|
+
expect(await logged(PROD) >= 1 && await logged(DEV) >= 1, "the read through the reference is not in both the source's log and the holder's");
|
|
2090
|
+
const archives = [[source, (archived) => admin.api.secrets.update(source, { archived })], [PROD, (archived) => admin.api.environments.update(PROD, { archived })]];
|
|
2091
|
+
for (const [what, archive] of archives) {
|
|
2092
|
+
const refusal = await archive(true).then(() => null, (error) => error);
|
|
2093
|
+
if (refusal === null) await archive(false);
|
|
2094
|
+
expect(refusal instanceof CoffreError && refusal.status === 409 && refusal.message.includes(`${DEV}/${HELD} reads ${source}`), `${what} was archived, or refused without naming the reference, while a reference read it`, refusal instanceof Error ? refusal.message : refusal);
|
|
2095
|
+
}
|
|
2096
|
+
await admin.api.secrets.update(`${DEV}/${HELD}`, { archived: true });
|
|
2097
|
+
const underArchived = await outcome(admin.api.secrets.update(source, { archived: true })).finally(() => admin.api.secrets.update(`${DEV}/${HELD}`, { archived: false }));
|
|
2098
|
+
try {
|
|
2099
|
+
expect(underArchived === "let through", `${source} could not be archived while only an archived key referred to it: ${underArchived}`);
|
|
2100
|
+
const restored = await outcome(reader.api.secrets.reveal(`${DEV}/${HELD}`));
|
|
2101
|
+
expect(restored.startsWith("409 "), `a reference read a source archived while its holder was: ${restored}`);
|
|
2102
|
+
} finally {
|
|
2103
|
+
if (underArchived === "let through") await admin.api.secrets.update(source, { archived: false });
|
|
2104
|
+
}
|
|
2105
|
+
expect((await reader.api.secrets.reveal(`${DEV}/${HELD}`)).values[HELD] === canaries[source], "a reference did not read its source again once both were restored");
|
|
2106
|
+
const forged = await using(deployment.database(), async (sql) => {
|
|
2107
|
+
const [holder] = await query(sql, "SELECT id, project_id, environment_id FROM secrets WHERE key = $1", [HELD]);
|
|
2108
|
+
const [target] = await query(sql, "SELECT s.id, s.project_id, s.environment_id FROM secrets s JOIN environments e ON e.id = s.environment_id WHERE s.key = $1 AND e.slug = $2", [sourceKey, PROD.split("/")[1]]);
|
|
2109
|
+
const [entry] = await query(sql, "SELECT seq FROM audit_log WHERE author = 'vault' AND action = 'access.grant' AND decision = 'allow' ORDER BY seq DESC LIMIT 1");
|
|
2110
|
+
const id = randomUUID();
|
|
2111
|
+
await query(sql, "INSERT INTO secrets (id, project_id, environment_id, key, current_version) VALUES ($1, $2, $3, $4, 0)", [
|
|
2112
|
+
id,
|
|
2113
|
+
holder.project_id,
|
|
2114
|
+
holder.environment_id,
|
|
2115
|
+
FORGED
|
|
2116
|
+
]);
|
|
2117
|
+
await query(sql, `INSERT INTO secret_references (id, project_id, environment_id, secret_id, source_project_id, source_environment_id, source_secret_id, created_seq, created_by)
|
|
2118
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)`, [
|
|
2119
|
+
randomUUID(),
|
|
2120
|
+
holder.project_id,
|
|
2121
|
+
holder.environment_id,
|
|
2122
|
+
id,
|
|
2123
|
+
target.project_id,
|
|
2124
|
+
target.environment_id,
|
|
2125
|
+
target.id,
|
|
2126
|
+
String(entry.seq),
|
|
2127
|
+
admin.member
|
|
2128
|
+
]);
|
|
2129
|
+
return id;
|
|
2130
|
+
});
|
|
2131
|
+
try {
|
|
2132
|
+
const forgedRead = await outcome(reader.api.secrets.reveal(`${DEV}/${FORGED}`));
|
|
2133
|
+
expect([
|
|
2134
|
+
"404 no_value",
|
|
2135
|
+
"404 not_found",
|
|
2136
|
+
"403 bad_claim"
|
|
2137
|
+
].includes(forgedRead), `a reference row the vault never made was read: ${forgedRead}`);
|
|
2138
|
+
} finally {
|
|
2139
|
+
await using(deployment.database(), async (sql) => {
|
|
2140
|
+
await query(sql, "DELETE FROM secret_references WHERE secret_id = $1", [forged]);
|
|
2141
|
+
await query(sql, "DELETE FROM secrets WHERE id = $1", [forged]);
|
|
2142
|
+
});
|
|
2143
|
+
}
|
|
2144
|
+
await admin.api.references.break(`${DEV}/${HELD}`);
|
|
2145
|
+
const after = await outcome(reader.api.secrets.reveal(`${DEV}/${HELD}`));
|
|
2146
|
+
expect(after.startsWith("409 "), `a broken reference still read: ${after}`);
|
|
2147
|
+
} finally {
|
|
2148
|
+
await admin.api.secrets.update(`${DEV}/${HELD}`, { archived: true });
|
|
2149
|
+
}
|
|
2150
|
+
return "a viewer on dev reads prod's value through a reference, logged in both; prod and its key cannot be archived while it reads them, but can once its holder is archived, which then reads nothing until they are back; a forged row is refused, a broken one reads no more, and none is made without read on the source";
|
|
2151
|
+
}
|
|
2152
|
+
/** A key prod has and dev does not, for the missing-keys check; archived once checked. */
|
|
2153
|
+
const PROD_ONLY = "CONFORMANCE_PROD_ONLY";
|
|
2154
|
+
/**
|
|
2155
|
+
* Key names are metadata: what dev is missing is compared only with the
|
|
2156
|
+
* environments the viewer reads. The admin sees prod's key missing from dev;
|
|
2157
|
+
* the reader, a viewer on dev alone, sees nothing of prod, and dismisses
|
|
2158
|
+
* nothing. A dismissal is the team's, and restoring undoes it.
|
|
2159
|
+
*/
|
|
2160
|
+
async function missingKeys({ admin, reader }) {
|
|
2161
|
+
await admin.api.secrets.set(PROD, { [PROD_ONLY]: canary() });
|
|
2162
|
+
try {
|
|
2163
|
+
const seen = await admin.api.environments.missing(DEV);
|
|
2164
|
+
expect(seen.missing.some((key) => key.key === PROD_ONLY), "the admin was not told dev lacks prod's key", seen);
|
|
2165
|
+
const hidden = await reader.api.environments.missing(DEV);
|
|
2166
|
+
expect(![...hidden.missing, ...hidden.dismissed].some((key) => key.key === PROD_ONLY), "a viewer on dev learned a key name from prod, which they cannot read", hidden);
|
|
2167
|
+
await refused$1("a viewer dismissed a missing key", reader.api.environments.dismiss(DEV, { [PROD_ONLY]: true }));
|
|
2168
|
+
await admin.api.environments.dismiss(DEV, { [PROD_ONLY]: true });
|
|
2169
|
+
const dismissed = await admin.api.environments.missing(DEV);
|
|
2170
|
+
expect(dismissed.dismissed.some((key) => key.key === PROD_ONLY) && !dismissed.missing.some((key) => key.key === PROD_ONLY), "a dismissed key was still listed as missing", dismissed);
|
|
2171
|
+
await admin.api.environments.dismiss(DEV, { [PROD_ONLY]: null });
|
|
2172
|
+
expect((await admin.api.environments.missing(DEV)).missing.some((key) => key.key === PROD_ONLY), "a restored key was not missing again");
|
|
2173
|
+
} finally {
|
|
2174
|
+
await admin.api.secrets.update(`${PROD}/${PROD_ONLY}`, { archived: true });
|
|
2175
|
+
}
|
|
2176
|
+
return "only who reads prod learns what dev lacks of it; a viewer dismisses nothing; a dismissal is listed, and restored";
|
|
2177
|
+
}
|
|
2178
|
+
//#endregion
|
|
1762
2179
|
//#region src/checks/logins.ts
|
|
1763
2180
|
const ZEROS = "decode(repeat('00', 32), 'hex')";
|
|
1764
2181
|
const appendAs = (author) => `INSERT INTO audit_log
|
|
@@ -1872,6 +2289,582 @@ async function vaultLogin(deployment) {
|
|
|
1872
2289
|
});
|
|
1873
2290
|
}
|
|
1874
2291
|
//#endregion
|
|
2292
|
+
//#region src/checks/mcp.ts
|
|
2293
|
+
const NAME = "Conformance MCP client";
|
|
2294
|
+
/** A native client's redirect, on loopback. A custom scheme is left out of a registration (D37). */
|
|
2295
|
+
const REDIRECT = "http://127.0.0.1:33418/callback";
|
|
2296
|
+
/** A `state` the router would read as a number: it must come back as sent. */
|
|
2297
|
+
const STATE = "1e5";
|
|
2298
|
+
/** What every 2026-07-28 request carries: its revision and the client's capabilities. */
|
|
2299
|
+
const ENVELOPE = {
|
|
2300
|
+
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
|
|
2301
|
+
"io.modelcontextprotocol/clientCapabilities": {}
|
|
2302
|
+
};
|
|
2303
|
+
const base64url = (bytes) => bytes.toString("base64url");
|
|
2304
|
+
async function json(response) {
|
|
2305
|
+
const text = await response.text();
|
|
2306
|
+
try {
|
|
2307
|
+
return JSON.parse(text);
|
|
2308
|
+
} catch {
|
|
2309
|
+
return { text };
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
/** A JSON-RPC message to /mcp, with the headers a client sends. */
|
|
2313
|
+
function mcp(deployment, headers, method = "server/discover", params = {}) {
|
|
2314
|
+
return fetch(`${deployment.origin}/mcp`, {
|
|
2315
|
+
method: "POST",
|
|
2316
|
+
headers: {
|
|
2317
|
+
"content-type": "application/json",
|
|
2318
|
+
accept: "application/json, text/event-stream",
|
|
2319
|
+
...headers
|
|
2320
|
+
},
|
|
2321
|
+
body: JSON.stringify({
|
|
2322
|
+
jsonrpc: "2.0",
|
|
2323
|
+
id: 1,
|
|
2324
|
+
method,
|
|
2325
|
+
params
|
|
2326
|
+
})
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
function token(deployment, fields) {
|
|
2330
|
+
return fetch(`${deployment.origin}/api/oauth/token`, {
|
|
2331
|
+
method: "POST",
|
|
2332
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
2333
|
+
body: new URLSearchParams(fields)
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
/** The person approves on the consent page, as its Approve does; the code comes back on the redirect. */
|
|
2337
|
+
async function connect(deployment, person, clientId, scope = "browse") {
|
|
2338
|
+
const verifier = base64url(randomBytes(32));
|
|
2339
|
+
const request = {
|
|
2340
|
+
client_id: clientId,
|
|
2341
|
+
redirect_uri: REDIRECT,
|
|
2342
|
+
response_type: "code",
|
|
2343
|
+
code_challenge: base64url(createHash("sha256").update(verifier).digest()),
|
|
2344
|
+
code_challenge_method: "S256",
|
|
2345
|
+
state: STATE,
|
|
2346
|
+
scope,
|
|
2347
|
+
resource: `${deployment.origin}/mcp`
|
|
2348
|
+
};
|
|
2349
|
+
const view = await person.api.oauth.describe(request);
|
|
2350
|
+
expect(view.status === "ready", "the consent page refused a good request", view);
|
|
2351
|
+
expect(view.client.registration === "dcr" && view.client.name === NAME && view.scopes.join(" ") === scope && view.loopbackOnly, "the consent page does not show the registered client as it is", view);
|
|
2352
|
+
const { redirect } = await person.api.oauth.decide({
|
|
2353
|
+
request,
|
|
2354
|
+
approve: true,
|
|
2355
|
+
scopes: scope.split(" ")
|
|
2356
|
+
});
|
|
2357
|
+
const back = new URL(redirect);
|
|
2358
|
+
expect(`${back.origin}${back.pathname}` === REDIRECT, `the answer went to ${back.origin}${back.pathname}, not the redirect`, redirect);
|
|
2359
|
+
expect(back.searchParams.get("state") === STATE && back.searchParams.get("iss") === deployment.origin, "the answer does not carry the state as sent and the issuer", redirect);
|
|
2360
|
+
const code = back.searchParams.get("code");
|
|
2361
|
+
expect(code !== null, "an approval carried no code", redirect);
|
|
2362
|
+
return {
|
|
2363
|
+
code,
|
|
2364
|
+
verifier
|
|
2365
|
+
};
|
|
2366
|
+
}
|
|
2367
|
+
async function redeem(deployment, clientId, { code, verifier }) {
|
|
2368
|
+
const answer = await token(deployment, {
|
|
2369
|
+
grant_type: "authorization_code",
|
|
2370
|
+
code,
|
|
2371
|
+
code_verifier: verifier,
|
|
2372
|
+
redirect_uri: REDIRECT,
|
|
2373
|
+
client_id: clientId,
|
|
2374
|
+
resource: `${deployment.origin}/mcp`
|
|
2375
|
+
});
|
|
2376
|
+
const body = await json(answer);
|
|
2377
|
+
expect(answer.status === 200 && typeof body.access_token === "string" && typeof body.refresh_token === "string", `redeeming the code answered ${answer.status}`, body);
|
|
2378
|
+
expect(answer.headers.get("cache-control") === "no-store", "tokens were answered without cache-control: no-store");
|
|
2379
|
+
return body;
|
|
2380
|
+
}
|
|
2381
|
+
async function refused(deployment, what, fields) {
|
|
2382
|
+
const answer = await token(deployment, fields);
|
|
2383
|
+
const body = await json(answer);
|
|
2384
|
+
expect(answer.status === 400 && body.error === "invalid_grant", `${what} answered ${answer.status}, not invalid_grant`, body);
|
|
2385
|
+
}
|
|
2386
|
+
async function discovers(deployment, access) {
|
|
2387
|
+
const answer = await mcp(deployment, {
|
|
2388
|
+
authorization: `Bearer ${access}`,
|
|
2389
|
+
"mcp-protocol-version": "2026-07-28",
|
|
2390
|
+
"mcp-method": "server/discover"
|
|
2391
|
+
}, "server/discover", { _meta: ENVELOPE });
|
|
2392
|
+
if (answer.status === 401) return false;
|
|
2393
|
+
const body = await json(answer);
|
|
2394
|
+
expect(answer.status === 200 && Array.isArray(body.result?.supportedVersions), `server/discover answered ${answer.status}`, body);
|
|
2395
|
+
return true;
|
|
2396
|
+
}
|
|
2397
|
+
async function mcpConnect(deployment, people) {
|
|
2398
|
+
const { origin } = deployment;
|
|
2399
|
+
const anonymous = await mcp(deployment, {});
|
|
2400
|
+
const challenge = anonymous.headers.get("www-authenticate") ?? "";
|
|
2401
|
+
expect(anonymous.status === 401, `/mcp answered ${anonymous.status} without a token, not 401`);
|
|
2402
|
+
expect(challenge.includes(`resource_metadata="${origin}/.well-known/oauth-protected-resource/mcp"`) && challenge.includes("scope=\"browse\""), "the 401's challenge does not name the resource metadata and Browse", challenge);
|
|
2403
|
+
const resource = await json(await fetch(`${origin}/.well-known/oauth-protected-resource/mcp`));
|
|
2404
|
+
expect(resource.resource === `${origin}/mcp` && resource.authorization_servers?.[0] === origin, "the protected resource metadata does not name /mcp and coffre as its issuer", resource);
|
|
2405
|
+
const server = await json(await fetch(`${origin}/.well-known/oauth-authorization-server`));
|
|
2406
|
+
expect(server.issuer === origin && server.authorization_endpoint === `${origin}/oauth/authorize`, "the authorization server metadata is wrong", server);
|
|
2407
|
+
for (const [field, value] of [
|
|
2408
|
+
["code_challenge_methods_supported", "S256"],
|
|
2409
|
+
["token_endpoint_auth_methods_supported", "none"],
|
|
2410
|
+
["grant_types_supported", "refresh_token"]
|
|
2411
|
+
]) expect(server[field]?.includes(value), `the authorization server metadata leaves ${value} out of ${field}`, server);
|
|
2412
|
+
expect(server.client_id_metadata_document_supported === true, "the authorization server metadata does not offer metadata documents", server);
|
|
2413
|
+
const registered = await fetch(`${origin}/api/oauth/register`, {
|
|
2414
|
+
method: "POST",
|
|
2415
|
+
headers: { "content-type": "application/json" },
|
|
2416
|
+
body: JSON.stringify({
|
|
2417
|
+
client_name: NAME,
|
|
2418
|
+
redirect_uris: [REDIRECT, "conformance-app://callback"],
|
|
2419
|
+
token_endpoint_auth_method: "none"
|
|
2420
|
+
})
|
|
2421
|
+
});
|
|
2422
|
+
const client = await json(registered);
|
|
2423
|
+
expect(registered.status === 201 && typeof client.client_id === "string", `registering answered ${registered.status}`, client);
|
|
2424
|
+
expect(JSON.stringify(client.redirect_uris) === JSON.stringify([REDIRECT]), "the registration kept a redirect it should have left out", client);
|
|
2425
|
+
const clientId = client.client_id;
|
|
2426
|
+
const page = await people.reader.browser.fetch(`/oauth/authorize?${new URLSearchParams({
|
|
2427
|
+
client_id: clientId,
|
|
2428
|
+
redirect_uri: REDIRECT
|
|
2429
|
+
})}`);
|
|
2430
|
+
expect(page.status === 200, `the consent page answered ${page.status}`);
|
|
2431
|
+
const forged = await people.reader.browser.fetch("/api/oauth/authorizations", {
|
|
2432
|
+
method: "POST",
|
|
2433
|
+
headers: {
|
|
2434
|
+
origin: "https://attacker.example",
|
|
2435
|
+
"sec-fetch-site": "cross-site",
|
|
2436
|
+
"content-type": "application/json"
|
|
2437
|
+
},
|
|
2438
|
+
body: JSON.stringify({
|
|
2439
|
+
request: {
|
|
2440
|
+
client_id: clientId,
|
|
2441
|
+
redirect_uri: REDIRECT
|
|
2442
|
+
},
|
|
2443
|
+
approve: true
|
|
2444
|
+
})
|
|
2445
|
+
});
|
|
2446
|
+
expect(forged.status === 403, `another site's approval answered ${forged.status}, not 403`);
|
|
2447
|
+
const first = await redeem(deployment, clientId, await connect(deployment, people.reader, clientId));
|
|
2448
|
+
expect(first.access_token.startsWith("coffre_mcp_") && first.refresh_token.startsWith("coffre_mcr_") && first.scope === "browse", "the tokens are not the shapes and scope coffre issues", { scope: first.scope });
|
|
2449
|
+
expect(await discovers(deployment, first.access_token), "a fresh access token was refused at /mcp");
|
|
2450
|
+
const atApi = await fetch(`${origin}/api/me`, { headers: { authorization: `Bearer ${first.access_token}` } });
|
|
2451
|
+
expect(atApi.status === 401, `an MCP token at /api answered ${atApi.status}, not 401`);
|
|
2452
|
+
const cli = await mcp(deployment, { authorization: `Bearer ${people.leaver.cliToken}` });
|
|
2453
|
+
expect(cli.status === 401, `a CLI session at /mcp answered ${cli.status}, not 401`);
|
|
2454
|
+
const browser = await people.reader.browser.fetch("/mcp", {
|
|
2455
|
+
method: "POST",
|
|
2456
|
+
headers: {
|
|
2457
|
+
"content-type": "application/json",
|
|
2458
|
+
origin
|
|
2459
|
+
},
|
|
2460
|
+
body: JSON.stringify({
|
|
2461
|
+
jsonrpc: "2.0",
|
|
2462
|
+
id: 1,
|
|
2463
|
+
method: "server/discover"
|
|
2464
|
+
})
|
|
2465
|
+
});
|
|
2466
|
+
expect(browser.status === 401, `a browser's cookie at /mcp answered ${browser.status}, not 401`);
|
|
2467
|
+
const foreign = await mcp(deployment, {
|
|
2468
|
+
authorization: `Bearer ${first.access_token}`,
|
|
2469
|
+
origin: "https://attacker.example"
|
|
2470
|
+
});
|
|
2471
|
+
expect(foreign.status === 403, `/mcp answered ${foreign.status} to another site's page, not 403`);
|
|
2472
|
+
const rotate = (refresh) => token(deployment, {
|
|
2473
|
+
grant_type: "refresh_token",
|
|
2474
|
+
refresh_token: refresh,
|
|
2475
|
+
client_id: clientId
|
|
2476
|
+
});
|
|
2477
|
+
const rotated = await rotate(first.refresh_token);
|
|
2478
|
+
const next = await json(rotated);
|
|
2479
|
+
expect(rotated.status === 200 && next.refresh_token !== first.refresh_token, `refreshing answered ${rotated.status}, or the same refresh token`);
|
|
2480
|
+
expect(await discovers(deployment, next.access_token), "a refreshed access token was refused");
|
|
2481
|
+
await refused(deployment, "a replaced refresh token", {
|
|
2482
|
+
grant_type: "refresh_token",
|
|
2483
|
+
refresh_token: first.refresh_token,
|
|
2484
|
+
client_id: clientId
|
|
2485
|
+
});
|
|
2486
|
+
await refused(deployment, "the current refresh token, after a reuse", {
|
|
2487
|
+
grant_type: "refresh_token",
|
|
2488
|
+
refresh_token: next.refresh_token,
|
|
2489
|
+
client_id: clientId
|
|
2490
|
+
});
|
|
2491
|
+
expect(!await discovers(deployment, next.access_token), "an access token outlived its connection, ended by a reused refresh token");
|
|
2492
|
+
const asked = await connect(deployment, people.reader, clientId);
|
|
2493
|
+
const second = await redeem(deployment, clientId, asked);
|
|
2494
|
+
await refused(deployment, "a code redeemed already", {
|
|
2495
|
+
grant_type: "authorization_code",
|
|
2496
|
+
code: asked.code,
|
|
2497
|
+
code_verifier: asked.verifier,
|
|
2498
|
+
redirect_uri: REDIRECT,
|
|
2499
|
+
client_id: clientId
|
|
2500
|
+
});
|
|
2501
|
+
expect(!await discovers(deployment, second.access_token), "an access token outlived its connection, ended by a reused code");
|
|
2502
|
+
const third = await redeem(deployment, clientId, await connect(deployment, people.reader, clientId));
|
|
2503
|
+
const listed = (await people.reader.api.apps.list()).apps;
|
|
2504
|
+
expect(listed.length === 1 && listed[0].name === NAME && listed[0].registration === "dcr", "Connected apps does not list the one live connection", listed);
|
|
2505
|
+
await people.reader.api.apps.disconnect(listed[0].id);
|
|
2506
|
+
expect(!await discovers(deployment, third.access_token), "an access token outlived its disconnection");
|
|
2507
|
+
expect((await people.reader.api.apps.list()).apps.length === 0, "a disconnected app is still listed");
|
|
2508
|
+
const { entries } = await people.admin.api.audit.list({
|
|
2509
|
+
actor: people.reader.member,
|
|
2510
|
+
detail: "1",
|
|
2511
|
+
limit: 500
|
|
2512
|
+
});
|
|
2513
|
+
const mine = entries.filter((entry) => entry.metadata.clientId === clientId);
|
|
2514
|
+
const count = (action) => mine.filter((entry) => entry.action === action && entry.decision === "allow").length;
|
|
2515
|
+
const counts = {
|
|
2516
|
+
connect: count("mcp.connect"),
|
|
2517
|
+
token: count("mcp.token"),
|
|
2518
|
+
disconnect: count("mcp.disconnect")
|
|
2519
|
+
};
|
|
2520
|
+
expect(counts.connect === 3 && counts.token === 4 && counts.disconnect === 3, "the log does not hold each connection, token and disconnection", counts);
|
|
2521
|
+
const reasons = mine.filter((entry) => entry.action === "mcp.disconnect").map((entry) => entry.metadata.reason).sort();
|
|
2522
|
+
expect(JSON.stringify(reasons) === JSON.stringify([
|
|
2523
|
+
"code_reused",
|
|
2524
|
+
"person",
|
|
2525
|
+
"refresh_reused"
|
|
2526
|
+
]), "the disconnections do not say why", reasons);
|
|
2527
|
+
return "401 and both metadata documents; registered, approved, redeemed and discovered; only at /mcp, and only its token there; a reused refresh token, a reused code and a disconnection each end the connection, and the log says so";
|
|
2528
|
+
}
|
|
2529
|
+
/** A 2026-07-28 request as a client sends it: its headers say what its body does; `capabilities` are the client's. */
|
|
2530
|
+
async function modern(deployment, access, method, params = {}, name, capabilities = {}) {
|
|
2531
|
+
const response = await mcp(deployment, {
|
|
2532
|
+
authorization: `Bearer ${access}`,
|
|
2533
|
+
"mcp-protocol-version": "2026-07-28",
|
|
2534
|
+
"mcp-method": method,
|
|
2535
|
+
...name === void 0 ? {} : { "mcp-name": name }
|
|
2536
|
+
}, method, {
|
|
2537
|
+
...params,
|
|
2538
|
+
_meta: {
|
|
2539
|
+
...ENVELOPE,
|
|
2540
|
+
"io.modelcontextprotocol/clientCapabilities": capabilities
|
|
2541
|
+
}
|
|
2542
|
+
});
|
|
2543
|
+
return {
|
|
2544
|
+
response,
|
|
2545
|
+
body: await json(response)
|
|
2546
|
+
};
|
|
2547
|
+
}
|
|
2548
|
+
/** A client registered for one check, by the name every check's client has. */
|
|
2549
|
+
async function register(deployment) {
|
|
2550
|
+
return (await json(await fetch(`${deployment.origin}/api/oauth/register`, {
|
|
2551
|
+
method: "POST",
|
|
2552
|
+
headers: { "content-type": "application/json" },
|
|
2553
|
+
body: JSON.stringify({
|
|
2554
|
+
client_name: NAME,
|
|
2555
|
+
redirect_uris: [REDIRECT]
|
|
2556
|
+
})
|
|
2557
|
+
}))).client_id;
|
|
2558
|
+
}
|
|
2559
|
+
/**
|
|
2560
|
+
* The Browse tools, as a client calls them (design section 14, checks 1, 4
|
|
2561
|
+
* and 5): on 2026-07-28 and through a 2025-11-25 `initialize`, as the
|
|
2562
|
+
* reader, who sees dev and not prod. No value appears in any answer, the
|
|
2563
|
+
* headers must agree with the body, and every call is in the log under the
|
|
2564
|
+
* client, the API's own entries naming the connection.
|
|
2565
|
+
*/
|
|
2566
|
+
async function mcpBrowse(deployment, people, canaries) {
|
|
2567
|
+
const clientId = await register(deployment);
|
|
2568
|
+
const { access_token: access } = await redeem(deployment, clientId, await connect(deployment, people.reader, clientId));
|
|
2569
|
+
const answers = [];
|
|
2570
|
+
const discovered = await modern(deployment, access, "server/discover");
|
|
2571
|
+
answers.push(JSON.stringify(discovered.body));
|
|
2572
|
+
expect(discovered.response.status === 200, `server/discover answered ${discovered.response.status}`, discovered.body);
|
|
2573
|
+
const listed = await modern(deployment, access, "tools/list");
|
|
2574
|
+
const result = listed.body.result;
|
|
2575
|
+
const names = result?.tools?.map((tool) => tool.name) ?? [];
|
|
2576
|
+
expect(names.includes("list_secrets") && names.includes("run_with_secrets") && result?.cacheScope === "public" && typeof result.ttlMs === "number", "tools/list does not list the Browse tools, cacheable", listed.body);
|
|
2577
|
+
const callTool = async (tool, args) => {
|
|
2578
|
+
const { response, body } = await modern(deployment, access, "tools/call", {
|
|
2579
|
+
name: tool,
|
|
2580
|
+
arguments: args
|
|
2581
|
+
}, tool);
|
|
2582
|
+
answers.push(JSON.stringify(body));
|
|
2583
|
+
expect(response.status === 200, `tools/call ${tool} answered ${response.status}`, body);
|
|
2584
|
+
return body.result;
|
|
2585
|
+
};
|
|
2586
|
+
const keys = ((await callTool("list_secrets", { environment: DEV })).structuredContent?.keys ?? []).map((key) => key.key);
|
|
2587
|
+
expect(["API_KEY", "DATABASE_URL"].every((key) => keys.includes(key)), `list_secrets on ${DEV} does not list its keys`, keys);
|
|
2588
|
+
const prod = await callTool("list_secrets", { environment: PROD });
|
|
2589
|
+
expect(prod.isError === true, `the reader listed ${PROD}'s keys through MCP, which they cannot`, prod);
|
|
2590
|
+
const run = await callTool("run_with_secrets", {
|
|
2591
|
+
environment: DEV,
|
|
2592
|
+
command: "npm test"
|
|
2593
|
+
});
|
|
2594
|
+
expect(run.content?.[0]?.text?.includes(`coffre run ${DEV} -- npm test`) === true, "run_with_secrets does not say how to run the command", run);
|
|
2595
|
+
for (const tool of ["whoami", "list_projects"]) await callTool(tool, {});
|
|
2596
|
+
await callTool("secret_history", { secret: `${DEV}/API_KEY` });
|
|
2597
|
+
const mismatched = await mcp(deployment, {
|
|
2598
|
+
authorization: `Bearer ${access}`,
|
|
2599
|
+
"mcp-protocol-version": "2026-07-28",
|
|
2600
|
+
"mcp-method": "tools/call",
|
|
2601
|
+
"mcp-name": "list_projects"
|
|
2602
|
+
}, "tools/call", {
|
|
2603
|
+
name: "whoami",
|
|
2604
|
+
arguments: {},
|
|
2605
|
+
_meta: ENVELOPE
|
|
2606
|
+
});
|
|
2607
|
+
const mismatch = await json(mismatched);
|
|
2608
|
+
expect(mismatched.status === 400 && mismatch.error?.code === -32020, `a Mcp-Name naming another tool answered ${mismatched.status}`, mismatch);
|
|
2609
|
+
const initialized = await mcp(deployment, { authorization: `Bearer ${access}` }, "initialize", {
|
|
2610
|
+
protocolVersion: "2025-11-25",
|
|
2611
|
+
capabilities: {},
|
|
2612
|
+
clientInfo: {
|
|
2613
|
+
name: "coffre-conformance",
|
|
2614
|
+
version: "1"
|
|
2615
|
+
}
|
|
2616
|
+
});
|
|
2617
|
+
const init = await json(initialized);
|
|
2618
|
+
expect(initialized.status === 200 && init.result?.protocolVersion === "2025-11-25", `initialize for 2025-11-25 answered ${initialized.status}`, init);
|
|
2619
|
+
expect(initialized.headers.get("mcp-session-id") === null, "initialize minted a session: coffre keeps none");
|
|
2620
|
+
const legacy = await mcp(deployment, {
|
|
2621
|
+
authorization: `Bearer ${access}`,
|
|
2622
|
+
"mcp-protocol-version": "2025-11-25"
|
|
2623
|
+
}, "tools/call", {
|
|
2624
|
+
name: "list_secrets",
|
|
2625
|
+
arguments: { environment: DEV }
|
|
2626
|
+
});
|
|
2627
|
+
const legacyBody = await json(legacy);
|
|
2628
|
+
answers.push(JSON.stringify(legacyBody));
|
|
2629
|
+
expect(legacy.status === 200 && legacyBody.result?.isError !== true, `a 2025-11-25 tools/call answered ${legacy.status}`, legacyBody);
|
|
2630
|
+
const leaked = Object.entries(canaries).filter(([, value]) => answers.some((answer) => answer.includes(value))).map(([path]) => path);
|
|
2631
|
+
expect(leaked.length === 0, "a Browse tool answered with a secret value", leaked);
|
|
2632
|
+
const { entries } = await people.admin.api.audit.list({
|
|
2633
|
+
actor: people.reader.member,
|
|
2634
|
+
detail: "1",
|
|
2635
|
+
limit: 500
|
|
2636
|
+
});
|
|
2637
|
+
const mine = entries.filter((entry) => entry.metadata.via?.clientId === clientId);
|
|
2638
|
+
const reads = mine.filter((entry) => entry.action === "mcp.read").length;
|
|
2639
|
+
const refused = mine.filter((entry) => entry.action === "mcp.call" && entry.decision === "deny").length;
|
|
2640
|
+
expect(reads === 6 && refused === 1, "the log does not hold each call under the client", {
|
|
2641
|
+
reads,
|
|
2642
|
+
refused
|
|
2643
|
+
});
|
|
2644
|
+
expect(mine.filter((entry) => !entry.action.startsWith("mcp.")).length > 0, "the API's own entries for the calls do not name the connection", mine.map((entry) => entry.action));
|
|
2645
|
+
const shown = (await people.admin.api.audit.list({
|
|
2646
|
+
actor: people.reader.member,
|
|
2647
|
+
limit: 500
|
|
2648
|
+
})).entries;
|
|
2649
|
+
expect(!shown.some((entry) => entry.action === "mcp.read"), "read-only calls are not detail");
|
|
2650
|
+
return `on 2026-07-28 and 2025-11-25, the Browse tools as the reader: ${DEV} listed, ${PROD} refused, no value in any answer; headers held to the body; ${reads} reads as detail and the refusal shown, each under the client`;
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* Changes, as a client asks for them (design section 14, checks 2 and 3):
|
|
2654
|
+
* Browse cannot ask at all, and with Write nothing changes until the person
|
|
2655
|
+
* approves on coffre's page. A client without URL elicitation gets the link
|
|
2656
|
+
* and calls again; one with it is asked to open the page, and retries with
|
|
2657
|
+
* its requestState, which no other call may use. Only the person decides,
|
|
2658
|
+
* with the digest the page showed; the page makes the change, once, and its
|
|
2659
|
+
* entries name the client and the approval. A value comes from the page.
|
|
2660
|
+
*/
|
|
2661
|
+
async function mcpChanges(deployment, people, canaries) {
|
|
2662
|
+
const { admin } = people;
|
|
2663
|
+
const place = `${PROJECT$1}-mcp/dev`;
|
|
2664
|
+
await admin.api.projects.create(`${PROJECT$1}-mcp`, { name: "MCP changes" });
|
|
2665
|
+
await admin.api.environments.create(place, { name: "Development" });
|
|
2666
|
+
const values = {
|
|
2667
|
+
KEEP: canary(),
|
|
2668
|
+
OLD: canary()
|
|
2669
|
+
};
|
|
2670
|
+
for (const [key, value] of Object.entries(values)) canaries[`${place}/${key}`] = value;
|
|
2671
|
+
await admin.api.secrets.set(place, values);
|
|
2672
|
+
const changer = await personaOn(deployment, admin, "changer", { [`${PROJECT$1}-mcp`]: "maintainer" });
|
|
2673
|
+
const clientId = await register(deployment);
|
|
2674
|
+
const answers = [];
|
|
2675
|
+
const call = async (access, tool, args, more = {}, capabilities = {}) => {
|
|
2676
|
+
const { response, body } = await modern(deployment, access, "tools/call", {
|
|
2677
|
+
name: tool,
|
|
2678
|
+
arguments: args,
|
|
2679
|
+
...more
|
|
2680
|
+
}, tool, capabilities);
|
|
2681
|
+
answers.push(JSON.stringify(body));
|
|
2682
|
+
return {
|
|
2683
|
+
status: response.status,
|
|
2684
|
+
challenge: response.headers.get("www-authenticate") ?? "",
|
|
2685
|
+
result: body.result,
|
|
2686
|
+
error: body.error
|
|
2687
|
+
};
|
|
2688
|
+
};
|
|
2689
|
+
const archived = async (key) => (await admin.api.secrets.history(`${place}/${key}`)).archived;
|
|
2690
|
+
const browse = (await redeem(deployment, clientId, await connect(deployment, changer, clientId))).access_token;
|
|
2691
|
+
const stepUp = await call(browse, "archive_secret", { secret: `${place}/OLD` });
|
|
2692
|
+
expect(stepUp.status === 403 && stepUp.challenge.includes("error=\"insufficient_scope\"") && stepUp.challenge.includes("scope=\"browse write\""), `archive_secret with Browse answered ${stepUp.status}, not a step-up to Write`, stepUp.challenge);
|
|
2693
|
+
expect(!await archived("OLD"), "archive_secret with Browse archived the secret");
|
|
2694
|
+
const write = (await redeem(deployment, clientId, await connect(deployment, changer, clientId, "browse write"))).access_token;
|
|
2695
|
+
const linked = await call(write, "archive_secret", { secret: `${place}/OLD` });
|
|
2696
|
+
const approval = linked.result?.structuredContent?.approval;
|
|
2697
|
+
expect(linked.status === 200 && linked.result?.structuredContent?.status === "pending" && approval?.url === `${deployment.origin}/approvals/${approval?.id}`, "a change without URL elicitation was not answered with its approval link", linked.result);
|
|
2698
|
+
expect(linked.result?.content?.[0]?.text?.includes(approval.url) === true, "the link is not in the text the model reads", linked.result);
|
|
2699
|
+
expect(!await archived("OLD"), "a change was made before its approval");
|
|
2700
|
+
const theirs = await people.reader.api.approvals.get(approval.id).then(() => null, (error) => error);
|
|
2701
|
+
expect(theirs instanceof CoffreError && theirs.status === 403, "another person opened someone else's approval", theirs);
|
|
2702
|
+
const page = await changer.browser.fetch(`/approvals/${approval.id}`);
|
|
2703
|
+
expect(page.status === 200, `the approval page answered ${page.status}`);
|
|
2704
|
+
const shown = (await changer.api.approvals.get(approval.id)).approval;
|
|
2705
|
+
expect(shown.status === "pending" && shown.summary === `archive ${place}/OLD` && shown.client.name === NAME, "the approval page does not show the change asked for", shown);
|
|
2706
|
+
const forgedDigest = await changer.api.approvals.decide(approval.id, {
|
|
2707
|
+
approve: true,
|
|
2708
|
+
digest: "0".repeat(64)
|
|
2709
|
+
}).then(() => null, (error) => error);
|
|
2710
|
+
expect(forgedDigest instanceof CoffreError && forgedDigest.status === 409, "a decision on a change the page did not show was taken", forgedDigest);
|
|
2711
|
+
const forgedSite = await changer.browser.fetch(`/api/approvals/${approval.id}`, {
|
|
2712
|
+
method: "POST",
|
|
2713
|
+
headers: {
|
|
2714
|
+
origin: "https://attacker.example",
|
|
2715
|
+
"sec-fetch-site": "cross-site",
|
|
2716
|
+
"content-type": "application/json"
|
|
2717
|
+
},
|
|
2718
|
+
body: JSON.stringify({
|
|
2719
|
+
approve: true,
|
|
2720
|
+
digest: shown.digest
|
|
2721
|
+
})
|
|
2722
|
+
});
|
|
2723
|
+
expect(forgedSite.status === 403, `another site's approval answered ${forgedSite.status}, not 403`);
|
|
2724
|
+
expect(!await archived("OLD"), "a refused decision changed something");
|
|
2725
|
+
const decided = await changer.api.approvals.decide(approval.id, {
|
|
2726
|
+
approve: true,
|
|
2727
|
+
digest: shown.digest
|
|
2728
|
+
});
|
|
2729
|
+
expect(decided.status === "approved" && await archived("OLD"), "Approve did not make the change", decided);
|
|
2730
|
+
const again = await changer.api.approvals.decide(approval.id, {
|
|
2731
|
+
approve: true,
|
|
2732
|
+
digest: shown.digest
|
|
2733
|
+
}).then(() => null, (error) => error);
|
|
2734
|
+
expect(again instanceof CoffreError && again.status === 409, "an approval was decided twice", again);
|
|
2735
|
+
const reported = await call(write, "archive_secret", { secret: `${place}/OLD` });
|
|
2736
|
+
expect(reported.result?.structuredContent?.status === "approved" && reported.result.isError !== true, "calling again does not report the approved change", reported.result);
|
|
2737
|
+
const elicits = { elicitation: { url: {} } };
|
|
2738
|
+
const asked = await call(write, "rename_secret", {
|
|
2739
|
+
secret: `${place}/KEEP`,
|
|
2740
|
+
newKey: "KEPT"
|
|
2741
|
+
}, {}, elicits);
|
|
2742
|
+
const request = asked.result?.inputRequests?.approve;
|
|
2743
|
+
expect(asked.result?.resultType === "input_required" && request?.method === "elicitation/create" && request.params.mode === "url" && typeof asked.result.requestState === "string", "a change with URL elicitation was not answered with an input_required URL elicitation", asked.result);
|
|
2744
|
+
const id = request.params.url.split("/").at(-1);
|
|
2745
|
+
const replayed = await call(write, "rename_secret", {
|
|
2746
|
+
secret: `${place}/KEEP`,
|
|
2747
|
+
newKey: "OTHER"
|
|
2748
|
+
}, {
|
|
2749
|
+
requestState: asked.result.requestState,
|
|
2750
|
+
inputResponses: { approve: { action: "accept" } }
|
|
2751
|
+
}, elicits);
|
|
2752
|
+
expect(replayed.error?.code === -32602, "a requestState was accepted for another call", replayed);
|
|
2753
|
+
const renamedEarly = await admin.api.secrets.list(place);
|
|
2754
|
+
expect(renamedEarly.keys.some((key) => key.key === "KEEP"), "a change was made before its approval", renamedEarly.keys);
|
|
2755
|
+
const second = (await changer.api.approvals.get(id)).approval;
|
|
2756
|
+
expect((await changer.api.approvals.decide(id, {
|
|
2757
|
+
approve: true,
|
|
2758
|
+
digest: second.digest
|
|
2759
|
+
})).status === "approved", "the second approval was not made");
|
|
2760
|
+
const retried = await call(write, "rename_secret", {
|
|
2761
|
+
secret: `${place}/KEEP`,
|
|
2762
|
+
newKey: "KEPT"
|
|
2763
|
+
}, {
|
|
2764
|
+
requestState: asked.result.requestState,
|
|
2765
|
+
inputResponses: { approve: { action: "accept" } }
|
|
2766
|
+
}, elicits);
|
|
2767
|
+
expect(retried.result?.structuredContent?.status === "approved", "the retry does not report the approved change", retried.result);
|
|
2768
|
+
const typed = canary();
|
|
2769
|
+
canaries[`${place}/TYPED`] = typed;
|
|
2770
|
+
const valueId = (await call(write, "request_secret_value", { secret: `${place}/TYPED` })).result.structuredContent.approval.id;
|
|
2771
|
+
const valuePage = (await changer.api.approvals.get(valueId)).approval;
|
|
2772
|
+
expect(valuePage.asks?.value !== void 0, "the approval page does not ask for the value");
|
|
2773
|
+
await changer.api.approvals.decide(valueId, {
|
|
2774
|
+
approve: true,
|
|
2775
|
+
digest: valuePage.digest,
|
|
2776
|
+
value: typed
|
|
2777
|
+
});
|
|
2778
|
+
expect((await admin.api.secrets.reveal(`${place}/TYPED`)).values.TYPED === typed, "the value typed on the page was not written");
|
|
2779
|
+
await call(write, "request_secret_value", { secret: `${place}/TYPED` });
|
|
2780
|
+
const generatedId = (await call(write, "generate_secret_value", {
|
|
2781
|
+
secret: `${place}/GENERATED`,
|
|
2782
|
+
alphabet: "hex"
|
|
2783
|
+
})).result.structuredContent.approval.id;
|
|
2784
|
+
const generatedPage = (await changer.api.approvals.get(generatedId)).approval;
|
|
2785
|
+
const generated = await changer.api.approvals.decide(generatedId, {
|
|
2786
|
+
approve: true,
|
|
2787
|
+
digest: generatedPage.digest
|
|
2788
|
+
});
|
|
2789
|
+
const made = (await admin.api.secrets.reveal(`${place}/GENERATED`)).values.GENERATED ?? "";
|
|
2790
|
+
canaries[`${place}/GENERATED`] = made;
|
|
2791
|
+
expect(/^[0-9a-f]{64}$/.test(made) && generated.shown.length === 0 && !JSON.stringify(generated).includes(made), "generate_secret_value did not make a 64-character hex value, shown to no one");
|
|
2792
|
+
await call(write, "generate_secret_value", {
|
|
2793
|
+
secret: `${place}/GENERATED`,
|
|
2794
|
+
alphabet: "hex"
|
|
2795
|
+
});
|
|
2796
|
+
const leaked = Object.entries(canaries).filter(([, value]) => answers.some((answer) => answer.includes(value))).map(([path]) => path);
|
|
2797
|
+
expect(leaked.length === 0, "a change tool answered with a secret value", leaked);
|
|
2798
|
+
const { entries } = await admin.api.audit.list({
|
|
2799
|
+
actor: changer.member,
|
|
2800
|
+
limit: 500
|
|
2801
|
+
});
|
|
2802
|
+
const viaApproval = (action) => entries.filter((entry) => entry.action === action && entry.decision === "allow" && typeof entry.metadata.via?.approvalId === "string");
|
|
2803
|
+
const once = {
|
|
2804
|
+
archive: viaApproval("secret.archive").length,
|
|
2805
|
+
rename: viaApproval("secret.rename").length,
|
|
2806
|
+
write: viaApproval("secret.write").length
|
|
2807
|
+
};
|
|
2808
|
+
expect(once.archive === 1 && once.rename === 1 && once.write === 2, "the changes are not each made once, via the client and its approval", once);
|
|
2809
|
+
const decisions = entries.filter((entry) => entry.action === "mcp.approve").map((entry) => `${entry.decision} ${entry.reason ?? ""}`.trim()).sort();
|
|
2810
|
+
expect(JSON.stringify(decisions) === JSON.stringify([
|
|
2811
|
+
"allow",
|
|
2812
|
+
"allow",
|
|
2813
|
+
"allow",
|
|
2814
|
+
"allow",
|
|
2815
|
+
"deny approved",
|
|
2816
|
+
"deny changed"
|
|
2817
|
+
]), "the decisions, and the two refused, are not in the log", decisions);
|
|
2818
|
+
return `Browse stepped up to Write; with Write, the link without URL elicitation and an elicitation with it; nothing changed until ${changer.email} approved on coffre's page, another person and another site refused, a replayed requestState refused; each change made once, via the client and its approval; a value typed on the page only, and one coffre made reaching no one`;
|
|
2819
|
+
}
|
|
2820
|
+
/**
|
|
2821
|
+
* Values (design section 14, checks 2 and 4): Browse cannot read one, Read
|
|
2822
|
+
* values reads what the person may, a value shown on coffre's page goes to
|
|
2823
|
+
* the person and not the client, and one a client asks coffre to make
|
|
2824
|
+
* reaches no one.
|
|
2825
|
+
*/
|
|
2826
|
+
async function mcpValues(deployment, people, canaries) {
|
|
2827
|
+
const { reader } = people;
|
|
2828
|
+
const clientId = await register(deployment);
|
|
2829
|
+
const answers = [];
|
|
2830
|
+
const call = async (access, tool, args) => {
|
|
2831
|
+
const { response, body } = await modern(deployment, access, "tools/call", {
|
|
2832
|
+
name: tool,
|
|
2833
|
+
arguments: args
|
|
2834
|
+
}, tool);
|
|
2835
|
+
answers.push(JSON.stringify(body));
|
|
2836
|
+
return {
|
|
2837
|
+
status: response.status,
|
|
2838
|
+
challenge: response.headers.get("www-authenticate") ?? "",
|
|
2839
|
+
result: body.result
|
|
2840
|
+
};
|
|
2841
|
+
};
|
|
2842
|
+
const dev = valuesIn(canaries, DEV);
|
|
2843
|
+
const browse = (await redeem(deployment, clientId, await connect(deployment, reader, clientId))).access_token;
|
|
2844
|
+
const stepUp = await call(browse, "read_secret_values", { path: DEV });
|
|
2845
|
+
expect(stepUp.status === 403 && stepUp.challenge.includes("scope=\"browse read-values\""), `read_secret_values with Browse answered ${stepUp.status}, not a step-up`, stepUp.challenge);
|
|
2846
|
+
const show = await call(browse, "show_secret_value", { secret: `${DEV}/API_KEY` });
|
|
2847
|
+
const id = show.result?.structuredContent?.approval?.id;
|
|
2848
|
+
expect(show.result?.structuredContent?.status === "pending" && id !== void 0, "show_secret_value did not open an approval", show.result);
|
|
2849
|
+
const page = (await reader.api.approvals.get(id)).approval;
|
|
2850
|
+
expect(page.kind === "reveal", "the approval page does not say it shows a value", page);
|
|
2851
|
+
expect((await reader.api.approvals.decide(id, {
|
|
2852
|
+
approve: true,
|
|
2853
|
+
digest: page.digest
|
|
2854
|
+
})).shown.some((line) => line.value === dev.API_KEY), "Reveal did not show the person the value");
|
|
2855
|
+
const told = await call(browse, "show_secret_value", { secret: `${DEV}/API_KEY` });
|
|
2856
|
+
expect(told.result?.structuredContent?.status === "approved", "show_secret_value does not report the value as shown", told.result);
|
|
2857
|
+
const browseLeaks = Object.entries(canaries).filter(([, value]) => answers.some((answer) => answer.includes(value))).map(([path]) => path);
|
|
2858
|
+
expect(browseLeaks.length === 0, "a Browse answer held a value", browseLeaks);
|
|
2859
|
+
const reading = (await redeem(deployment, clientId, await connect(deployment, reader, clientId, "browse read-values"))).access_token;
|
|
2860
|
+
const read = await call(reading, "read_secret_values", { path: DEV });
|
|
2861
|
+
expect(JSON.stringify(read.result?.structuredContent?.values) === JSON.stringify(dev), `read_secret_values on ${DEV} did not answer its values`);
|
|
2862
|
+
expect(read.result?.content?.[0]?.text?.startsWith("These values are now part of this conversation") === true, "read_secret_values does not warn first", read.result?.content);
|
|
2863
|
+
const prod = await call(reading, "read_secret_values", { path: PROD });
|
|
2864
|
+
expect(prod.result?.isError === true && !JSON.stringify(prod.result).includes(canaries[`${PROD}/API_KEY`]), `the reader read ${PROD} through MCP`, prod.result);
|
|
2865
|
+
return `Browse stepped up for values and showed ${DEV}/API_KEY to ${reader.email} on coffre's page only; Read values answered ${DEV}'s values, warning first, and refused ${PROD}`;
|
|
2866
|
+
}
|
|
2867
|
+
//#endregion
|
|
1875
2868
|
//#region src/checks/readiness.ts
|
|
1876
2869
|
async function red(deployment) {
|
|
1877
2870
|
await until("readiness red", async () => (await fetch(`${deployment.origin}/readyz`)).status === 503, 10);
|
|
@@ -1958,11 +2951,19 @@ function getCalls({ places, secrets, members, services }) {
|
|
|
1958
2951
|
"GET /me": [{ params: {} }],
|
|
1959
2952
|
"GET /projects": [{ params: {} }],
|
|
1960
2953
|
"GET /secrets/:project/:environment": places.map((params) => ({ params })),
|
|
2954
|
+
"GET /projects/:project/:environment/missing": places.map((params) => ({ params })),
|
|
1961
2955
|
"GET /secrets/:project/:environment/:key/versions": secrets.map((params) => ({ params })),
|
|
1962
2956
|
"GET /members": [{ params: {} }, ...first === void 0 ? [] : [{
|
|
1963
2957
|
params: {},
|
|
1964
2958
|
input: { path: `${first.project}/${first.environment}` }
|
|
1965
2959
|
}]],
|
|
2960
|
+
"GET /references": [...first === void 0 ? [] : [{
|
|
2961
|
+
params: {},
|
|
2962
|
+
input: { path: first.project }
|
|
2963
|
+
}, {
|
|
2964
|
+
params: {},
|
|
2965
|
+
input: { path: `${first.project}/${first.environment}` }
|
|
2966
|
+
}]],
|
|
1966
2967
|
"GET /members/:member": members.map((member) => ({ params: { member } })),
|
|
1967
2968
|
"GET /members/:member/tokens": services.map((member) => ({ params: { member } })),
|
|
1968
2969
|
"GET /members/:member/bindings": services.map((member) => ({ params: { member } })),
|
|
@@ -1973,6 +2974,15 @@ function getCalls({ places, secrets, members, services }) {
|
|
|
1973
2974
|
"GET /sessions": [{ params: {} }],
|
|
1974
2975
|
"GET /identities": [{ params: {} }],
|
|
1975
2976
|
"GET /device-logins/:code": [{ params: { code: "BCDF-GHJK" } }],
|
|
2977
|
+
"GET /oauth/authorizations": [{
|
|
2978
|
+
params: {},
|
|
2979
|
+
input: {
|
|
2980
|
+
client_id: "00000000-0000-4000-8000-000000000000",
|
|
2981
|
+
redirect_uri: "https://conformance.invalid/callback"
|
|
2982
|
+
}
|
|
2983
|
+
}],
|
|
2984
|
+
"GET /approvals/:id": [{ params: { id: "00000000-0000-4000-8000-000000000000" } }],
|
|
2985
|
+
"GET /apps": [{ params: {} }],
|
|
1976
2986
|
"GET /audit": [{
|
|
1977
2987
|
params: {},
|
|
1978
2988
|
input: { limit: 500 }
|
|
@@ -2027,8 +3037,8 @@ function calls(people) {
|
|
|
2027
3037
|
people.reader,
|
|
2028
3038
|
people.leaver,
|
|
2029
3039
|
people.bulk
|
|
2030
|
-
].map((person) => person.member), SERVICE],
|
|
2031
|
-
services: [SERVICE]
|
|
3040
|
+
].map((person) => person.member), SERVICE$2],
|
|
3041
|
+
services: [SERVICE$2]
|
|
2032
3042
|
});
|
|
2033
3043
|
}
|
|
2034
3044
|
function pages(people) {
|
|
@@ -2047,17 +3057,27 @@ function pages(people) {
|
|
|
2047
3057
|
"/audit",
|
|
2048
3058
|
"/settings",
|
|
2049
3059
|
"/auth/device",
|
|
3060
|
+
"/oauth/authorize",
|
|
2050
3061
|
"/projects",
|
|
2051
|
-
|
|
3062
|
+
...[
|
|
3063
|
+
"",
|
|
3064
|
+
"/users",
|
|
3065
|
+
"/service-accounts",
|
|
3066
|
+
"/settings"
|
|
3067
|
+
].map((tab) => `/projects/${PROJECT$1}${tab}`),
|
|
2052
3068
|
...[
|
|
2053
3069
|
DEV,
|
|
2054
3070
|
PROD,
|
|
2055
3071
|
BULK
|
|
2056
3072
|
].map((path) => `/projects/${path}`),
|
|
2057
3073
|
"/users",
|
|
2058
|
-
...users.
|
|
2059
|
-
"/
|
|
2060
|
-
|
|
3074
|
+
...users.flatMap((person) => ["", "/activity"].map((tab) => `/users/${encodeURIComponent(person.email)}${tab}`)),
|
|
3075
|
+
"/service-accounts",
|
|
3076
|
+
...[
|
|
3077
|
+
"",
|
|
3078
|
+
"/access",
|
|
3079
|
+
"/activity"
|
|
3080
|
+
].map((tab) => `/service-accounts/${SERVICE$2.slice(6)}${tab}`)
|
|
2061
3081
|
];
|
|
2062
3082
|
}
|
|
2063
3083
|
async function canaryScan(deployment, people, canaries) {
|
|
@@ -2242,16 +3262,19 @@ function marks(output) {
|
|
|
2242
3262
|
/** The token's run, from CI: as no one, then as the token, which is no owner and skips verification. */
|
|
2243
3263
|
async function verifyWithToken(cli, live) {
|
|
2244
3264
|
const { canary } = live;
|
|
3265
|
+
const login = await cli.run([
|
|
3266
|
+
"login",
|
|
3267
|
+
cli.origin,
|
|
3268
|
+
"--token"
|
|
3269
|
+
], {}, `${live.token}\n`);
|
|
3270
|
+
expect(login.code === 0, `coffre login --token exited ${login.code}`, login.output);
|
|
2245
3271
|
const run = await cli.run([
|
|
2246
3272
|
"verify",
|
|
2247
3273
|
"instance",
|
|
2248
3274
|
cli.origin,
|
|
2249
3275
|
"--canary",
|
|
2250
3276
|
`${canary.project}/${canary.environment}/${canary.key}`
|
|
2251
|
-
], {
|
|
2252
|
-
COFFRE_TOKEN: live.token,
|
|
2253
|
-
COFFRE_CONFORMANCE_CANARY: canary.value
|
|
2254
|
-
});
|
|
3277
|
+
], {}, `${canary.value}\n`);
|
|
2255
3278
|
const seen = marks(run.output);
|
|
2256
3279
|
expect(run.code === 0, `coffre verify instance with a token exited ${run.code}`, run.output);
|
|
2257
3280
|
expect(seen["token verification"] === "–", "a token that is no owner did not skip verification", run.output);
|
|
@@ -2332,7 +3355,7 @@ async function verifyInterrupted(cli, admin) {
|
|
|
2332
3355
|
* else changed; the runs' reads are in the audit log.
|
|
2333
3356
|
*/
|
|
2334
3357
|
async function verifyLeftovers(cli, admin, setups, before, kept) {
|
|
2335
|
-
expect(setups[0].includes(`the service ${PROBE.service}`), "the first run did not make its service", setups[0]);
|
|
3358
|
+
expect(setups[0].includes(`the service account ${PROBE.service.replace(/^token:/, "service:")}`), "the first run did not make its service account", setups[0]);
|
|
2336
3359
|
expect(setups.slice(1).every((line) => line.startsWith("all found")), "a later run made something again", setups);
|
|
2337
3360
|
const { tokens } = await admin.api.tokens.list(PROBE.service);
|
|
2338
3361
|
expect(tokens.length === 0, `${PROBE.service} still holds ${tokens.length} credential(s)`, tokens);
|
|
@@ -2351,24 +3374,22 @@ async function verifyLeftovers(cli, admin, setups, before, kept) {
|
|
|
2351
3374
|
return `the second run found all; ${PROBE.service} holds no credential; the CLI's session signed in; ${place}/${kept.key} untouched; nothing else changed; ${entries.length} entries by ${PROBE.service} stay`;
|
|
2352
3375
|
}
|
|
2353
3376
|
/**
|
|
2354
|
-
* `coffre verify keys`, with the admin's session: this
|
|
2355
|
-
* pass
|
|
2356
|
-
*
|
|
3377
|
+
* `coffre verify keys`, with the admin's session, the keys piped in: this
|
|
3378
|
+
* deployment's pass; a wrong vault key fails and the right app key passes;
|
|
3379
|
+
* a malformed app key fails. No key is ever printed.
|
|
2357
3380
|
*/
|
|
2358
3381
|
async function verifyKeys(cli) {
|
|
2359
3382
|
const wrong = Buffer.alloc(32, 7).toString("base64");
|
|
2360
3383
|
const runs = [
|
|
2361
3384
|
{
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
COFFRE_APP_KEY: KEYS.APP_KEY,
|
|
2365
|
-
COFFRE_VAULT_KEY_ID: KEYS.VAULT_KEY_ID
|
|
2366
|
-
},
|
|
3385
|
+
args: ["--vault-id", KEYS.VAULT_KEY_ID],
|
|
3386
|
+
input: `${KEYS.VAULT_KEY}\n${KEYS.APP_KEY}\n`,
|
|
2367
3387
|
code: 0,
|
|
2368
3388
|
vault: "✓",
|
|
2369
3389
|
app: "✓"
|
|
2370
3390
|
},
|
|
2371
3391
|
{
|
|
3392
|
+
args: [],
|
|
2372
3393
|
input: `${wrong}\n${KEYS.APP_KEY}\n`,
|
|
2373
3394
|
code: 1,
|
|
2374
3395
|
vault: "✗",
|
|
@@ -2376,18 +3397,20 @@ async function verifyKeys(cli) {
|
|
|
2376
3397
|
said: /✗ vault key +not this instance's vault key/
|
|
2377
3398
|
},
|
|
2378
3399
|
{
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
COFFRE_APP_KEY: "not-a-key"
|
|
2382
|
-
},
|
|
3400
|
+
args: [],
|
|
3401
|
+
input: `${KEYS.VAULT_KEY}\nnot-a-key\n`,
|
|
2383
3402
|
code: 1,
|
|
2384
3403
|
vault: "✓",
|
|
2385
3404
|
app: "✗",
|
|
2386
3405
|
said: /✗ app key +not an app key/
|
|
2387
3406
|
}
|
|
2388
3407
|
];
|
|
2389
|
-
for (const {
|
|
2390
|
-
const run = await cli.run([
|
|
3408
|
+
for (const { args, input, code, vault, app, said } of runs) {
|
|
3409
|
+
const run = await cli.run([
|
|
3410
|
+
"verify",
|
|
3411
|
+
"keys",
|
|
3412
|
+
...args
|
|
3413
|
+
], {}, input);
|
|
2391
3414
|
const seen = marks(run.output);
|
|
2392
3415
|
expect(run.code === code && seen["vault key"] === vault && seen["app key"] === app, `coffre verify keys exited ${run.code}`, run.output);
|
|
2393
3416
|
if (said !== void 0) expect(said.test(run.output), "it did not say which key is not right", run.output);
|
|
@@ -2400,8 +3423,151 @@ async function verifyKeys(cli) {
|
|
|
2400
3423
|
}
|
|
2401
3424
|
return "this deployment's keys pass, vault ID included; a wrong vault key and a malformed app key are each named; no key shown";
|
|
2402
3425
|
}
|
|
3426
|
+
/**
|
|
3427
|
+
* Everything the API does, the CLI does: with the admin's `coffre login`
|
|
3428
|
+
* session, a project and its environment, a secret set and renamed, a
|
|
3429
|
+
* service admitted and granted, a token issued into a 0600 file, then
|
|
3430
|
+
* piped to `coffre login --token` in a CLI of the service's own, read
|
|
3431
|
+
* with, revoked after its preview, and refused from then on; the grant
|
|
3432
|
+
* revoked, the secret and the project archived. No token shows in what
|
|
3433
|
+
* either prints.
|
|
3434
|
+
*/
|
|
3435
|
+
async function manageByCli(cli) {
|
|
3436
|
+
const steps = [];
|
|
3437
|
+
const ci = new Cli(cli.origin);
|
|
3438
|
+
const as = (who, label) => async (args, input, code = 0) => {
|
|
3439
|
+
const run = await who.run(args, {}, input);
|
|
3440
|
+
expect(run.code === code, `coffre ${args.join(" ")}${label} exited ${run.code}, not ${code}`, run.output);
|
|
3441
|
+
steps.push(`${args.slice(0, 2).join(" ")}${label}`);
|
|
3442
|
+
return run.output;
|
|
3443
|
+
};
|
|
3444
|
+
const [coffre, service] = [as(cli, ""), as(ci, ", as the service")];
|
|
3445
|
+
try {
|
|
3446
|
+
const value = `cli-value-${randomBytes(8).toString("hex")}`;
|
|
3447
|
+
await coffre([
|
|
3448
|
+
"projects",
|
|
3449
|
+
"create",
|
|
3450
|
+
"conformance-cli",
|
|
3451
|
+
"--name",
|
|
3452
|
+
"CLI"
|
|
3453
|
+
]);
|
|
3454
|
+
await coffre([
|
|
3455
|
+
"environments",
|
|
3456
|
+
"create",
|
|
3457
|
+
"conformance-cli/ci"
|
|
3458
|
+
]);
|
|
3459
|
+
await coffre(["set", "conformance-cli/ci/API_KEY"], value);
|
|
3460
|
+
await coffre([
|
|
3461
|
+
"rename",
|
|
3462
|
+
"conformance-cli/ci/API_KEY",
|
|
3463
|
+
"API_TOKEN"
|
|
3464
|
+
]);
|
|
3465
|
+
const refused = await coffre([
|
|
3466
|
+
"grant",
|
|
3467
|
+
"conformance-cli",
|
|
3468
|
+
"conformance-deploy",
|
|
3469
|
+
"--role",
|
|
3470
|
+
"viewer",
|
|
3471
|
+
"--env",
|
|
3472
|
+
"ci",
|
|
3473
|
+
"--service"
|
|
3474
|
+
], void 0, 1);
|
|
3475
|
+
expect(refused.includes("admit them first, `coffre admit service:conformance-deploy`"), "grant to a service not yet admitted did not say to admit it", refused);
|
|
3476
|
+
const admitted = await coffre([
|
|
3477
|
+
"admit",
|
|
3478
|
+
"conformance-deploy",
|
|
3479
|
+
"--service"
|
|
3480
|
+
]);
|
|
3481
|
+
expect(admitted.includes("admitted service:conformance-deploy") && !admitted.includes("token:"), "admit --service did not name the service account as service:<name>", admitted);
|
|
3482
|
+
expect(admitted.includes("next: coffre grant <project> conformance-deploy"), "admit --service did not say what comes next", admitted);
|
|
3483
|
+
await coffre([
|
|
3484
|
+
"grant",
|
|
3485
|
+
"conformance-cli",
|
|
3486
|
+
"conformance-deploy",
|
|
3487
|
+
"--role",
|
|
3488
|
+
"viewer",
|
|
3489
|
+
"--env",
|
|
3490
|
+
"ci",
|
|
3491
|
+
"--service"
|
|
3492
|
+
]);
|
|
3493
|
+
const file = join(cli.home, "ci-token");
|
|
3494
|
+
const wrote = await coffre([
|
|
3495
|
+
"tokens",
|
|
3496
|
+
"issue",
|
|
3497
|
+
"conformance-deploy",
|
|
3498
|
+
"--label",
|
|
3499
|
+
"conformance",
|
|
3500
|
+
"--expires-in",
|
|
3501
|
+
"1",
|
|
3502
|
+
"--output-file",
|
|
3503
|
+
file
|
|
3504
|
+
]);
|
|
3505
|
+
const token = readFileSync(file, "utf8").trim();
|
|
3506
|
+
expect(/^coffre_svc_/.test(token) && (statSync(file).mode & 511) === 384, "the token file is not a 0600 file holding a service token", statSync(file).mode);
|
|
3507
|
+
expect(!wrote.includes(token), "tokens issue --output-file printed the token");
|
|
3508
|
+
expect(!(await service([
|
|
3509
|
+
"login",
|
|
3510
|
+
cli.origin,
|
|
3511
|
+
"--token"
|
|
3512
|
+
], `${token}\n`)).includes(token), "coffre login --token printed the token");
|
|
3513
|
+
const read = await service(["get", "conformance-cli/ci/API_TOKEN"]);
|
|
3514
|
+
expect(read.trim() === value, "the issued token did not read the renamed secret", read);
|
|
3515
|
+
const [listed] = JSON.parse(await coffre([
|
|
3516
|
+
"tokens",
|
|
3517
|
+
"conformance-deploy",
|
|
3518
|
+
"--json"
|
|
3519
|
+
]));
|
|
3520
|
+
expect(listed?.label === "conformance", "tokens --json does not list the issued token", listed);
|
|
3521
|
+
const preview = await coffre([
|
|
3522
|
+
"tokens",
|
|
3523
|
+
"revoke",
|
|
3524
|
+
"conformance-deploy",
|
|
3525
|
+
listed.id
|
|
3526
|
+
]);
|
|
3527
|
+
expect(/Nothing changed\. Re-run with --apply/.test(preview), "tokens revoke without --apply did not preview", preview);
|
|
3528
|
+
await service(["get", "conformance-cli/ci/API_TOKEN"]);
|
|
3529
|
+
await coffre([
|
|
3530
|
+
"tokens",
|
|
3531
|
+
"revoke",
|
|
3532
|
+
"conformance-deploy",
|
|
3533
|
+
listed.id,
|
|
3534
|
+
"--apply"
|
|
3535
|
+
]);
|
|
3536
|
+
const gone = await service(["get", "conformance-cli/ci/API_TOKEN"], void 0, 1);
|
|
3537
|
+
expect(/does not know this bearer token/.test(gone), "a revoked token was not refused plainly", gone);
|
|
3538
|
+
await coffre([
|
|
3539
|
+
"revoke",
|
|
3540
|
+
"conformance-cli",
|
|
3541
|
+
"conformance-deploy",
|
|
3542
|
+
"--env",
|
|
3543
|
+
"ci",
|
|
3544
|
+
"--service"
|
|
3545
|
+
]);
|
|
3546
|
+
await coffre(["archive", "conformance-cli/ci/API_TOKEN"]);
|
|
3547
|
+
const keys = JSON.parse(await coffre([
|
|
3548
|
+
"list",
|
|
3549
|
+
"conformance-cli/ci",
|
|
3550
|
+
"--json"
|
|
3551
|
+
]));
|
|
3552
|
+
expect(keys.length === 1 && keys[0].key === "API_TOKEN" && keys[0].archived, "the renamed secret is not listed, archived", keys);
|
|
3553
|
+
await coffre([
|
|
3554
|
+
"projects",
|
|
3555
|
+
"archive",
|
|
3556
|
+
"conformance-cli"
|
|
3557
|
+
]);
|
|
3558
|
+
const projects = JSON.parse(await coffre(["projects", "--json"]));
|
|
3559
|
+
expect(projects.find(({ slug }) => slug === "conformance-cli")?.archivedAt !== null, "the project is not archived", projects);
|
|
3560
|
+
const sessions = JSON.parse(await coffre(["sessions", "--json"]));
|
|
3561
|
+
expect(sessions.some(({ kind, current }) => kind === "cli" && current), "sessions --json does not mark this CLI's session", sessions);
|
|
3562
|
+
return `${steps.length} commands: ${[...new Set(steps)].join(", ")}; the token only in its 0600 file and piped to login, refused once revoked`;
|
|
3563
|
+
} finally {
|
|
3564
|
+
ci.remove();
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
2403
3567
|
//#endregion
|
|
2404
3568
|
//#region src/chrome.ts
|
|
3569
|
+
/** How long one DevTools call may take: a Chrome stalled on a loaded host fails the call rather than hang whoever waits on it. */
|
|
3570
|
+
const ANSWER_MS = 6e4;
|
|
2405
3571
|
const NAMES = [
|
|
2406
3572
|
"google-chrome",
|
|
2407
3573
|
"google-chrome-stable",
|
|
@@ -2489,9 +3655,17 @@ var Chrome = class Chrome {
|
|
|
2489
3655
|
#send(method, params = {}, sessionId) {
|
|
2490
3656
|
const id = ++this.#next;
|
|
2491
3657
|
return new Promise((resolve, reject) => {
|
|
3658
|
+
const timer = setTimeout(() => {
|
|
3659
|
+
this.#pending.delete(id);
|
|
3660
|
+
reject(/* @__PURE__ */ new Error(`Chrome did not answer ${method} within ${ANSWER_MS / 1e3} s`));
|
|
3661
|
+
}, ANSWER_MS);
|
|
3662
|
+
const settled = (then) => (value) => {
|
|
3663
|
+
clearTimeout(timer);
|
|
3664
|
+
then(value);
|
|
3665
|
+
};
|
|
2492
3666
|
this.#pending.set(id, {
|
|
2493
|
-
resolve,
|
|
2494
|
-
reject
|
|
3667
|
+
resolve: settled(resolve),
|
|
3668
|
+
reject: settled(reject)
|
|
2495
3669
|
});
|
|
2496
3670
|
this.#socket.send(JSON.stringify({
|
|
2497
3671
|
id,
|
|
@@ -2504,9 +3678,11 @@ var Chrome = class Chrome {
|
|
|
2504
3678
|
/**
|
|
2505
3679
|
* `url` in a tab of its own, with `cookies` for its origin: the heading it
|
|
2506
3680
|
* shows once its scripts have run and settled, and every uncaught error,
|
|
2507
|
-
* console error and failed load along the way.
|
|
3681
|
+
* console error and failed load along the way. `then`, a script run once
|
|
3682
|
+
* the page settles, does what a person would next, such as open a dialog,
|
|
3683
|
+
* whose text is read with the rest.
|
|
2508
3684
|
*/
|
|
2509
|
-
async load(url, cookies, settle = 2e3) {
|
|
3685
|
+
async load(url, cookies, settle = 2e3, then) {
|
|
2510
3686
|
const { targetId } = await this.#send("Target.createTarget", { url: "about:blank" });
|
|
2511
3687
|
const { sessionId } = await this.#send("Target.attachToTarget", {
|
|
2512
3688
|
targetId,
|
|
@@ -2545,12 +3721,26 @@ var Chrome = class Chrome {
|
|
|
2545
3721
|
await this.#send("Page.navigate", { url }, sessionId);
|
|
2546
3722
|
await Promise.race([load, new Promise((resolve) => setTimeout(resolve, 3e4))]);
|
|
2547
3723
|
await new Promise((resolve) => setTimeout(resolve, settle));
|
|
3724
|
+
if (then !== void 0) {
|
|
3725
|
+
await this.#send("Runtime.evaluate", {
|
|
3726
|
+
expression: then,
|
|
3727
|
+
awaitPromise: true
|
|
3728
|
+
}, sessionId);
|
|
3729
|
+
await new Promise((resolve) => setTimeout(resolve, settle));
|
|
3730
|
+
}
|
|
2548
3731
|
const { result } = await this.#send("Runtime.evaluate", {
|
|
2549
|
-
expression:
|
|
3732
|
+
expression: `({
|
|
3733
|
+
heading: document.querySelector('h1')?.textContent?.trim() || null,
|
|
3734
|
+
tab: document.querySelector('.tabs [aria-current=page]')?.textContent?.trim() || null,
|
|
3735
|
+
cards: [...document.querySelectorAll('h2.card-title')].map((title) => title.textContent.trim()),
|
|
3736
|
+
text: document.body.innerText,
|
|
3737
|
+
href: location.href,
|
|
3738
|
+
dialog: document.querySelector('[role=alertdialog], [role=dialog]')?.innerText ?? null,
|
|
3739
|
+
})`,
|
|
2550
3740
|
returnByValue: true
|
|
2551
3741
|
}, sessionId);
|
|
2552
3742
|
return {
|
|
2553
|
-
|
|
3743
|
+
...result.value,
|
|
2554
3744
|
errors
|
|
2555
3745
|
};
|
|
2556
3746
|
} finally {
|
|
@@ -2573,26 +3763,230 @@ var Chrome = class Chrome {
|
|
|
2573
3763
|
};
|
|
2574
3764
|
//#endregion
|
|
2575
3765
|
//#region src/checks/pages.ts
|
|
2576
|
-
/** Each page, and the
|
|
3766
|
+
/** Each page, the heading it shows, and the tab it is, for a page with tabs. */
|
|
2577
3767
|
const PAGES = [
|
|
2578
|
-
[
|
|
2579
|
-
|
|
2580
|
-
|
|
3768
|
+
[
|
|
3769
|
+
"/projects",
|
|
3770
|
+
"Projects",
|
|
3771
|
+
null
|
|
3772
|
+
],
|
|
3773
|
+
[
|
|
3774
|
+
`/projects/${PROJECT$1}`,
|
|
3775
|
+
"Conformance",
|
|
3776
|
+
"Environments"
|
|
3777
|
+
],
|
|
3778
|
+
[
|
|
3779
|
+
`/projects/${PROJECT$1}/users`,
|
|
3780
|
+
"Conformance",
|
|
3781
|
+
"Users"
|
|
3782
|
+
],
|
|
3783
|
+
[
|
|
3784
|
+
`/projects/${PROJECT$1}/service-accounts`,
|
|
3785
|
+
"Conformance",
|
|
3786
|
+
"Service accounts"
|
|
3787
|
+
],
|
|
3788
|
+
[
|
|
3789
|
+
`/projects/${PROJECT$1}/settings`,
|
|
3790
|
+
"Conformance",
|
|
3791
|
+
"Settings"
|
|
3792
|
+
],
|
|
3793
|
+
[
|
|
3794
|
+
"/audit",
|
|
3795
|
+
"Audit",
|
|
3796
|
+
null
|
|
3797
|
+
]
|
|
2581
3798
|
];
|
|
2582
|
-
|
|
3799
|
+
/**
|
|
3800
|
+
* A project's tabs walked as a person would: Users, then Settings, by their
|
|
3801
|
+
* links, then back twice and forward once, which ends on Users.
|
|
3802
|
+
*/
|
|
3803
|
+
const WALK_TABS = `(async () => {
|
|
3804
|
+
const wait = () => new Promise((resolve) => setTimeout(resolve, 1000));
|
|
3805
|
+
const open = (label) => [...document.querySelectorAll('.tabs a')].find((link) => link.textContent.trim() === label)?.click();
|
|
3806
|
+
open('Users');
|
|
3807
|
+
await wait();
|
|
3808
|
+
open('Settings');
|
|
3809
|
+
await wait();
|
|
3810
|
+
history.back();
|
|
3811
|
+
await wait();
|
|
3812
|
+
history.back();
|
|
3813
|
+
await wait();
|
|
3814
|
+
history.forward();
|
|
3815
|
+
})()`;
|
|
3816
|
+
/**
|
|
3817
|
+
* A menu item's dialog opened as a person would: the menu by its button,
|
|
3818
|
+
* then the item, by its words. Base UI's menu opens on a pointer press, not
|
|
3819
|
+
* a bare click.
|
|
3820
|
+
*/
|
|
3821
|
+
const openFromMenu = (menu, item) => `(async () => {
|
|
3822
|
+
const press = { bubbles: true, cancelable: true, pointerType: 'mouse', button: 0 };
|
|
3823
|
+
const trigger = document.querySelector(${JSON.stringify(menu)});
|
|
3824
|
+
for (const [Kind, type] of [[PointerEvent, 'pointerdown'], [MouseEvent, 'mousedown'], [PointerEvent, 'pointerup'], [MouseEvent, 'mouseup'], [MouseEvent, 'click']]) {
|
|
3825
|
+
trigger?.dispatchEvent(new Kind(type, press));
|
|
3826
|
+
}
|
|
3827
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
3828
|
+
[...document.querySelectorAll('[role=menuitem]')].find((entry) => entry.textContent.includes(${JSON.stringify(item)}))?.click();
|
|
3829
|
+
})()`;
|
|
3830
|
+
/** A service account of the pages' own, whose page shows how it signs in. */
|
|
3831
|
+
const SERVICE = "token:conformance-pages";
|
|
3832
|
+
const CONSENT_CLIENT = "Conformance pages client";
|
|
3833
|
+
/** A registered client's authorization request, as the consent page receives it. */
|
|
3834
|
+
async function consentUrl(deployment) {
|
|
3835
|
+
const redirect = "http://127.0.0.1:33419/callback";
|
|
3836
|
+
const registered = await fetch(`${deployment.origin}/api/oauth/register`, {
|
|
3837
|
+
method: "POST",
|
|
3838
|
+
headers: { "content-type": "application/json" },
|
|
3839
|
+
body: JSON.stringify({
|
|
3840
|
+
client_name: CONSENT_CLIENT,
|
|
3841
|
+
redirect_uris: [redirect]
|
|
3842
|
+
})
|
|
3843
|
+
});
|
|
3844
|
+
const { client_id: clientId } = await registered.json();
|
|
3845
|
+
expect(registered.status === 201 && clientId !== void 0, `registering an MCP client answered ${registered.status}`);
|
|
3846
|
+
const request = new URLSearchParams({
|
|
3847
|
+
client_id: clientId,
|
|
3848
|
+
redirect_uri: redirect,
|
|
3849
|
+
response_type: "code",
|
|
3850
|
+
code_challenge: "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
|
|
3851
|
+
code_challenge_method: "S256",
|
|
3852
|
+
state: "pages",
|
|
3853
|
+
scope: "browse write"
|
|
3854
|
+
});
|
|
3855
|
+
return `${deployment.origin}/oauth/authorize?${request}`;
|
|
3856
|
+
}
|
|
3857
|
+
/** The Chrome to run, the one given or the one found; skips the check when there is none. */
|
|
3858
|
+
function chromeOrSkip(browser) {
|
|
2583
3859
|
const executable = browser ?? findChrome();
|
|
2584
3860
|
if (executable === null) throw new Skip("no Chrome or Chromium here: --browser <path> names one");
|
|
3861
|
+
return executable;
|
|
3862
|
+
}
|
|
3863
|
+
async function pagesInBrowser(deployment, admin, browser) {
|
|
3864
|
+
const executable = chromeOrSkip(browser);
|
|
3865
|
+
await admin.api.members.add(SERVICE);
|
|
3866
|
+
const name = SERVICE.slice(6);
|
|
3867
|
+
const account = `/service-accounts/${name}`;
|
|
3868
|
+
const person = `/users/${encodeURIComponent(admin.email)}`;
|
|
3869
|
+
const pages = [
|
|
3870
|
+
...PAGES,
|
|
3871
|
+
[
|
|
3872
|
+
"/settings",
|
|
3873
|
+
"Settings",
|
|
3874
|
+
null
|
|
3875
|
+
],
|
|
3876
|
+
[
|
|
3877
|
+
person,
|
|
3878
|
+
admin.email,
|
|
3879
|
+
"Access"
|
|
3880
|
+
],
|
|
3881
|
+
[
|
|
3882
|
+
`${person}/activity`,
|
|
3883
|
+
admin.email,
|
|
3884
|
+
"Activity"
|
|
3885
|
+
],
|
|
3886
|
+
[
|
|
3887
|
+
"/service-accounts",
|
|
3888
|
+
"Service accounts",
|
|
3889
|
+
null
|
|
3890
|
+
],
|
|
3891
|
+
[
|
|
3892
|
+
account,
|
|
3893
|
+
`service:${name}`,
|
|
3894
|
+
"Sign-in"
|
|
3895
|
+
],
|
|
3896
|
+
[
|
|
3897
|
+
`${account}/activity`,
|
|
3898
|
+
`service:${name}`,
|
|
3899
|
+
"Activity"
|
|
3900
|
+
]
|
|
3901
|
+
];
|
|
2585
3902
|
const chrome = await Chrome.open(executable);
|
|
2586
3903
|
try {
|
|
2587
|
-
for (const [path, heading] of
|
|
2588
|
-
const
|
|
3904
|
+
for (const [path, heading, tab] of pages) {
|
|
3905
|
+
const then = path === account ? openFromMenu("button[aria-label^=\"Actions for\"]", "Remove") : void 0;
|
|
3906
|
+
const loaded = await chrome.load(new URL(path, deployment.origin).href, admin.browser.cookies(), void 0, then);
|
|
2589
3907
|
expect(loaded.errors.length === 0, `${path}, signed in, reported errors in the browser`, loaded.errors.join("\n"));
|
|
2590
3908
|
expect(loaded.heading?.startsWith(heading), `${path}, signed in, shows ${JSON.stringify(loaded.heading)}, not the heading ${JSON.stringify(heading)}`);
|
|
3909
|
+
expect(loaded.tab === tab, `${path}, signed in, shows the tab ${JSON.stringify(loaded.tab)}, not ${JSON.stringify(tab)}`);
|
|
3910
|
+
if (path.startsWith("/service-accounts")) expect(!/(?<![\w-])token:[A-Za-z0-9]/.test(loaded.text), `${path} shows a service account as token:<name>`, loaded.text);
|
|
3911
|
+
if (path === account) {
|
|
3912
|
+
expect(loaded.cards.filter((title) => title === "Sign in with OIDC" || title === "Bearer tokens").join(" then ") === "Sign in with OIDC then Bearer tokens", `${path} does not show OIDC, then bearer tokens`, loaded.cards);
|
|
3913
|
+
expect(loaded.dialog?.includes("Removing revokes 0 grants, 0 bearer tokens") === true, `${path}: Remove… does not preview what it would revoke`, loaded.dialog);
|
|
3914
|
+
}
|
|
3915
|
+
if (path === "/settings") expect(loaded.cards.includes("Keys"), "/settings does not show what the keys are checked against", loaded.cards);
|
|
2591
3916
|
}
|
|
3917
|
+
const project = new URL(`/projects/${PROJECT$1}`, deployment.origin).href;
|
|
3918
|
+
const walked = await chrome.load(project, admin.browser.cookies(), void 0, WALK_TABS);
|
|
3919
|
+
expect(walked.errors.length === 0, `${project}'s tabs reported errors in the browser`, walked.errors.join("\n"));
|
|
3920
|
+
expect(walked.href === `${project}/users` && walked.tab === "Users", `Users, Settings, back, back and forward from ${project} ended on ${walked.href}, the tab ${JSON.stringify(walked.tab)}`);
|
|
3921
|
+
const access = `${account}/access`;
|
|
3922
|
+
await admin.api.access.set(SERVICE, { "*/dev": "viewer" });
|
|
3923
|
+
try {
|
|
3924
|
+
const loaded = await chrome.load(new URL(access, deployment.origin).href, admin.browser.cookies());
|
|
3925
|
+
expect(loaded.errors.length === 0, `${access} reported errors in the browser`, loaded.errors.join("\n"));
|
|
3926
|
+
expect(loaded.tab === "Access", `${access} shows the tab ${JSON.stringify(loaded.tab)}, not "Access"`);
|
|
3927
|
+
for (const shown of ["dev in every project", "Grant on every project"]) expect(loaded.text.includes(shown), `${access}, to an owner, does not show "${shown}"`, loaded.text);
|
|
3928
|
+
} finally {
|
|
3929
|
+
await admin.api.access.set(SERVICE, { "*/dev": null });
|
|
3930
|
+
}
|
|
3931
|
+
const consent = await consentUrl(deployment);
|
|
3932
|
+
const loaded = await chrome.load(consent, admin.browser.cookies());
|
|
3933
|
+
expect(loaded.errors.length === 0, "/oauth/authorize reported errors in the browser", loaded.errors.join("\n"));
|
|
3934
|
+
expect(loaded.heading === `Connect ${CONSENT_CLIENT} to coffre?`, `/oauth/authorize shows ${JSON.stringify(loaded.heading)}`);
|
|
3935
|
+
for (const shown of [
|
|
3936
|
+
"Unverified",
|
|
3937
|
+
"localhost",
|
|
3938
|
+
admin.email,
|
|
3939
|
+
"Browse",
|
|
3940
|
+
"Approve",
|
|
3941
|
+
"Deny"
|
|
3942
|
+
]) expect(loaded.text.includes(shown), `/oauth/authorize does not show "${shown}"`, loaded.text);
|
|
2592
3943
|
} finally {
|
|
2593
3944
|
await chrome.close();
|
|
2594
3945
|
}
|
|
2595
|
-
return `${
|
|
3946
|
+
return `${pages.map(([path]) => path).join(", ")}, signed in, in Chrome: each rendered, on its tab, no error from their scripts; a project's tabs by their links, back and forward; a service account shown as service:${name}, OIDC then bearer tokens, its removal previewed; the keys' checks in Settings; its grant on dev in every project with an owner's grant button; the MCP consent page, a registered client shown as unverified`;
|
|
3947
|
+
}
|
|
3948
|
+
/**
|
|
3949
|
+
* A refused sign-in, said once: the page coffre sends the browser back to
|
|
3950
|
+
* shows why, rendered by the server, then takes it out of the address, so a
|
|
3951
|
+
* reload is a clean retry. The refusal is a real one: a member's address
|
|
3952
|
+
* that GitHub now gives another account, which names the provider the
|
|
3953
|
+
* address already signs in with.
|
|
3954
|
+
*/
|
|
3955
|
+
async function signinErrorOnce(deployment, admin, browser) {
|
|
3956
|
+
const executable = chromeOrSkip(browser);
|
|
3957
|
+
const email = "recycled@conformance.example";
|
|
3958
|
+
await admin.api.members.add(`user:${email}`);
|
|
3959
|
+
const first = await signIn(deployment, new Browser(deployment.origin), email);
|
|
3960
|
+
expect(first.ok, `${email} was refused before anything changed: ${"error" in first ? first.error : ""}`);
|
|
3961
|
+
deployment.idp.setGitHubUser(email, { id: deployment.idp.gitHubUserFor(email).id + 1e6 });
|
|
3962
|
+
const visitor = new Browser(deployment.origin);
|
|
3963
|
+
const refused = await signIn(deployment, visitor, email);
|
|
3964
|
+
expect(!refused.ok && refused.error === "account_mismatch", "another GitHub account with a member's address was not refused as account_mismatch", refused);
|
|
3965
|
+
const back = new URL(refused.location, deployment.origin);
|
|
3966
|
+
expect(back.searchParams.get("with") === "github", `the refusal does not name the provider the address signs in with: ${refused.location}`);
|
|
3967
|
+
const said = "already signs in with another GitHub account";
|
|
3968
|
+
const html = await visitor.fetch(refused.location);
|
|
3969
|
+
expect(html.status === 200 && (await html.text()).includes(said), `${refused.location}, without scripts, does not say the address ${said}`, html.status);
|
|
3970
|
+
const chrome = await Chrome.open(executable);
|
|
3971
|
+
let clean;
|
|
3972
|
+
try {
|
|
3973
|
+
const shown = await chrome.load(back.href, visitor.cookies());
|
|
3974
|
+
expect(shown.errors.length === 0, `${refused.location} reported errors in the browser`, shown.errors.join("\n"));
|
|
3975
|
+
expect(shown.text.includes(said), `${refused.location} does not say the address ${said}`, shown.text);
|
|
3976
|
+
const after = new URL(shown.href);
|
|
3977
|
+
clean = `${after.pathname}${after.search}`;
|
|
3978
|
+
expect([
|
|
3979
|
+
"error",
|
|
3980
|
+
"with",
|
|
3981
|
+
"via"
|
|
3982
|
+
].every((name) => !after.searchParams.has(name)), `${refused.location} kept the refusal in its address`, shown.href);
|
|
3983
|
+
const reloaded = await chrome.load(shown.href, visitor.cookies());
|
|
3984
|
+
expect(!reloaded.text.includes(said), `${clean}, reloaded, still says the address ${said}`, reloaded.text);
|
|
3985
|
+
expect(reloaded.heading !== null, `${clean}, reloaded, rendered no heading`);
|
|
3986
|
+
} finally {
|
|
3987
|
+
await chrome.close();
|
|
3988
|
+
}
|
|
3989
|
+
return `${refused.location}: said by the server, once: Chrome then shows ${clean}, and a reload shows no error`;
|
|
2596
3990
|
}
|
|
2597
3991
|
/** What only server code carries. */
|
|
2598
3992
|
const MARKERS = [
|
|
@@ -2605,6 +3999,11 @@ const MARKERS = [
|
|
|
2605
3999
|
"audit_log",
|
|
2606
4000
|
"consumed_tokens",
|
|
2607
4001
|
"device_authorizations",
|
|
4002
|
+
"dismissed_keys",
|
|
4003
|
+
"mcp_approvals",
|
|
4004
|
+
"mcp_connections",
|
|
4005
|
+
"oauth_clients",
|
|
4006
|
+
"secret_references",
|
|
2608
4007
|
"secret_versions",
|
|
2609
4008
|
"service_bindings",
|
|
2610
4009
|
"vault_grants",
|
|
@@ -2794,6 +4193,7 @@ function twin(jwt) {
|
|
|
2794
4193
|
}
|
|
2795
4194
|
/** A viewer on dev, and a binding that trusts deploy.yml pushed to main of acme/api. */
|
|
2796
4195
|
async function trustRun(deployment, admin) {
|
|
4196
|
+
if (!(await admin.api.me()).features.workloads) throw new Skip("this deployment trusts no workloads: its signin({ workloads }) is off");
|
|
2797
4197
|
await admin.api.members.add(RUNNER);
|
|
2798
4198
|
await admin.api.access.set(RUNNER, { [DEV]: "viewer" });
|
|
2799
4199
|
const made = await admin.api.bindings.create(RUNNER, {
|
|
@@ -2801,9 +4201,6 @@ async function trustRun(deployment, admin) {
|
|
|
2801
4201
|
issuer: deployment.idp.workloads.issuer,
|
|
2802
4202
|
claims: DEPLOY,
|
|
2803
4203
|
label: "conformance"
|
|
2804
|
-
}).catch((error) => {
|
|
2805
|
-
if (error.status === 404) throw new Skip(`this deployment trusts no workloads: ${error.message}`);
|
|
2806
|
-
throw error;
|
|
2807
4204
|
});
|
|
2808
4205
|
return {
|
|
2809
4206
|
detail: `${RUNNER}, viewer on ${DEV}, trusts deploy.yml pushed to main of acme/api, from the dev IdP`,
|
|
@@ -2912,38 +4309,47 @@ async function runsRefused(deployment, admin) {
|
|
|
2912
4309
|
return `${cases.length + 1} refused, each for its reason, none saying what the binding expects, none logged: ${cases.map(([what]) => what).join(", ")}, for another service`;
|
|
2913
4310
|
}
|
|
2914
4311
|
/**
|
|
2915
|
-
* The CLI, as a CI job runs it
|
|
2916
|
-
*
|
|
2917
|
-
*
|
|
4312
|
+
* The CLI, as a CI job runs it, as a service by its ID token: on GitHub
|
|
4313
|
+
* Actions, `--service` and the runner's token endpoint, nothing else and
|
|
4314
|
+
* nothing kept; elsewhere, the token piped to `coffre login --service
|
|
4315
|
+
* --id-token`, whose credential the next command uses. No token printed.
|
|
2918
4316
|
*/
|
|
2919
4317
|
async function cliSignsIn(deployment, canaries) {
|
|
2920
4318
|
const issuer = deployment.idp.workloads;
|
|
2921
4319
|
const cli = new Cli(deployment.origin);
|
|
2922
4320
|
try {
|
|
2923
|
-
const
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
"on GitHub Actions": {
|
|
2930
|
-
...base,
|
|
2931
|
-
ACTIONS_ID_TOKEN_REQUEST_URL: issuer.requestUrl,
|
|
2932
|
-
ACTIONS_ID_TOKEN_REQUEST_TOKEN: issuer.requestToken
|
|
2933
|
-
},
|
|
2934
|
-
"with COFFRE_ID_TOKEN": {
|
|
2935
|
-
...base,
|
|
2936
|
-
COFFRE_ID_TOKEN: given
|
|
2937
|
-
}
|
|
2938
|
-
};
|
|
2939
|
-
for (const [where, env] of Object.entries(runs)) {
|
|
2940
|
-
const run = await cli.run(["get", `${DEV}/API_KEY`], env);
|
|
4321
|
+
const read = async (where, args, env, secrets) => {
|
|
4322
|
+
const run = await cli.run([
|
|
4323
|
+
...args,
|
|
4324
|
+
"get",
|
|
4325
|
+
`${DEV}/API_KEY`
|
|
4326
|
+
], env);
|
|
2941
4327
|
expect(run.code === 0, `coffre get ${where} exited ${run.code}`, run.output);
|
|
2942
4328
|
expect(run.output.trim() === canaries[`${DEV}/API_KEY`], `coffre get ${where} did not print the value`);
|
|
2943
|
-
expect(!
|
|
2944
|
-
}
|
|
2945
|
-
|
|
2946
|
-
|
|
4329
|
+
expect(!secrets.some((secret) => run.output.includes(secret)) && !/coffre_svc_/.test(run.output), `coffre get ${where} printed a token`);
|
|
4330
|
+
};
|
|
4331
|
+
await read("on GitHub Actions", [
|
|
4332
|
+
"--url",
|
|
4333
|
+
deployment.origin,
|
|
4334
|
+
"--service",
|
|
4335
|
+
RUNNER
|
|
4336
|
+
], {
|
|
4337
|
+
ACTIONS_ID_TOKEN_REQUEST_URL: issuer.requestUrl,
|
|
4338
|
+
ACTIONS_ID_TOKEN_REQUEST_TOKEN: issuer.requestToken
|
|
4339
|
+
}, [issuer.requestToken]);
|
|
4340
|
+
expect(!existsSync(join(cli.home, ".coffre", "credentials.json")), "the CLI kept a credential on disk, for one command");
|
|
4341
|
+
const given = await mint(deployment);
|
|
4342
|
+
const login = await cli.run([
|
|
4343
|
+
"login",
|
|
4344
|
+
deployment.origin,
|
|
4345
|
+
"--service",
|
|
4346
|
+
RUNNER,
|
|
4347
|
+
"--id-token"
|
|
4348
|
+
], {}, `${given}\n`);
|
|
4349
|
+
expect(login.code === 0, `coffre login --service --id-token exited ${login.code}`, login.output);
|
|
4350
|
+
expect(!login.output.includes(given) && !/coffre_svc_/.test(login.output), "coffre login --service printed a token");
|
|
4351
|
+
await read("after coffre login --service --id-token", [], {}, [given]);
|
|
4352
|
+
return `\`coffre --service ${RUNNER} get\` on GitHub Actions, nothing kept; \`coffre login --service --id-token\` with the token piped in, then \`coffre get\`; no token printed`;
|
|
2947
4353
|
} finally {
|
|
2948
4354
|
cli.remove();
|
|
2949
4355
|
}
|
|
@@ -3000,6 +4406,7 @@ async function conform(deployment, options) {
|
|
|
3000
4406
|
admin,
|
|
3001
4407
|
canaries
|
|
3002
4408
|
}, ({ admin }) => pagesInBrowser(deployment, admin, options.browser));
|
|
4409
|
+
await report.check("sign-in error, once", { admin }, ({ admin }) => signinErrorOnce(deployment, admin, options.browser));
|
|
3003
4410
|
const people = await report.check("personas", {
|
|
3004
4411
|
admin,
|
|
3005
4412
|
canaries
|
|
@@ -3010,6 +4417,14 @@ async function conform(deployment, options) {
|
|
|
3010
4417
|
};
|
|
3011
4418
|
await report.check("members only", { people }, ({ people }) => membersOnly(deployment, people));
|
|
3012
4419
|
await report.check("grant scoping", all, ({ people, canaries }) => grantScoping(people, canaries));
|
|
4420
|
+
await report.check("folders", all, ({ people, canaries }) => folders(people, canaries));
|
|
4421
|
+
await report.check("forks", all, ({ people, canaries }) => forks(people, canaries));
|
|
4422
|
+
await report.check("references", all, ({ people, canaries }) => references(deployment, people, canaries));
|
|
4423
|
+
await report.check("missing keys", { people }, ({ people }) => missingKeys(people));
|
|
4424
|
+
await report.check("MCP connect", { people }, ({ people }) => mcpConnect(deployment, people));
|
|
4425
|
+
await report.check("MCP browse", all, ({ people, canaries }) => mcpBrowse(deployment, people, canaries));
|
|
4426
|
+
await report.check("MCP changes", all, ({ people, canaries }) => mcpChanges(deployment, people, canaries));
|
|
4427
|
+
await report.check("MCP values", all, ({ people, canaries }) => mcpValues(deployment, people, canaries));
|
|
3013
4428
|
await report.check("reveals audited", all, ({ people, canaries }) => revealAudited(deployment, people, canaries, "reveal"));
|
|
3014
4429
|
await report.check("runs audited", all, ({ people, canaries }) => revealAudited(deployment, people, canaries, "run"));
|
|
3015
4430
|
await report.check("cross-site", all, ({ people, canaries }) => crossSite(people, canaries));
|
|
@@ -3053,10 +4468,16 @@ async function conform(deployment, options) {
|
|
|
3053
4468
|
live
|
|
3054
4469
|
}, ({ admin, owner, before, first, second, live }) => verifyLeftovers(owner, admin, [first, second], before, live.canary));
|
|
3055
4470
|
await report.check("verify keys", { owner }, ({ owner }) => verifyKeys(owner));
|
|
4471
|
+
await report.check("manage by CLI", { owner }, ({ owner }) => manageByCli(owner));
|
|
4472
|
+
await report.check("delete by CLI", {
|
|
4473
|
+
owner,
|
|
4474
|
+
admin
|
|
4475
|
+
}, ({ owner, admin }) => deletion(deployment, owner, admin));
|
|
3056
4476
|
} finally {
|
|
3057
4477
|
for (const cli of clis) cli.remove();
|
|
3058
4478
|
}
|
|
3059
4479
|
await report.check("offboarding", all, ({ people, canaries }) => offboarding(deployment, people, canaries));
|
|
4480
|
+
await report.check("grants on every project", all, ({ people, canaries }) => everyProject(deployment, people, canaries));
|
|
3060
4481
|
await report.check("bulk limit", { people }, ({ people }) => bulkLimit$1(people, options.bulkLimit));
|
|
3061
4482
|
const binding = await report.check("trust a run", { admin }, ({ admin }) => trustRun(deployment, admin));
|
|
3062
4483
|
const credential = await report.check("run signs in", {
|