@coffre/conformance 0.5.1 → 0.6.1
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-Dyaj6k5N.js → idp-B8u4UPA4.js} +373 -22
- package/dist/idp.d.ts +80 -2
- package/dist/idp.js +2 -2
- package/dist/main.js +217 -32
- package/package.json +4 -4
- package/src/checks/access.ts +13 -4
- package/src/checks/canaries.ts +1 -1
- package/src/checks/cli.ts +1 -1
- package/src/checks/environments.ts +11 -8
- package/src/checks/pages.ts +147 -0
- package/src/checks/people.ts +6 -5
- package/src/chrome.ts +9 -3
- package/src/harness.ts +15 -7
- package/src/idp/github-app.ts +259 -0
- package/src/idp/github.ts +38 -7
- package/src/idp/idp.ts +17 -2
- package/src/idp/index.ts +1 -0
- package/src/idp/people.ts +2 -2
- package/src/suite.ts +2 -1
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as defaultGitHubAccount, n as DevIdp, r as GITHUB_RUN } from "./idp-B8u4UPA4.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";
|
|
@@ -224,7 +224,7 @@ function createClient(options) {
|
|
|
224
224
|
},
|
|
225
225
|
/** Delete an archived environment for good, as a project is. Owners only. */
|
|
226
226
|
delete: (path) => call("DELETE /projects/:project/:environment", place(path)),
|
|
227
|
-
/** The keys its sibling environments have and it lacks,
|
|
227
|
+
/** The keys its sibling environments have and it lacks, read or not, and those its team dismissed. */
|
|
228
228
|
missing: (path) => call("GET /projects/:project/:environment/missing", place(path)),
|
|
229
229
|
/** Dismiss missing keys (`true`) or restore them (`null`). */
|
|
230
230
|
dismiss: (path, patch) => call("PATCH /projects/:project/:environment/dismissals", place(path), patch)
|
|
@@ -299,8 +299,10 @@ function createClient(options) {
|
|
|
299
299
|
member,
|
|
300
300
|
id
|
|
301
301
|
}),
|
|
302
|
-
/** A
|
|
303
|
-
lookup: (input) => call("GET /workloads/lookup", {}, input)
|
|
302
|
+
/** A GitHub repository's or GitLab project's IDs, which bindings name: a public one's, or one the deployment's GitHub App is installed on. */
|
|
303
|
+
lookup: (input) => call("GET /workloads/lookup", {}, input),
|
|
304
|
+
/** The repositories the deployment's GitHub App is installed on, private ones too; `{ app: null }` without one. */
|
|
305
|
+
repositories: () => call("GET /workloads/repositories", {})
|
|
304
306
|
},
|
|
305
307
|
access: {
|
|
306
308
|
/** What they should hold at each place; the server applies the difference. `null` revokes. */
|
|
@@ -377,7 +379,7 @@ set: (member, access) => call("PATCH /access/:member", { member }, access) },
|
|
|
377
379
|
audit: {
|
|
378
380
|
list: (query = {}) => call("GET /audit", {}, query),
|
|
379
381
|
verify: () => call("GET /audit/verification", {}),
|
|
380
|
-
/** What an escrowed key is checked against: public material,
|
|
382
|
+
/** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
|
|
381
383
|
keys: () => call("GET /audit/keys", {})
|
|
382
384
|
}
|
|
383
385
|
};
|
|
@@ -472,7 +474,18 @@ var Report = class {
|
|
|
472
474
|
};
|
|
473
475
|
//#endregion
|
|
474
476
|
//#region src/harness.ts
|
|
475
|
-
const
|
|
477
|
+
const OWNER = "root@conformance.example";
|
|
478
|
+
/**
|
|
479
|
+
* The vault's Owners, under each name a deployment's vault may read them by:
|
|
480
|
+
* `OWNERS`, and `BOOTSTRAP_OWNERS` and 0.5's `ROOT_ADMINS`, read until 0.7,
|
|
481
|
+
* as an older deployment's vault entry still does. Each Worker gets only the
|
|
482
|
+
* vars its wrangler.jsonc declares.
|
|
483
|
+
*/
|
|
484
|
+
const OWNER_VARS = {
|
|
485
|
+
OWNERS: OWNER,
|
|
486
|
+
BOOTSTRAP_OWNERS: OWNER,
|
|
487
|
+
ROOT_ADMINS: OWNER
|
|
488
|
+
};
|
|
476
489
|
/**
|
|
477
490
|
* The CLI the deployment pins, as its pipeline runs it: `pnpm exec coffre`,
|
|
478
491
|
* found from its folder, so only as one of its own packages. Its entry is
|
|
@@ -636,7 +649,7 @@ async function boot(kind, at, options) {
|
|
|
636
649
|
APP_KEY: KEYS.APP_KEY,
|
|
637
650
|
VAULT_KEY_ID: KEYS.VAULT_KEY_ID,
|
|
638
651
|
VAULT_KEY: KEYS.VAULT_KEY,
|
|
639
|
-
|
|
652
|
+
...OWNER_VARS,
|
|
640
653
|
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE: runtime,
|
|
641
654
|
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_VAULT_HYPERDRIVE: vaultRuntime,
|
|
642
655
|
WRANGLER_SEND_METRICS: "false"
|
|
@@ -645,7 +658,7 @@ async function boot(kind, at, options) {
|
|
|
645
658
|
kind,
|
|
646
659
|
origin,
|
|
647
660
|
idp,
|
|
648
|
-
|
|
661
|
+
owner: OWNER,
|
|
649
662
|
beforeFirstBeat: true,
|
|
650
663
|
async scheduled(options = {}) {
|
|
651
664
|
const response = await fetch(`${origin}/cdn-cgi/local/scheduled?cron=*/5+*+*+*+*`);
|
|
@@ -669,7 +682,7 @@ async function boot(kind, at, options) {
|
|
|
669
682
|
DATABASE_URL: `file:${database}`,
|
|
670
683
|
VAULT_KEY_ID: KEYS.VAULT_KEY_ID,
|
|
671
684
|
VAULT_KEY: KEYS.VAULT_KEY,
|
|
672
|
-
|
|
685
|
+
...OWNER_VARS
|
|
673
686
|
});
|
|
674
687
|
await until("the vault socket", async () => existsSync(socket), 30, alive);
|
|
675
688
|
await run(bin("vite"), ["build", "app"]);
|
|
@@ -691,7 +704,7 @@ async function boot(kind, at, options) {
|
|
|
691
704
|
kind,
|
|
692
705
|
origin,
|
|
693
706
|
idp,
|
|
694
|
-
|
|
707
|
+
owner: OWNER,
|
|
695
708
|
beforeFirstBeat: false,
|
|
696
709
|
async scheduled() {
|
|
697
710
|
const exited = new Promise((done) => server.child.once("exit", done));
|
|
@@ -825,19 +838,19 @@ async function signIn(deployment, browser, email) {
|
|
|
825
838
|
}
|
|
826
839
|
async function signInAdmin(deployment) {
|
|
827
840
|
const browser = new Browser(deployment.origin);
|
|
828
|
-
const signed = await signIn(deployment, browser, deployment.
|
|
829
|
-
expect(signed.ok, `the
|
|
841
|
+
const signed = await signIn(deployment, browser, deployment.owner);
|
|
842
|
+
expect(signed.ok, `the bootstrap Owner was refused: ${"error" in signed ? signed.error : ""}`);
|
|
830
843
|
const api = browser.client();
|
|
831
844
|
const me = await api.me();
|
|
832
|
-
expect(me.principal.id === deployment.
|
|
845
|
+
expect(me.principal.id === deployment.owner && me.instanceRole === "owner" && me.runsInstance, "signed in as someone else, or not as the Owner", me);
|
|
833
846
|
const admin = {
|
|
834
|
-
email: deployment.
|
|
835
|
-
member: `user:${deployment.
|
|
847
|
+
email: deployment.owner,
|
|
848
|
+
member: `user:${deployment.owner}`,
|
|
836
849
|
browser,
|
|
837
850
|
api
|
|
838
851
|
};
|
|
839
852
|
return {
|
|
840
|
-
detail: `${admin.email},
|
|
853
|
+
detail: `${admin.email}, the bootstrap Owner, through GitHub`,
|
|
841
854
|
value: admin
|
|
842
855
|
};
|
|
843
856
|
}
|
|
@@ -2174,8 +2187,9 @@ async function offboarding(deployment, { admin, leaver, service }, canaries) {
|
|
|
2174
2187
|
/**
|
|
2175
2188
|
* Instance roles: a Developer scoped to dev reads and writes the dev of a
|
|
2176
2189
|
* 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
|
-
*
|
|
2190
|
+
* grants there and nowhere else, and sets no role, its own or anyone's; an
|
|
2191
|
+
* Admin of the whole instance changes no Owner's; and no grant is on every
|
|
2192
|
+
* project. The reader is a member again as it
|
|
2179
2193
|
* ends, its service removed, its project archived.
|
|
2180
2194
|
*/
|
|
2181
2195
|
async function instanceRoles(deployment, { admin, reader }, canaries) {
|
|
@@ -2218,12 +2232,16 @@ async function instanceRoles(deployment, { admin, reader }, canaries) {
|
|
|
2218
2232
|
await refused$1("a scoped admin read a value no grant of its gives", reader.api.secrets.reveal(PROD));
|
|
2219
2233
|
await admin.api.members.add(reader.member, { role: "admin" });
|
|
2220
2234
|
await refused$1("an admin made itself an owner", reader.api.members.add(reader.member, { role: "owner" }));
|
|
2235
|
+
for (const [what, call] of [["an admin demoted the Owner", () => reader.api.members.add(admin.member, { role: "admin" })], ["an admin removed the Owner", () => reader.api.members.remove(admin.member)]]) {
|
|
2236
|
+
const refusal = await refused$1(what, call());
|
|
2237
|
+
expect(refusal.status === 403 && refusal.reason === "not_allowed", `${what}, or was refused for another reason`, refusal);
|
|
2238
|
+
}
|
|
2221
2239
|
await admin.api.members.add(reader.member, { role: "member" });
|
|
2222
2240
|
await admin.api.members.remove(scoped);
|
|
2223
2241
|
await admin.api.projects.update(later, { archived: true });
|
|
2224
2242
|
const me = await reader.api.me();
|
|
2225
2243
|
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";
|
|
2244
|
+
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; an admin demotes and removes no Owner; no grant is on every project";
|
|
2227
2245
|
}
|
|
2228
2246
|
/** Reading more values at once than the vault allows in its window is refused. */
|
|
2229
2247
|
async function bulkLimit$1({ admin, bulk }, limit) {
|
|
@@ -2830,18 +2848,21 @@ async function references(deployment, { admin, reader, leaver }, canaries) {
|
|
|
2830
2848
|
/** A key prod has and dev does not, for the missing-keys check; archived once checked. */
|
|
2831
2849
|
const PROD_ONLY = "CONFORMANCE_PROD_ONLY";
|
|
2832
2850
|
/**
|
|
2833
|
-
*
|
|
2834
|
-
*
|
|
2835
|
-
*
|
|
2836
|
-
* nothing. A dismissal is the team's, and
|
|
2851
|
+
* Within a project, key names are not secret; values are. What dev is
|
|
2852
|
+
* missing is compared with every sibling: the reader, a viewer on dev who
|
|
2853
|
+
* cannot read prod, is told prod has the key, as the admin is, and nothing
|
|
2854
|
+
* of its value, and dismisses nothing. A dismissal is the team's, and
|
|
2855
|
+
* restoring undoes it.
|
|
2837
2856
|
*/
|
|
2838
2857
|
async function missingKeys({ admin, reader }) {
|
|
2839
|
-
|
|
2858
|
+
const value = canary();
|
|
2859
|
+
await admin.api.secrets.set(PROD, { [PROD_ONLY]: value });
|
|
2840
2860
|
try {
|
|
2841
2861
|
const seen = await admin.api.environments.missing(DEV);
|
|
2842
2862
|
expect(seen.missing.some((key) => key.key === PROD_ONLY), "the admin was not told dev lacks prod's key", seen);
|
|
2843
|
-
const
|
|
2844
|
-
expect(
|
|
2863
|
+
const told = await reader.api.environments.missing(DEV);
|
|
2864
|
+
expect(told.missing.some((key) => key.key === PROD_ONLY && key.in.includes("prod")), "a viewer on dev was not told dev lacks prod's key, by name", told);
|
|
2865
|
+
expect(!JSON.stringify(told).includes(value), "a viewer on dev was told prod's value with its key's name");
|
|
2845
2866
|
await refused$1("a viewer dismissed a missing key", reader.api.environments.dismiss(DEV, { [PROD_ONLY]: true }));
|
|
2846
2867
|
await admin.api.environments.dismiss(DEV, { [PROD_ONLY]: true });
|
|
2847
2868
|
const dismissed = await admin.api.environments.missing(DEV);
|
|
@@ -2851,7 +2872,7 @@ async function missingKeys({ admin, reader }) {
|
|
|
2851
2872
|
} finally {
|
|
2852
2873
|
await admin.api.secrets.update(`${PROD}/${PROD_ONLY}`, { archived: true });
|
|
2853
2874
|
}
|
|
2854
|
-
return "
|
|
2875
|
+
return "a viewer on dev learns prod's key name, not its value, and dismisses nothing; a dismissal is listed, and restored";
|
|
2855
2876
|
}
|
|
2856
2877
|
//#endregion
|
|
2857
2878
|
//#region src/checks/logins.ts
|
|
@@ -3074,6 +3095,7 @@ function getCalls({ places, secrets, members, services }) {
|
|
|
3074
3095
|
params: {},
|
|
3075
3096
|
input: { github: "acme/api" }
|
|
3076
3097
|
}],
|
|
3098
|
+
"GET /workloads/repositories": [{ params: {} }],
|
|
3077
3099
|
"GET /settings": [{ params: {} }],
|
|
3078
3100
|
"GET /sessions": [{ params: {} }],
|
|
3079
3101
|
"GET /identities": [{ params: {} }],
|
|
@@ -3202,7 +3224,7 @@ async function canaryScan(deployment, people, canaries) {
|
|
|
3202
3224
|
};
|
|
3203
3225
|
const token = (value) => (url) => fetch(url, { headers: { authorization: `Bearer ${value}` } });
|
|
3204
3226
|
const browsers = {
|
|
3205
|
-
"the
|
|
3227
|
+
"the Owner": people.admin.browser,
|
|
3206
3228
|
"the reader": people.reader.browser,
|
|
3207
3229
|
"the bulk reader": people.bulk.browser,
|
|
3208
3230
|
"the leaver, removed": people.leaver.browser,
|
|
@@ -3412,7 +3434,7 @@ async function verifyAsUser(cli, user, admin) {
|
|
|
3412
3434
|
const run = await cli.run(["verify", "instance"]);
|
|
3413
3435
|
expect(run.code === 1, `coffre verify instance as a user exited ${run.code}, not 1`, run.output);
|
|
3414
3436
|
expect(marks(run.output).owner === "✗", "the run went on past a user", run.output);
|
|
3415
|
-
expect(/is not an admin or owner of all of \S
|
|
3437
|
+
expect(/is not an admin or owner of all of \S+: nothing was made/.test(run.output), "the run did not say plainly why it stopped", run.output);
|
|
3416
3438
|
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`);
|
|
3417
3439
|
await bearer(cli.origin, cli.session()).me();
|
|
3418
3440
|
expect(await everythingElse(admin.api) === before, "the run changed a member, a grant, a project or an environment for a user");
|
|
@@ -3792,7 +3814,7 @@ var Chrome = class Chrome {
|
|
|
3792
3814
|
* shows once its scripts have run and settled, and every uncaught error,
|
|
3793
3815
|
* console error and failed load along the way. `then`, a script run once
|
|
3794
3816
|
* the page settles, does what a person would next, such as open a dialog,
|
|
3795
|
-
* whose text is read with the rest.
|
|
3817
|
+
* whose text is read with the rest, and may answer what it saw.
|
|
3796
3818
|
*/
|
|
3797
3819
|
async load(url, cookies, settle = 2e3, then) {
|
|
3798
3820
|
const { targetId } = await this.#send("Target.createTarget", { url: "about:blank" });
|
|
@@ -3833,11 +3855,14 @@ var Chrome = class Chrome {
|
|
|
3833
3855
|
await this.#send("Page.navigate", { url }, sessionId);
|
|
3834
3856
|
await Promise.race([load, new Promise((resolve) => setTimeout(resolve, 3e4))]);
|
|
3835
3857
|
await new Promise((resolve) => setTimeout(resolve, settle));
|
|
3858
|
+
let answer = null;
|
|
3836
3859
|
if (then !== void 0) {
|
|
3837
|
-
await this.#send("Runtime.evaluate", {
|
|
3860
|
+
const { result } = await this.#send("Runtime.evaluate", {
|
|
3838
3861
|
expression: then,
|
|
3839
|
-
awaitPromise: true
|
|
3862
|
+
awaitPromise: true,
|
|
3863
|
+
returnByValue: true
|
|
3840
3864
|
}, sessionId);
|
|
3865
|
+
answer = result.value ?? null;
|
|
3841
3866
|
await new Promise((resolve) => setTimeout(resolve, settle));
|
|
3842
3867
|
}
|
|
3843
3868
|
const { result } = await this.#send("Runtime.evaluate", {
|
|
@@ -3853,6 +3878,7 @@ var Chrome = class Chrome {
|
|
|
3853
3878
|
}, sessionId);
|
|
3854
3879
|
return {
|
|
3855
3880
|
...result.value,
|
|
3881
|
+
answer,
|
|
3856
3882
|
errors
|
|
3857
3883
|
};
|
|
3858
3884
|
} finally {
|
|
@@ -4095,6 +4121,164 @@ async function pagesInBrowser(deployment, admin, browser) {
|
|
|
4095
4121
|
}
|
|
4096
4122
|
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`;
|
|
4097
4123
|
}
|
|
4124
|
+
/** Where values are pasted in: an environment of their own, the others' values being the canaries'. */
|
|
4125
|
+
const PASTED = `${PROJECT$1}/pasted`;
|
|
4126
|
+
/** A private key as a PEM file holds it, made up: random base64 in lines of 64, each ending in a line break, the last too. */
|
|
4127
|
+
function pem() {
|
|
4128
|
+
return `-----BEGIN PRIVATE KEY-----\n${randomBytes(120).toString("base64").match(/.{1,64}/g).join("\n")}\n-----END PRIVATE KEY-----\n`;
|
|
4129
|
+
}
|
|
4130
|
+
/**
|
|
4131
|
+
* A row's value field, opened by the button `open` names, and `text`
|
|
4132
|
+
* pasted into it as the clipboard would, over the characters `select`
|
|
4133
|
+
* picks; then the row saved by its own button. A new secret is named first.
|
|
4134
|
+
* Answers which field has the focus after the paste, and where its caret is.
|
|
4135
|
+
*/
|
|
4136
|
+
const pasteInto = (steps) => `(async () => {
|
|
4137
|
+
const { open, name, field, select, text, save } = ${JSON.stringify(steps)};
|
|
4138
|
+
const wait = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4139
|
+
// What the page shows once it has it: an edit first reads the value it starts from.
|
|
4140
|
+
const shown = async (label) => {
|
|
4141
|
+
for (let tries = 0; tries < 50; tries++, await wait()) {
|
|
4142
|
+
const found = document.querySelector(\`[aria-label="\${label}"]\`);
|
|
4143
|
+
if (found !== null) return found;
|
|
4144
|
+
}
|
|
4145
|
+
return null;
|
|
4146
|
+
};
|
|
4147
|
+
const button = (words) => [...document.querySelectorAll('button')].find((each) => each.getAttribute('aria-label') === words || each.textContent.trim() === words);
|
|
4148
|
+
button(open)?.click();
|
|
4149
|
+
if (name !== undefined) {
|
|
4150
|
+
const named = await shown('Name of the new secret');
|
|
4151
|
+
if (named === null) return { field: null };
|
|
4152
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(named, name);
|
|
4153
|
+
named.dispatchEvent(new Event('input', { bubbles: true }));
|
|
4154
|
+
}
|
|
4155
|
+
const input = await shown(field);
|
|
4156
|
+
if (input === null) return { field: null };
|
|
4157
|
+
input.focus();
|
|
4158
|
+
if (select !== undefined) input.setSelectionRange(...select);
|
|
4159
|
+
const clipboard = new DataTransfer();
|
|
4160
|
+
clipboard.setData('text/plain', text);
|
|
4161
|
+
input.dispatchEvent(new ClipboardEvent('paste', { clipboardData: clipboard, bubbles: true, cancelable: true }));
|
|
4162
|
+
await wait(300);
|
|
4163
|
+
const focused = document.activeElement;
|
|
4164
|
+
const answer = { field: focused.tagName.toLowerCase(), label: focused.getAttribute('aria-label'), caret: [focused.selectionStart, focused.selectionEnd] };
|
|
4165
|
+
button(save)?.click();
|
|
4166
|
+
return answer;
|
|
4167
|
+
})()`;
|
|
4168
|
+
/**
|
|
4169
|
+
* A new secret's value typed as a person would: `first`, Shift+Enter while composing (which does nothing), Shift+Enter, then
|
|
4170
|
+
* `second` into whichever field the page has by then; then the row saved.
|
|
4171
|
+
* Answers which field has the focus after the line break, and where its caret is.
|
|
4172
|
+
*/
|
|
4173
|
+
const typeLines = (steps) => `(async () => {
|
|
4174
|
+
const { name, field, first, second, save } = ${JSON.stringify(steps)};
|
|
4175
|
+
const wait = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4176
|
+
const shown = async (label) => {
|
|
4177
|
+
for (let tries = 0; tries < 50; tries++, await wait()) {
|
|
4178
|
+
const found = document.querySelector(\`[aria-label="\${label}"]\`);
|
|
4179
|
+
if (found !== null) return found;
|
|
4180
|
+
}
|
|
4181
|
+
return null;
|
|
4182
|
+
};
|
|
4183
|
+
const button = (words) => [...document.querySelectorAll('button')].find((each) => each.getAttribute('aria-label') === words || each.textContent.trim() === words);
|
|
4184
|
+
const typed = (node, text) => {
|
|
4185
|
+
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(node), 'value').set.call(node, text);
|
|
4186
|
+
node.dispatchEvent(new Event('input', { bubbles: true }));
|
|
4187
|
+
node.setSelectionRange(text.length, text.length);
|
|
4188
|
+
};
|
|
4189
|
+
button('New secret')?.click();
|
|
4190
|
+
const named = await shown('Name of the new secret');
|
|
4191
|
+
if (named === null) return { field: null };
|
|
4192
|
+
typed(named, name);
|
|
4193
|
+
const input = await shown(field);
|
|
4194
|
+
if (input === null) return { field: null };
|
|
4195
|
+
input.focus();
|
|
4196
|
+
typed(input, first);
|
|
4197
|
+
// Shift+Enter that confirms an input method's composition is not a line break.
|
|
4198
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', shiftKey: true, isComposing: true, bubbles: true, cancelable: true }));
|
|
4199
|
+
await wait(300);
|
|
4200
|
+
if (document.activeElement !== input || input.value !== first) return { field: 'composing', value: document.activeElement.value };
|
|
4201
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', shiftKey: true, bubbles: true, cancelable: true }));
|
|
4202
|
+
await wait(300);
|
|
4203
|
+
const focused = document.activeElement;
|
|
4204
|
+
const answer = { field: focused.tagName.toLowerCase(), label: focused.getAttribute('aria-label'), value: focused.value, caret: [focused.selectionStart, focused.selectionEnd] };
|
|
4205
|
+
typed(focused, focused.value + second);
|
|
4206
|
+
await wait(100);
|
|
4207
|
+
button(save)?.click();
|
|
4208
|
+
return answer;
|
|
4209
|
+
})()`;
|
|
4210
|
+
/**
|
|
4211
|
+
* A multi-line value pasted into a secret's value field keeps its line
|
|
4212
|
+
* breaks. A text input drops them, so the page puts the paste into the
|
|
4213
|
+
* value itself and turns the field into a textarea, the caret after the
|
|
4214
|
+
* paste. A new secret's PEM key saves byte for byte; one pasted over part
|
|
4215
|
+
* of an existing value replaces just that part, its \r\n saved as \n.
|
|
4216
|
+
* Values never shown: a failure says their lengths and line counts.
|
|
4217
|
+
*/
|
|
4218
|
+
async function pastedValues(deployment, admin, browser) {
|
|
4219
|
+
const executable = chromeOrSkip(browser);
|
|
4220
|
+
await admin.api.environments.create(PASTED, { name: "Pasted" });
|
|
4221
|
+
const before = `coffre-paste-${randomBytes(12).toString("hex")}`;
|
|
4222
|
+
await admin.api.secrets.set(PASTED, { EDITED_KEY: before });
|
|
4223
|
+
const page = new URL(`/projects/${PASTED}`, deployment.origin).href;
|
|
4224
|
+
const added = pem();
|
|
4225
|
+
const edit = pem();
|
|
4226
|
+
const shape = (value) => value === void 0 ? "nothing" : `${value.length} characters, ${value.split("\n").length} lines`;
|
|
4227
|
+
const chrome = await Chrome.open(executable);
|
|
4228
|
+
try {
|
|
4229
|
+
const caret = added.length;
|
|
4230
|
+
const adding = await chrome.load(page, admin.browser.cookies(), void 0, pasteInto({
|
|
4231
|
+
open: "New secret",
|
|
4232
|
+
name: "PASTED_KEY",
|
|
4233
|
+
field: "Value for PASTED_KEY",
|
|
4234
|
+
text: added,
|
|
4235
|
+
save: "Save PASTED_KEY now"
|
|
4236
|
+
}));
|
|
4237
|
+
expect(adding.errors.length === 0, `${page} reported errors in the browser`, adding.errors.join("\n"));
|
|
4238
|
+
expect(JSON.stringify(adding.answer) === JSON.stringify({
|
|
4239
|
+
field: "textarea",
|
|
4240
|
+
label: "Value for PASTED_KEY",
|
|
4241
|
+
caret: [caret, caret]
|
|
4242
|
+
}), "a PEM key pasted into a new secret's value did not leave a textarea focused, its caret after the paste", adding.answer);
|
|
4243
|
+
const at = [8, 20];
|
|
4244
|
+
const editing = await chrome.load(page, admin.browser.cookies(), void 0, pasteInto({
|
|
4245
|
+
open: "Edit EDITED_KEY",
|
|
4246
|
+
field: "New value for EDITED_KEY",
|
|
4247
|
+
select: [...at],
|
|
4248
|
+
text: edit.replaceAll("\n", "\r\n"),
|
|
4249
|
+
save: "Save EDITED_KEY now"
|
|
4250
|
+
}));
|
|
4251
|
+
expect(editing.errors.length === 0, `${page} reported errors in the browser`, editing.errors.join("\n"));
|
|
4252
|
+
const after = at[0] + edit.length;
|
|
4253
|
+
expect(JSON.stringify(editing.answer) === JSON.stringify({
|
|
4254
|
+
field: "textarea",
|
|
4255
|
+
label: "New value for EDITED_KEY",
|
|
4256
|
+
caret: [after, after]
|
|
4257
|
+
}), "a PEM key pasted into an edited value did not leave a textarea focused, its caret after the paste", editing.answer);
|
|
4258
|
+
const typing = await chrome.load(page, admin.browser.cookies(), void 0, typeLines({
|
|
4259
|
+
name: "TYPED_KEY",
|
|
4260
|
+
field: "Value for TYPED_KEY",
|
|
4261
|
+
first: "abc",
|
|
4262
|
+
second: "def",
|
|
4263
|
+
save: "Save TYPED_KEY now"
|
|
4264
|
+
}));
|
|
4265
|
+
expect(typing.errors.length === 0, `${page} reported errors in the browser`, typing.errors.join("\n"));
|
|
4266
|
+
expect(JSON.stringify(typing.answer) === JSON.stringify({
|
|
4267
|
+
field: "textarea",
|
|
4268
|
+
label: "Value for TYPED_KEY",
|
|
4269
|
+
value: "abc\n",
|
|
4270
|
+
caret: [4, 4]
|
|
4271
|
+
}), "Shift+Enter typed in a new secret's value did not leave a textarea focused holding the line break, its caret after it", typing.answer);
|
|
4272
|
+
} finally {
|
|
4273
|
+
await chrome.close();
|
|
4274
|
+
}
|
|
4275
|
+
const { values } = await admin.api.secrets.reveal(PASTED);
|
|
4276
|
+
expect(values.TYPED_KEY === "abc\ndef", `the typed secret saved ${shape(values.TYPED_KEY)}, not two lines, abc and def`);
|
|
4277
|
+
expect(values.PASTED_KEY === added, `the new secret saved ${shape(values.PASTED_KEY)}, not the ${shape(added)} pasted`);
|
|
4278
|
+
const edited = before.slice(0, 8) + edit + before.slice(20);
|
|
4279
|
+
expect(values.EDITED_KEY === edited, `the edited secret saved ${shape(values.EDITED_KEY)}, not the ${shape(edited)} of its value with the paste in characters 8 to 20`);
|
|
4280
|
+
return `in Chrome, a ${added.split("\n").length - 1}-line PEM key pasted into a new secret's value and into part of an edited one: each field a textarea after, focused, its caret after the paste; the new value saved byte for byte, the edited one with the paste in place and its \r\n as \n; and a value typed with Shift+Enter between two words saved as two lines`;
|
|
4281
|
+
}
|
|
4098
4282
|
/**
|
|
4099
4283
|
* A refused sign-in, said once: the page coffre sends the browser back to
|
|
4100
4284
|
* shows why, rendered by the server, then takes it out of the address, so a
|
|
@@ -4562,6 +4746,7 @@ async function conform(deployment, options) {
|
|
|
4562
4746
|
admin,
|
|
4563
4747
|
canaries
|
|
4564
4748
|
}, ({ admin }) => pagesInBrowser(deployment, admin, options.browser));
|
|
4749
|
+
await report.check("pasted values", { admin }, ({ admin }) => pastedValues(deployment, admin, options.browser));
|
|
4565
4750
|
await report.check("sign-in error, once", { admin }, ({ admin }) => signinErrorOnce(deployment, admin, options.browser));
|
|
4566
4751
|
const people = await report.check("personas", {
|
|
4567
4752
|
admin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/conformance",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
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/
|
|
35
|
-
"@coffre/
|
|
34
|
+
"@coffre/db": "0.6.1",
|
|
35
|
+
"@coffre/cli": "0.6.1"
|
|
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.6.1"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsdown",
|
package/src/checks/access.ts
CHANGED
|
@@ -131,8 +131,9 @@ export async function offboarding(deployment: Deployment, { admin, leaver, servi
|
|
|
131
131
|
/**
|
|
132
132
|
* Instance roles: a Developer scoped to dev reads and writes the dev of a
|
|
133
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
|
-
*
|
|
134
|
+
* grants there and nowhere else, and sets no role, its own or anyone's; an
|
|
135
|
+
* Admin of the whole instance changes no Owner's; and no grant is on every
|
|
136
|
+
* project. The reader is a member again as it
|
|
136
137
|
* ends, its service removed, its project archived.
|
|
137
138
|
*/
|
|
138
139
|
export async function instanceRoles(deployment: Deployment, { admin, reader }: People, canaries: Canaries): Promise<string> {
|
|
@@ -168,9 +169,17 @@ export async function instanceRoles(deployment: Deployment, { admin, reader }: P
|
|
|
168
169
|
await refused('a scoped admin promoted someone', reader.api.members.add(scoped, { role: 'member' }));
|
|
169
170
|
await refused('a scoped admin made a project', reader.api.projects.create(`${PROJECT}-scoped`, { name: 'Scoped' }));
|
|
170
171
|
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
|
+
// Nor does an admin of the whole instance set its own, nor make, change or remove an Owner: only an Owner does.
|
|
172
173
|
await admin.api.members.add(reader.member, { role: 'admin' });
|
|
173
174
|
await refused('an admin made itself an owner', reader.api.members.add(reader.member, { role: 'owner' }));
|
|
175
|
+
for (const [what, call] of [
|
|
176
|
+
['an admin demoted the Owner', () => reader.api.members.add(admin.member, { role: 'admin' })],
|
|
177
|
+
['an admin removed the Owner', () => reader.api.members.remove(admin.member)],
|
|
178
|
+
] as const) {
|
|
179
|
+
// Not that the Owner is the last, which an Owner hears too: that only an Owner may.
|
|
180
|
+
const refusal = await refused(what, call());
|
|
181
|
+
expect(refusal.status === 403 && refusal.reason === 'not_allowed', `${what}, or was refused for another reason`, refusal);
|
|
182
|
+
}
|
|
174
183
|
|
|
175
184
|
// As it was: a member, with its viewer on dev; the service and the project gone.
|
|
176
185
|
await admin.api.members.add(reader.member, { role: 'member' });
|
|
@@ -178,7 +187,7 @@ export async function instanceRoles(deployment: Deployment, { admin, reader }: P
|
|
|
178
187
|
await admin.api.projects.update(later, { archived: true });
|
|
179
188
|
const me = await reader.api.me();
|
|
180
189
|
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';
|
|
190
|
+
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; an admin demotes and removes no Owner; no grant is on every project';
|
|
182
191
|
}
|
|
183
192
|
|
|
184
193
|
/** Reading more values at once than the vault allows in its window is refused. */
|
package/src/checks/canaries.ts
CHANGED
|
@@ -55,7 +55,7 @@ export async function canaryScan(deployment: Deployment, people: People, canarie
|
|
|
55
55
|
|
|
56
56
|
const token = (value: string) => (url: string) => fetch(url, { headers: { authorization: `Bearer ${value}` } });
|
|
57
57
|
const browsers = {
|
|
58
|
-
'the
|
|
58
|
+
'the Owner': people.admin.browser,
|
|
59
59
|
'the reader': people.reader.browser,
|
|
60
60
|
'the bulk reader': people.bulk.browser,
|
|
61
61
|
'the leaver, removed': people.leaver.browser,
|
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 not an admin or owner of all of \S
|
|
149
|
+
expect(/is not an admin or owner of all of \S+: 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)),
|
|
@@ -168,18 +168,21 @@ export async function references(deployment: Deployment, { admin, reader, leaver
|
|
|
168
168
|
const PROD_ONLY = 'CONFORMANCE_PROD_ONLY';
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* nothing. A dismissal is the team's, and
|
|
171
|
+
* Within a project, key names are not secret; values are. What dev is
|
|
172
|
+
* missing is compared with every sibling: the reader, a viewer on dev who
|
|
173
|
+
* cannot read prod, is told prod has the key, as the admin is, and nothing
|
|
174
|
+
* of its value, and dismisses nothing. A dismissal is the team's, and
|
|
175
|
+
* restoring undoes it.
|
|
175
176
|
*/
|
|
176
177
|
export async function missingKeys({ admin, reader }: People): Promise<string> {
|
|
177
|
-
|
|
178
|
+
const value = canary();
|
|
179
|
+
await admin.api.secrets.set(PROD, { [PROD_ONLY]: value });
|
|
178
180
|
try {
|
|
179
181
|
const seen = await admin.api.environments.missing(DEV);
|
|
180
182
|
expect(seen.missing.some((key) => key.key === PROD_ONLY), "the admin was not told dev lacks prod's key", seen);
|
|
181
|
-
const
|
|
182
|
-
expect(
|
|
183
|
+
const told = await reader.api.environments.missing(DEV);
|
|
184
|
+
expect(told.missing.some((key) => key.key === PROD_ONLY && key.in.includes('prod')), "a viewer on dev was not told dev lacks prod's key, by name", told);
|
|
185
|
+
expect(!JSON.stringify(told).includes(value), "a viewer on dev was told prod's value with its key's name");
|
|
183
186
|
await refused('a viewer dismissed a missing key', reader.api.environments.dismiss(DEV, { [PROD_ONLY]: true }));
|
|
184
187
|
await admin.api.environments.dismiss(DEV, { [PROD_ONLY]: true });
|
|
185
188
|
const dismissed = await admin.api.environments.missing(DEV);
|
|
@@ -189,5 +192,5 @@ export async function missingKeys({ admin, reader }: People): Promise<string> {
|
|
|
189
192
|
} finally {
|
|
190
193
|
await admin.api.secrets.update(`${PROD}/${PROD_ONLY}`, { archived: true });
|
|
191
194
|
}
|
|
192
|
-
return "
|
|
195
|
+
return "a viewer on dev learns prod's key name, not its value, and dismisses nothing; a dismissal is listed, and restored";
|
|
193
196
|
}
|