@coffre/conformance 0.4.5 → 0.5.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/main.js +116 -64
- package/package.json +4 -4
- package/src/checks/access.ts +47 -42
- package/src/checks/canaries.ts +1 -1
- package/src/checks/cli.ts +1 -1
- package/src/checks/mcp.ts +19 -11
- package/src/checks/members.ts +2 -1
- package/src/checks/pages.ts +9 -9
- package/src/checks/people.ts +1 -1
- package/src/checks/workloads.ts +2 -1
- package/src/suite.ts +2 -2
package/dist/main.js
CHANGED
|
@@ -266,12 +266,19 @@ function createClient(options) {
|
|
|
266
266
|
list: (path) => call("GET /members", {}, { path }),
|
|
267
267
|
/** What they hold, and what to rotate if they leave. */
|
|
268
268
|
get: (member) => call("GET /members/:member", { member }),
|
|
269
|
+
/** Their instance role and scope, and the grants you manage, in one read. */
|
|
270
|
+
access: (member) => call("GET /members/:member/access", { member }),
|
|
269
271
|
add: (member, input = {}) => call("PUT /members/:member", { member }, input),
|
|
270
272
|
/** Offboards; returns what to rotate. */
|
|
271
273
|
remove: (member) => call("DELETE /members/:member", { member })
|
|
272
274
|
},
|
|
273
275
|
tokens: {
|
|
274
276
|
list: (member) => call("GET /members/:member/tokens", { member }),
|
|
277
|
+
/** What the token would reach, as the server would issue it now; issues nothing. */
|
|
278
|
+
preview: (member, input) => {
|
|
279
|
+
const [method, route] = address("POST /members/:member/tokens", { member });
|
|
280
|
+
return send(method, `${route}?dryRun=1`, input);
|
|
281
|
+
},
|
|
275
282
|
/** The value is in the answer, and only there. */
|
|
276
283
|
issue: (member, input) => call("POST /members/:member/tokens", { member }, input),
|
|
277
284
|
revoke: (member, id) => call("DELETE /members/:member/tokens/:id", {
|
|
@@ -362,6 +369,11 @@ set: (member, access) => call("PATCH /access/:member", { member }, access) },
|
|
|
362
369
|
list: () => call("GET /apps", {}),
|
|
363
370
|
disconnect: (id) => call("DELETE /apps/:id", { id })
|
|
364
371
|
},
|
|
372
|
+
/** The instance's settings, for those who run it: where people set up service accounts themselves. */
|
|
373
|
+
settings: {
|
|
374
|
+
get: () => call("GET /settings", {}),
|
|
375
|
+
set: (input) => call("PUT /settings", {}, input)
|
|
376
|
+
},
|
|
365
377
|
audit: {
|
|
366
378
|
list: (query = {}) => call("GET /audit", {}, query),
|
|
367
379
|
verify: () => call("GET /audit/verification", {}),
|
|
@@ -1270,7 +1282,7 @@ async function mcpRead(deployment, people, canaries) {
|
|
|
1270
1282
|
const listed = await modern(deployment, access, "tools/list");
|
|
1271
1283
|
const result = listed.body.result;
|
|
1272
1284
|
const names = result?.tools?.map((tool) => tool.name) ?? [];
|
|
1273
|
-
expect(names.includes("list_secrets") && !names.includes("run_with_secrets") && !names.includes("
|
|
1285
|
+
expect(names.includes("list_secrets") && !names.includes("run_with_secrets") && !names.includes("create_project") && !names.includes("read_audit_log") && result?.cacheScope === "private" && typeof result.ttlMs === "number" && result.ttlMs <= 6e5, "tools/list does not list the reader's tools alone, cached for them only and briefly", listed.body);
|
|
1274
1286
|
const callTool = async (tool, args) => {
|
|
1275
1287
|
const { response, body } = await modern(deployment, access, "tools/call", {
|
|
1276
1288
|
name: tool,
|
|
@@ -1347,8 +1359,9 @@ async function mcpRead(deployment, people, canaries) {
|
|
|
1347
1359
|
* approves on coffre's page. A client without URL elicitation gets the link
|
|
1348
1360
|
* and calls again; one with it is asked to open the page, and retries with
|
|
1349
1361
|
* its requestState, which no other call may use. Only the person decides,
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
1362
|
+
* in their browser, never with a CLI session, with the digest the page
|
|
1363
|
+
* showed; the page makes the change, once, and its entries name the client
|
|
1364
|
+
* and the approval. A value comes from the page.
|
|
1352
1365
|
*/
|
|
1353
1366
|
async function mcpChanges(deployment, people, canaries) {
|
|
1354
1367
|
const { admin } = people;
|
|
@@ -1416,15 +1429,27 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1416
1429
|
})
|
|
1417
1430
|
});
|
|
1418
1431
|
expect(forgedSite.status === 403, `another site's approval answered ${forgedSite.status}, not 403`);
|
|
1432
|
+
const cli = bearer(deployment.origin, await deviceLogin(deployment, changer.browser));
|
|
1433
|
+
const fromCli = await cli.approvals.get(approval.id).then(() => null, (error) => error);
|
|
1434
|
+
const decidedFromCli = await cli.approvals.decide(approval.id, {
|
|
1435
|
+
approve: true,
|
|
1436
|
+
digest: shown.digest
|
|
1437
|
+
}).then(() => null, (error) => error);
|
|
1438
|
+
expect(fromCli instanceof CoffreError && fromCli.status === 403 && decidedFromCli instanceof CoffreError && decidedFromCli.status === 403, "a CLI session opened or decided an approval", {
|
|
1439
|
+
fromCli,
|
|
1440
|
+
decidedFromCli
|
|
1441
|
+
});
|
|
1419
1442
|
expect(!await archived("OLD"), "a refused decision changed something");
|
|
1420
1443
|
const decided = await changer.api.approvals.decide(approval.id, {
|
|
1421
1444
|
approve: true,
|
|
1422
|
-
digest: shown.digest
|
|
1445
|
+
digest: shown.digest,
|
|
1446
|
+
basis: shown.basis
|
|
1423
1447
|
});
|
|
1424
1448
|
expect(decided.status === "approved" && await archived("OLD"), "Approve did not make the change", decided);
|
|
1425
1449
|
const again = await changer.api.approvals.decide(approval.id, {
|
|
1426
1450
|
approve: true,
|
|
1427
|
-
digest: shown.digest
|
|
1451
|
+
digest: shown.digest,
|
|
1452
|
+
basis: shown.basis
|
|
1428
1453
|
}).then(() => null, (error) => error);
|
|
1429
1454
|
expect(again instanceof CoffreError && again.status === 409, "an approval was decided twice", again);
|
|
1430
1455
|
const reported = await call(write, "archive_secret", { secret: `${place}/OLD` });
|
|
@@ -1450,7 +1475,8 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1450
1475
|
const second = (await changer.api.approvals.get(id)).approval;
|
|
1451
1476
|
expect((await changer.api.approvals.decide(id, {
|
|
1452
1477
|
approve: true,
|
|
1453
|
-
digest: second.digest
|
|
1478
|
+
digest: second.digest,
|
|
1479
|
+
basis: second.basis
|
|
1454
1480
|
})).status === "approved", "the second approval was not made");
|
|
1455
1481
|
const retried = await call(write, "rename_secret", {
|
|
1456
1482
|
secret: `${place}/KEEP`,
|
|
@@ -1468,6 +1494,7 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1468
1494
|
await changer.api.approvals.decide(valueId, {
|
|
1469
1495
|
approve: true,
|
|
1470
1496
|
digest: valuePage.digest,
|
|
1497
|
+
basis: valuePage.basis,
|
|
1471
1498
|
value: typed
|
|
1472
1499
|
});
|
|
1473
1500
|
expect((await admin.api.secrets.reveal(`${place}/TYPED`)).values.TYPED === typed, "the value typed on the page was not written");
|
|
@@ -1479,7 +1506,8 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1479
1506
|
const generatedPage = (await changer.api.approvals.get(generatedId)).approval;
|
|
1480
1507
|
const generated = await changer.api.approvals.decide(generatedId, {
|
|
1481
1508
|
approve: true,
|
|
1482
|
-
digest: generatedPage.digest
|
|
1509
|
+
digest: generatedPage.digest,
|
|
1510
|
+
basis: generatedPage.basis
|
|
1483
1511
|
});
|
|
1484
1512
|
const made = (await admin.api.secrets.reveal(`${place}/GENERATED`)).values.GENERATED ?? "";
|
|
1485
1513
|
canaries[`${place}/GENERATED`] = made;
|
|
@@ -1510,7 +1538,7 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1510
1538
|
"deny approved",
|
|
1511
1539
|
"deny changed"
|
|
1512
1540
|
]), "the decisions, and the two refused, are not in the log", decisions);
|
|
1513
|
-
return `Read stepped up to Write, saying how as its result; Write ticked beyond what was asked; with Write, the link without URL elicitation and an elicitation with it; nothing changed until ${changer.email} approved on coffre's page, another person
|
|
1541
|
+
return `Read stepped up to Write, saying how as its result; Write ticked beyond what was asked; with Write, the link without URL elicitation and an elicitation with it; nothing changed until ${changer.email} approved on coffre's page, another person, another site and a CLI session 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`;
|
|
1514
1542
|
}
|
|
1515
1543
|
/**
|
|
1516
1544
|
* Values (design section 14, checks 2 and 4): Read cannot get one, Reveal
|
|
@@ -1545,7 +1573,8 @@ async function mcpValues(deployment, people, canaries) {
|
|
|
1545
1573
|
expect(page.kind === "reveal", "the approval page does not say it shows a value", page);
|
|
1546
1574
|
expect((await reader.api.approvals.decide(id, {
|
|
1547
1575
|
approve: true,
|
|
1548
|
-
digest: page.digest
|
|
1576
|
+
digest: page.digest,
|
|
1577
|
+
basis: page.basis
|
|
1549
1578
|
})).shown.some((line) => line.value === dev.API_KEY), "Reveal did not show the person the value");
|
|
1550
1579
|
const told = await call(reading, "show_secret_value", { secret: `${DEV}/API_KEY` });
|
|
1551
1580
|
expect(told.result?.structuredContent?.status === "approved", "show_secret_value does not report the value as shown", told.result);
|
|
@@ -1733,7 +1762,7 @@ async function memberTampering(deployment, people, kind) {
|
|
|
1733
1762
|
grants[0].granted_by,
|
|
1734
1763
|
person.member
|
|
1735
1764
|
]);
|
|
1736
|
-
} else if (kind === "member") await query(sql, "UPDATE vault_members SET
|
|
1765
|
+
} else if (kind === "member") await query(sql, "UPDATE vault_members SET role = 'owner' WHERE principal = $1", [person.member]);
|
|
1737
1766
|
else {
|
|
1738
1767
|
const [place] = await query(sql, `SELECT e.id FROM environments e JOIN projects p ON p.id = e.project_id
|
|
1739
1768
|
WHERE p.slug = 'conformance' AND e.slug = 'prod'`);
|
|
@@ -2045,14 +2074,16 @@ async function grantScoping({ reader, service, bulk }, canaries) {
|
|
|
2045
2074
|
await refused$1("a viewer wrote a value", reader.api.secrets.set(DEV, { API_KEY: "from the reader" }));
|
|
2046
2075
|
await refused$1("a viewer granted themselves more", reader.api.access.set(reader.member, { [PROD]: "owner" }));
|
|
2047
2076
|
await refused$1("a viewer added a member", reader.api.members.add("user:friend@conformance.example"));
|
|
2048
|
-
await refused$1("a viewer issued a service
|
|
2077
|
+
await refused$1("a viewer on bulk issued a token for a service on dev", bulk.api.tokens.issue(service.member, { expiresInDays: 1 }));
|
|
2078
|
+
await refused$1("a viewer on bulk gave a service dev", bulk.api.access.set(service.member, { [DEV]: "viewer" }));
|
|
2079
|
+
await refused$1("a viewer on dev gave a service prod", reader.api.access.set(service.member, { [PROD]: "viewer" }));
|
|
2049
2080
|
const places = (await reader.api.me()).environments.map((place) => `${place.project}/${place.environment}`);
|
|
2050
2081
|
expect(places.length === 1 && places[0] === DEV, "a viewer on dev is told of other places", places);
|
|
2051
2082
|
const served = await service.api.secrets.reveal(DEV);
|
|
2052
2083
|
expect(same(served.values, valuesIn(canaries, DEV)), "a service viewer on dev did not get dev's values", served.values);
|
|
2053
2084
|
await refused$1("a service viewer on dev revealed prod", service.api.secrets.reveal(PROD));
|
|
2054
2085
|
await refused$1("a viewer on bulk revealed dev", bulk.api.secrets.reveal(DEV));
|
|
2055
|
-
return "a viewer on dev reads dev and nothing else, in a browser or with a token, and changes nothing";
|
|
2086
|
+
return "a viewer on dev reads dev and nothing else, in a browser or with a token, and changes nothing; nobody gives a service account, or a token for one, beyond what they hold";
|
|
2056
2087
|
}
|
|
2057
2088
|
/**
|
|
2058
2089
|
* A change sent with the session cookie from another site's page, or from
|
|
@@ -2114,6 +2145,7 @@ async function offboarding(deployment, { admin, leaver, service }, canaries) {
|
|
|
2114
2145
|
const before = await admin.api.members.get(leaver.member);
|
|
2115
2146
|
expect(before.live.apps === 1 && before.apps.length === 1, "the owner's report does not list the app the leaver connected", before.apps);
|
|
2116
2147
|
const { revoked, report } = await admin.api.members.remove(leaver.member);
|
|
2148
|
+
expect(report !== null, "an owner's removal does not answer with the leaver's report");
|
|
2117
2149
|
expect(revoked.apps === 1 && report.live.apps === 0 && report.apps.length === 0, "removal does not say it disconnected their app", {
|
|
2118
2150
|
revoked,
|
|
2119
2151
|
apps: report.apps
|
|
@@ -2140,56 +2172,58 @@ async function offboarding(deployment, { admin, leaver, service }, canaries) {
|
|
|
2140
2172
|
return `the report names ${exposed.length} values and their connected app, which removal disconnects; re-admission revives no old session, token or approval; a fresh provider callback works`;
|
|
2141
2173
|
}
|
|
2142
2174
|
/**
|
|
2143
|
-
*
|
|
2144
|
-
*
|
|
2145
|
-
*
|
|
2146
|
-
*
|
|
2175
|
+
* Instance roles: a Developer scoped to dev reads and writes the dev of a
|
|
2176
|
+
* project made after it, and no prod; an Admin scoped to one environment
|
|
2177
|
+
* grants there and nowhere else, and sets no role, its own or anyone's;
|
|
2178
|
+
* and no grant is on every project. The reader is a member again as it
|
|
2179
|
+
* ends, its service removed, its project archived.
|
|
2147
2180
|
*/
|
|
2148
|
-
async function
|
|
2149
|
-
const
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
};
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
await admin.api.
|
|
2161
|
-
const [everything, dev] = [await client(services.everything), await client(services.dev)];
|
|
2162
|
-
const later = `${PROJECT$1}-later`;
|
|
2163
|
-
const made = await admin.api.projects.create(later, { name: "Made later" });
|
|
2164
|
-
expect(made.inherited.some((grant) => grant.member === services.everything && grant.place === "*"), "making a project did not say who reaches it", made.inherited);
|
|
2181
|
+
async function instanceRoles(deployment, { admin, reader }, canaries) {
|
|
2182
|
+
const scoped = "token:conformance-scoped";
|
|
2183
|
+
await admin.api.members.add(scoped);
|
|
2184
|
+
await refused$1("a grant on every project was given", admin.api.access.set(scoped, { "*": "viewer" }));
|
|
2185
|
+
await refused$1("a grant on dev in every project was given", admin.api.access.set(scoped, { "*/dev": "viewer" }));
|
|
2186
|
+
await refused$1("a service account was given an instance role", admin.api.members.add(scoped, { role: "developer" }));
|
|
2187
|
+
await refused$1("a viewer gave themselves an instance role", reader.api.members.add(reader.member, { role: "owner" }));
|
|
2188
|
+
await admin.api.members.add(reader.member, {
|
|
2189
|
+
role: "developer",
|
|
2190
|
+
scope: { environments: { only: ["dev"] } }
|
|
2191
|
+
});
|
|
2192
|
+
const later = `${PROJECT$1}-roles`;
|
|
2193
|
+
await admin.api.projects.create(later, { name: "Made later" });
|
|
2165
2194
|
for (const environment of ["dev", "prod"]) {
|
|
2166
2195
|
const path = `${later}/${environment}`;
|
|
2167
|
-
|
|
2168
|
-
const reaches = inherited.filter((grant) => grant.member === services.dev).length;
|
|
2169
|
-
expect(reaches === (environment === "dev" ? 1 : 0), `making ${path} misnamed who reaches it through dev in every project`, inherited);
|
|
2196
|
+
await admin.api.environments.create(path, { name: environment });
|
|
2170
2197
|
canaries[`${path}/API_KEY`] = canary();
|
|
2171
2198
|
await admin.api.secrets.set(path, valuesIn(canaries, path));
|
|
2172
2199
|
}
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
await
|
|
2186
|
-
|
|
2187
|
-
await refused$1("a
|
|
2188
|
-
await refused$1("a
|
|
2189
|
-
|
|
2190
|
-
|
|
2200
|
+
const read = await reader.api.secrets.reveal(`${later}/dev`);
|
|
2201
|
+
expect(read.values.API_KEY === canaries[`${later}/dev/API_KEY`], "a Developer scoped to dev could not read a dev made later", read.values);
|
|
2202
|
+
await reader.api.secrets.set(`${later}/dev`, { API_KEY: canaries[`${later}/dev/API_KEY`] });
|
|
2203
|
+
await refused$1("a Developer scoped to dev read a prod made later", reader.api.secrets.reveal(`${later}/prod`));
|
|
2204
|
+
await refused$1("a Developer scoped to dev read prod", reader.api.secrets.reveal(PROD));
|
|
2205
|
+
await admin.api.members.add(reader.member, {
|
|
2206
|
+
role: "admin",
|
|
2207
|
+
scope: {
|
|
2208
|
+
projects: { only: [PROJECT$1] },
|
|
2209
|
+
environments: { only: ["dev"] }
|
|
2210
|
+
}
|
|
2211
|
+
});
|
|
2212
|
+
await reader.api.access.set(scoped, { [DEV]: "viewer" });
|
|
2213
|
+
await refused$1("a scoped admin granted outside its scope", reader.api.access.set(scoped, { [PROD]: "viewer" }));
|
|
2214
|
+
await refused$1("a scoped admin granted on the project around its scope", reader.api.access.set(scoped, { [PROJECT$1]: "viewer" }));
|
|
2215
|
+
await refused$1("a scoped admin widened its own role", reader.api.members.add(reader.member, { role: "admin" }));
|
|
2216
|
+
await refused$1("a scoped admin promoted someone", reader.api.members.add(scoped, { role: "member" }));
|
|
2217
|
+
await refused$1("a scoped admin made a project", reader.api.projects.create(`${PROJECT$1}-scoped`, { name: "Scoped" }));
|
|
2218
|
+
await refused$1("a scoped admin read a value no grant of its gives", reader.api.secrets.reveal(PROD));
|
|
2219
|
+
await admin.api.members.add(reader.member, { role: "admin" });
|
|
2220
|
+
await refused$1("an admin made itself an owner", reader.api.members.add(reader.member, { role: "owner" }));
|
|
2221
|
+
await admin.api.members.add(reader.member, { role: "member" });
|
|
2222
|
+
await admin.api.members.remove(scoped);
|
|
2191
2223
|
await admin.api.projects.update(later, { archived: true });
|
|
2192
|
-
|
|
2224
|
+
const me = await reader.api.me();
|
|
2225
|
+
expect(me.instanceRole === "member" && me.environments.length === 1, "the reader is not back as it was", me);
|
|
2226
|
+
return "a Developer scoped to dev reaches a dev made later and no prod; a scoped admin grants only inside its scope and sets no role; no grant is on every project";
|
|
2193
2227
|
}
|
|
2194
2228
|
/** Reading more values at once than the vault allows in its window is refused. */
|
|
2195
2229
|
async function bulkLimit$1({ admin, bulk }, limit) {
|
|
@@ -3033,12 +3067,14 @@ function getCalls({ places, secrets, members, services }) {
|
|
|
3033
3067
|
input: { path: `${first.project}/${first.environment}` }
|
|
3034
3068
|
}]],
|
|
3035
3069
|
"GET /members/:member": members.map((member) => ({ params: { member } })),
|
|
3070
|
+
"GET /members/:member/access": members.map((member) => ({ params: { member } })),
|
|
3036
3071
|
"GET /members/:member/tokens": services.map((member) => ({ params: { member } })),
|
|
3037
3072
|
"GET /members/:member/bindings": services.map((member) => ({ params: { member } })),
|
|
3038
3073
|
"GET /workloads/lookup": [{
|
|
3039
3074
|
params: {},
|
|
3040
3075
|
input: { github: "acme/api" }
|
|
3041
3076
|
}],
|
|
3077
|
+
"GET /settings": [{ params: {} }],
|
|
3042
3078
|
"GET /sessions": [{ params: {} }],
|
|
3043
3079
|
"GET /identities": [{ params: {} }],
|
|
3044
3080
|
"GET /device-logins/:code": [{ params: { code: "BCDF-GHJK" } }],
|
|
@@ -3143,7 +3179,11 @@ function pages(people) {
|
|
|
3143
3179
|
BULK
|
|
3144
3180
|
].map((path) => `/projects/${path}`),
|
|
3145
3181
|
"/users",
|
|
3146
|
-
...users.flatMap((person) => [
|
|
3182
|
+
...users.flatMap((person) => [
|
|
3183
|
+
"",
|
|
3184
|
+
"/apps",
|
|
3185
|
+
"/activity"
|
|
3186
|
+
].map((tab) => `/users/${encodeURIComponent(person.email)}${tab}`)),
|
|
3147
3187
|
"/service-accounts",
|
|
3148
3188
|
...[
|
|
3149
3189
|
"",
|
|
@@ -3372,7 +3412,7 @@ async function verifyAsUser(cli, user, admin) {
|
|
|
3372
3412
|
const run = await cli.run(["verify", "instance"]);
|
|
3373
3413
|
expect(run.code === 1, `coffre verify instance as a user exited ${run.code}, not 1`, run.output);
|
|
3374
3414
|
expect(marks(run.output).owner === "✗", "the run went on past a user", run.output);
|
|
3375
|
-
expect(/is
|
|
3415
|
+
expect(/is not an admin or owner of all of \S+, nor a root admin: nothing was made/.test(run.output), "the run did not say plainly why it stopped", run.output);
|
|
3376
3416
|
expect(await admin.api.members.get(PROBE.service).then(() => "there", (error) => error instanceof CoffreError && error.status === 404 ? "absent" : Promise.reject(error)) === "absent", `${PROBE.service} was made for a user`);
|
|
3377
3417
|
await bearer(cli.origin, cli.session()).me();
|
|
3378
3418
|
expect(await everythingElse(admin.api) === before, "the run changed a member, a grant, a project or an environment for a user");
|
|
@@ -3950,6 +3990,11 @@ async function pagesInBrowser(deployment, admin, browser) {
|
|
|
3950
3990
|
admin.email,
|
|
3951
3991
|
"Access"
|
|
3952
3992
|
],
|
|
3993
|
+
[
|
|
3994
|
+
`${person}/apps`,
|
|
3995
|
+
admin.email,
|
|
3996
|
+
"Connected apps"
|
|
3997
|
+
],
|
|
3953
3998
|
[
|
|
3954
3999
|
`${person}/activity`,
|
|
3955
4000
|
admin.email,
|
|
@@ -4006,7 +4051,7 @@ async function pagesInBrowser(deployment, admin, browser) {
|
|
|
4006
4051
|
expect(loaded.dialog?.includes("Removing revokes 0 grants, 0 bearer tokens") === true, `${path}: Remove… does not preview what it would revoke`, loaded.dialog);
|
|
4007
4052
|
}
|
|
4008
4053
|
if (path === "/settings") expect(loaded.cards.includes("Keys"), "/settings does not show what the keys are checked against", loaded.cards);
|
|
4009
|
-
if (path === person) expect(loaded.cards.includes("Connected apps"), `${path} does not show an owner the person's connected apps`, loaded.cards);
|
|
4054
|
+
if (path === `${person}/apps`) expect(loaded.cards.includes("Connected apps"), `${path} does not show an owner the person's connected apps`, loaded.cards);
|
|
4010
4055
|
if (path === "/account/apps") {
|
|
4011
4056
|
expect(loaded.cards.join(" then ") === "Connect an app then Connected apps", `${path} does not show Connect an app, then the connected apps`, loaded.cards);
|
|
4012
4057
|
for (const shown of [
|
|
@@ -4021,14 +4066,15 @@ async function pagesInBrowser(deployment, admin, browser) {
|
|
|
4021
4066
|
expect(walked.errors.length === 0, `${project}'s tabs reported errors in the browser`, walked.errors.join("\n"));
|
|
4022
4067
|
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)}`);
|
|
4023
4068
|
const access = `${account}/access`;
|
|
4024
|
-
await admin.api.access.set(SERVICE, {
|
|
4069
|
+
await admin.api.access.set(SERVICE, { [DEV]: "viewer" });
|
|
4025
4070
|
try {
|
|
4026
4071
|
const loaded = await chrome.load(new URL(access, deployment.origin).href, admin.browser.cookies());
|
|
4027
4072
|
expect(loaded.errors.length === 0, `${access} reported errors in the browser`, loaded.errors.join("\n"));
|
|
4028
4073
|
expect(loaded.tab === "Access", `${access} shows the tab ${JSON.stringify(loaded.tab)}, not "Access"`);
|
|
4029
|
-
|
|
4074
|
+
expect(loaded.text.includes("Viewer") && loaded.text.includes("Edit access"), `${access}, to an admin, does not show its grant and Edit access`, loaded.text);
|
|
4075
|
+
expect(!loaded.text.includes("every project"), `${access} still offers a grant on every project`, loaded.text);
|
|
4030
4076
|
} finally {
|
|
4031
|
-
await admin.api.access.set(SERVICE, {
|
|
4077
|
+
await admin.api.access.set(SERVICE, { [DEV]: null });
|
|
4032
4078
|
}
|
|
4033
4079
|
const consent = await consentUrl(deployment);
|
|
4034
4080
|
const loaded = await chrome.load(consent, admin.browser.cookies());
|
|
@@ -4047,7 +4093,7 @@ async function pagesInBrowser(deployment, admin, browser) {
|
|
|
4047
4093
|
} finally {
|
|
4048
4094
|
await chrome.close();
|
|
4049
4095
|
}
|
|
4050
|
-
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
|
|
4096
|
+
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, project by project; the account's Connected apps tab, with this instance's MCP URL and Claude Code's command; the MCP consent page, a registered client shown as unverified`;
|
|
4051
4097
|
}
|
|
4052
4098
|
/**
|
|
4053
4099
|
* A refused sign-in, said once: the page coffre sends the browser back to
|
|
@@ -4382,7 +4428,13 @@ async function runsRefused(deployment, admin) {
|
|
|
4382
4428
|
],
|
|
4383
4429
|
[
|
|
4384
4430
|
"from a pull request",
|
|
4385
|
-
await mint(deployment, {
|
|
4431
|
+
await mint(deployment, {
|
|
4432
|
+
event_name: "pull_request",
|
|
4433
|
+
ref: "refs/pull/1/merge",
|
|
4434
|
+
base_ref: "main",
|
|
4435
|
+
workflow_ref: GITHUB_RUN.workflow_ref.replace(/@.*/, "@refs/pull/1/merge"),
|
|
4436
|
+
sub: "repo:acme/api:pull_request"
|
|
4437
|
+
}),
|
|
4386
4438
|
"no_match"
|
|
4387
4439
|
],
|
|
4388
4440
|
[
|
|
@@ -4581,7 +4633,7 @@ async function conform(deployment, options) {
|
|
|
4581
4633
|
for (const cli of clis) cli.remove();
|
|
4582
4634
|
}
|
|
4583
4635
|
await report.check("offboarding", all, ({ people, canaries }) => offboarding(deployment, people, canaries));
|
|
4584
|
-
await report.check("
|
|
4636
|
+
await report.check("instance roles", all, ({ people, canaries }) => instanceRoles(deployment, people, canaries));
|
|
4585
4637
|
await report.check("bulk limit", { people }, ({ people }) => bulkLimit$1(people, options.bulkLimit));
|
|
4586
4638
|
const binding = await report.check("trust a run", { admin }, ({ admin }) => trustRun(deployment, admin));
|
|
4587
4639
|
const credential = await report.check("run signs in", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/conformance",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Checks a coffre deployment from outside: what it must never do, whatever code it runs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"jose": "6.2.3",
|
|
33
33
|
"pg": "8.16.3",
|
|
34
|
-
"@coffre/cli": "0.
|
|
35
|
-
"@coffre/db": "0.
|
|
34
|
+
"@coffre/cli": "0.5.0",
|
|
35
|
+
"@coffre/db": "0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "26.1.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"tsdown": "0.23.0",
|
|
42
42
|
"typescript": "5.9.3",
|
|
43
43
|
"vite": "8.1.5",
|
|
44
|
-
"@coffre/client": "0.
|
|
44
|
+
"@coffre/client": "0.5.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsdown",
|
package/src/checks/access.ts
CHANGED
|
@@ -39,7 +39,10 @@ export async function grantScoping({ reader, service, bulk }: People, canaries:
|
|
|
39
39
|
await refused('a viewer wrote a value', reader.api.secrets.set(DEV, { API_KEY: 'from the reader' }));
|
|
40
40
|
await refused('a viewer granted themselves more', reader.api.access.set(reader.member, { [PROD]: 'owner' }));
|
|
41
41
|
await refused('a viewer added a member', reader.api.members.add('user:friend@conformance.example'));
|
|
42
|
-
|
|
42
|
+
// A service account is set up by whoever holds all it holds: a viewer on bulk, who holds nothing on dev, may not.
|
|
43
|
+
await refused("a viewer on bulk issued a token for a service on dev", bulk.api.tokens.issue(service.member, { expiresInDays: 1 }));
|
|
44
|
+
await refused('a viewer on bulk gave a service dev', bulk.api.access.set(service.member, { [DEV]: 'viewer' }));
|
|
45
|
+
await refused('a viewer on dev gave a service prod', reader.api.access.set(service.member, { [PROD]: 'viewer' }));
|
|
43
46
|
const me = await reader.api.me();
|
|
44
47
|
const places = me.environments.map((place) => `${place.project}/${place.environment}`);
|
|
45
48
|
expect(places.length === 1 && places[0] === DEV, 'a viewer on dev is told of other places', places);
|
|
@@ -48,7 +51,7 @@ export async function grantScoping({ reader, service, bulk }: People, canaries:
|
|
|
48
51
|
expect(same(served.values, valuesIn(canaries, DEV)), "a service viewer on dev did not get dev's values", served.values);
|
|
49
52
|
await refused('a service viewer on dev revealed prod', service.api.secrets.reveal(PROD));
|
|
50
53
|
await refused('a viewer on bulk revealed dev', bulk.api.secrets.reveal(DEV));
|
|
51
|
-
return 'a viewer on dev reads dev and nothing else, in a browser or with a token, and changes nothing';
|
|
54
|
+
return 'a viewer on dev reads dev and nothing else, in a browser or with a token, and changes nothing; nobody gives a service account, or a token for one, beyond what they hold';
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
/**
|
|
@@ -96,6 +99,7 @@ export async function offboarding(deployment: Deployment, { admin, leaver, servi
|
|
|
96
99
|
const before = await admin.api.members.get(leaver.member);
|
|
97
100
|
expect(before.live.apps === 1 && before.apps.length === 1, "the owner's report does not list the app the leaver connected", before.apps);
|
|
98
101
|
const { revoked, report } = await admin.api.members.remove(leaver.member);
|
|
102
|
+
expect(report !== null, "an owner's removal does not answer with the leaver's report");
|
|
99
103
|
expect(revoked.apps === 1 && report.live.apps === 0 && report.apps.length === 0, 'removal does not say it disconnected their app', { revoked, apps: report.apps });
|
|
100
104
|
expect(!(await discovers(deployment, app)), "a removed member's app still reaches /mcp");
|
|
101
105
|
const exposed = report.exposed.map((entry) => `${entry.project}/${entry.environment}/${entry.key}`).sort();
|
|
@@ -125,55 +129,56 @@ export async function offboarding(deployment: Deployment, { admin, leaver, servi
|
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
+
* Instance roles: a Developer scoped to dev reads and writes the dev of a
|
|
133
|
+
* project made after it, and no prod; an Admin scoped to one environment
|
|
134
|
+
* grants there and nowhere else, and sets no role, its own or anyone's;
|
|
135
|
+
* and no grant is on every project. The reader is a member again as it
|
|
136
|
+
* ends, its service removed, its project archived.
|
|
132
137
|
*/
|
|
133
|
-
export async function
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
export async function instanceRoles(deployment: Deployment, { admin, reader }: People, canaries: Canaries): Promise<string> {
|
|
139
|
+
const scoped = 'token:conformance-scoped';
|
|
140
|
+
await admin.api.members.add(scoped);
|
|
141
|
+
await refused('a grant on every project was given', admin.api.access.set(scoped, { '*': 'viewer' }));
|
|
142
|
+
await refused('a grant on dev in every project was given', admin.api.access.set(scoped, { '*/dev': 'viewer' }));
|
|
143
|
+
await refused('a service account was given an instance role', admin.api.members.add(scoped, { role: 'developer' }));
|
|
144
|
+
await refused('a viewer gave themselves an instance role', reader.api.members.add(reader.member, { role: 'owner' }));
|
|
137
145
|
|
|
138
|
-
//
|
|
139
|
-
await admin.api.
|
|
140
|
-
const
|
|
141
|
-
await
|
|
142
|
-
await refused('a viewer granted themselves every project', reader.api.access.set(reader.member, { '*/prod': 'viewer' }));
|
|
143
|
-
await admin.api.access.set(services.everything, { '*': 'viewer' });
|
|
144
|
-
await admin.api.access.set(services.dev, { '*/dev': 'viewer' });
|
|
145
|
-
const [everything, dev] = [await client(services.everything), await client(services.dev)];
|
|
146
|
-
|
|
147
|
-
// Made after the grants: a project with a dev and a prod.
|
|
148
|
-
const later = `${PROJECT}-later`;
|
|
149
|
-
const made = await admin.api.projects.create(later, { name: 'Made later' });
|
|
150
|
-
expect(made.inherited.some((grant) => grant.member === services.everything && grant.place === '*'), 'making a project did not say who reaches it', made.inherited);
|
|
146
|
+
// Made after the role: a project with a dev and a prod.
|
|
147
|
+
await admin.api.members.add(reader.member, { role: 'developer', scope: { environments: { only: ['dev'] } } });
|
|
148
|
+
const later = `${PROJECT}-roles`;
|
|
149
|
+
await admin.api.projects.create(later, { name: 'Made later' });
|
|
151
150
|
for (const environment of ['dev', 'prod']) {
|
|
152
151
|
const path = `${later}/${environment}`;
|
|
153
|
-
|
|
154
|
-
const reaches = inherited.filter((grant) => grant.member === services.dev).length;
|
|
155
|
-
expect(reaches === (environment === 'dev' ? 1 : 0), `making ${path} misnamed who reaches it through dev in every project`, inherited);
|
|
152
|
+
await admin.api.environments.create(path, { name: environment });
|
|
156
153
|
canaries[`${path}/API_KEY`] = canary();
|
|
157
154
|
await admin.api.secrets.set(path, valuesIn(canaries, path));
|
|
158
155
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
await refused('
|
|
164
|
-
const devRead = await dev.secrets.reveal(`${later}/dev`);
|
|
165
|
-
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);
|
|
166
|
-
await refused('viewer on dev in every project read a prod made later', dev.secrets.reveal(`${later}/prod`));
|
|
167
|
-
await refused('viewer on dev in every project read prod', dev.secrets.reveal(PROD));
|
|
156
|
+
const read = await reader.api.secrets.reveal(`${later}/dev`);
|
|
157
|
+
expect(read.values.API_KEY === canaries[`${later}/dev/API_KEY`], 'a Developer scoped to dev could not read a dev made later', read.values);
|
|
158
|
+
await reader.api.secrets.set(`${later}/dev`, { API_KEY: canaries[`${later}/dev/API_KEY`]! });
|
|
159
|
+
await refused('a Developer scoped to dev read a prod made later', reader.api.secrets.reveal(`${later}/prod`));
|
|
160
|
+
await refused('a Developer scoped to dev read prod', reader.api.secrets.reveal(PROD));
|
|
168
161
|
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
await
|
|
172
|
-
await refused('a
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
// An admin scoped to one environment manages it alone.
|
|
163
|
+
await admin.api.members.add(reader.member, { role: 'admin', scope: { projects: { only: [PROJECT] }, environments: { only: ['dev'] } } });
|
|
164
|
+
await reader.api.access.set(scoped, { [DEV]: 'viewer' });
|
|
165
|
+
await refused('a scoped admin granted outside its scope', reader.api.access.set(scoped, { [PROD]: 'viewer' }));
|
|
166
|
+
await refused('a scoped admin granted on the project around its scope', reader.api.access.set(scoped, { [PROJECT]: 'viewer' }));
|
|
167
|
+
await refused('a scoped admin widened its own role', reader.api.members.add(reader.member, { role: 'admin' }));
|
|
168
|
+
await refused('a scoped admin promoted someone', reader.api.members.add(scoped, { role: 'member' }));
|
|
169
|
+
await refused('a scoped admin made a project', reader.api.projects.create(`${PROJECT}-scoped`, { name: 'Scoped' }));
|
|
170
|
+
await refused('a scoped admin read a value no grant of its gives', reader.api.secrets.reveal(PROD));
|
|
171
|
+
// Nor does an admin of the whole instance set its own.
|
|
172
|
+
await admin.api.members.add(reader.member, { role: 'admin' });
|
|
173
|
+
await refused('an admin made itself an owner', reader.api.members.add(reader.member, { role: 'owner' }));
|
|
174
|
+
|
|
175
|
+
// As it was: a member, with its viewer on dev; the service and the project gone.
|
|
176
|
+
await admin.api.members.add(reader.member, { role: 'member' });
|
|
177
|
+
await admin.api.members.remove(scoped);
|
|
175
178
|
await admin.api.projects.update(later, { archived: true });
|
|
176
|
-
|
|
179
|
+
const me = await reader.api.me();
|
|
180
|
+
expect(me.instanceRole === 'member' && me.environments.length === 1, 'the reader is not back as it was', me);
|
|
181
|
+
return 'a Developer scoped to dev reaches a dev made later and no prod; a scoped admin grants only inside its scope and sets no role; no grant is on every project';
|
|
177
182
|
}
|
|
178
183
|
|
|
179
184
|
/** Reading more values at once than the vault allows in its window is refused. */
|
package/src/checks/canaries.ts
CHANGED
|
@@ -38,7 +38,7 @@ function pages(people: People): string[] {
|
|
|
38
38
|
...['', '/users', '/service-accounts', '/settings'].map((tab) => `/projects/${PROJECT}${tab}`),
|
|
39
39
|
...[DEV, PROD, BULK].map((path) => `/projects/${path}`),
|
|
40
40
|
'/users',
|
|
41
|
-
...users.flatMap((person) => ['', '/activity'].map((tab) => `/users/${encodeURIComponent(person.email)}${tab}`)),
|
|
41
|
+
...users.flatMap((person) => ['', '/apps', '/activity'].map((tab) => `/users/${encodeURIComponent(person.email)}${tab}`)),
|
|
42
42
|
'/service-accounts',
|
|
43
43
|
...['', '/access', '/activity'].map((tab) => `/service-accounts/${SERVICE.slice('token:'.length)}${tab}`),
|
|
44
44
|
];
|
package/src/checks/cli.ts
CHANGED
|
@@ -146,7 +146,7 @@ export async function verifyAsUser(cli: Cli, user: Person, admin: Person): Promi
|
|
|
146
146
|
const run = await cli.run(['verify', 'instance']);
|
|
147
147
|
expect(run.code === 1, `coffre verify instance as a user exited ${run.code}, not 1`, run.output);
|
|
148
148
|
expect(marks(run.output).owner === '✗', 'the run went on past a user', run.output);
|
|
149
|
-
expect(/is
|
|
149
|
+
expect(/is not an admin or owner of all of \S+, nor a root admin: nothing was made/.test(run.output), 'the run did not say plainly why it stopped', run.output);
|
|
150
150
|
const service = await admin.api.members.get(PROBE.service).then(
|
|
151
151
|
() => 'there',
|
|
152
152
|
(error: unknown) => (error instanceof CoffreError && error.status === 404 ? 'absent' : Promise.reject(error)),
|
package/src/checks/mcp.ts
CHANGED
|
@@ -11,7 +11,8 @@ import { CoffreError } from '@coffre/client';
|
|
|
11
11
|
import type { Deployment } from '../harness.ts';
|
|
12
12
|
import { expect } from '../report.ts';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { bearer } from '../browser.ts';
|
|
15
|
+
import { canary, deviceLogin, DEV, personaOn, PROD, PROJECT, valuesIn, type Canaries, type People, type Person } from './people.ts';
|
|
15
16
|
|
|
16
17
|
const NAME = 'Conformance MCP client';
|
|
17
18
|
/** A native client's redirect, on loopback. A custom scheme is left out of a registration (D37). */
|
|
@@ -263,7 +264,7 @@ export async function mcpRead(deployment: Deployment, people: People, canaries:
|
|
|
263
264
|
const result = listed.body.result as { tools?: { name: string; annotations?: { readOnlyHint?: boolean } }[]; cacheScope?: string; ttlMs?: number } | undefined;
|
|
264
265
|
const names = result?.tools?.map((tool) => tool.name) ?? [];
|
|
265
266
|
// The reader's list: their role's tools, and none of an instance owner's; theirs alone to cache, and not for long, so a role's change shows.
|
|
266
|
-
expect(names.includes('list_secrets') && !names.includes('run_with_secrets') && !names.includes('
|
|
267
|
+
expect(names.includes('list_secrets') && !names.includes('run_with_secrets') && !names.includes('create_project') && !names.includes('read_audit_log') && result?.cacheScope === 'private' && typeof result.ttlMs === 'number' && result.ttlMs <= 600_000,
|
|
267
268
|
"tools/list does not list the reader's tools alone, cached for them only and briefly", listed.body);
|
|
268
269
|
const callTool = async (tool: string, args: Record<string, unknown>) => {
|
|
269
270
|
const { response, body } = await modern(deployment, access, 'tools/call', { name: tool, arguments: args }, tool);
|
|
@@ -331,8 +332,9 @@ type ToolAnswer = {
|
|
|
331
332
|
* approves on coffre's page. A client without URL elicitation gets the link
|
|
332
333
|
* and calls again; one with it is asked to open the page, and retries with
|
|
333
334
|
* its requestState, which no other call may use. Only the person decides,
|
|
334
|
-
*
|
|
335
|
-
*
|
|
335
|
+
* in their browser, never with a CLI session, with the digest the page
|
|
336
|
+
* showed; the page makes the change, once, and its entries name the client
|
|
337
|
+
* and the approval. A value comes from the page.
|
|
336
338
|
*/
|
|
337
339
|
export async function mcpChanges(deployment: Deployment, people: People, canaries: Canaries): Promise<string> {
|
|
338
340
|
const { admin } = people;
|
|
@@ -389,11 +391,17 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
389
391
|
body: JSON.stringify({ approve: true, digest: shown.digest }),
|
|
390
392
|
});
|
|
391
393
|
expect(forgedSite.status === 403, `another site's approval answered ${forgedSite.status}, not 403`);
|
|
394
|
+
// On coffre's page only: the person's CLI session, which an app on their machine may hold, can neither open nor decide it.
|
|
395
|
+
const cli = bearer(deployment.origin, await deviceLogin(deployment, changer.browser));
|
|
396
|
+
const fromCli = await cli.approvals.get(approval!.id).then(() => null, (error: unknown) => error);
|
|
397
|
+
const decidedFromCli = await cli.approvals.decide(approval!.id, { approve: true, digest: shown.digest }).then(() => null, (error: unknown) => error);
|
|
398
|
+
expect(fromCli instanceof CoffreError && fromCli.status === 403 && decidedFromCli instanceof CoffreError && decidedFromCli.status === 403,
|
|
399
|
+
'a CLI session opened or decided an approval', { fromCli, decidedFromCli });
|
|
392
400
|
expect(!(await archived('OLD')), 'a refused decision changed something');
|
|
393
401
|
|
|
394
|
-
const decided = await changer.api.approvals.decide(approval!.id, { approve: true, digest: shown.digest });
|
|
402
|
+
const decided = await changer.api.approvals.decide(approval!.id, { approve: true, digest: shown.digest, basis: shown.basis });
|
|
395
403
|
expect(decided.status === 'approved' && (await archived('OLD')), 'Approve did not make the change', decided);
|
|
396
|
-
const again = await changer.api.approvals.decide(approval!.id, { approve: true, digest: shown.digest }).then(() => null, (error: unknown) => error);
|
|
404
|
+
const again = await changer.api.approvals.decide(approval!.id, { approve: true, digest: shown.digest, basis: shown.basis }).then(() => null, (error: unknown) => error);
|
|
397
405
|
expect(again instanceof CoffreError && again.status === 409, 'an approval was decided twice', again);
|
|
398
406
|
const reported = await call(write, 'archive_secret', { secret: `${place}/OLD` });
|
|
399
407
|
expect(reported.result?.structuredContent?.status === 'approved' && reported.result.isError !== true, 'calling again does not report the approved change', reported.result);
|
|
@@ -410,7 +418,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
410
418
|
const renamedEarly = await admin.api.secrets.list(place);
|
|
411
419
|
expect(renamedEarly.keys.some((key) => key.key === 'KEEP'), 'a change was made before its approval', renamedEarly.keys);
|
|
412
420
|
const second = (await changer.api.approvals.get(id)).approval;
|
|
413
|
-
expect((await changer.api.approvals.decide(id, { approve: true, digest: second.digest })).status === 'approved', 'the second approval was not made');
|
|
421
|
+
expect((await changer.api.approvals.decide(id, { approve: true, digest: second.digest, basis: second.basis })).status === 'approved', 'the second approval was not made');
|
|
414
422
|
const retried = await call(write, 'rename_secret', { secret: `${place}/KEEP`, newKey: 'KEPT' }, { requestState: asked.result!.requestState, inputResponses: { approve: { action: 'accept' } } }, elicits);
|
|
415
423
|
expect(retried.result?.structuredContent?.status === 'approved', 'the retry does not report the approved change', retried.result);
|
|
416
424
|
|
|
@@ -421,7 +429,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
421
429
|
const valueId = valueAsked.result!.structuredContent!.approval!.id;
|
|
422
430
|
const valuePage = (await changer.api.approvals.get(valueId)).approval;
|
|
423
431
|
expect(valuePage.asks?.value !== undefined, 'the approval page does not ask for the value');
|
|
424
|
-
await changer.api.approvals.decide(valueId, { approve: true, digest: valuePage.digest, value: typed });
|
|
432
|
+
await changer.api.approvals.decide(valueId, { approve: true, digest: valuePage.digest, basis: valuePage.basis, value: typed });
|
|
425
433
|
expect((await admin.api.secrets.reveal(`${place}/TYPED`)).values.TYPED === typed, 'the value typed on the page was not written');
|
|
426
434
|
await call(write, 'request_secret_value', { secret: `${place}/TYPED` });
|
|
427
435
|
|
|
@@ -429,7 +437,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
429
437
|
const generating = await call(write, 'generate_secret_value', { secret: `${place}/GENERATED`, alphabet: 'hex' });
|
|
430
438
|
const generatedId = generating.result!.structuredContent!.approval!.id;
|
|
431
439
|
const generatedPage = (await changer.api.approvals.get(generatedId)).approval;
|
|
432
|
-
const generated = await changer.api.approvals.decide(generatedId, { approve: true, digest: generatedPage.digest });
|
|
440
|
+
const generated = await changer.api.approvals.decide(generatedId, { approve: true, digest: generatedPage.digest, basis: generatedPage.basis });
|
|
433
441
|
const made = (await admin.api.secrets.reveal(`${place}/GENERATED`)).values.GENERATED ?? '';
|
|
434
442
|
canaries[`${place}/GENERATED`] = made;
|
|
435
443
|
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');
|
|
@@ -444,7 +452,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
444
452
|
expect(once.archive === 1 && once.rename === 1 && once.write === 2, 'the changes are not each made once, via the client and its approval', once);
|
|
445
453
|
const decisions = entries.filter((entry) => entry.action === 'mcp.approve').map((entry) => `${entry.decision} ${entry.reason ?? ''}`.trim()).sort();
|
|
446
454
|
expect(JSON.stringify(decisions) === JSON.stringify(['allow', 'allow', 'allow', 'allow', 'deny approved', 'deny changed']), 'the decisions, and the two refused, are not in the log', decisions);
|
|
447
|
-
return `Read stepped up to Write, saying how as its result; Write ticked beyond what was asked; with Write, the link without URL elicitation and an elicitation with it; nothing changed until ${changer.email} approved on coffre's page, another person
|
|
455
|
+
return `Read stepped up to Write, saying how as its result; Write ticked beyond what was asked; with Write, the link without URL elicitation and an elicitation with it; nothing changed until ${changer.email} approved on coffre's page, another person, another site and a CLI session 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`;
|
|
448
456
|
}
|
|
449
457
|
|
|
450
458
|
/**
|
|
@@ -473,7 +481,7 @@ export async function mcpValues(deployment: Deployment, people: People, canaries
|
|
|
473
481
|
expect(show.result?.structuredContent?.status === 'pending' && id !== undefined, 'show_secret_value did not open an approval', show.result);
|
|
474
482
|
const page = (await reader.api.approvals.get(id!)).approval;
|
|
475
483
|
expect(page.kind === 'reveal', 'the approval page does not say it shows a value', page);
|
|
476
|
-
const shown = await reader.api.approvals.decide(id!, { approve: true, digest: page.digest });
|
|
484
|
+
const shown = await reader.api.approvals.decide(id!, { approve: true, digest: page.digest, basis: page.basis });
|
|
477
485
|
expect(shown.shown.some((line) => line.value === dev.API_KEY), 'Reveal did not show the person the value');
|
|
478
486
|
const told = await call(reading, 'show_secret_value', { secret: `${DEV}/API_KEY` });
|
|
479
487
|
expect(told.result?.structuredContent?.status === 'approved', 'show_secret_value does not report the value as shown', told.result);
|
package/src/checks/members.ts
CHANGED
|
@@ -39,7 +39,8 @@ export async function memberTampering(deployment: Deployment, people: People, ki
|
|
|
39
39
|
await query(sql, 'UPDATE vault_grants SET role = $1, granted_at = $2, granted_by = $3 WHERE principal = $4',
|
|
40
40
|
[grants[0].role, grants[0].granted_at, grants[0].granted_by, person.member]);
|
|
41
41
|
} else if (kind === 'member') {
|
|
42
|
-
|
|
42
|
+
// The instance role, as the database's owner could set it: an Owner reads every value.
|
|
43
|
+
await query(sql, "UPDATE vault_members SET role = 'owner' WHERE principal = $1", [person.member]);
|
|
43
44
|
} else {
|
|
44
45
|
const [place] = await query<{ id: string }>(sql, `SELECT e.id FROM environments e JOIN projects p ON p.id = e.project_id
|
|
45
46
|
WHERE p.slug = 'conformance' AND e.slug = 'prod'`);
|
package/src/checks/pages.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Browser } from '../browser.ts';
|
|
|
7
7
|
import { Chrome, findChrome } from '../chrome.ts';
|
|
8
8
|
import type { Deployment } from '../harness.ts';
|
|
9
9
|
import { expect, Skip } from '../report.ts';
|
|
10
|
-
import { type Person, PROJECT, signIn } from './people.ts';
|
|
10
|
+
import { DEV, type Person, PROJECT, signIn } from './people.ts';
|
|
11
11
|
|
|
12
12
|
/** Each page, the heading it shows, and the tab it is, for a page with tabs. */
|
|
13
13
|
const PAGES: [path: string, heading: string, tab: string | null][] = [
|
|
@@ -97,6 +97,7 @@ export async function pagesInBrowser(deployment: Deployment, admin: Person, brow
|
|
|
97
97
|
...PAGES,
|
|
98
98
|
['/settings', 'Settings', null],
|
|
99
99
|
[person, admin.email, 'Access'],
|
|
100
|
+
[`${person}/apps`, admin.email, 'Connected apps'],
|
|
100
101
|
[`${person}/activity`, admin.email, 'Activity'],
|
|
101
102
|
['/service-accounts', 'Service accounts', null],
|
|
102
103
|
[account, `service:${name}`, 'Sign-in'],
|
|
@@ -124,7 +125,7 @@ export async function pagesInBrowser(deployment: Deployment, admin: Person, brow
|
|
|
124
125
|
expect(loaded.dialog?.includes('Removing revokes 0 grants, 0 bearer tokens') === true, `${path}: Remove… does not preview what it would revoke`, loaded.dialog);
|
|
125
126
|
}
|
|
126
127
|
if (path === '/settings') expect(loaded.cards.includes('Keys'), '/settings does not show what the keys are checked against', loaded.cards);
|
|
127
|
-
if (path === person) expect(loaded.cards.includes('Connected apps'), `${path} does not show an owner the person's connected apps`, loaded.cards);
|
|
128
|
+
if (path === `${person}/apps`) expect(loaded.cards.includes('Connected apps'), `${path} does not show an owner the person's connected apps`, loaded.cards);
|
|
128
129
|
if (path === '/account/apps') {
|
|
129
130
|
expect(loaded.cards.join(' then ') === 'Connect an app then Connected apps', `${path} does not show Connect an app, then the connected apps`, loaded.cards);
|
|
130
131
|
for (const shown of [mcp, `claude mcp add --transport http coffre ${mcp}`, 'Add custom connector']) {
|
|
@@ -137,18 +138,17 @@ export async function pagesInBrowser(deployment: Deployment, admin: Person, brow
|
|
|
137
138
|
const walked = await chrome.load(project, admin.browser.cookies(), undefined, WALK_TABS);
|
|
138
139
|
expect(walked.errors.length === 0, `${project}'s tabs reported errors in the browser`, walked.errors.join('\n'));
|
|
139
140
|
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)}`);
|
|
140
|
-
// Its access
|
|
141
|
+
// Its access, project by project: a grant on one of its environments, and none on every project to give.
|
|
141
142
|
const access = `${account}/access`;
|
|
142
|
-
await admin.api.access.set(SERVICE, {
|
|
143
|
+
await admin.api.access.set(SERVICE, { [DEV]: 'viewer' });
|
|
143
144
|
try {
|
|
144
145
|
const loaded = await chrome.load(new URL(access, deployment.origin).href, admin.browser.cookies());
|
|
145
146
|
expect(loaded.errors.length === 0, `${access} reported errors in the browser`, loaded.errors.join('\n'));
|
|
146
147
|
expect(loaded.tab === 'Access', `${access} shows the tab ${JSON.stringify(loaded.tab)}, not "Access"`);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
148
|
+
expect(loaded.text.includes('Viewer') && loaded.text.includes('Edit access'), `${access}, to an admin, does not show its grant and Edit access`, loaded.text);
|
|
149
|
+
expect(!loaded.text.includes('every project'), `${access} still offers a grant on every project`, loaded.text);
|
|
150
150
|
} finally {
|
|
151
|
-
await admin.api.access.set(SERVICE, {
|
|
151
|
+
await admin.api.access.set(SERVICE, { [DEV]: null });
|
|
152
152
|
}
|
|
153
153
|
// The page an MCP client sends a person to: who asks, where the answer goes, and what it may do.
|
|
154
154
|
const consent = await consentUrl(deployment);
|
|
@@ -161,7 +161,7 @@ export async function pagesInBrowser(deployment: Deployment, admin: Person, brow
|
|
|
161
161
|
} finally {
|
|
162
162
|
await chrome.close();
|
|
163
163
|
}
|
|
164
|
-
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
|
|
164
|
+
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, project by project; the account's Connected apps tab, with this instance's MCP URL and Claude Code's command; the MCP consent page, a registered client shown as unverified`;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
/**
|
package/src/checks/people.ts
CHANGED
|
@@ -169,7 +169,7 @@ export async function personas(deployment: Deployment, admin: Person) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/** `coffre login`: a device code, approved in a signed-in browser, for a CLI session. */
|
|
172
|
-
async function deviceLogin(deployment: Deployment, browser: Browser): Promise<string> {
|
|
172
|
+
export async function deviceLogin(deployment: Deployment, browser: Browser): Promise<string> {
|
|
173
173
|
const json = { 'content-type': 'application/json' };
|
|
174
174
|
const started = await fetch(`${deployment.origin}/api/auth/device`, {
|
|
175
175
|
method: 'POST',
|
package/src/checks/workloads.ts
CHANGED
|
@@ -128,7 +128,8 @@ export async function runsRefused(deployment: Deployment, admin: Person): Promis
|
|
|
128
128
|
['for another instance', await mint(deployment, {}, { audience: 'https://secrets.elsewhere.example' }), 'audience'],
|
|
129
129
|
['expired', await mint(deployment, { iat: now - 600, nbf: now - 600, exp: now - 120 }), 'expired'],
|
|
130
130
|
['from a feature branch', await mint(deployment, { ref: feature, workflow_ref: GITHUB_RUN.workflow_ref.replace(/@.*/, `@${feature}`), sub: `repo:acme/api:ref:${feature}` }), 'no_match'],
|
|
131
|
-
|
|
131
|
+
// Into the very branch the binding names: it lists push alone.
|
|
132
|
+
['from a pull request', await mint(deployment, { event_name: 'pull_request', ref: 'refs/pull/1/merge', base_ref: 'main', workflow_ref: GITHUB_RUN.workflow_ref.replace(/@.*/, '@refs/pull/1/merge'), sub: 'repo:acme/api:pull_request' }), 'no_match'],
|
|
132
133
|
['from another repository', await mint(deployment, { repository_id: '1', repository: 'acme/fork' }), 'no_match'],
|
|
133
134
|
] as const;
|
|
134
135
|
const before = (await admin.api.audit.list({ actor: RUNNER, detail: '1' })).entries.filter((entry) => entry.action === 'token.exchange').length;
|
package/src/suite.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// which leaves the audit log broken for good.
|
|
4
4
|
import type { Deployment } from './harness.ts';
|
|
5
5
|
import { Report } from './report.ts';
|
|
6
|
-
import { bulkLimit, crossSite,
|
|
6
|
+
import { bulkLimit, crossSite, grantScoping, instanceRoles, membersOnly, offboarding } from './checks/access.ts';
|
|
7
7
|
import { checkpoints, deletedTail, forgedVaultEntry, missingEntry, noAuditNoValue, revealAudited, rewrittenEntry, verification, writesAgree } from './checks/audit.ts';
|
|
8
8
|
import { earlierCheckpoint } from './checks/checkpoints.ts';
|
|
9
9
|
import { deletion } from './checks/deletion.ts';
|
|
@@ -71,7 +71,7 @@ export async function conform(deployment: Deployment, options: { bulkLimit: numb
|
|
|
71
71
|
for (const cli of clis) cli.remove();
|
|
72
72
|
}
|
|
73
73
|
await report.check('offboarding', all, ({ people, canaries }) => offboarding(deployment, people, canaries));
|
|
74
|
-
await report.check('
|
|
74
|
+
await report.check('instance roles', all, ({ people, canaries }) => instanceRoles(deployment, people, canaries));
|
|
75
75
|
await report.check('bulk limit', { people }, ({ people }) => bulkLimit(people, options.bulkLimit));
|
|
76
76
|
// A CI run signing in with its ID token, through a binding. The limit
|
|
77
77
|
// comes last of these: it spends this address's exchanges for the minute.
|