@coffre/ui 0.0.0 → 0.1.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/LICENSE +21 -0
- package/README.md +7 -3
- package/dist/client/.assetsignore +2 -0
- package/dist/client/_coffre/assets/account-C3Zo1l5A.js +1 -0
- package/dist/client/_coffre/assets/account-C4bNbeO7.js +2 -0
- package/dist/client/_coffre/assets/affordances-DiuJIiR2.js +1 -0
- package/dist/client/_coffre/assets/audit-1xLyuxGz.js +2 -0
- package/dist/client/_coffre/assets/audit-Dab2GuRj.js +1 -0
- package/dist/client/_coffre/assets/auth.device-BfCfeBWe.js +2 -0
- package/dist/client/_coffre/assets/auth.device-D2pCLF-X.js +1 -0
- package/dist/client/_coffre/assets/coffre-C7qL3HGR.js +1 -0
- package/dist/client/_coffre/assets/directory-C2Ou4SQv.js +1 -0
- package/dist/client/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/client/_coffre/assets/grants-fqTtJ-aW.js +1 -0
- package/dist/client/_coffre/assets/index-BpGwbjmM.js +12 -0
- package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/client/_coffre/assets/login-CR9CBXlw.js +2 -0
- package/dist/client/_coffre/assets/login-DZizFxa4.js +1 -0
- package/dist/client/_coffre/assets/offboarding-DOLJQcXU.js +1 -0
- package/dist/client/_coffre/assets/page-BxW2MwaX.js +1 -0
- package/dist/client/_coffre/assets/preload-helper-BHuP8_FL.js +46 -0
- package/dist/client/_coffre/assets/principal-page-xnBZVURr.js +1 -0
- package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +1 -0
- package/dist/client/_coffre/assets/projects._project._environment-CrWjQmIA.js +2 -0
- package/dist/client/_coffre/assets/projects._project._environment-CwRVG9Ne.js +3 -0
- package/dist/client/_coffre/assets/projects._project.index-CCDEuE-z.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-DCJsmnD7.js +1 -0
- package/dist/client/_coffre/assets/projects.index-B8eV8JIn.js +1 -0
- package/dist/client/_coffre/assets/projects.index-BNEC7Oz8.js +2 -0
- package/dist/client/_coffre/assets/settings-2BPsenNM.js +2 -0
- package/dist/client/_coffre/assets/settings-BrS0-wEt.js +1 -0
- package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +1 -0
- package/dist/client/_coffre/assets/tokens._token-B3-YwuKp.js +2 -0
- package/dist/client/_coffre/assets/tokens._token-D_hsbHx6.js +1 -0
- package/dist/client/_coffre/assets/tokens.index-BdKE2Jv8.js +2 -0
- package/dist/client/_coffre/assets/tokens.index-XvA4XRxh.js +1 -0
- package/dist/client/_coffre/assets/unregistered-CTRMtBIy.js +1 -0
- package/dist/client/_coffre/assets/use-action-DgAf-tiX.js +1 -0
- package/dist/client/_coffre/assets/users._user-BFPXcJ4y.js +2 -0
- package/dist/client/_coffre/assets/users._user-DEtMeSoh.js +1 -0
- package/dist/client/_coffre/assets/users.index-B03beUHq.js +1 -0
- package/dist/client/_coffre/assets/users.index-D8hwzM6P.js +2 -0
- package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/server/.vite/manifest.json +572 -0
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-B6CZDfrB.js +133 -0
- package/dist/server/_coffre/assets/account-B71_b5xc.js +296 -0
- package/dist/server/_coffre/assets/account-BoO6ZqMc.js +176 -0
- package/dist/server/_coffre/assets/affordances-BNaXjMOb.js +46 -0
- package/dist/server/_coffre/assets/async-local-storage-C0cwgkEr.js +3107 -0
- package/dist/server/_coffre/assets/audit-CwRFnSAY.js +74 -0
- package/dist/server/_coffre/assets/audit-t1sYjtrf.js +964 -0
- package/dist/server/_coffre/assets/auth.device-1IcJ475s.js +208 -0
- package/dist/server/_coffre/assets/auth.device-CJwZYYtn.js +29 -0
- package/dist/server/_coffre/assets/coffre-1hxT2E_U.js +278 -0
- package/dist/server/_coffre/assets/directory-wm_JQUfk.js +396 -0
- package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +5 -0
- package/dist/server/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/server/_coffre/assets/grants-BmhEY1vz.js +243 -0
- package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/server/_coffre/assets/login-B5O5LPXV.js +100 -0
- package/dist/server/_coffre/assets/login-Bvc4gp0X.js +22 -0
- package/dist/server/_coffre/assets/offboarding-CvSilnSm.js +330 -0
- package/dist/server/_coffre/assets/page-BjXk0Ehu.js +2003 -0
- package/dist/server/_coffre/assets/principal-page-DkwNGzM2.js +617 -0
- package/dist/server/_coffre/assets/project-environments-lEzFHUt4.js +9 -0
- package/dist/server/_coffre/assets/projects._project._environment-7grhqlgq.js +2227 -0
- package/dist/server/_coffre/assets/projects._project._environment-ByEf6pmz.js +55 -0
- package/dist/server/_coffre/assets/projects._project.index-B1bjowP-.js +932 -0
- package/dist/server/_coffre/assets/projects._project.index-DU8wtoHD.js +22 -0
- package/dist/server/_coffre/assets/projects.index-B0DoHbCz.js +280 -0
- package/dist/server/_coffre/assets/projects.index-kMDA6pMy.js +54 -0
- package/dist/server/_coffre/assets/react-dom-qCTiwGGR.js +1352 -0
- package/dist/server/_coffre/assets/router-ChU_CwCX.js +2028 -0
- package/dist/server/_coffre/assets/settings-CM9-h7in.js +18 -0
- package/dist/server/_coffre/assets/settings-Cg5qOGij.js +60 -0
- package/dist/server/_coffre/assets/signin-errors-BEFlVDbQ.js +28 -0
- package/dist/server/_coffre/assets/start-DR3rN0St.js +4 -0
- package/dist/server/_coffre/assets/tokens._token-CCpaPMAk.js +268 -0
- package/dist/server/_coffre/assets/tokens._token-Di4OZdAA.js +18 -0
- package/dist/server/_coffre/assets/tokens.index-Do3OHR31.js +34 -0
- package/dist/server/_coffre/assets/tokens.index-tDKq4AFh.js +10 -0
- package/dist/server/_coffre/assets/ui-BNzhIAQP.js +15710 -0
- package/dist/server/_coffre/assets/unregistered-BqaWYFJK.js +51 -0
- package/dist/server/_coffre/assets/use-action-BkJXC5JM.js +953 -0
- package/dist/server/_coffre/assets/useStore-DWGPqzXR.js +892 -0
- package/dist/server/_coffre/assets/users._user-BenYva93.js +15 -0
- package/dist/server/_coffre/assets/users._user-Cp039Va-.js +10 -0
- package/dist/server/_coffre/assets/users.index-BrzG1Ecq.js +10 -0
- package/dist/server/_coffre/assets/users.index-DQ_45DQl.js +34 -0
- package/dist/server/_coffre/assets/validation-BQtqPe2V.js +27 -0
- package/dist/server/index.js +13910 -0
- package/package.json +58 -5
- package/src/components/affordances.ts +80 -0
- package/src/components/agentation.tsx +34 -0
- package/src/components/command-palette.tsx +271 -0
- package/src/components/directory.tsx +448 -0
- package/src/components/grants.tsx +204 -0
- package/src/components/icons.tsx +283 -0
- package/src/components/offboarding.tsx +286 -0
- package/src/components/page.tsx +128 -0
- package/src/components/principal-page.tsx +549 -0
- package/src/components/principal-picker.tsx +168 -0
- package/src/components/principal.tsx +53 -0
- package/src/components/route-states.tsx +60 -0
- package/src/components/service-tokens.tsx +212 -0
- package/src/components/shell.tsx +641 -0
- package/src/components/syncs.tsx +581 -0
- package/src/components/theme.tsx +141 -0
- package/src/components/tile.tsx +22 -0
- package/src/components/ui.tsx +440 -0
- package/src/entry.ts +19 -0
- package/src/lib/access-plan.ts +201 -0
- package/src/lib/audit-sentences.ts +468 -0
- package/src/lib/capabilities.ts +45 -0
- package/src/lib/coffre.ts +57 -0
- package/src/lib/project-access.ts +95 -0
- package/src/lib/project-environments.ts +23 -0
- package/src/lib/reveal.ts +21 -0
- package/src/lib/secret-edit-batch.ts +181 -0
- package/src/lib/signin-errors.ts +33 -0
- package/src/lib/use-action.ts +50 -0
- package/src/lib/validation.ts +27 -0
- package/src/routeTree.gen.ts +367 -0
- package/src/router.tsx +84 -0
- package/src/routes/__root.tsx +192 -0
- package/src/routes/access.tsx +11 -0
- package/src/routes/account.tsx +359 -0
- package/src/routes/audit.tsx +545 -0
- package/src/routes/auth.device.tsx +200 -0
- package/src/routes/index.tsx +15 -0
- package/src/routes/login.tsx +129 -0
- package/src/routes/projects.$project.$environment.tsx +1659 -0
- package/src/routes/projects.$project.index.tsx +917 -0
- package/src/routes/projects.index.tsx +353 -0
- package/src/routes/settings.tsx +72 -0
- package/src/routes/tokens.$token.tsx +35 -0
- package/src/routes/tokens.index.tsx +37 -0
- package/src/routes/unregistered.tsx +59 -0
- package/src/routes/users.$user.tsx +13 -0
- package/src/routes/users.index.tsx +37 -0
- package/src/shared/models.ts +55 -0
- package/src/styles/globals.css +4118 -0
- package/src/types.ts +21 -0
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import type { AuditEntryView, CoffreClient } from '@coffre/client';
|
|
2
|
+
import { Fragment, useState, type ReactNode } from 'react';
|
|
3
|
+
import { createFileRoute, Link } from '@tanstack/react-router';
|
|
4
|
+
import { statusOf, uiResult } from '../lib/coffre';
|
|
5
|
+
import {
|
|
6
|
+
decidedBy,
|
|
7
|
+
describe,
|
|
8
|
+
hiddenInWords,
|
|
9
|
+
lines,
|
|
10
|
+
who,
|
|
11
|
+
type Part,
|
|
12
|
+
} from '../lib/audit-sentences';
|
|
13
|
+
import { breakAfterUnderscores, EmptyState, Notice, Timestamp, Toggletip } from '../components/ui';
|
|
14
|
+
import { ClosedDoor, PageHeader } from '../components/page';
|
|
15
|
+
import {
|
|
16
|
+
Activity,
|
|
17
|
+
AlertTriangle,
|
|
18
|
+
ChevronRight,
|
|
19
|
+
Clock,
|
|
20
|
+
Info,
|
|
21
|
+
Ledger,
|
|
22
|
+
ShieldCheck,
|
|
23
|
+
SlashCircle,
|
|
24
|
+
User,
|
|
25
|
+
X,
|
|
26
|
+
} from '../components/icons';
|
|
27
|
+
|
|
28
|
+
type AuditSearch = { decision?: 'deny'; actorId?: string; detail?: '1' };
|
|
29
|
+
|
|
30
|
+
const PAGE_SIZE = 200;
|
|
31
|
+
type ChainResult = Awaited<ReturnType<typeof verifyChain>>;
|
|
32
|
+
|
|
33
|
+
export const Route = createFileRoute('/audit')({
|
|
34
|
+
// Filters live in the URL so a finding can cite the exact view it came from.
|
|
35
|
+
validateSearch: (search: Record<string, unknown>): AuditSearch => ({
|
|
36
|
+
decision: search.decision === 'deny' ? 'deny' : undefined,
|
|
37
|
+
actorId:
|
|
38
|
+
typeof search.actorId === 'string' && search.actorId !== '' ? search.actorId : undefined,
|
|
39
|
+
detail: search.detail === '1' || search.detail === 1 ? '1' : undefined,
|
|
40
|
+
}),
|
|
41
|
+
loaderDeps: ({ search }) => search,
|
|
42
|
+
// The log is verified on every visit rather than on demand: a status that
|
|
43
|
+
// is always current beats a button nobody presses.
|
|
44
|
+
loader: async ({ context: { client }, deps }) => {
|
|
45
|
+
const [entries, chain] = await Promise.all([listEntries(client, deps), verifyChain(client)]);
|
|
46
|
+
return { entries, chain };
|
|
47
|
+
},
|
|
48
|
+
component: AuditPage,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function listEntries(client: CoffreClient, search: AuditSearch) {
|
|
52
|
+
return uiResult(async () => {
|
|
53
|
+
// Detail is left out by the server unless asked for, and counted.
|
|
54
|
+
return client.audit.list({
|
|
55
|
+
limit: PAGE_SIZE,
|
|
56
|
+
decision: search.decision,
|
|
57
|
+
actor: search.actorId,
|
|
58
|
+
detail: search.detail,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Whether the log holds, or why that is not known. Verifying is for owners:
|
|
65
|
+
* anyone else reads their projects' part of the log, and a part cannot be
|
|
66
|
+
* checked as a chain, so for them it is a fact about the page, not a fault.
|
|
67
|
+
*/
|
|
68
|
+
async function verifyChain(client: CoffreClient) {
|
|
69
|
+
try {
|
|
70
|
+
const result = await client.audit.verify();
|
|
71
|
+
return result.ok
|
|
72
|
+
? {
|
|
73
|
+
integrity: 'intact' as const,
|
|
74
|
+
through: result.through,
|
|
75
|
+
entries: result.entries,
|
|
76
|
+
checkpoint: result.checkpoint,
|
|
77
|
+
pending: result.pending ?? 0,
|
|
78
|
+
}
|
|
79
|
+
: {
|
|
80
|
+
integrity: 'broken' as const,
|
|
81
|
+
through: result.through,
|
|
82
|
+
failedAtSeq: result.failedAtSeq,
|
|
83
|
+
author: result.author,
|
|
84
|
+
reason: result.reason,
|
|
85
|
+
};
|
|
86
|
+
} catch (error) {
|
|
87
|
+
const status = statusOf(error);
|
|
88
|
+
if (status === 403) return { integrity: 'owners-only' as const };
|
|
89
|
+
return {
|
|
90
|
+
integrity: 'unknown' as const,
|
|
91
|
+
problem: status === undefined ? 'the request never got an answer' : `the request failed with HTTP ${status}`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function AuditPage() {
|
|
97
|
+
const { entries: result, chain } = Route.useLoaderData();
|
|
98
|
+
const search = Route.useSearch();
|
|
99
|
+
const { decision, actorId } = search;
|
|
100
|
+
const detail = search.detail === '1';
|
|
101
|
+
const deniedOnly = decision === 'deny';
|
|
102
|
+
|
|
103
|
+
if (!result.ok) {
|
|
104
|
+
return (
|
|
105
|
+
<ClosedDoor icon={<Ledger size={18} />} label="Audit" title="The audit log is closed to you">
|
|
106
|
+
{result.error}
|
|
107
|
+
</ClosedDoor>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const broken = chain.integrity === 'broken' ? chain : null;
|
|
112
|
+
const breakAt = broken?.failedAtSeq ?? null;
|
|
113
|
+
const shown = lines(result.entries);
|
|
114
|
+
const hiddenText = detail ? null : hiddenInWords(result.hidden ?? []);
|
|
115
|
+
const filters = { decision, actorId };
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<>
|
|
119
|
+
<PageHeader title="Audit" actions={<ChainStatus chain={chain} />} />
|
|
120
|
+
|
|
121
|
+
{broken !== null && (
|
|
122
|
+
<div style={{ marginBottom: '1.25rem' }}>
|
|
123
|
+
<Notice tone="bad">
|
|
124
|
+
<strong>Treat this as an incident.</strong>{' '}
|
|
125
|
+
{broken.failedAtSeq === null
|
|
126
|
+
? `The log does not verify, found by the ${broken.author}'s check: ${broken.reason}.`
|
|
127
|
+
: `The log breaks at entry ${broken.failedAtSeq}, found by the ${broken.author}'s check: ${broken.reason}.`}{' '}
|
|
128
|
+
{broken.through !== null && `Every entry through ${broken.through} holds. `}
|
|
129
|
+
Something with direct access to the database has changed what it records
|
|
130
|
+
{broken.failedAtSeq === null ? '' : `, and nothing from entry ${broken.failedAtSeq} on can be relied on`} until
|
|
131
|
+
that is explained.
|
|
132
|
+
{breakAt !== null && !result.entries.some((entry) => entry.seq === breakAt) && (
|
|
133
|
+
<>
|
|
134
|
+
{' '}Entry {breakAt} is not among the entries below
|
|
135
|
+
{detail ? (
|
|
136
|
+
<>
|
|
137
|
+
; <code>coffre audit</code> lists them all.
|
|
138
|
+
</>
|
|
139
|
+
) : (
|
|
140
|
+
<>
|
|
141
|
+
: it may be detail,{' '}
|
|
142
|
+
<Link to="/audit" search={{ ...filters, detail: '1' }}>
|
|
143
|
+
shown on request
|
|
144
|
+
</Link>
|
|
145
|
+
.
|
|
146
|
+
</>
|
|
147
|
+
)}
|
|
148
|
+
</>
|
|
149
|
+
)}
|
|
150
|
+
</Notice>
|
|
151
|
+
</div>
|
|
152
|
+
)}
|
|
153
|
+
|
|
154
|
+
<p className="section-desc">
|
|
155
|
+
Everything done in coffre, one line per action, refusals included, and who decided it: the
|
|
156
|
+
app, or the vault, which holds the keys and the access.
|
|
157
|
+
</p>
|
|
158
|
+
|
|
159
|
+
<div className="toolbar">
|
|
160
|
+
<nav className="segmented" aria-label="Filter by decision">
|
|
161
|
+
{/* `exact` compares the whole search, not a subset of it: otherwise
|
|
162
|
+
"All events" for one actor also counts as active while that
|
|
163
|
+
actor's denials are showing, and both halves light up. */}
|
|
164
|
+
<Link to="/audit" search={{ ...filters, decision: undefined, detail: search.detail }} activeOptions={{ exact: true }}>
|
|
165
|
+
All events
|
|
166
|
+
</Link>
|
|
167
|
+
<Link to="/audit" search={{ ...filters, decision: 'deny', detail: search.detail }} activeOptions={{ exact: true }}>
|
|
168
|
+
<SlashCircle size={13} />
|
|
169
|
+
Denials only
|
|
170
|
+
</Link>
|
|
171
|
+
</nav>
|
|
172
|
+
|
|
173
|
+
{actorId !== undefined && (
|
|
174
|
+
<Link
|
|
175
|
+
className="filter-chip"
|
|
176
|
+
to="/audit"
|
|
177
|
+
search={{ ...filters, actorId: undefined, detail: search.detail }}
|
|
178
|
+
aria-label={`Stop filtering by ${actorId}`}
|
|
179
|
+
>
|
|
180
|
+
Actor <span className="mono">{actorId}</span>
|
|
181
|
+
<X size={13} />
|
|
182
|
+
</Link>
|
|
183
|
+
)}
|
|
184
|
+
|
|
185
|
+
<Link
|
|
186
|
+
className="detail-toggle"
|
|
187
|
+
to="/audit"
|
|
188
|
+
search={{ ...filters, detail: detail ? undefined : '1' }}
|
|
189
|
+
aria-pressed={detail}
|
|
190
|
+
>
|
|
191
|
+
<span className="switch" aria-hidden="true" />
|
|
192
|
+
Show detail
|
|
193
|
+
</Link>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<section className="card" aria-label="Audit entries">
|
|
197
|
+
{shown.length === 0 ? (
|
|
198
|
+
<EmptyState title={deniedOnly ? 'No denials recorded' : 'Nothing recorded yet'}>
|
|
199
|
+
{deniedOnly
|
|
200
|
+
? 'Every decision reaches this log, refusals included. An empty page means nobody has been turned away.'
|
|
201
|
+
: 'The log fills as people read and write secrets and change who has access.'}
|
|
202
|
+
</EmptyState>
|
|
203
|
+
) : (
|
|
204
|
+
<div className="dt-wrap">
|
|
205
|
+
<table className="dt audit events stacks">
|
|
206
|
+
<thead>
|
|
207
|
+
<tr>
|
|
208
|
+
<th className="n" title="Sequence number in the log">
|
|
209
|
+
#
|
|
210
|
+
</th>
|
|
211
|
+
<th className="col-shrink">
|
|
212
|
+
<span className="th">
|
|
213
|
+
<Clock size={14} />
|
|
214
|
+
When (UTC)
|
|
215
|
+
</span>
|
|
216
|
+
</th>
|
|
217
|
+
<th className="col-shrink">
|
|
218
|
+
<span className="th">
|
|
219
|
+
<User size={14} />
|
|
220
|
+
Who
|
|
221
|
+
</span>
|
|
222
|
+
</th>
|
|
223
|
+
<th>
|
|
224
|
+
<span className="th">
|
|
225
|
+
<Activity size={14} />
|
|
226
|
+
What they did
|
|
227
|
+
</span>
|
|
228
|
+
</th>
|
|
229
|
+
<th className="col-shrink">
|
|
230
|
+
<span className="th">
|
|
231
|
+
<ShieldCheck size={14} />
|
|
232
|
+
Decided by
|
|
233
|
+
</span>
|
|
234
|
+
</th>
|
|
235
|
+
</tr>
|
|
236
|
+
</thead>
|
|
237
|
+
<tbody>
|
|
238
|
+
{shown.map((batch) => (
|
|
239
|
+
<Line key={batch[0]!.seq} batch={batch} filters={filters} detail={search.detail} breakAt={breakAt} />
|
|
240
|
+
))}
|
|
241
|
+
</tbody>
|
|
242
|
+
</table>
|
|
243
|
+
</div>
|
|
244
|
+
)}
|
|
245
|
+
</section>
|
|
246
|
+
|
|
247
|
+
{hiddenText !== null && (
|
|
248
|
+
<p className="hint section-foot">
|
|
249
|
+
Hidden: {hiddenText}.{' '}
|
|
250
|
+
<Link to="/audit" search={{ ...filters, detail: '1' }}>
|
|
251
|
+
Show detail
|
|
252
|
+
</Link>
|
|
253
|
+
</p>
|
|
254
|
+
)}
|
|
255
|
+
</>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
type Entry = AuditEntryView;
|
|
260
|
+
type Filters = { decision?: 'deny'; actorId?: string };
|
|
261
|
+
|
|
262
|
+
/** One action: an entry, or a batch of them under one operation, which opens to each. */
|
|
263
|
+
function Line({
|
|
264
|
+
batch,
|
|
265
|
+
filters,
|
|
266
|
+
detail,
|
|
267
|
+
breakAt,
|
|
268
|
+
}: {
|
|
269
|
+
batch: Entry[];
|
|
270
|
+
filters: Filters;
|
|
271
|
+
detail: '1' | undefined;
|
|
272
|
+
breakAt: number | null;
|
|
273
|
+
}) {
|
|
274
|
+
const breaksInside = breakAt !== null && batch.some((entry) => entry.seq === breakAt);
|
|
275
|
+
const [open, setOpen] = useState(breaksInside);
|
|
276
|
+
const lead = batch[0]!;
|
|
277
|
+
const sentence = describe(batch);
|
|
278
|
+
const seqs = batch.map((entry) => entry.seq);
|
|
279
|
+
const grouped = batch.length > 1;
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<>
|
|
283
|
+
<Row
|
|
284
|
+
entry={lead}
|
|
285
|
+
seq={grouped ? `${Math.min(...seqs)}–${Math.max(...seqs)}` : String(lead.seq)}
|
|
286
|
+
parts={sentence.parts}
|
|
287
|
+
refused={sentence.refused}
|
|
288
|
+
decided={decidedBy(batch)}
|
|
289
|
+
filters={filters}
|
|
290
|
+
detail={detail}
|
|
291
|
+
breaks={breaksInside && !grouped}
|
|
292
|
+
marked={breaksInside}
|
|
293
|
+
batch={batch}
|
|
294
|
+
toggle={
|
|
295
|
+
grouped ? (
|
|
296
|
+
<button
|
|
297
|
+
type="button"
|
|
298
|
+
className="batch-toggle"
|
|
299
|
+
aria-expanded={open}
|
|
300
|
+
aria-label={open ? 'Hide each entry' : `Show each of ${batch.length} entries`}
|
|
301
|
+
onClick={() => setOpen(!open)}
|
|
302
|
+
>
|
|
303
|
+
<ChevronRight size={14} />
|
|
304
|
+
</button>
|
|
305
|
+
) : undefined
|
|
306
|
+
}
|
|
307
|
+
/>
|
|
308
|
+
{grouped &&
|
|
309
|
+
open &&
|
|
310
|
+
batch.map((entry) => {
|
|
311
|
+
const one = describe([entry]);
|
|
312
|
+
return (
|
|
313
|
+
<Row
|
|
314
|
+
key={entry.seq}
|
|
315
|
+
entry={entry}
|
|
316
|
+
seq={String(entry.seq)}
|
|
317
|
+
parts={one.parts}
|
|
318
|
+
refused={one.refused}
|
|
319
|
+
decided={decidedBy([entry])}
|
|
320
|
+
filters={filters}
|
|
321
|
+
detail={detail}
|
|
322
|
+
breaks={entry.seq === breakAt}
|
|
323
|
+
marked={false}
|
|
324
|
+
child
|
|
325
|
+
/>
|
|
326
|
+
);
|
|
327
|
+
})}
|
|
328
|
+
</>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function Row({
|
|
333
|
+
entry,
|
|
334
|
+
seq,
|
|
335
|
+
parts,
|
|
336
|
+
refused,
|
|
337
|
+
decided,
|
|
338
|
+
filters,
|
|
339
|
+
detail,
|
|
340
|
+
breaks,
|
|
341
|
+
marked,
|
|
342
|
+
toggle,
|
|
343
|
+
child = false,
|
|
344
|
+
batch,
|
|
345
|
+
}: {
|
|
346
|
+
entry: Entry;
|
|
347
|
+
seq: string;
|
|
348
|
+
parts: Part[];
|
|
349
|
+
refused: boolean;
|
|
350
|
+
decided: string;
|
|
351
|
+
filters: Filters;
|
|
352
|
+
detail: '1' | undefined;
|
|
353
|
+
/** The entry where verification stopped. */
|
|
354
|
+
breaks: boolean;
|
|
355
|
+
/** A batch holding it, closed or open. */
|
|
356
|
+
marked: boolean;
|
|
357
|
+
toggle?: ReactNode;
|
|
358
|
+
child?: boolean;
|
|
359
|
+
/** The batch a line stands for, to name a sync by any of its entries. */
|
|
360
|
+
batch?: Entry[];
|
|
361
|
+
}) {
|
|
362
|
+
const actor = who(batch ?? [entry]);
|
|
363
|
+
const classes = [
|
|
364
|
+
refused && 'is-denied',
|
|
365
|
+
(breaks || marked) && 'is-break',
|
|
366
|
+
child && 'is-child',
|
|
367
|
+
entry.detail && 'is-detail',
|
|
368
|
+
entry.action === 'vault.tampered' && 'is-tampered',
|
|
369
|
+
].filter(Boolean);
|
|
370
|
+
return (
|
|
371
|
+
<tr className={classes.length === 0 ? undefined : classes.join(' ')}>
|
|
372
|
+
<td className="n" data-label="Sequence">
|
|
373
|
+
{seq}
|
|
374
|
+
</td>
|
|
375
|
+
<td className="nowrap cell-mono" data-label="When (UTC)">
|
|
376
|
+
<Timestamp iso={entry.occurredAt} precise />
|
|
377
|
+
</td>
|
|
378
|
+
<td data-label="Who">
|
|
379
|
+
{/* Filtering to one actor is the second question anyone asks after
|
|
380
|
+
"what happened", so the actor is the control. */}
|
|
381
|
+
<span className="actor">
|
|
382
|
+
{typeof actor === 'string' ? (
|
|
383
|
+
<Link to="/audit" search={{ ...filters, actorId: entry.actorId, detail }}>
|
|
384
|
+
{actor}
|
|
385
|
+
</Link>
|
|
386
|
+
) : (
|
|
387
|
+
<Link to="/audit" search={{ ...filters, actorId: entry.actorId, detail }}>
|
|
388
|
+
{memberName(actor.member)}
|
|
389
|
+
</Link>
|
|
390
|
+
)}
|
|
391
|
+
</span>
|
|
392
|
+
</td>
|
|
393
|
+
<td className="cell-sentence" data-label="What they did">
|
|
394
|
+
<span className="sentence">
|
|
395
|
+
{toggle}
|
|
396
|
+
{entry.action === 'vault.tampered' && <AlertTriangle size={13} />}
|
|
397
|
+
<Sentence parts={parts} />
|
|
398
|
+
{breaks && <BreakMark />}
|
|
399
|
+
</span>
|
|
400
|
+
</td>
|
|
401
|
+
<td className="nowrap" data-label="Decided by">
|
|
402
|
+
<span className={refused ? 'decided decided-refused' : 'decided'}>
|
|
403
|
+
{refused && <SlashCircle size={13} />}
|
|
404
|
+
{decided}
|
|
405
|
+
{refused && ', refused'}
|
|
406
|
+
</span>
|
|
407
|
+
</td>
|
|
408
|
+
</tr>
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** A sentence, its people and places links to their pages. */
|
|
413
|
+
function Sentence({ parts }: { parts: Part[] }) {
|
|
414
|
+
return (
|
|
415
|
+
<>
|
|
416
|
+
{parts.map((part, index) => (
|
|
417
|
+
<Fragment key={index}>
|
|
418
|
+
{typeof part === 'string' ? (
|
|
419
|
+
part
|
|
420
|
+
) : 'place' in part ? (
|
|
421
|
+
<PlaceLink path={part.place} />
|
|
422
|
+
) : (
|
|
423
|
+
<MemberLink member={part.member} />
|
|
424
|
+
)}
|
|
425
|
+
</Fragment>
|
|
426
|
+
))}
|
|
427
|
+
</>
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function PlaceLink({ path }: { path: string }) {
|
|
432
|
+
const [project, environment] = path.split('/') as [string, string | undefined];
|
|
433
|
+
const text = <span className="mono">{breakAfterUnderscores(path)}</span>;
|
|
434
|
+
return environment === undefined ? (
|
|
435
|
+
<Link to="/projects/$project" params={{ project }}>
|
|
436
|
+
{text}
|
|
437
|
+
</Link>
|
|
438
|
+
) : (
|
|
439
|
+
<Link to="/projects/$project/$environment" params={{ project, environment }}>
|
|
440
|
+
{text}
|
|
441
|
+
</Link>
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function MemberLink({ member }: { member: string }) {
|
|
446
|
+
return member.startsWith('token:') ? (
|
|
447
|
+
<Link to="/tokens/$token" params={{ token: member.slice('token:'.length) }}>
|
|
448
|
+
{member}
|
|
449
|
+
</Link>
|
|
450
|
+
) : (
|
|
451
|
+
<Link to="/users/$user" params={{ user: memberName(member) }}>
|
|
452
|
+
{memberName(member)}
|
|
453
|
+
</Link>
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function memberName(member: string): string {
|
|
458
|
+
return member.startsWith('user:') ? member.slice('user:'.length) : member;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** The entry the log breaks at, said in words as well as in red. */
|
|
462
|
+
function BreakMark() {
|
|
463
|
+
return (
|
|
464
|
+
<span className="break-mark">
|
|
465
|
+
<AlertTriangle size={11} />
|
|
466
|
+
breaks here
|
|
467
|
+
</span>
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Whether the log still verifies, beside the title.
|
|
473
|
+
*
|
|
474
|
+
* This replaced a card with a "Verify chain" button on it. A green result you
|
|
475
|
+
* have to ask for is reassurance rather than evidence: it is checked when
|
|
476
|
+
* someone is already feeling confident, and not on the morning it would have
|
|
477
|
+
* mattered. Recomputing on load makes the claim continuous.
|
|
478
|
+
*/
|
|
479
|
+
function ChainStatus({ chain }: { chain: ChainResult }) {
|
|
480
|
+
if (chain.integrity === 'owners-only') {
|
|
481
|
+
return (
|
|
482
|
+
<Toggletip
|
|
483
|
+
align="end"
|
|
484
|
+
label="Owners and root admins see whether the log is intact. Checking it means recomputing every entry, and you read only your projects' part of it."
|
|
485
|
+
>
|
|
486
|
+
<button type="button" className="chain-note">
|
|
487
|
+
<Info size={14} />
|
|
488
|
+
Verified by owners
|
|
489
|
+
</button>
|
|
490
|
+
</Toggletip>
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (chain.integrity === 'unknown') {
|
|
495
|
+
return (
|
|
496
|
+
<Toggletip
|
|
497
|
+
align="end"
|
|
498
|
+
label={`coffre could not check the log: ${chain.problem}. The entries below loaded, but whether they are intact is unknown until it can. Reload to try again.`}
|
|
499
|
+
>
|
|
500
|
+
<button type="button" className="chain-flag chain-flag-warn">
|
|
501
|
+
<AlertTriangle size={14} />
|
|
502
|
+
Log not verified
|
|
503
|
+
</button>
|
|
504
|
+
</Toggletip>
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (chain.integrity === 'broken') {
|
|
509
|
+
return (
|
|
510
|
+
<span className="chain-flag chain-flag-bad" role="status">
|
|
511
|
+
<AlertTriangle size={14} />
|
|
512
|
+
{chain.failedAtSeq === null ? 'Log does not verify' : `Log broken at ${chain.failedAtSeq}`}
|
|
513
|
+
</span>
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
return (
|
|
518
|
+
<div className="chain">
|
|
519
|
+
{chain.pending > 0 && (
|
|
520
|
+
<Toggletip
|
|
521
|
+
align="end"
|
|
522
|
+
label="Keys released through KMS whose outcome the vault has not logged yet. Each settles within seconds, or is logged as failed."
|
|
523
|
+
>
|
|
524
|
+
<button type="button" className="chain-note" role="status">
|
|
525
|
+
{chain.pending} key operation{chain.pending === 1 ? '' : 's'} in flight
|
|
526
|
+
</button>
|
|
527
|
+
</Toggletip>
|
|
528
|
+
)}
|
|
529
|
+
<Toggletip
|
|
530
|
+
align="end"
|
|
531
|
+
label={
|
|
532
|
+
`Every entry through ${chain.through ?? 0} holds, under the app's key and the vault's.` +
|
|
533
|
+
(chain.checkpoint === null
|
|
534
|
+
? ' The vault has not signed the log yet.'
|
|
535
|
+
: ` The vault last signed it through entry ${chain.checkpoint.seq}, at ${chain.checkpoint.signedAt}.`)
|
|
536
|
+
}
|
|
537
|
+
>
|
|
538
|
+
<button type="button" className="chain-seal">
|
|
539
|
+
<ShieldCheck size={14} />
|
|
540
|
+
{chain.through === null ? 'Verified' : `Verified through ${chain.through}`}
|
|
541
|
+
</button>
|
|
542
|
+
</Toggletip>
|
|
543
|
+
</div>
|
|
544
|
+
);
|
|
545
|
+
}
|