@coffre/ui 0.14.7 → 0.16.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/audit-sentences.d.ts +56 -0
- package/dist/audit-sentences.js +886 -0
- package/dist/audit-sentences.js.map +1 -0
- package/dist/chunks/audit-sentence-C8NnAdjF.js +48 -0
- package/dist/chunks/audit-sentence-C8NnAdjF.js.map +1 -0
- package/dist/chunks/{connected-apps-IJdunsu8.js → connected-apps-6sMSgQ9U.js} +5 -5
- package/dist/chunks/{connected-apps-IJdunsu8.js.map → connected-apps-6sMSgQ9U.js.map} +1 -1
- package/dist/chunks/{delete-place-dIVoK87I.js → delete-place-T469tSN9.js} +5 -5
- package/dist/chunks/{delete-place-dIVoK87I.js.map → delete-place-T469tSN9.js.map} +1 -1
- package/dist/chunks/{directory-BM8yoiJN.js → directory-B_gVf7UL.js} +13 -12
- package/dist/chunks/{directory-BM8yoiJN.js.map → directory-B_gVf7UL.js.map} +1 -1
- package/dist/chunks/{folders-D3A1NGpt.js → folders-CVYauIDz.js} +3 -3
- package/dist/chunks/{folders-D3A1NGpt.js.map → folders-CVYauIDz.js.map} +1 -1
- package/dist/chunks/{grants-CjVmOgb2.js → grants-Dn_EW2XW.js} +6 -6
- package/dist/chunks/{grants-CjVmOgb2.js.map → grants-Dn_EW2XW.js.map} +1 -1
- package/dist/chunks/{multi-combobox-B0JzP1QN.js → multi-combobox-fbBRzi9z.js} +3 -3
- package/dist/chunks/{multi-combobox-B0JzP1QN.js.map → multi-combobox-fbBRzi9z.js.map} +1 -1
- package/dist/chunks/{offboarding-DbozhPym.js → offboarding-CXM464J_.js} +19 -13
- package/dist/chunks/offboarding-CXM464J_.js.map +1 -0
- package/dist/chunks/{page-JTORvh-N.js → page-Cb0ZjGda.js} +2 -2
- package/dist/chunks/{page-JTORvh-N.js.map → page-Cb0ZjGda.js.map} +1 -1
- package/dist/chunks/{personal-tokens-zWZOzLIC.js → personal-tokens-CSHMlRHy.js} +7 -7
- package/dist/chunks/personal-tokens-CSHMlRHy.js.map +1 -0
- package/dist/chunks/{principal-DFBswTBr.js → principal-BKJxbAtE.js} +2 -2
- package/dist/chunks/{principal-DFBswTBr.js.map → principal-BKJxbAtE.js.map} +1 -1
- package/dist/chunks/{principal-page-jJ0RVFg8.js → principal-page-COPmTDVW.js} +20 -17
- package/dist/chunks/principal-page-COPmTDVW.js.map +1 -0
- package/dist/chunks/{project-page-BjwEoXfU.js → project-page-g5_n46Nz.js} +3 -3
- package/dist/chunks/{project-page-BjwEoXfU.js.map → project-page-g5_n46Nz.js.map} +1 -1
- package/dist/chunks/{protected-y7KVhtHd.js → protected-DEWeOrmI.js} +7 -7
- package/dist/chunks/{protected-y7KVhtHd.js.map → protected-DEWeOrmI.js.map} +1 -1
- package/dist/chunks/{queries-2jdgTwfZ.js → queries-D4_o-bz3.js} +11 -88
- package/dist/chunks/queries-D4_o-bz3.js.map +1 -0
- package/dist/chunks/{references-CRT2BsOS.js → references-wTh_DT0M.js} +27 -23
- package/dist/chunks/references-wTh_DT0M.js.map +1 -0
- package/dist/chunks/{role-field-DswIpPqY.js → role-field-BiP09qfN.js} +4 -4
- package/dist/chunks/{role-field-DswIpPqY.js.map → role-field-BiP09qfN.js.map} +1 -1
- package/dist/chunks/{row-state-xtRGFnDc.js → row-state-CYhtmUkc.js} +3 -3
- package/dist/chunks/{row-state-xtRGFnDc.js.map → row-state-CYhtmUkc.js.map} +1 -1
- package/dist/chunks/{signin-errors-TlQmQe0t.js → signin-errors-BMnox7XD.js} +5 -19
- package/dist/chunks/signin-errors-BMnox7XD.js.map +1 -0
- package/dist/chunks/{theme-Ck45wzWB.js → theme-imSolE1q.js} +3 -3
- package/dist/chunks/{theme-Ck45wzWB.js.map → theme-imSolE1q.js.map} +1 -1
- package/dist/chunks/{ui-D-blFWfx.js → ui-Q_Eczt7m.js} +7 -3
- package/dist/chunks/{ui-D-blFWfx.js.map → ui-Q_Eczt7m.js.map} +1 -1
- package/dist/chunks/{use-action-CXEFFjx5.js → use-action-BfnN-De2.js} +3 -3
- package/dist/chunks/{use-action-CXEFFjx5.js.map → use-action-BfnN-De2.js.map} +1 -1
- package/dist/chunks/{use-change-BC4xo02c.js → use-change-Cc0X4sF3.js} +6 -4
- package/dist/chunks/use-change-Cc0X4sF3.js.map +1 -0
- package/dist/chunks/{use-roles-DswiNxBk.js → use-roles-stcv2QFj.js} +3 -3
- package/dist/chunks/{use-roles-DswiNxBk.js.map → use-roles-stcv2QFj.js.map} +1 -1
- package/dist/chunks/{use-shell-zpjE_MKh.js → use-shell-DMhLa2sh.js} +3 -3
- package/dist/chunks/{use-shell-zpjE_MKh.js.map → use-shell-DMhLa2sh.js.map} +1 -1
- package/dist/index.d.ts +22 -10
- package/dist/index.js +7 -7
- package/dist/pages/account.js +11 -11
- package/dist/pages/approval.js +2 -2
- package/dist/pages/audit.js +163 -152
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +2 -2
- package/dist/pages/environment.js +67 -35
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +6 -15
- package/dist/pages/login.js.map +1 -1
- package/dist/pages/oauth-authorize.js +2 -2
- package/dist/pages/project-access.js +11 -11
- package/dist/pages/project-environments.js +12 -12
- package/dist/pages/project-settings.js +8 -8
- package/dist/pages/project.js +3 -3
- package/dist/pages/projects.js +8 -8
- package/dist/pages/service-account.js +19 -15
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +5 -5
- package/dist/pages/settings.js +26 -37
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +2 -2
- package/dist/pages/user.js +7 -7
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +5 -5
- package/package.json +8 -3
- package/src/components/directory.tsx +5 -4
- package/src/components/offboarding.tsx +9 -9
- package/src/components/personal-tokens.tsx +5 -2
- package/src/components/principal-page.tsx +4 -3
- package/src/components/references.tsx +18 -7
- package/src/components/trusted-workloads.tsx +6 -5
- package/src/components/ui.tsx +5 -0
- package/src/lib/audit-proofs.ts +51 -0
- package/src/lib/audit-sentences.ts +473 -509
- package/src/lib/bindings.ts +6 -0
- package/src/lib/changes.ts +3 -1
- package/src/lib/coffre.ts +2 -2
- package/src/lib/queries.ts +9 -94
- package/src/lib/reveal.ts +32 -5
- package/src/lib/row-reads.ts +2 -2
- package/src/lib/signin-errors.ts +5 -33
- package/src/pages/audit.tsx +145 -182
- package/src/pages/environment.tsx +21 -20
- package/src/pages/login.tsx +2 -4
- package/src/pages/settings.tsx +6 -10
- package/src/pages/user.tsx +2 -2
- package/src/parity.ts +0 -2
- package/src/styles/globals.css +18 -2
- package/dist/chunks/audit-sentence-JgJEwQEC.js +0 -969
- package/dist/chunks/audit-sentence-JgJEwQEC.js.map +0 -1
- package/dist/chunks/offboarding-DbozhPym.js.map +0 -1
- package/dist/chunks/personal-tokens-zWZOzLIC.js.map +0 -1
- package/dist/chunks/principal-page-jJ0RVFg8.js.map +0 -1
- package/dist/chunks/queries-2jdgTwfZ.js.map +0 -1
- package/dist/chunks/references-CRT2BsOS.js.map +0 -1
- package/dist/chunks/signin-errors-TlQmQe0t.js.map +0 -1
- package/dist/chunks/use-change-BC4xo02c.js.map +0 -1
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* and places in it links. `plain` flattens it, for tests and titles.
|
|
9
9
|
*/
|
|
10
10
|
import { shownMember, type AuditEntryView } from '@coffre/client';
|
|
11
|
-
import { INSTANCE_ROLES, isBuiltinRole, isInstanceRole, isScope, ROLES, scopeInWords, type Scope } from '@coffre/core/access';
|
|
11
|
+
import { INSTANCE_ROLES, isBuiltinRole, isInstanceRole, isScope, normalDefinition, ROLES, scopeInWords, type Scope } from '@coffre/core/access';
|
|
12
|
+
import type { LogAction } from '@coffre/core/vault';
|
|
12
13
|
|
|
13
14
|
/** What a sentence is made from: an entry of the log, as `GET /api/audit` gives it. */
|
|
14
15
|
export type AuditEntry = Pick<
|
|
@@ -40,604 +41,505 @@ export type Part = string | { place: string } | { member: string };
|
|
|
40
41
|
|
|
41
42
|
export type Sentence = { parts: Part[]; refused: boolean };
|
|
42
43
|
|
|
43
|
-
/** What one template needs: the line's leading entry, its batch
|
|
44
|
+
/** What one template needs: the line's leading entry, and its batch. */
|
|
44
45
|
type Facts = {
|
|
45
46
|
entry: AuditEntry;
|
|
46
47
|
/** Every entry of the batch, the lead included, a read of several once per secret (`perSecret`). */
|
|
47
48
|
batch: AuditEntry[];
|
|
48
49
|
/** Secrets the batch was about. */
|
|
49
50
|
count: number;
|
|
50
|
-
refused: boolean;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
/** An allowed entry's sentence; a refused one has none (`refusal`). */
|
|
53
54
|
type Template = {
|
|
54
55
|
/** What they did: "revealed". */
|
|
55
56
|
did: string | ((facts: Facts) => string);
|
|
56
|
-
/** What they tried, after "tried to": "reveal". */
|
|
57
|
-
tried: string | ((facts: Facts) => string);
|
|
58
57
|
/** To what: "market/prod/API_KEY". */
|
|
59
58
|
what: (facts: Facts) => Part[];
|
|
60
59
|
/** Said only of what happened: ", now version 5". */
|
|
61
60
|
then?: (facts: Facts) => Part[];
|
|
61
|
+
/** Asked, and nothing changed: said after it, ", unchanged", as `unchanged: true` in its detail is. */
|
|
62
|
+
unchanged?: (facts: Facts) => boolean;
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
// --- the pieces of a sentence ---------------------------------------------------
|
|
65
66
|
|
|
66
67
|
const text = (value: unknown): string | null => (typeof value === 'string' && value !== '' ? value : null);
|
|
67
68
|
const number = (value: unknown): number | null => (typeof value === 'number' ? value : null);
|
|
69
|
+
const list = (value: unknown): string[] => (Array.isArray(value) ? value.filter((item): item is string => text(item) !== null) : []);
|
|
68
70
|
|
|
69
|
-
/**
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
return path.length === 0 ? ['coffre'] : [{ place: path.join('/') }];
|
|
71
|
+
/** An object of the detail's, or an empty one for anything else. */
|
|
72
|
+
function record(value: unknown): Record<string, unknown> {
|
|
73
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? (value as Record<string, unknown>) : {};
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
/** The entry's place, as deep as it goes. */
|
|
77
|
+
function place(entry: Pick<AuditEntry, 'project' | 'environment' | 'key'>): Part[] {
|
|
78
|
+
const path = [entry.project, entry.environment, entry.key].filter((part): part is string => part !== null);
|
|
79
|
+
return path.length === 0 ? ['coffre'] : [{ place: path.join('/') }];
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (entry.subject !== null) return [{ member: entry.subject }];
|
|
82
|
-
const id = text(entry.metadata.principalId);
|
|
83
|
-
if (id === null) return ['someone'];
|
|
84
|
-
return [{ member: `${entry.metadata.principalType === 'service' ? 'token' : 'user'}:${id}` }];
|
|
82
|
+
function environmentOf(entry: AuditEntry): Part[] {
|
|
83
|
+
return place({ ...entry, key: null });
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
/**
|
|
88
|
-
function
|
|
89
|
-
|
|
86
|
+
/** A personal config's entry by the environment it is a config of, `market/dev`: its own slug is generated, and shown nowhere else. */
|
|
87
|
+
function asPersonal(entry: AuditEntry): [AuditEntry, Part[]] {
|
|
88
|
+
const of = text(entry.metadata.personal);
|
|
89
|
+
return of === null || entry.project === null ? [entry, []] : [{ ...entry, environment: of }, [', in their personal config']];
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
/**
|
|
93
|
-
function
|
|
94
|
-
const
|
|
95
|
-
return
|
|
92
|
+
/** The member an entry is about: its subject, or the member or principal its detail names. */
|
|
93
|
+
function subject(entry: AuditEntry): Part[] {
|
|
94
|
+
const member = entry.subject ?? text(entry.metadata.member) ?? text(entry.metadata.principal);
|
|
95
|
+
return member === null ? ['someone'] : [{ member }];
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
/**
|
|
99
|
-
function
|
|
100
|
-
|
|
98
|
+
/** An entry about its actor's own credential: the principal it names is who acted. */
|
|
99
|
+
function own(entry: AuditEntry): boolean {
|
|
100
|
+
const actor = who(entry);
|
|
101
|
+
return typeof actor !== 'string' && text(entry.metadata.principal) === actor.member;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
/** An MCP client, by the
|
|
104
|
+
/** An MCP client, by the host its metadata document is at; one registered by its own request names none in the entry. */
|
|
104
105
|
function app(entry: AuditEntry): Part[] {
|
|
105
|
-
return [text(entry.metadata.
|
|
106
|
+
return [text(entry.metadata.host) ?? 'an MCP client'];
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
/** A tool's call: its name, and what it named. */
|
|
109
110
|
function tool(entry: AuditEntry): Part[] {
|
|
110
|
-
const names =
|
|
111
|
+
const names = list(entry.metadata.names);
|
|
111
112
|
return [text(entry.metadata.tool) ?? 'a tool', ...(names.length === 0 ? [] : [` on ${names.join(', ')}`])];
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
/**
|
|
115
|
-
function via(entry: AuditEntry): Part[] {
|
|
116
|
-
const client = (entry.metadata.via as { clientName?: unknown } | undefined)?.clientName;
|
|
117
|
-
return typeof client === 'string' ? [` via ${client}`] : [];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** Why coffre itself ended a connection, said after it. */
|
|
115
|
+
/** Why the vault itself ended a connection, said after it. */
|
|
121
116
|
const DISCONNECTED: Record<string, string> = {
|
|
122
117
|
code_reused: ': its sign-in code was used twice',
|
|
123
118
|
refresh_reused: ': a refresh token it had replaced was used again',
|
|
124
|
-
revocation_endpoint: ', at its own request',
|
|
125
|
-
superseded: ': a connection with more scopes replaced it',
|
|
126
119
|
};
|
|
127
120
|
|
|
128
121
|
function plural(count: number, one: string, many = `${one}s`): string {
|
|
129
122
|
return `${count} ${count === 1 ? one : many}`;
|
|
130
123
|
}
|
|
131
124
|
|
|
132
|
-
/** A batch reads as its environment and a count; one entry as its secret. */
|
|
133
125
|
/**
|
|
134
|
-
* The secrets a read or write was about
|
|
135
|
-
* read
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
126
|
+
* The secrets a read or write was about: one entry as its secret, a batch as
|
|
127
|
+
* its environment and a count. The vault logs a read where it was asked, so
|
|
128
|
+
* a read through a reference is the reference's, "billing/prod/DATABASE_URL
|
|
129
|
+
* through a reference"; its own part of the entry names the source by id
|
|
130
|
+
* alone (`through`), which the page cannot say as a path.
|
|
139
131
|
*/
|
|
140
132
|
function secrets(facts: Facts): Part[] {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const project = through(entry)?.split('/')[0] ?? entry.project;
|
|
146
|
-
return slug === null || project === null ? null : `${project}/${slug}`;
|
|
147
|
-
};
|
|
148
|
-
if (facts.batch.length === 1) {
|
|
149
|
-
const [held, fork] = [through(facts.entry), forkOf(facts.entry)];
|
|
150
|
-
return [...place(facts.entry), ...(held === null ? [] : [' through ', { place: held }]), ...(fork === null ? [] : [' in ', { place: fork }])];
|
|
151
|
-
}
|
|
152
|
-
const fork = facts.batch.map(forkOf).find((path) => path !== null);
|
|
153
|
-
const own = facts.batch.find((entry) => through(entry) === null && forkOf(entry) === null);
|
|
154
|
-
const held = facts.batch.map(through).filter((path): path is string => path !== null);
|
|
155
|
-
const inherited = facts.batch.filter((entry) => forkOf(entry) !== null).length;
|
|
156
|
-
const where = fork !== undefined && fork !== null
|
|
157
|
-
? [{ place: fork }]
|
|
158
|
-
: own !== undefined ? environmentOf(own) : [{ place: held[0]!.split('/').slice(0, 2).join('/') }];
|
|
133
|
+
const [entry, mine] = asPersonal(facts.entry);
|
|
134
|
+
const referred = (entry: AuditEntry) => text(entry.metadata.through) !== null;
|
|
135
|
+
if (facts.batch.length === 1) return [...place(entry), ...(referred(entry) ? [' through a reference'] : []), ...mine];
|
|
136
|
+
const held = facts.batch.filter(referred).length;
|
|
159
137
|
return [
|
|
160
|
-
...
|
|
161
|
-
|
|
138
|
+
...environmentOf(entry),
|
|
139
|
+
': ',
|
|
162
140
|
plural(facts.count, 'secret'),
|
|
163
|
-
...(held
|
|
164
|
-
...
|
|
141
|
+
...(held === 0 ? [] : [`, ${held} through ${held === 1 ? 'a reference' : 'references'}`]),
|
|
142
|
+
...mine,
|
|
165
143
|
];
|
|
166
144
|
}
|
|
167
145
|
|
|
168
|
-
/** "market/prod
|
|
169
|
-
function
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
|
|
146
|
+
/** "OLD in market/prod", "OLD and STALE in market/prod", or "5 keys in market/prod". */
|
|
147
|
+
function keysIn(entry: AuditEntry, keys: string[]): Part[] {
|
|
148
|
+
const [here, mine] = asPersonal(entry);
|
|
149
|
+
if (keys.length === 0) return [...environmentOf(here), ...mine];
|
|
150
|
+
const named = keys.length > 3 ? plural(keys.length, 'key') : keys.length === 1 ? keys[0]! : `${keys.slice(0, -1).join(', ')} and ${keys.at(-1)!}`;
|
|
151
|
+
return [named, ' in ', ...environmentOf(here), ...mine];
|
|
173
152
|
}
|
|
174
153
|
|
|
175
|
-
/**
|
|
176
|
-
|
|
177
|
-
const key = text(facts.entry.metadata.key);
|
|
178
|
-
return [facts.batch.length === 1 && key !== null ? key : plural(facts.count, 'key'), ' in ', ...environmentOf(facts.entry)];
|
|
179
|
-
}
|
|
154
|
+
/** A folder renamed onto its own name: nothing moved. */
|
|
155
|
+
const sameFolder = ({ entry }: Facts) => entry.metadata.folder === entry.metadata.to;
|
|
180
156
|
|
|
181
|
-
/** "
|
|
182
|
-
function
|
|
183
|
-
|
|
184
|
-
const key = text(entry.metadata.key);
|
|
185
|
-
const source = text(entry.metadata.source) ?? text((entry.metadata.source as { path?: unknown } | undefined)?.path);
|
|
186
|
-
return [
|
|
187
|
-
...(holder !== null ? [{ place: holder }] : key !== null ? place(entry) : environmentOf(entry)),
|
|
188
|
-
...(source === null ? [] : [' a reference to ', { place: source }]),
|
|
189
|
-
];
|
|
157
|
+
/** " to the folder stripe", or " out of its folder". */
|
|
158
|
+
function intoFolder(folder: unknown): Part[] {
|
|
159
|
+
return [text(folder) === null ? ' out of its folder' : ` to the folder ${text(folder)}`];
|
|
190
160
|
}
|
|
191
161
|
|
|
192
|
-
const READ_VERBS: Record<string,
|
|
193
|
-
reveal:
|
|
194
|
-
run:
|
|
195
|
-
compare:
|
|
196
|
-
copy:
|
|
162
|
+
const READ_VERBS: Record<string, string> = {
|
|
163
|
+
reveal: 'revealed',
|
|
164
|
+
run: 'ran',
|
|
165
|
+
compare: 'compared',
|
|
166
|
+
copy: 'copied',
|
|
197
167
|
// The credential proxy's: a value injected into a request for its person, or one handed to their app.
|
|
198
|
-
use:
|
|
199
|
-
expose:
|
|
168
|
+
use: 'used',
|
|
169
|
+
expose: 'was given',
|
|
200
170
|
};
|
|
201
171
|
|
|
202
|
-
|
|
203
|
-
|
|
172
|
+
/**
|
|
173
|
+
* What a write did to one key, from its line of the entry (`keys`): made it
|
|
174
|
+
* a reference, restored a version, wrote a value (a new key's, or one over
|
|
175
|
+
* a reference's), set it aside for what a parent passes down or took it
|
|
176
|
+
* back, archived it or brought it back, or filed it in a folder.
|
|
177
|
+
*/
|
|
178
|
+
type Written = 'reference' | 'restore' | 'add' | 'own' | 'mark' | 'change' | 'reset' | 'archive' | 'unarchive' | 'move';
|
|
179
|
+
|
|
180
|
+
function written({ metadata: line }: AuditEntry): Written {
|
|
181
|
+
if (text(line.refers) !== null) return 'reference';
|
|
182
|
+
if (number(line.restored) !== null) return 'restore';
|
|
183
|
+
// A nature marked in place: `was` the nature it had, `kept` the version whose value it is.
|
|
184
|
+
if (text(line.was) !== null && number(line.kept) !== null) return 'mark';
|
|
185
|
+
if (number(line.version) !== null) return line.made === true ? 'add' : text(line.source) !== null ? 'own' : 'change';
|
|
186
|
+
if (line.reset === true) return 'reset';
|
|
187
|
+
if (typeof line.archived === 'boolean') return line.archived ? 'archive' : 'unarchive';
|
|
188
|
+
return 'folder' in line ? 'move' : 'change';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const WRITTEN: Record<Written, string> = {
|
|
192
|
+
reference: 'made',
|
|
193
|
+
restore: 'restored',
|
|
194
|
+
add: 'added',
|
|
195
|
+
own: 'gave a value of its own to',
|
|
196
|
+
mark: 'marked',
|
|
197
|
+
change: 'changed',
|
|
198
|
+
reset: 'reset',
|
|
199
|
+
archive: 'archived',
|
|
200
|
+
unarchive: 'brought back',
|
|
201
|
+
move: 'moved',
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/** Who sees a value written: said where it is not a secret's. */
|
|
205
|
+
function nature(entry: AuditEntry): Part[] {
|
|
206
|
+
return entry.metadata.nature === 'plain' ? [', as a plain value, no secret'] : entry.metadata.nature === 'sensitive' ? [', as a sensitive value, shown to nobody'] : [];
|
|
204
207
|
}
|
|
205
208
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
/** A project's or an environment's, as `place` names it: a personal config by what it is a config of. */
|
|
210
|
+
function placeWhat(kind: 'project' | 'environment') {
|
|
211
|
+
return ({ entry }: Facts): Part[] => {
|
|
212
|
+
if (kind === 'project') return ['project ', ...place({ ...entry, environment: null, key: null })];
|
|
213
|
+
const of = text(entry.metadata.personal);
|
|
214
|
+
if (of !== null && entry.project !== null) return ['a personal config of ', { place: `${entry.project}/${of}` }];
|
|
215
|
+
if (entry.metadata.personal === true) return [`a personal config, ${text(entry.metadata.path) ?? ''}`];
|
|
216
|
+
return ['environment ', ...environmentOf(entry)];
|
|
211
217
|
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** A re-slugging, said as one where the slug changed. */
|
|
221
|
+
function updated(kind: 'project' | 'environment'): Template {
|
|
222
|
+
const renamed = ({ metadata }: AuditEntry) => text(metadata.from) !== null && metadata.from !== metadata.slug;
|
|
223
|
+
return {
|
|
224
|
+
did: ({ entry }) => (renamed(entry) ? 'renamed' : 'changed'),
|
|
225
|
+
what: placeWhat(kind),
|
|
226
|
+
then: ({ entry }) => (renamed(entry) ? [`, was ${text(entry.metadata.from)}`] : []),
|
|
217
227
|
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Archived, restored or deleted: a deleted one is named by its tombstone from then on, `market~deleted-2026-10-05`, as every entry about it is. */
|
|
231
|
+
const plainly = (kind: 'project' | 'environment', did: string): Template => ({ did, what: placeWhat(kind) });
|
|
232
|
+
|
|
233
|
+
/** An environment made: a fork names the one it inherits from, a copy the one it copied. */
|
|
234
|
+
function created(kind: 'project' | 'environment'): Template {
|
|
218
235
|
return {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
then: ({ entry }) =>
|
|
225
|
-
text(entry.metadata.inherits) !== null
|
|
226
|
-
? [`, inheriting from ${text(entry.metadata.inherits)}`]
|
|
227
|
-
: text(entry.metadata.from) === null
|
|
228
|
-
? []
|
|
229
|
-
: [`, a fork of ${text(entry.metadata.from)}`],
|
|
230
|
-
},
|
|
231
|
-
[`${kind}.update`]: { did: 'changed', tried: 'change', what },
|
|
232
|
-
[`${kind}.archive`]: { did: 'archived', tried: 'archive', what },
|
|
233
|
-
[`${kind}.restore`]: { did: 'restored', tried: 'restore', what },
|
|
234
|
-
// Named by its tombstone from then on, `market~deleted-2026-10-05`, as every entry about it is.
|
|
235
|
-
[`${kind}.delete`]: { did: 'deleted', tried: 'delete', what },
|
|
236
|
+
...plainly(kind, 'created'),
|
|
237
|
+
then: ({ entry }) =>
|
|
238
|
+
text(entry.metadata.inherits) !== null
|
|
239
|
+
? [`, inheriting from ${text(entry.metadata.inherits)}`]
|
|
240
|
+
: text(entry.metadata.from) === null ? [] : [`, a copy of ${text(entry.metadata.from)}`],
|
|
236
241
|
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** A grant's lines (`changes`), the first said, the others counted. */
|
|
245
|
+
const changesOf = ({ metadata }: AuditEntry) => (Array.isArray(metadata.changes) ? metadata.changes.map(record) : []);
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* A grant's sentence, and a revocation's, from what changed: the action is the
|
|
249
|
+
* request's (a grant if it gives any role), and its lines only what changed, a
|
|
250
|
+
* role given (`role`) or taken (`role: null`), each at its own place, which the
|
|
251
|
+
* server names the entry for (`viewOf`).
|
|
252
|
+
*/
|
|
253
|
+
const accessSentence: Template = {
|
|
254
|
+
did: ({ entry }) => {
|
|
255
|
+
const [first] = changesOf(entry);
|
|
256
|
+
return first === undefined ? 'set' : first.role === null ? 'took' : 'gave';
|
|
257
|
+
},
|
|
258
|
+
what: ({ entry }) => {
|
|
259
|
+
const [first] = changesOf(entry);
|
|
260
|
+
if (first === undefined) return ['the access of ', ...subject(entry), ' on ', ...environmentOf(entry)];
|
|
261
|
+
if (first.role !== null) return [...subject(entry), ` ${text(first.role) ?? 'a role'} on `, ...environmentOf(entry)];
|
|
262
|
+
const role = text(first.was);
|
|
263
|
+
return [...(role === null ? ['access to '] : [`${role} on `]), ...environmentOf(entry), ' from ', ...subject(entry)];
|
|
264
|
+
},
|
|
265
|
+
then: ({ entry }) => {
|
|
266
|
+
const [first] = changesOf(entry);
|
|
267
|
+
if (first === undefined) return [];
|
|
268
|
+
return [
|
|
269
|
+
...(first.role === null ? [] : [
|
|
270
|
+
...(text(first.was) === null ? [] : [`, was ${text(first.was)}`]),
|
|
271
|
+
...(text(first.expiresAt) === null ? [] : [`, until ${text(first.expiresAt)!.slice(0, 10)}`]),
|
|
272
|
+
]),
|
|
273
|
+
...others(entry),
|
|
274
|
+
// Admitted with it, which 0.14.7 logged apart.
|
|
275
|
+
...(entry.metadata.admitted === 'member.add' ? [', added to coffre with it'] : entry.metadata.admitted === 'member.restore' ? [', brought back with it'] : []),
|
|
276
|
+
];
|
|
277
|
+
},
|
|
278
|
+
unchanged: ({ entry }) => changesOf(entry).length === 0,
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
/** The changes after a grant's first: "on 2 other places" where each gave or took what the first did; else "2 other changes". */
|
|
282
|
+
function others(entry: AuditEntry): Part[] {
|
|
283
|
+
const [first, ...rest] = changesOf(entry);
|
|
284
|
+
if (first === undefined || rest.length === 0) return [];
|
|
285
|
+
const same = rest.every((line) => (['role', 'was', 'expiresAt'] as const).every((field) => text(line[field]) === text(first[field])));
|
|
286
|
+
return [same ? `, and on ${plural(rest.length, 'other place')}` : `, and ${plural(rest.length, 'other change')}`];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** Who a revoked credential was: a token, or a session or handle ended. */
|
|
290
|
+
const REVOKED: Record<string, string> = {
|
|
291
|
+
personal: 'revoked a personal token of',
|
|
292
|
+
service: 'revoked a bearer token of',
|
|
293
|
+
handle: 'ended a handle of',
|
|
294
|
+
cli: 'ended a CLI session of',
|
|
295
|
+
browser: 'ended a browser session of',
|
|
296
|
+
mcp: 'disconnected an MCP app of',
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
/** A CLI sign-in's label, as its CLI named it: `, “laptop”`. */
|
|
300
|
+
const labelled = ({ entry }: Facts): Part[] => (text(entry.metadata.label) === null ? [] : [`, “${text(entry.metadata.label)}”`]);
|
|
301
|
+
|
|
302
|
+
/** A trust binding's keys replaced, rather than a binding made. */
|
|
303
|
+
const rekeyed = ({ entry }: Facts) => entry.metadata.reason === 'keys_replaced';
|
|
304
|
+
|
|
305
|
+
/** The profiles whose tokens are CI runs'; every other binding trusts a workload. */
|
|
306
|
+
const CI_PROFILES = ['github', 'github-reusable', 'github-reusable-organization', 'gitlab'];
|
|
307
|
+
|
|
308
|
+
/** Whom a binding trusts, by its profile: CI runs, a platform's workloads, or a custom issuer's tokens. */
|
|
309
|
+
function trusted({ metadata }: AuditEntry): string {
|
|
310
|
+
const profile = text(metadata.profile) ?? 'custom';
|
|
311
|
+
if (CI_PROFILES.includes(profile)) return 'CI runs';
|
|
312
|
+
return profile === 'custom' ? `tokens from ${text(metadata.issuer) ?? 'an issuer'}` : `${profile} workloads`;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** What a freeze is on: the whole instance, a service account's workloads, a binding's or a session. */
|
|
316
|
+
function frozen({ entry }: Facts): Part[] {
|
|
317
|
+
const target = text(entry.metadata.target);
|
|
318
|
+
if (target === null) return ['workloads'];
|
|
319
|
+
if (target === 'instance') return ['every workload'];
|
|
320
|
+
if (target.startsWith('token:')) return ['the workloads of ', { member: target }];
|
|
321
|
+
return [target.startsWith('binding:') ? 'the workloads of a trust binding of ' : 'a workload session of ', ...subject(entry)];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** A write that wrote no key: asked of keys as they were already (a nature they had, archived already, filed where they are). The entry records none of what was asked. */
|
|
325
|
+
const empty = ({ metadata }: AuditEntry) => Array.isArray(metadata.keys) && metadata.keys.length === 0;
|
|
326
|
+
|
|
327
|
+
/** A write's sentence, and a loosening's: one key as what was done to it; a batch as what was done to every key, or as written. */
|
|
328
|
+
const writeSentence: Template = {
|
|
329
|
+
did: ({ entry, batch }) => {
|
|
330
|
+
if (empty(entry)) return 'wrote to';
|
|
331
|
+
const kinds = new Set(batch.map(written));
|
|
332
|
+
if (batch.length === 1 || (kinds.size === 1 && !kinds.has('reference') && !kinds.has('own'))) return WRITTEN[written(entry)];
|
|
333
|
+
return [...kinds].every((kind) => kind === 'add' || kind === 'change') ? 'wrote' : 'changed';
|
|
334
|
+
},
|
|
335
|
+
what: (facts) => (empty(facts.entry) ? keysIn(facts.entry, []) : [...secrets(facts), ...(facts.batch.length === 1 && written(facts.entry) === 'reference' ? [' a reference'] : [])]),
|
|
336
|
+
then: ({ entry, batch }) => {
|
|
337
|
+
if (empty(entry)) return [];
|
|
338
|
+
const kind = written(entry);
|
|
339
|
+
const folder = entry.metadata.folder;
|
|
340
|
+
// A folder said of the batch only where every key moved to it.
|
|
341
|
+
if (kind === 'move' && batch.every((other) => written(other) === 'move' && other.metadata.folder === folder)) return intoFolder(folder);
|
|
342
|
+
if (batch.length > 1) return [];
|
|
343
|
+
if (kind === 'restore') return [` to version ${number(entry.metadata.restored)}`, ...(entry.version === null ? [] : [`, now ${entry.version}`])];
|
|
344
|
+
if (kind === 'mark') return [` ${text(entry.metadata.nature) ?? ''}, from ${text(entry.metadata.was) ?? ''}, its value kept`];
|
|
345
|
+
return kind === 'add' || kind === 'change' || kind === 'own' ? [...((entry.version ?? 1) === 1 ? [] : [`, now version ${entry.version}`]), ...nature(entry)] : [];
|
|
346
|
+
},
|
|
347
|
+
unchanged: ({ entry }) => empty(entry),
|
|
237
348
|
};
|
|
238
349
|
|
|
239
350
|
// --- one template per action ----------------------------------------------------
|
|
240
351
|
|
|
241
|
-
const TEMPLATES: Record<
|
|
242
|
-
'secret.read': {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
'secret.write': {
|
|
248
|
-
// New secrets are added, others changed; a batch of both is written. One whose level changed is made that.
|
|
249
|
-
did: ({ entry, batch }) => {
|
|
250
|
-
if (batch.length === 1 && text(entry.metadata.was) !== null) return 'made';
|
|
251
|
-
const firsts = batch.filter((entry) => entry.version === 1).length;
|
|
252
|
-
return firsts === batch.length ? 'added' : firsts === 0 ? 'changed' : 'wrote';
|
|
253
|
-
},
|
|
254
|
-
tried: 'change',
|
|
255
|
-
what: secrets,
|
|
256
|
-
// Who sees the value, where it is not a secret's or it changed: a mark keeps the value, a write gives a new one.
|
|
257
|
-
then: ({ entry, batch }) => {
|
|
258
|
-
const version = batch.length > 1 || entry.version === null || entry.version === 1 ? [] : [`, now version ${entry.version}`];
|
|
259
|
-
if (batch.length > 1) return version;
|
|
260
|
-
const level = entry.metadata.sensitive === true ? 'sensitive' : entry.metadata.plain === true ? 'plain' : 'secret';
|
|
261
|
-
if (text(entry.metadata.was) !== null) return [` ${level}`, ...(number(entry.metadata.kept) === null ? [' with a new value'] : []), ...version];
|
|
262
|
-
return [...version, ...(level === 'plain' ? [', as a plain value, no secret'] : level === 'sensitive' ? [', as a sensitive value, shown to nobody'] : [])];
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
// The credential proxy's record beside the vault's read, the vault's own since 0.14.5: which credential the keys went into, where, and by which road.
|
|
266
|
-
// Like the read, it records the release: a `credential_ended` refusal of the same operation after it says the value was withheld,
|
|
267
|
-
// as a 409 for a policy changed meanwhile withholds it too, logging nothing more.
|
|
268
|
-
'credential.use': {
|
|
269
|
-
did: ({ entry }) => (entry.metadata.purpose === 'expose' ? 'was given the values of' : 'used the credential'),
|
|
270
|
-
tried: ({ entry }) => (entry.metadata.purpose === 'expose' ? 'be given the values of' : 'use the credential'),
|
|
271
|
-
what: ({ entry }) => [
|
|
272
|
-
text(entry.metadata.credential) ?? '',
|
|
273
|
-
...(text(entry.metadata.host) === null ? [] : [` on ${text(entry.metadata.host)}`]),
|
|
274
|
-
...(entry.metadata.egress === true ? [", through the deployment's egress"] : []),
|
|
275
|
-
],
|
|
276
|
-
},
|
|
277
|
-
'secret.restore': {
|
|
278
|
-
did: 'restored',
|
|
279
|
-
tried: 'restore',
|
|
280
|
-
what: ({ entry }) => [...place(entry), ...(number(entry.metadata.from) === null ? [] : [` to version ${number(entry.metadata.from)}`])],
|
|
281
|
-
then: ({ entry }) => (entry.version === null ? [] : [`, now ${entry.version}`]),
|
|
282
|
-
},
|
|
283
|
-
// A sensitive value made a secret in place, by an Owner of its project: its value kept, shown to its readers from then on.
|
|
284
|
-
'secret.loosen': {
|
|
285
|
-
did: 'made',
|
|
286
|
-
tried: 'make',
|
|
287
|
-
what: ({ entry }) => place(entry),
|
|
288
|
-
then: ({ entry }) => [
|
|
289
|
-
` ${text(entry.metadata.to) ?? 'secret'}, from ${text(entry.metadata.from) ?? 'sensitive'}, its value kept`,
|
|
290
|
-
...(entry.version === null ? [] : [`, now version ${entry.version}`]),
|
|
291
|
-
],
|
|
292
|
-
},
|
|
352
|
+
const TEMPLATES: Record<LogAction, Template> = {
|
|
353
|
+
'secret.read': { did: ({ entry }) => READ_VERBS[text(entry.metadata.purpose) ?? 'reveal'] ?? READ_VERBS.reveal!, what: secrets },
|
|
354
|
+
// One key as what was done to it; a batch as what was done to every key, or as written.
|
|
355
|
+
'secret.write': writeSentence,
|
|
356
|
+
// A nature marked looser in place, by an Owner of the project: its own action, as 0.14.7 logged it.
|
|
357
|
+
'secret.loosen': writeSentence,
|
|
293
358
|
'secret.rename': {
|
|
294
359
|
did: 'renamed',
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
360
|
+
what: ({ entry }) => {
|
|
361
|
+
const [here, mine] = asPersonal(entry);
|
|
362
|
+
return [...place({ ...here, key: text(entry.metadata.key) ?? entry.key }), ...(text(entry.metadata.to) === null ? [] : [` to ${text(entry.metadata.to)}`]), ...mine];
|
|
363
|
+
},
|
|
364
|
+
// Carried down to the forks that inherit it.
|
|
365
|
+
then: ({ entry }) => {
|
|
366
|
+
// Each line is a row renamed, moved aside or a dismissal moved or ended, by its environment's id: the first, the key's own.
|
|
367
|
+
const [own, ...rest] = changesOf(entry).map((line) => text(line.environment));
|
|
368
|
+
const forks = new Set(rest.filter((environment) => environment !== null && environment !== own)).size;
|
|
369
|
+
return forks === 0 ? [] : [`, and in ${plural(forks, 'fork')}`];
|
|
370
|
+
},
|
|
371
|
+
unchanged: ({ entry }) => text(entry.metadata.to) === text(entry.metadata.key),
|
|
307
372
|
},
|
|
373
|
+
'secret.refile': { did: 'moved', what: ({ entry }) => keysIn(entry, list(entry.metadata.keys)), then: ({ entry }) => intoFolder(entry.metadata.to), unchanged: sameFolder },
|
|
374
|
+
// The source, by id alone in the entry, is no path the page can say.
|
|
375
|
+
'reference.break': { did: 'broke', what: ({ entry }) => ['the reference ', ...place(entry)] },
|
|
376
|
+
// What changed, by key: dismissed, brought back, both, or neither (asked as it was).
|
|
308
377
|
'missing.dismiss': {
|
|
309
|
-
did: 'dismissed',
|
|
310
|
-
tried: 'dismiss',
|
|
311
|
-
what: (facts) => missingKeys(facts),
|
|
312
|
-
then: () => [' as not needed'],
|
|
313
|
-
},
|
|
314
|
-
'missing.restore': { did: 'restored', tried: 'restore', what: (facts) => missingKeys(facts), then: () => [' to the missing keys'] },
|
|
315
|
-
'secret.reference': { did: 'made', tried: 'make', what: ({ entry }) => referenceTo(entry) },
|
|
316
|
-
'reference.create': { did: 'made', tried: 'make', what: ({ entry }) => referenceTo(entry) },
|
|
317
|
-
'reference.end': {
|
|
318
|
-
did: ({ entry }) => (entry.metadata.reason === 'replaced' ? 'gave a value of its own to' : entry.metadata.reason === 'abandoned' ? 'abandoned' : 'broke'),
|
|
319
|
-
tried: ({ entry }) => (entry.metadata.reason === 'replaced' ? 'replace' : entry.metadata.reason === 'abandoned' ? 'abandon' : 'break'),
|
|
378
|
+
did: ({ entry }) => (list(entry.metadata.dismissed).length > 0 ? 'dismissed' : list(entry.metadata.restored).length > 0 ? 'restored' : 'set which missing keys are dismissed in'),
|
|
320
379
|
what: ({ entry }) => {
|
|
321
|
-
const
|
|
322
|
-
const
|
|
323
|
-
if (
|
|
324
|
-
return
|
|
380
|
+
const dismissed = list(entry.metadata.dismissed);
|
|
381
|
+
const restored = list(entry.metadata.restored);
|
|
382
|
+
if (dismissed.length === 0 && restored.length === 0) return keysIn(entry, []);
|
|
383
|
+
return keysIn(entry, dismissed.length > 0 ? dismissed : restored);
|
|
325
384
|
},
|
|
326
|
-
then: ({ entry }) => (entry.metadata.reason === 'abandoned' ? [', which its write never stored'] : []),
|
|
327
|
-
},
|
|
328
|
-
'secret.unarchive': { did: 'brought back', tried: 'bring back', what: (facts) => place(facts.entry) },
|
|
329
|
-
'secret.move': { did: 'moved', tried: 'move', what: (facts) => place(facts.entry), then: ({ entry }) => intoFolder(entry) },
|
|
330
|
-
...placeTemplates('project'),
|
|
331
|
-
'project.move': {
|
|
332
|
-
did: 'moved',
|
|
333
|
-
tried: 'move',
|
|
334
|
-
what: ({ entry }) => ['project ', ...place({ ...entry, environment: null, key: null })],
|
|
335
|
-
then: ({ entry }) => intoFolder(entry),
|
|
336
|
-
},
|
|
337
|
-
...placeTemplates('environment'),
|
|
338
|
-
'environment.fork': {
|
|
339
|
-
did: 'forked',
|
|
340
|
-
tried: 'fork',
|
|
341
|
-
what: ({ entry }) => [...environmentOf(entry), ...(text(entry.metadata.slug) === null ? [] : [` into ${text(entry.metadata.slug)}`])],
|
|
342
|
-
},
|
|
343
|
-
'access.grant': {
|
|
344
|
-
did: 'gave',
|
|
345
|
-
tried: 'give',
|
|
346
|
-
what: ({ entry }) => [...subject(entry), ` ${text(entry.metadata.role) ?? 'a role'} on `, ...placeOnly(entry)],
|
|
347
|
-
then: ({ entry }) => [
|
|
348
|
-
...(text(entry.metadata.previousRole) === null ? [] : [`, was ${text(entry.metadata.previousRole)}`]),
|
|
349
|
-
...(text(entry.metadata.expiresAt) === null ? [] : [`, until ${text(entry.metadata.expiresAt)!.slice(0, 10)}`]),
|
|
350
|
-
...(entry.metadata.reason === 'every-project' ? [', for a grant on every project'] : []),
|
|
351
|
-
],
|
|
352
|
-
},
|
|
353
|
-
'access.revoke': {
|
|
354
|
-
did: 'took',
|
|
355
|
-
tried: 'take',
|
|
356
|
-
what: ({ entry }) => [
|
|
357
|
-
...(text(entry.metadata.previousRole ?? entry.metadata.role) === null ? ['access to '] : [`${text(entry.metadata.previousRole ?? entry.metadata.role)} on `]),
|
|
358
|
-
...placeOnly(entry),
|
|
359
|
-
' from ',
|
|
360
|
-
...subject(entry),
|
|
361
|
-
],
|
|
362
|
-
// The vault replacing a grant on every project of 0.4: by what, an instance role or project grants.
|
|
363
385
|
then: ({ entry }) => {
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
return [
|
|
386
|
+
const dismissed = list(entry.metadata.dismissed);
|
|
387
|
+
const restored = list(entry.metadata.restored);
|
|
388
|
+
if (dismissed.length === 0) return restored.length === 0 ? [] : [' to the missing keys'];
|
|
389
|
+
return [' as not needed', ...(restored.length === 0 ? [] : [`, and restored ${restored.length > 3 ? plural(restored.length, 'key') : restored.join(', ')} to the missing keys`])];
|
|
368
390
|
},
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
391
|
+
unchanged: ({ entry }) => list(entry.metadata.dismissed).length === 0 && list(entry.metadata.restored).length === 0,
|
|
392
|
+
},
|
|
393
|
+
'project.create': created('project'),
|
|
394
|
+
'project.update': updated('project'),
|
|
395
|
+
'project.archive': plainly('project', 'archived'),
|
|
396
|
+
'project.restore': plainly('project', 'restored'),
|
|
397
|
+
'project.delete': plainly('project', 'deleted'),
|
|
398
|
+
'project.move': { ...plainly('project', 'moved'), then: ({ entry }) => intoFolder(entry.metadata.to), unchanged: ({ entry }) => entry.metadata.from === entry.metadata.to },
|
|
399
|
+
// A folder renamed, or emptied: every project filed there.
|
|
400
|
+
'folder.refile': {
|
|
401
|
+
did: ({ entry }) => (text(entry.metadata.to) === null ? 'emptied' : 'renamed'),
|
|
402
|
+
what: ({ entry }) => [text(entry.metadata.folder) === null ? 'a folder' : `the folder ${text(entry.metadata.folder)}`],
|
|
403
|
+
then: ({ entry }) => [...(text(entry.metadata.to) === null ? [] : [` to ${text(entry.metadata.to)}`]), `, ${plural(list(entry.metadata.projects).length, 'project')}`],
|
|
404
|
+
unchanged: sameFolder,
|
|
405
|
+
},
|
|
406
|
+
'environment.create': created('environment'),
|
|
407
|
+
'environment.update': updated('environment'),
|
|
408
|
+
'environment.archive': plainly('environment', 'archived'),
|
|
409
|
+
'environment.restore': plainly('environment', 'restored'),
|
|
410
|
+
'environment.delete': plainly('environment', 'deleted'),
|
|
411
|
+
'environment.protect': { did: 'protected', what: ({ entry }) => environmentOf(entry) },
|
|
412
|
+
'environment.unprotect': { did: 'unprotected', what: ({ entry }) => environmentOf(entry) },
|
|
413
|
+
// An upstream credential a deployment names, frozen in one environment.
|
|
414
|
+
'upstream.freeze': { did: 'froze the upstream credential', what: ({ entry }) => [`${text(entry.metadata.upstream) ?? ''} in `, ...environmentOf(entry)] },
|
|
415
|
+
'upstream.thaw': { did: 'unfroze the upstream credential', what: ({ entry }) => [`${text(entry.metadata.upstream) ?? ''} in `, ...environmentOf(entry)] },
|
|
416
|
+
'access.grant': accessSentence,
|
|
417
|
+
'access.revoke': accessSentence,
|
|
418
|
+
'member.add': { did: 'added', what: ({ entry }) => [...subject(entry), ...asRole(entry)] },
|
|
419
|
+
'member.restore': { did: 'brought back', what: ({ entry }) => [...subject(entry), ...asRole(entry)] },
|
|
379
420
|
'member.remove': {
|
|
380
421
|
did: 'removed',
|
|
381
|
-
tried: 'remove',
|
|
382
422
|
what: (facts) => subject(facts.entry),
|
|
383
|
-
then: ({ entry }) => (
|
|
384
|
-
},
|
|
385
|
-
'member.restore': {
|
|
386
|
-
did: 'brought back',
|
|
387
|
-
tried: 'bring back',
|
|
388
|
-
what: ({ entry }) => [...subject(entry), ...asRole(entry)],
|
|
389
|
-
then: ({ entry }) => owned(entry),
|
|
423
|
+
then: ({ entry }) => (Array.isArray(entry.metadata.revoked) && entry.metadata.revoked.length > 0 ? [`, who held ${plural(entry.metadata.revoked.length, 'grant')}`] : []),
|
|
390
424
|
},
|
|
391
425
|
'member.role': {
|
|
392
426
|
did: 'made',
|
|
393
|
-
tried: 'make',
|
|
394
427
|
what: ({ entry }) => [...subject(entry), ` ${article(roleName(text(entry.metadata.role) ?? 'member') ?? 'Member')}`, ...scoped(entry)],
|
|
395
|
-
then: ({ entry }) => {
|
|
396
|
-
const before = roleName(text(entry.metadata.previousRole) ?? '');
|
|
397
|
-
return [
|
|
398
|
-
...(before === null ? [] : [`, was ${before}`]),
|
|
399
|
-
...(entry.metadata.reason === 'every-project' ? [', for their grants on every project'] : []),
|
|
400
|
-
...owned(entry),
|
|
401
|
-
];
|
|
402
|
-
},
|
|
403
|
-
},
|
|
404
|
-
'member.owner': {
|
|
405
|
-
did: ({ entry }) => (entry.metadata.owner === false ? 'took owner from' : 'made'),
|
|
406
|
-
tried: ({ entry }) => (entry.metadata.owner === false ? 'take owner from' : 'make'),
|
|
407
|
-
what: ({ entry }) => [...subject(entry), ...(entry.metadata.owner === false ? [] : [' an owner'])],
|
|
408
428
|
},
|
|
409
429
|
// Where people set up service accounts themselves, which those who run the instance set.
|
|
410
430
|
'settings.change': {
|
|
411
431
|
did: 'set',
|
|
412
|
-
tried: 'set',
|
|
413
432
|
what: ({ entry }) => ['where people set up service accounts', ...setting(entry.metadata.serviceAccounts).map((words) => `: ${words}`)],
|
|
414
|
-
then: ({ entry }) => {
|
|
415
|
-
const previous = (entry.metadata.previous as { serviceAccounts?: unknown } | undefined)?.serviceAccounts;
|
|
416
|
-
return setting(previous).map((words) => `, was ${words}`);
|
|
417
|
-
},
|
|
433
|
+
then: ({ entry }) => setting(entry.metadata.was).map((words) => `, was ${words}`),
|
|
418
434
|
},
|
|
419
|
-
// The roles an Owner edits
|
|
435
|
+
// The roles an Owner edits (docs/design/roles.md), the vault's to change.
|
|
420
436
|
'policy.change': {
|
|
421
|
-
did: ({ entry }) =>
|
|
422
|
-
tried: ({ entry }) => POLICY_VERBS[policyOf(entry).verb][1],
|
|
437
|
+
did: ({ entry }) => policyOf(entry).verb,
|
|
423
438
|
what: ({ entry }) => policyOf(entry).what,
|
|
424
439
|
},
|
|
425
|
-
// A binding trusts CI runs to sign in as a service; removing one is its tombstone.
|
|
440
|
+
// A binding trusts CI runs or a workload to sign in as a service; removing one is its tombstone. New keys uploaded replace the bindings that named the old.
|
|
426
441
|
'token.bind': {
|
|
427
|
-
did: 'trusted
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
'
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
},
|
|
439
|
-
'
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
what: (facts) => subject(facts.entry),
|
|
443
|
-
},
|
|
444
|
-
'vault.tampered': {
|
|
445
|
-
did: 'found',
|
|
446
|
-
tried: 'check',
|
|
447
|
-
what: ({ entry }) => [
|
|
448
|
-
...(entry.subject === null ? ['an entry'] : [...subject(entry), "'s record"]),
|
|
449
|
-
` tampered with: ${TAMPERING[entry.reason ?? ''] ?? 'it fails its seal'}`,
|
|
450
|
-
],
|
|
451
|
-
},
|
|
452
|
-
// The vault's rotation to a new vault key, or the app's to a new app key, which names the key it moved from.
|
|
453
|
-
'key.rotate': {
|
|
454
|
-
did: ({ entry }) => (entry.author === 'app' ? 'moved to its new app key' : 'rotated its key'),
|
|
455
|
-
tried: ({ entry }) => (entry.author === 'app' ? 'move to its new app key' : 'rotate its key'),
|
|
456
|
-
what: () => [],
|
|
457
|
-
},
|
|
458
|
-
// An MCP client a person connected, such as Claude: named as the consent page showed it.
|
|
459
|
-
'mcp.connect': { did: 'connected', tried: 'connect', what: ({ entry }) => app(entry) },
|
|
460
|
-
// A tool an MCP client called, by its name, and the places it named.
|
|
461
|
-
'mcp.call': { did: 'used', tried: 'use', what: ({ entry }) => tool(entry), then: ({ entry }) => via(entry) },
|
|
462
|
-
// A person's decision, on coffre's page, on a change an MCP client asked for; the change's own entries follow, via the client.
|
|
463
|
-
'mcp.approve': { did: 'approved', tried: 'approve', what: ({ entry }) => tool(entry), then: ({ entry }) => [` for ${text(entry.metadata.clientName) ?? 'an app'}`] },
|
|
464
|
-
'mcp.deny': { did: 'turned down', tried: 'turn down', what: ({ entry }) => tool(entry), then: ({ entry }) => [` for ${text(entry.metadata.clientName) ?? 'an app'}`] },
|
|
465
|
-
'mcp.view': { did: 'opened an approval', tried: 'open an approval', what: () => [] },
|
|
466
|
-
// The app's prompt declined, which cancels the approval it would have opened.
|
|
467
|
-
'mcp.cancel': { did: 'cancelled', tried: 'cancel', what: ({ entry }) => tool(entry), then: ({ entry }) => via(entry) },
|
|
442
|
+
did: (facts) => (rekeyed(facts) ? 'replaced the keys of' : `trusted ${trusted(facts.entry)} to sign in as`),
|
|
443
|
+
what: (facts) => [...(rekeyed(facts) ? [`${plural(Array.isArray(facts.entry.metadata.bindings) ? facts.entry.metadata.bindings.length : 0, 'trust binding')} of `] : []), ...subject(facts.entry)],
|
|
444
|
+
then: (facts) => (rekeyed(facts) ? [] : [...inGitHubEnvironment(facts.entry), ...reaching(facts.entry)]),
|
|
445
|
+
},
|
|
446
|
+
// Its entry names the binding by id alone, not whom it trusted.
|
|
447
|
+
'token.unbind': { did: 'removed a trust binding of', what: (facts) => subject(facts.entry) },
|
|
448
|
+
'workload.freeze': { did: 'froze', what: frozen, then: ({ entry }) => (text(entry.metadata.reason) === null ? [] : [`: ${text(entry.metadata.reason)}`]) },
|
|
449
|
+
'workload.unfreeze': { did: 'unfroze', what: frozen },
|
|
450
|
+
// An MCP client a person connected, such as Claude.
|
|
451
|
+
'mcp.connect': { did: 'connected', what: ({ entry }) => app(entry) },
|
|
452
|
+
// A change an MCP client asked for, on its access token: it waits for the person's approval.
|
|
453
|
+
'mcp.ask': { did: 'was asked by an MCP client for', what: ({ entry }) => tool(entry) },
|
|
454
|
+
// A person's decision, on coffre's page, on a change an MCP client asked for; the change's own entry follows, through the approval.
|
|
455
|
+
'mcp.approve': { did: 'approved', what: ({ entry }) => tool(entry) },
|
|
456
|
+
'mcp.deny': { did: 'turned down', what: ({ entry }) => tool(entry) },
|
|
468
457
|
'mcp.disconnect': {
|
|
469
458
|
did: 'disconnected',
|
|
470
|
-
|
|
471
|
-
what: ({ entry }) => [...app(entry), ...(entry.metadata.
|
|
459
|
+
// The vault's own, on a code or a token used twice, names whose it was.
|
|
460
|
+
what: ({ entry }) => [...app(entry), ...(entry.actorType === 'system' && text(entry.metadata.principal) !== null ? [' of ', ...subject(entry)] : [])],
|
|
472
461
|
then: ({ entry }) => [DISCONNECTED[text(entry.metadata.reason) ?? ''] ?? ''],
|
|
473
462
|
},
|
|
463
|
+
// What lapsed, removed by the vault itself: sessions, sign-in codes, apps never connected.
|
|
464
|
+
'upkeep.expire': { did: 'removed what had lapsed', what: () => [] },
|
|
465
|
+
// The log's first entry: an instance upgraded from 0.14 names where 0.14's log, archived, ends.
|
|
466
|
+
'vault.adopt': {
|
|
467
|
+
did: ({ entry }) => (entry.metadata.archive == null ? 'started the log' : 'took over the 0.14 database'),
|
|
468
|
+
what: () => [],
|
|
469
|
+
then: ({ entry }) => (number(record(entry.metadata.archive).seq) === null ? [] : [`, its log archived through entry ${number(record(entry.metadata.archive).seq)}`]),
|
|
470
|
+
},
|
|
474
471
|
|
|
475
472
|
// Detail, hidden unless asked for.
|
|
476
473
|
sign_in: {
|
|
477
474
|
did: ({ entry }) => (entry.metadata.kind === 'cli' ? 'signed in to the CLI' : 'signed in'),
|
|
478
|
-
tried: 'sign in',
|
|
479
475
|
what: ({ entry }) => (text(entry.metadata.provider) === null ? [] : [`with ${text(entry.metadata.provider)}`]),
|
|
476
|
+
// Made an Owner by the vault, as the deployment names them one.
|
|
477
|
+
then: ({ entry }) => (entry.metadata.owner === 'made' ? [', made an Owner: the deployment names them one'] : entry.metadata.owner === 'restored' ? [', brought back as an Owner: the deployment names them one'] : []),
|
|
480
478
|
},
|
|
481
|
-
sign_out: { did: 'signed out',
|
|
482
|
-
// A personal token is its person's own,
|
|
479
|
+
sign_out: { did: 'signed out', what: () => [] },
|
|
480
|
+
// A personal token is its person's own, a handle a run's; a bearer token is a service account's.
|
|
483
481
|
'token.create': {
|
|
484
|
-
did: ({ entry }) => (entry.metadata.kind === 'handle' ? 'made a handle' :
|
|
485
|
-
|
|
486
|
-
what: ({ entry }) => (personal(entry) ? labelled(entry) : subject(entry)),
|
|
482
|
+
did: ({ entry }) => (entry.metadata.kind === 'handle' ? 'made a handle' : entry.metadata.kind === 'personal' ? 'made a personal token' : 'issued a bearer token to'),
|
|
483
|
+
what: ({ entry }) => (entry.metadata.kind === 'handle' || entry.metadata.kind === 'personal' ? [] : subject(entry)),
|
|
487
484
|
then: ({ entry }) => reaching(entry),
|
|
488
485
|
},
|
|
489
|
-
'
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
},
|
|
494
|
-
// A
|
|
495
|
-
'token.
|
|
496
|
-
did: '
|
|
497
|
-
|
|
498
|
-
what: ({ entry }) => [text(entry.metadata.route) ?? 'something'],
|
|
486
|
+
// One's own, as Connected apps ends it most often, is "of their own": the entry names no subject then, only its principal.
|
|
487
|
+
'token.revoke': { did: ({ entry }) => REVOKED[text(entry.metadata.kind) ?? ''] ?? 'revoked a token of', what: ({ entry }) => (own(entry) ? ['their own'] : subject(entry)) },
|
|
488
|
+
'device.start': { did: 'was asked for a CLI sign-in', what: () => [], then: labelled },
|
|
489
|
+
'device.approve': { did: 'approved a CLI sign-in', what: () => [], then: labelled },
|
|
490
|
+
'device.deny': { did: 'turned down a CLI sign-in', what: () => [], then: labelled },
|
|
491
|
+
// A CI run's ID token, or a workload's proof, exchanged for a session.
|
|
492
|
+
'token.exchange': {
|
|
493
|
+
did: ({ entry }) => (entry.metadata.kind === 'workload' ? 'started a workload session' : 'signed in for a CI run'),
|
|
494
|
+
what: () => [],
|
|
499
495
|
},
|
|
500
|
-
'
|
|
501
|
-
|
|
502
|
-
'
|
|
496
|
+
'workload.renew': { did: 'renewed its workload session', what: () => [] },
|
|
497
|
+
// Anyone may register an MCP client: what it reaches is the person's to connect.
|
|
498
|
+
'oauth.register': { did: 'registered an MCP client', what: () => [] },
|
|
503
499
|
'mcp.token': {
|
|
504
500
|
did: ({ entry }) => (entry.metadata.grant === 'refresh_token' ? 'refreshed the tokens of' : 'gave its first tokens to'),
|
|
505
|
-
tried: 'give tokens to',
|
|
506
501
|
what: ({ entry }) => app(entry),
|
|
507
502
|
},
|
|
508
|
-
'account.link': {
|
|
509
|
-
|
|
510
|
-
tried: 'link',
|
|
511
|
-
what: ({ entry }) => [`a ${text(entry.metadata.provider) ?? 'sign-in'} account`],
|
|
512
|
-
},
|
|
513
|
-
'account.unlink': {
|
|
514
|
-
did: 'unlinked',
|
|
515
|
-
tried: 'unlink',
|
|
516
|
-
what: ({ entry }) => [`a ${text(entry.metadata.provider) ?? 'sign-in'} account`],
|
|
517
|
-
},
|
|
518
|
-
'key.wrap': { did: 'sealed the key of', tried: 'seal the key of', what: (facts) => versioned(facts.entry) },
|
|
519
|
-
'key.rewrap': { did: 'resealed the key of', tried: 'reseal the key of', what: (facts) => versioned(facts.entry) },
|
|
520
|
-
'key.intent': { did: 'asked KMS about', tried: 'ask KMS about', what: (facts) => secrets(facts) },
|
|
521
|
-
'key.check': {
|
|
522
|
-
did: 'recorded the check value of',
|
|
523
|
-
tried: 'check',
|
|
524
|
-
what: ({ entry }) => [['the', text(entry.metadata.kekProvider) === 'local' ? null : text(entry.metadata.kekProvider), 'vault key', text(entry.metadata.kekId)].filter((word) => word !== null).join(' ')],
|
|
525
|
-
},
|
|
526
|
-
'audit.heartbeat': { did: 'checked in', tried: 'check in', what: () => [] },
|
|
527
|
-
// A step of the app key's rotation: the rows it signed again under the new key, the sessions it signed out, any it could not sign.
|
|
528
|
-
'key.reseal': {
|
|
529
|
-
did: 'signed rows again under its new app key:',
|
|
530
|
-
tried: 'sign rows again under its new app key',
|
|
531
|
-
what: ({ entry }) => {
|
|
532
|
-
const count = (name: string) => (typeof entry.metadata[name] === 'number' ? (entry.metadata[name] as number) : 0);
|
|
533
|
-
const [unsigned, later] = [count('unsignedCount'), count('later')];
|
|
534
|
-
return [`${count('resealed')}, and ${count('signedOut')} signed out${later === 0 ? '' : `; ${later} another listed key signed, for its own rotation`}${unsigned === 0 ? '' : `; ${unsigned} no key listed had signed, left as they were`}`];
|
|
535
|
-
},
|
|
536
|
-
},
|
|
537
|
-
// The audit watch's (server plugins/audit-watch.ts): what it found, what cleared it, and an Owner's acceptance.
|
|
538
|
-
'audit.finding': {
|
|
539
|
-
did: 'found the log changed',
|
|
540
|
-
tried: 'find the log changed',
|
|
541
|
-
what: ({ entry }) => [number(entry.metadata.seq) === null ? text(entry.metadata.reason) ?? 'where it walked' : `at entry ${number(entry.metadata.seq)}`],
|
|
542
|
-
},
|
|
543
|
-
'audit.finding_cleared': { did: 'found the log whole again', tried: 'find the log whole again', what: () => [] },
|
|
544
|
-
'audit.reanchor': {
|
|
545
|
-
did: 're-anchored the log',
|
|
546
|
-
tried: 're-anchor the log',
|
|
547
|
-
what: ({ entry }) => (number(entry.metadata.at) === null ? [] : [`at entry ${number(entry.metadata.at)}`]),
|
|
548
|
-
},
|
|
549
|
-
'audit.loss_accepted': {
|
|
550
|
-
did: 'accepted as lost',
|
|
551
|
-
tried: 'accept as lost',
|
|
552
|
-
what: ({ entry }) => [`entries ${number(entry.metadata.from) ?? '?'} to ${number(entry.metadata.to) ?? '?'}`],
|
|
553
|
-
},
|
|
554
|
-
'audit.loss_unapplied': {
|
|
555
|
-
did: 'could not apply the acceptance of',
|
|
556
|
-
tried: 'apply the acceptance of',
|
|
557
|
-
what: ({ entry }) => [`entries ${number(entry.metadata.from) ?? '?'} to ${number(entry.metadata.to) ?? '?'} as lost`],
|
|
558
|
-
},
|
|
559
|
-
'audit.checkpoint': {
|
|
560
|
-
did: 'signed the log',
|
|
561
|
-
tried: 'sign the log',
|
|
562
|
-
what: ({ entry }) => (number(entry.metadata.seq) === null ? [] : [`through entry ${number(entry.metadata.seq)}`]),
|
|
563
|
-
},
|
|
564
|
-
|
|
565
|
-
// Only ever refused: a read of a list, which is not logged when allowed.
|
|
566
|
-
'secret.list': { did: 'listed', tried: 'list', what: ({ entry }) => environmentOf(entry) },
|
|
567
|
-
'secret.history': { did: 'read the history of', tried: 'read the history of', what: (facts) => place(facts.entry) },
|
|
568
|
-
'secret.update': { did: 'changed', tried: 'change', what: (facts) => place(facts.entry) },
|
|
503
|
+
'account.link': { did: 'linked', what: ({ entry }) => [`a ${text(entry.metadata.provider) ?? 'sign-in'} account`] },
|
|
504
|
+
'account.unlink': { did: 'unlinked', what: ({ entry }) => [`a ${text(entry.metadata.provider) ?? 'sign-in'} account`] },
|
|
569
505
|
};
|
|
570
506
|
|
|
571
|
-
/** " to the folder stripe", or " out of its folder". */
|
|
572
|
-
function intoFolder(entry: AuditEntry): Part[] {
|
|
573
|
-
const folder = text(entry.metadata.to);
|
|
574
|
-
return [folder === null ? ' out of its folder' : ` to the folder ${folder}`];
|
|
575
|
-
}
|
|
576
|
-
|
|
577
507
|
/** An instance role's name, from its slug; null for none it knows. */
|
|
578
508
|
function roleName(role: string): string | null {
|
|
579
509
|
return isInstanceRole(role) ? INSTANCE_ROLES[role].name : null;
|
|
580
510
|
}
|
|
581
511
|
|
|
582
|
-
/** What a policy change did, and what it did it to, as `did` and `tried` say it. */
|
|
583
|
-
const POLICY_VERBS = {
|
|
584
|
-
protect: ['protected', 'protect'],
|
|
585
|
-
unprotect: ['unprotected', 'unprotect'],
|
|
586
|
-
edit: ['edited', 'edit'],
|
|
587
|
-
reset: ['reset', 'reset'],
|
|
588
|
-
make: ['made', 'make'],
|
|
589
|
-
delete: ['deleted', 'delete'],
|
|
590
|
-
} as const;
|
|
591
|
-
|
|
592
512
|
/**
|
|
593
|
-
* A `policy.change` entry, from
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
* deletion; one that was not there, made. A refusal the app wrote names the
|
|
597
|
-
* role alone.
|
|
513
|
+
* A `policy.change` entry, from its role, its `definition` and the one it
|
|
514
|
+
* replaced (`was`): a built-in role put back as it ships is a reset; one
|
|
515
|
+
* an Owner made, gone, a deletion; one that was not there, made.
|
|
598
516
|
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
517
|
+
* edited the Developer role made the Release manager role
|
|
518
|
+
* reset the Auditor instance role deleted the Release manager role
|
|
601
519
|
*/
|
|
602
|
-
function policyOf(entry: AuditEntry): { verb:
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
const instance = (change.kind ?? entry.metadata.kind) === 'instance-role';
|
|
615
|
-
const id = text(change.role) ?? text(entry.metadata.role);
|
|
616
|
-
const shipped = id !== null && (instance ? isInstanceRole(id) : isBuiltinRole(id));
|
|
617
|
-
const definition = change.definition === null ? null : record(change.definition);
|
|
618
|
-
const before = record(entry.metadata.before);
|
|
619
|
-
const name = text(definition?.name) ?? text(record(before.definition).name)
|
|
620
|
-
?? (id === null ? null : shipped ? (instance ? INSTANCE_ROLES[id as keyof typeof INSTANCE_ROLES] : ROLES[id as keyof typeof ROLES]).name : id);
|
|
621
|
-
// A reset or deletion: the vault's entry says so in its change, a refusal of the app's in its own metadata.
|
|
622
|
-
const verb = change.definition === null || entry.metadata.definition === null || entry.reason === 'role_granted'
|
|
623
|
-
? (shipped ? 'reset' : 'delete')
|
|
624
|
-
: before.definition === null ? 'make' : 'edit';
|
|
520
|
+
function policyOf(entry: AuditEntry): { verb: 'edited' | 'reset' | 'made' | 'deleted'; what: Part[] } {
|
|
521
|
+
const instance = entry.metadata.instance === true;
|
|
522
|
+
const id = text(entry.metadata.role);
|
|
523
|
+
const shipped = id === null ? null : instance ? (isInstanceRole(id) ? INSTANCE_ROLES[id] : null) : isBuiltinRole(id) ? ROLES[id] : null;
|
|
524
|
+
const definition = entry.metadata.definition === null ? null : record(entry.metadata.definition);
|
|
525
|
+
const name = text(definition?.name) ?? text(record(entry.metadata.was).name) ?? shipped?.name ?? id;
|
|
526
|
+
const verb = definition === null
|
|
527
|
+
? 'deleted'
|
|
528
|
+
: shipped !== null && JSON.stringify(definition) === JSON.stringify(normalDefinition(shipped))
|
|
529
|
+
? 'reset'
|
|
530
|
+
: entry.metadata.was === null ? 'made' : 'edited';
|
|
625
531
|
return { verb, what: [name === null ? 'a role' : `the ${name} ${instance ? 'instance role' : 'role'}`] };
|
|
626
532
|
}
|
|
627
533
|
|
|
628
|
-
/** An object of the metadata's, or an empty one for anything else. */
|
|
629
|
-
function record(value: unknown): Record<string, unknown> {
|
|
630
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value) ? (value as Record<string, unknown>) : {};
|
|
631
|
-
}
|
|
632
|
-
|
|
633
534
|
function article(name: string): string {
|
|
634
535
|
return `${/^[AEIOU]/.test(name) ? 'an' : 'a'} ${name}`;
|
|
635
536
|
}
|
|
636
537
|
|
|
637
538
|
/** Whether an entry's scope narrows the role; its projects are ids, which a sentence cannot name. */
|
|
638
539
|
function scoped(entry: AuditEntry): Part[] {
|
|
639
|
-
|
|
640
|
-
|
|
540
|
+
// An unscoped member's is null, the vault's `standing`.
|
|
541
|
+
const scope = entry.metadata.scope as { projects?: unknown; environments?: unknown } | null | undefined;
|
|
542
|
+
return scope == null || (scope.projects === 'all' && scope.environments === 'all') ? [] : [', with a scope'];
|
|
641
543
|
}
|
|
642
544
|
|
|
643
545
|
/**
|
|
@@ -662,13 +564,6 @@ function inGitHubEnvironment(entry: AuditEntry): Part[] {
|
|
|
662
564
|
return environment === null || !String(entry.metadata.profile).startsWith('github') ? [] : [`, in GitHub environment ${environment}`];
|
|
663
565
|
}
|
|
664
566
|
|
|
665
|
-
/** The tokens and trust bindings a `token.seal` names, counted: `2 tokens and a trust binding`. */
|
|
666
|
-
function sealedOf(entry: AuditEntry): string {
|
|
667
|
-
const count = (key: string) => (Array.isArray(entry.metadata[key]) ? (entry.metadata[key] as unknown[]).length : 0);
|
|
668
|
-
const parts = [[count('tokens'), 'token'], [count('bindings'), 'trust binding']] as const;
|
|
669
|
-
return parts.filter(([n]) => n > 0).map(([n, one]) => plural(n, one)).join(' and ') || 'nothing';
|
|
670
|
-
}
|
|
671
|
-
|
|
672
567
|
/**
|
|
673
568
|
* The setting of where people set up service accounts, in words: its
|
|
674
569
|
* projects counted, as the log names them by id, its environments by name.
|
|
@@ -690,23 +585,82 @@ function asRole(entry: AuditEntry): Part[] {
|
|
|
690
585
|
return role === null || role === 'Member' ? [] : [` as ${article(role)}`, ...scoped(entry)];
|
|
691
586
|
}
|
|
692
587
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
588
|
+
/**
|
|
589
|
+
* A refused change in words, after "tried to": its kind alone. The vault
|
|
590
|
+
* logs a refusal once a minute per caller and action (D236), so one entry
|
|
591
|
+
* stands for every one refused them that minute, each asking its own key,
|
|
592
|
+
* kind or direction: none of those is the entry's to say.
|
|
593
|
+
*/
|
|
594
|
+
const TRIED: Record<LogAction, string> = {
|
|
595
|
+
'secret.read': 'read secrets',
|
|
596
|
+
'secret.write': 'write secrets',
|
|
597
|
+
'secret.loosen': 'make a sensitive value secret in place',
|
|
598
|
+
'secret.rename': 'rename a key',
|
|
599
|
+
'secret.refile': 'move keys between folders',
|
|
600
|
+
'reference.break': 'break a reference',
|
|
601
|
+
'missing.dismiss': 'change which missing keys are dismissed',
|
|
602
|
+
'project.create': 'create a project',
|
|
603
|
+
'project.update': 'change a project',
|
|
604
|
+
'project.archive': 'archive a project',
|
|
605
|
+
'project.restore': 'restore a project',
|
|
606
|
+
'project.move': 'move a project between folders',
|
|
607
|
+
'project.delete': 'delete a project',
|
|
608
|
+
'folder.refile': 'change a folder',
|
|
609
|
+
'environment.create': 'create an environment',
|
|
610
|
+
'environment.update': 'change an environment',
|
|
611
|
+
'environment.archive': 'archive an environment',
|
|
612
|
+
'environment.restore': 'restore an environment',
|
|
613
|
+
'environment.delete': 'delete an environment',
|
|
614
|
+
'environment.protect': 'protect an environment',
|
|
615
|
+
'environment.unprotect': 'unprotect an environment',
|
|
616
|
+
'upstream.freeze': 'freeze an upstream credential',
|
|
617
|
+
'upstream.thaw': 'unfreeze an upstream credential',
|
|
618
|
+
// Every membership asked is logged as an addition, a role change and a return too.
|
|
619
|
+
'member.add': 'change a membership',
|
|
620
|
+
'member.restore': 'change a membership',
|
|
621
|
+
'member.role': "change a member's instance role",
|
|
622
|
+
'member.remove': 'remove a member',
|
|
623
|
+
'access.grant': 'change access',
|
|
624
|
+
'access.revoke': 'take away access',
|
|
625
|
+
'policy.change': 'change a role',
|
|
626
|
+
'settings.change': 'change where people set up service accounts',
|
|
627
|
+
sign_in: 'sign in',
|
|
628
|
+
sign_out: 'sign out',
|
|
629
|
+
'token.create': 'issue a credential',
|
|
630
|
+
'token.revoke': 'end a credential',
|
|
631
|
+
'account.link': 'link a sign-in account',
|
|
632
|
+
'account.unlink': 'unlink a sign-in account',
|
|
633
|
+
'device.start': 'start a CLI sign-in',
|
|
634
|
+
'device.approve': 'approve a CLI sign-in',
|
|
635
|
+
'device.deny': 'turn down a CLI sign-in',
|
|
636
|
+
'token.exchange': 'start a session from a CI run or a workload',
|
|
637
|
+
'workload.renew': 'renew a workload session',
|
|
638
|
+
'token.bind': 'change a trust binding',
|
|
639
|
+
'token.unbind': 'remove a trust binding',
|
|
640
|
+
'workload.freeze': 'freeze workloads',
|
|
641
|
+
'workload.unfreeze': 'unfreeze workloads',
|
|
642
|
+
'mcp.connect': 'connect an MCP client',
|
|
643
|
+
'mcp.token': 'get tokens for an MCP client',
|
|
644
|
+
'mcp.disconnect': 'disconnect an MCP client',
|
|
645
|
+
'oauth.register': 'register an MCP client',
|
|
646
|
+
'mcp.ask': 'ask for a change through MCP',
|
|
647
|
+
'mcp.approve': 'approve a change asked through MCP',
|
|
648
|
+
'mcp.deny': 'turn down a change asked through MCP',
|
|
649
|
+
'upkeep.expire': 'remove what had lapsed',
|
|
650
|
+
'vault.adopt': 'take over the database',
|
|
651
|
+
};
|
|
699
652
|
|
|
700
|
-
|
|
701
|
-
|
|
653
|
+
/**
|
|
654
|
+
* A refused entry's sentence: what kind of change, where the entry's own
|
|
655
|
+
* rows put it (its project and environment, never a name the caller asked
|
|
656
|
+
* for), and why. "tried to rename a key at market/dev: no access".
|
|
657
|
+
*/
|
|
658
|
+
function refusal(entry: AuditEntry): Part[] {
|
|
659
|
+
const kind = Object.hasOwn(TRIED, entry.action) ? TRIED[entry.action as LogAction] : entry.action;
|
|
660
|
+
const at = entry.project === null ? [] : [' at ', { place: [entry.project, entry.environment].filter((part) => part !== null).join('/') }];
|
|
661
|
+
return ['tried to ', kind, ...at, `: ${reasonInWords(entry.reason)}`];
|
|
702
662
|
}
|
|
703
663
|
|
|
704
|
-
const TAMPERING: Record<string, string> = {
|
|
705
|
-
mac: "it does not carry the vault's seal",
|
|
706
|
-
stale: 'an older copy was put back',
|
|
707
|
-
forged_entry: 'the vault did not write it',
|
|
708
|
-
};
|
|
709
|
-
|
|
710
664
|
/** Why something was refused, in words. Codes from the vault and the app. */
|
|
711
665
|
const REASONS: Record<string, string> = {
|
|
712
666
|
no_grant: 'no grant',
|
|
@@ -776,8 +730,8 @@ export function reasonInWords(reason: string | null): string {
|
|
|
776
730
|
|
|
777
731
|
// --- lines ----------------------------------------------------------------------
|
|
778
732
|
|
|
779
|
-
/** In a batch of mixed actions, the one
|
|
780
|
-
const LEAD = ['secret.write', 'secret.read'];
|
|
733
|
+
/** In a batch of mixed actions, the one its line says first: a write, then its reads, then the rest. */
|
|
734
|
+
const LEAD = ['secret.write', 'secret.loosen', 'secret.read'];
|
|
781
735
|
|
|
782
736
|
export function leadOf(batch: AuditEntry[]): AuditEntry {
|
|
783
737
|
for (const action of LEAD) {
|
|
@@ -788,50 +742,60 @@ export function leadOf(batch: AuditEntry[]): AuditEntry {
|
|
|
788
742
|
}
|
|
789
743
|
|
|
790
744
|
/**
|
|
791
|
-
* A read
|
|
792
|
-
* would be about one
|
|
793
|
-
*
|
|
794
|
-
*
|
|
745
|
+
* A read, logged once for every key it released, or a write, once for
|
|
746
|
+
* every key it wrote, as the entries it would be about one key each: its
|
|
747
|
+
* key and version, and its own part of the detail (`keys`: a read's
|
|
748
|
+
* `{ key, secret, version, through? }`, a write's line), such as the
|
|
749
|
+
* reference it went through. Any other entry as it is.
|
|
795
750
|
*/
|
|
796
751
|
export function perSecret<T extends AuditEntry>(entry: T): T[] {
|
|
797
|
-
const listed = entry.metadata.
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
752
|
+
const listed = entry.metadata.keys;
|
|
753
|
+
const released = entry.secrets ?? [{ key: entry.key, version: entry.version }];
|
|
754
|
+
// One whose list was emptied or mangled, which its proof would flag, still reads as itself.
|
|
755
|
+
if (!['secret.read', 'secret.write', 'secret.loosen'].includes(entry.action) || !Array.isArray(listed) || released.length === 0 || listed.length !== released.length) return [entry];
|
|
756
|
+
return released.map(({ key, version }, i) => {
|
|
801
757
|
const own = listed[i];
|
|
802
758
|
return {
|
|
803
759
|
...entry,
|
|
804
760
|
key,
|
|
805
761
|
version,
|
|
806
762
|
secrets: null,
|
|
807
|
-
metadata: { ...entry.metadata,
|
|
763
|
+
metadata: { ...entry.metadata, keys: undefined, ...(typeof own === 'object' && own !== null && !Array.isArray(own) ? own : {}) },
|
|
808
764
|
};
|
|
809
765
|
});
|
|
810
766
|
}
|
|
811
767
|
|
|
812
|
-
/**
|
|
768
|
+
/**
|
|
769
|
+
* What a line says: one entry, or a batch that shares an operation. A batch
|
|
770
|
+
* of several actions says each, the lead's first ("revealed market/prod/API_KEY;
|
|
771
|
+
* approved show_secret_value"), and is refused only if each of them was.
|
|
772
|
+
*/
|
|
813
773
|
export function describe(batch: AuditEntry[]): Sentence {
|
|
814
|
-
const
|
|
815
|
-
const
|
|
774
|
+
const actions = [...new Set([leadOf(batch).action, ...batch.map((entry) => entry.action)])];
|
|
775
|
+
const said = actions.map((action) => describeAction(batch.filter((entry) => entry.action === action)));
|
|
776
|
+
return { parts: said.flatMap((one, i) => (i === 0 ? one.parts : ['; ', ...one.parts])), refused: said.every((one) => one.refused) };
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/** A batch of one action in words. */
|
|
780
|
+
function describeAction(batch: AuditEntry[]): Sentence {
|
|
781
|
+
const lead = perSecret(batch[0]!)[0]!;
|
|
782
|
+
const same = batch.flatMap(perSecret);
|
|
783
|
+
// A batch is what was done: its refusals are counted after it, never said or counted as done.
|
|
784
|
+
const allowed = same.filter((other) => other.decision !== 'deny');
|
|
816
785
|
const denied = same.filter((other) => other.decision === 'deny');
|
|
817
|
-
const refused =
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
refused,
|
|
823
|
-
};
|
|
824
|
-
const template = TEMPLATES[entry.action];
|
|
786
|
+
const refused = allowed.length === 0;
|
|
787
|
+
if (refused) return { parts: refusal(lead), refused };
|
|
788
|
+
const entry = allowed[0]!;
|
|
789
|
+
const facts: Facts = { entry, batch: allowed, count: new Set(allowed.map((other) => `${other.project}/${other.environment}/${other.key}`)).size };
|
|
790
|
+
const template = Object.hasOwn(TEMPLATES, entry.action) ? TEMPLATES[entry.action as LogAction] : undefined;
|
|
825
791
|
if (template === undefined) return { parts: [entry.action, ' ', ...place(entry)], refused };
|
|
826
|
-
const say = (verb: Template['did']) => (typeof verb === 'string' ? verb : verb(facts));
|
|
827
792
|
const what = template.what(facts);
|
|
828
793
|
const gap = what.length === 0 ? [] : [' '];
|
|
829
|
-
if (refused) {
|
|
830
|
-
const reason = reasonInWords((denied[0] ?? entry).reason);
|
|
831
|
-
return { parts: ['tried to ', say(template.tried), ...gap, ...what, `: ${reason}`], refused };
|
|
832
|
-
}
|
|
833
794
|
const partly = denied.length === 0 ? [] : [`, ${denied.length} refused: ${reasonInWords(denied[0]!.reason)}`];
|
|
834
|
-
|
|
795
|
+
// A change that changed nothing, and one made through an MCP client's approval, say so.
|
|
796
|
+
const unchanged = entry.metadata.unchanged === true || template.unchanged?.(facts) === true ? [', unchanged'] : [];
|
|
797
|
+
const approved = text(entry.metadata.via) === null ? [] : [', approved through MCP'];
|
|
798
|
+
return { parts: [typeof template.did === 'string' ? template.did : template.did(facts), ...gap, ...what, ...(template.then?.(facts) ?? []), ...unchanged, ...approved, ...partly], refused };
|
|
835
799
|
}
|
|
836
800
|
|
|
837
801
|
/** Who acted, as a part: a member links to their page; coffre itself is text. */
|