@skyhook-io/radar-app 1.21.0 → 1.21.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/package.json +1 -1
- package/src/App.tsx +13 -5
- package/src/api/radarFeatures.ts +4 -0
- package/src/api/velero.ts +176 -0
- package/src/api/vulnerabilities.ts +58 -0
- package/src/components/audit/ChecksViewTabs.test.tsx +4 -2
- package/src/components/audit/ChecksViewTabs.tsx +3 -2
- package/src/components/audit/Java4ShellPanel.test.tsx +31 -0
- package/src/components/audit/Java4ShellPanel.tsx +313 -0
- package/src/components/audit/VulnerabilitiesView.tsx +46 -9
- package/src/components/gitops/FluxOperatorCard.test.tsx +37 -0
- package/src/components/gitops/FluxOperatorCard.tsx +27 -0
- package/src/components/gitops/GitOpsView.rowsSummary.test.tsx +59 -0
- package/src/components/gitops/GitOpsView.tsx +7 -4
- package/src/components/gitops/gitopsRowEvents.test.ts +48 -0
- package/src/components/gitops/gitopsRowEvents.ts +31 -0
- package/src/components/velero/VeleroDetailPage.tsx +12 -2
- package/src/components/velero/VeleroRunArtifacts.test.tsx +241 -0
- package/src/components/velero/VeleroRunArtifacts.tsx +112 -0
- package/src/components/velero/VeleroRunVolumes.test.tsx +247 -0
- package/src/components/velero/VeleroRunVolumes.tsx +122 -0
- package/src/components/velero/VeleroSchedulePause.test.tsx +211 -0
- package/src/components/velero/VeleroSchedulePause.tsx +191 -0
- package/src/components/velero/host.tsx +9 -3
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +20 -8
- package/src/components/whats-new/WhatsNewDialog.test.tsx +6 -4
- package/src/components/whats-new/releaseNotes.ts +67 -1
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Link } from 'react-router-dom'
|
|
3
|
+
import { Download } from 'lucide-react'
|
|
4
|
+
import { Collapse, CollapseChevron, TimeValue, useDisclosure } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { JAVA4SHELL_CVE, useJava4ShellCheck, type Java4ShellFinding, type Java4ShellResult, type VulnerabilityWorkloadRef } from '../../api/vulnerabilities'
|
|
6
|
+
import type { SelectedResource } from '../../types'
|
|
7
|
+
import { triggerDownload } from '@skyhook-io/k8s-ui/utils/download'
|
|
8
|
+
import { resourceCoverageNotice, resourceNarrowedNotice } from '@skyhook-io/k8s-ui/utils/resource-coverage'
|
|
9
|
+
import { pluralize } from '@skyhook-io/k8s-ui/utils/pluralize'
|
|
10
|
+
import { resourceRefKey } from '@skyhook-io/k8s-ui/utils/resource-refs'
|
|
11
|
+
import { ImageName } from '../vulnerabilities/parts'
|
|
12
|
+
import { Tooltip } from '../ui/Tooltip'
|
|
13
|
+
|
|
14
|
+
const advisoryURL = 'https://github.com/advisories/GHSA-6g7j-4xh3-xq2q'
|
|
15
|
+
|
|
16
|
+
interface Java4ShellPanelProps {
|
|
17
|
+
namespaces?: string[]
|
|
18
|
+
context: string
|
|
19
|
+
connected: boolean
|
|
20
|
+
trivySearch?: string
|
|
21
|
+
workload?: VulnerabilityWorkloadRef
|
|
22
|
+
onNavigateToResource?: (resource: SelectedResource) => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Java4ShellPanel({ namespaces = [], context, connected, trivySearch, workload, onNavigateToResource }: Java4ShellPanelProps) {
|
|
26
|
+
const { data, dataUpdatedAt, isFetching, error, refetch } = useJava4ShellCheck(namespaces, context, workload)
|
|
27
|
+
const checkedAt = new Date(dataUpdatedAt).toISOString()
|
|
28
|
+
return (
|
|
29
|
+
<section aria-label="Java4Shell check" className={`rounded-xl border border-theme-border bg-theme-surface ${workload ? 'p-3' : 'p-4'}`}>
|
|
30
|
+
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
31
|
+
<div className="flex min-w-0 flex-col gap-1">
|
|
32
|
+
<h2 className="text-sm font-semibold text-theme-text-primary">Java4Shell</h2>
|
|
33
|
+
<p className="text-xs text-theme-text-secondary">
|
|
34
|
+
{workload
|
|
35
|
+
? 'Check the running images in this workload for affected Java versions.'
|
|
36
|
+
: 'Check running workloads for affected Java versions and prioritize patching with current node evidence.'}
|
|
37
|
+
</p>
|
|
38
|
+
<p className="text-xs text-theme-text-tertiary">Radar reads image metadata using the registry credentials your access allows.</p>
|
|
39
|
+
<div className="flex flex-wrap gap-x-4 gap-y-1 text-xs">
|
|
40
|
+
<a className="text-accent-text hover:underline" href={advisoryURL} target="_blank" rel="noreferrer">{JAVA4SHELL_CVE} advisory</a>
|
|
41
|
+
{trivySearch && <Link className="text-accent-text hover:underline" to={{ search: trivySearch }}>Find in Trivy reports</Link>}
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
45
|
+
{data && (
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
className="btn-secondary inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium"
|
|
49
|
+
onClick={() => triggerDownload(
|
|
50
|
+
JSON.stringify({ cve: JAVA4SHELL_CVE, checkedAt, ...data }, null, 2),
|
|
51
|
+
'application/json',
|
|
52
|
+
`java4shell-${checkedAt.replace(/[:.]/g, '-')}.json`,
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
<Download className="h-3.5 w-3.5" /> Download JSON
|
|
56
|
+
</button>
|
|
57
|
+
)}
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
className="btn-brand shrink-0 px-3 py-1.5 text-xs font-medium"
|
|
61
|
+
onClick={() => void refetch()}
|
|
62
|
+
disabled={!connected || isFetching}
|
|
63
|
+
>
|
|
64
|
+
{isFetching ? (workload ? 'Checking workload…' : 'Checking workloads…') : data ? 'Run check again' : 'Check for Java4Shell'}
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
{isFetching && <p role="status" className="mt-3 text-xs text-theme-text-secondary">Reading running Pods and image metadata. This can take up to 40 seconds after the Pods are read.</p>}
|
|
69
|
+
{error && <p role="alert" className="mt-3 text-xs text-warning-text">{error.message}{data && ' Showing the previous result.'}</p>}
|
|
70
|
+
{data && <Java4ShellResults data={data} checkedAt={checkedAt} onOpen={onNavigateToResource} />}
|
|
71
|
+
</section>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const reasonLabels: Record<string, string> = {
|
|
76
|
+
image_identity_unknown: 'Running image digest unavailable',
|
|
77
|
+
version_unknown: 'Unrecognized Java version',
|
|
78
|
+
platform_unknown: 'Image platform unknown',
|
|
79
|
+
auth_required: 'Registry authentication required',
|
|
80
|
+
not_found: 'Image missing or private',
|
|
81
|
+
blocked: 'Registry address blocked',
|
|
82
|
+
rate_limited: 'Registry rate limit',
|
|
83
|
+
error: 'Registry read failed',
|
|
84
|
+
not_checked: 'Check limit reached',
|
|
85
|
+
java_home_declared: 'Image sets JAVA_HOME. Java version unknown',
|
|
86
|
+
no_java_declaration: 'Image declares no Java version',
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function Java4ShellResults({ data, checkedAt, onOpen }: { data: Java4ShellResult; checkedAt: string; onOpen?: (resource: SelectedResource) => void }) {
|
|
90
|
+
const missingDeclaration = data.unassessed.no_java_declaration ?? 0
|
|
91
|
+
const javaHomeDeclared = data.unassessed.java_home_declared ?? 0
|
|
92
|
+
const unassessed = Object.values(data.unassessed).reduce((count, n) => count + n, 0)
|
|
93
|
+
const otherUnassessed = unassessed - missingDeclaration - javaHomeDeclared
|
|
94
|
+
const coverage = resourceCoverageNotice(data.coverage, 'Pods') ?? resourceNarrowedNotice(data.coverage)
|
|
95
|
+
const namespaces = data.coverage.read?.namespaces
|
|
96
|
+
const scope = data.workload?.name ?? (
|
|
97
|
+
namespaces?.names && namespaces.names.length <= 3
|
|
98
|
+
? namespaces.names.join(', ')
|
|
99
|
+
: namespaces ? pluralize(namespaces.count, 'namespace') : 'all namespaces'
|
|
100
|
+
)
|
|
101
|
+
const groups = new Map<string, Java4ShellFinding[]>()
|
|
102
|
+
for (const row of data.findings) {
|
|
103
|
+
const key = resourceRefKey(row.workload)
|
|
104
|
+
const rows = groups.get(key)
|
|
105
|
+
if (rows) rows.push(row)
|
|
106
|
+
else groups.set(key, [row])
|
|
107
|
+
}
|
|
108
|
+
const summary = data.matches > 0
|
|
109
|
+
? `${pluralize(data.matches, 'container')} with a declared Java version in an affected range`
|
|
110
|
+
: data.containers === 0
|
|
111
|
+
? data.workload ? 'Radar found no running containers in this workload' : 'Radar found no running containers in the scope it read'
|
|
112
|
+
: missingDeclaration === data.containers
|
|
113
|
+
? 'Images checked declared no Java version'
|
|
114
|
+
: unassessed === data.containers
|
|
115
|
+
? 'Radar could not assess the Java version of any running container'
|
|
116
|
+
: 'No matches among containers whose declared Java version Radar could assess'
|
|
117
|
+
return (
|
|
118
|
+
<div className="mt-3 flex flex-col gap-2 border-t border-theme-border pt-3 text-xs">
|
|
119
|
+
<div className="flex flex-wrap justify-between gap-x-3 gap-y-1">
|
|
120
|
+
<p role="status" className="font-medium text-theme-text-primary">{summary}</p>
|
|
121
|
+
<p className="text-theme-text-tertiary">Checked <TimeValue timestamp={checkedAt} /> · {scope}</p>
|
|
122
|
+
</div>
|
|
123
|
+
{coverage && <p className="text-warning-text">{coverage}</p>}
|
|
124
|
+
{javaHomeDeclared > 0 && (
|
|
125
|
+
<p className="text-theme-text-secondary">
|
|
126
|
+
Images for {pluralize(javaHomeDeclared, 'container')} set <code>JAVA_HOME</code>. Verify the installed Java version.
|
|
127
|
+
</p>
|
|
128
|
+
)}
|
|
129
|
+
{otherUnassessed > 0 && (
|
|
130
|
+
<p className="text-theme-text-secondary">
|
|
131
|
+
Java version unassessed in {pluralize(otherUnassessed, 'container')}.
|
|
132
|
+
</p>
|
|
133
|
+
)}
|
|
134
|
+
{missingDeclaration > 0 && (
|
|
135
|
+
<p className="text-theme-text-secondary">
|
|
136
|
+
Images for {pluralize(missingDeclaration, 'container')} had no Java version declaration.
|
|
137
|
+
</p>
|
|
138
|
+
)}
|
|
139
|
+
{data.findings.length > 0 && (
|
|
140
|
+
<p className="text-theme-text-secondary">Image metadata describes the declared Java version. Confirm the deployed JVM and the fix from its vendor.</p>
|
|
141
|
+
)}
|
|
142
|
+
{data.workload && <WorkloadJava4ShellRows data={data} />}
|
|
143
|
+
{!data.workload && onOpen && data.findings.length > 0 && (
|
|
144
|
+
<>
|
|
145
|
+
<div role="region" aria-label="Matching containers by workload" tabIndex={0} className="max-h-96 overflow-auto rounded-lg border border-theme-border">
|
|
146
|
+
<table className="w-full min-w-[40rem] text-left">
|
|
147
|
+
<thead className="sticky top-0 bg-theme-elevated text-theme-text-secondary">
|
|
148
|
+
<tr>
|
|
149
|
+
<th scope="col" className="px-3 py-2 font-medium">Workload</th>
|
|
150
|
+
<th scope="col" className="px-3 py-2 font-medium">Container</th>
|
|
151
|
+
<th scope="col" className="px-3 py-2 font-medium">Declared Java</th>
|
|
152
|
+
<th scope="col" className="px-3 py-2 font-medium">Node evidence at check time</th>
|
|
153
|
+
</tr>
|
|
154
|
+
</thead>
|
|
155
|
+
{[...groups.entries()].map(([key, rows]) => (
|
|
156
|
+
<tbody key={key} className="divide-y divide-theme-border border-t border-theme-border">
|
|
157
|
+
{rows.map((row, index) => (
|
|
158
|
+
<tr key={JSON.stringify([row.container, row.digest, row.version])} className="align-top">
|
|
159
|
+
{index === 0 && (
|
|
160
|
+
<th rowSpan={rows.length} scope="rowgroup" className="px-3 py-2 font-medium">
|
|
161
|
+
<WorkloadLink workload={row.workload} onOpen={onOpen} />
|
|
162
|
+
</th>
|
|
163
|
+
)}
|
|
164
|
+
<td className="px-3 py-2">
|
|
165
|
+
<div className="text-theme-text-primary">{row.container}</div>
|
|
166
|
+
<div className="max-w-48 truncate text-theme-text-tertiary"><ImageName image={row.image} /></div>
|
|
167
|
+
<div className="text-theme-text-tertiary">{pluralize(row.pods, 'Pod')}</div>
|
|
168
|
+
</td>
|
|
169
|
+
<td className="px-3 py-2">
|
|
170
|
+
<div className="font-mono text-theme-text-primary">{row.version}</div>
|
|
171
|
+
<div className="text-theme-text-secondary">{row.fixedIn ? `Upstream fix ${row.fixedIn}` : 'Check the vendor for an upgrade'}</div>
|
|
172
|
+
</td>
|
|
173
|
+
<td className="px-3 py-2">
|
|
174
|
+
<JavaPlacement row={row} />
|
|
175
|
+
</td>
|
|
176
|
+
</tr>
|
|
177
|
+
))}
|
|
178
|
+
</tbody>
|
|
179
|
+
))}
|
|
180
|
+
</table>
|
|
181
|
+
</div>
|
|
182
|
+
</>
|
|
183
|
+
)}
|
|
184
|
+
{data.findingGroups > data.findings.length && (
|
|
185
|
+
<p className="text-theme-text-secondary">Showing {data.findings.length} of {data.findingGroups} matching groups.{!data.workload && ' Narrow the namespace scope to see more.'}</p>
|
|
186
|
+
)}
|
|
187
|
+
{!data.workload && onOpen && data.unassessedGroups > 0 && <UnassessedDetails data={data} onOpen={onOpen} />}
|
|
188
|
+
</div>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function WorkloadJava4ShellRows({ data }: { data: Java4ShellResult }) {
|
|
193
|
+
return (
|
|
194
|
+
<>
|
|
195
|
+
{data.findings.length > 0 && (
|
|
196
|
+
<ul aria-label="Matching containers" className="divide-y divide-theme-border rounded-md border border-theme-border">
|
|
197
|
+
{data.findings.map(row => (
|
|
198
|
+
<li key={JSON.stringify([row.container, row.digest, row.version])} className="space-y-1 p-2">
|
|
199
|
+
<div className="flex flex-wrap items-baseline gap-x-2">
|
|
200
|
+
<span className="font-medium text-theme-text-primary">{row.container}</span>
|
|
201
|
+
<ImageName image={row.image} className="text-theme-text-tertiary" />
|
|
202
|
+
<span className="text-theme-text-tertiary">{pluralize(row.pods, 'Pod')}</span>
|
|
203
|
+
</div>
|
|
204
|
+
<div className="flex flex-wrap items-baseline gap-x-2">
|
|
205
|
+
<span className="font-mono text-theme-text-primary">{row.version}</span>
|
|
206
|
+
<span className="text-theme-text-secondary">{row.fixedIn ? `Upstream fix ${row.fixedIn}` : 'Check the vendor for an upgrade'}</span>
|
|
207
|
+
</div>
|
|
208
|
+
<JavaPlacement row={row} />
|
|
209
|
+
</li>
|
|
210
|
+
))}
|
|
211
|
+
</ul>
|
|
212
|
+
)}
|
|
213
|
+
{data.unassessedRows.length > 0 && (
|
|
214
|
+
<>
|
|
215
|
+
<div className="font-medium text-theme-text-secondary">Unassessed containers</div>
|
|
216
|
+
<ul aria-label="Unassessed containers" className="divide-y divide-theme-border rounded-md border border-theme-border">
|
|
217
|
+
{data.unassessedRows.map(row => (
|
|
218
|
+
<li key={JSON.stringify([row.container, row.image, row.digest, row.reason])} className="space-y-1 p-2">
|
|
219
|
+
<div className="flex flex-wrap items-baseline gap-x-2">
|
|
220
|
+
<span className="font-medium text-theme-text-primary">{row.container}</span>
|
|
221
|
+
<ImageName image={row.image} className="text-theme-text-tertiary" />
|
|
222
|
+
<span className="text-theme-text-tertiary">{pluralize(row.pods, 'Pod')}</span>
|
|
223
|
+
</div>
|
|
224
|
+
<div className="text-theme-text-secondary">{reasonLabels[row.reason] ?? row.reason}</div>
|
|
225
|
+
</li>
|
|
226
|
+
))}
|
|
227
|
+
</ul>
|
|
228
|
+
{data.unassessedGroups > data.unassessedRows.length && (
|
|
229
|
+
<p className="text-theme-text-secondary">Showing {data.unassessedRows.length} of {data.unassessedGroups} unassessed groups.</p>
|
|
230
|
+
)}
|
|
231
|
+
</>
|
|
232
|
+
)}
|
|
233
|
+
</>
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function WorkloadLink({ workload, onOpen }: { workload: Java4ShellFinding['workload']; onOpen: (resource: SelectedResource) => void }) {
|
|
238
|
+
return (
|
|
239
|
+
<>
|
|
240
|
+
<button type="button" onClick={() => onOpen(workload)} className="text-left text-accent-text hover:underline">{workload.name}</button>
|
|
241
|
+
<div className="text-theme-text-tertiary">{workload.kind} · {workload.namespace}</div>
|
|
242
|
+
</>
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function UnassessedDetails({ data, onOpen }: { data: Java4ShellResult; onOpen: (resource: SelectedResource) => void }) {
|
|
247
|
+
const [open, setOpen] = useState(false)
|
|
248
|
+
const { panelId, buttonProps } = useDisclosure(open)
|
|
249
|
+
const { unassessedRows, unassessedGroups } = data
|
|
250
|
+
const reasonTotals = Object.entries(data.unassessed).sort(([, a], [, b]) => b - a)
|
|
251
|
+
return (
|
|
252
|
+
<div>
|
|
253
|
+
<button {...buttonProps} type="button" onClick={() => setOpen(!open)} className="inline-flex items-center gap-1.5 py-1 font-medium text-accent-text hover:underline">
|
|
254
|
+
<CollapseChevron open={open} className="h-3.5 w-3.5" />
|
|
255
|
+
Unassessed containers
|
|
256
|
+
</button>
|
|
257
|
+
<Collapse open={open} id={panelId} mountLazily>
|
|
258
|
+
{reasonTotals.length > 1 && (
|
|
259
|
+
<ul aria-label="Totals by reason" className="mt-1 flex flex-wrap gap-x-4 gap-y-1 text-theme-text-secondary">
|
|
260
|
+
{reasonTotals.map(([reason, count]) => (
|
|
261
|
+
<li key={reason}>{reasonLabels[reason] ?? reason} · <span className="tabular-nums">{count}</span></li>
|
|
262
|
+
))}
|
|
263
|
+
</ul>
|
|
264
|
+
)}
|
|
265
|
+
<div role="region" aria-label="Unassessed containers by workload" tabIndex={0} className="mt-1 max-h-64 overflow-auto rounded-lg border border-theme-border">
|
|
266
|
+
<table className="w-full min-w-[32rem] text-left">
|
|
267
|
+
<thead className="sticky top-0 bg-theme-elevated text-theme-text-secondary">
|
|
268
|
+
<tr>
|
|
269
|
+
<th scope="col" className="px-3 py-2 font-medium">Workload</th>
|
|
270
|
+
<th scope="col" className="px-3 py-2 font-medium">Container</th>
|
|
271
|
+
<th scope="col" className="px-3 py-2 font-medium">Reason</th>
|
|
272
|
+
<th scope="col" className="px-3 py-2 text-right font-medium">Pods</th>
|
|
273
|
+
</tr>
|
|
274
|
+
</thead>
|
|
275
|
+
<tbody className="divide-y divide-theme-border border-t border-theme-border">
|
|
276
|
+
{unassessedRows.map(row => (
|
|
277
|
+
<tr key={JSON.stringify([resourceRefKey(row.workload), row.container, row.image, row.digest, row.reason])} className="align-top">
|
|
278
|
+
<th scope="row" className="px-3 py-2 font-medium"><WorkloadLink workload={row.workload} onOpen={onOpen} /></th>
|
|
279
|
+
<td className="px-3 py-2">
|
|
280
|
+
<div className="text-theme-text-primary">{row.container}</div>
|
|
281
|
+
<div className="max-w-48 truncate text-theme-text-tertiary"><ImageName image={row.image} /></div>
|
|
282
|
+
{row.digest && (
|
|
283
|
+
<Tooltip content={row.digest}>
|
|
284
|
+
<span className="font-mono text-theme-text-tertiary">{row.digest.replace(/^sha256:/, '').slice(0, 12)}</span>
|
|
285
|
+
</Tooltip>
|
|
286
|
+
)}
|
|
287
|
+
</td>
|
|
288
|
+
<td className="px-3 py-2 text-theme-text-secondary">{reasonLabels[row.reason] ?? row.reason}</td>
|
|
289
|
+
<td className="px-3 py-2 text-right tabular-nums text-theme-text-secondary">{row.pods}</td>
|
|
290
|
+
</tr>
|
|
291
|
+
))}
|
|
292
|
+
</tbody>
|
|
293
|
+
</table>
|
|
294
|
+
</div>
|
|
295
|
+
{unassessedGroups > unassessedRows.length && (
|
|
296
|
+
<p className="mt-2 text-theme-text-secondary">Showing {unassessedRows.length} of {unassessedGroups} workload or Pod groups. Narrow the namespace scope to see more.</p>
|
|
297
|
+
)}
|
|
298
|
+
</Collapse>
|
|
299
|
+
</div>
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function JavaPlacement({ row }: { row: Java4ShellFinding }) {
|
|
304
|
+
const other = row.pods - row.vbmiPods - row.unknownCPUPods
|
|
305
|
+
return (
|
|
306
|
+
<>
|
|
307
|
+
{row.vbmiPods > 0 && <div className="font-medium text-warning-text">Prioritize patching · {pluralize(row.vbmiPods, 'Pod')} on nodes reporting AVX-512 VBMI</div>}
|
|
308
|
+
{row.unknownCPUPods > 0 && <div className="text-theme-text-secondary">CPU capability unknown for {pluralize(row.unknownCPUPods, 'Pod')}</div>}
|
|
309
|
+
{other > 0 && <div className="text-theme-text-secondary">{pluralize(other, 'Pod')} on non-x86 nodes at check time</div>}
|
|
310
|
+
{row.mitigationDeclaredPods > 0 && <div className="text-theme-text-tertiary">Mitigation flag declared in {pluralize(row.mitigationDeclaredPods, 'Pod spec')}</div>}
|
|
311
|
+
</>
|
|
312
|
+
)
|
|
313
|
+
}
|
|
@@ -25,8 +25,11 @@ import {
|
|
|
25
25
|
} from '@skyhook-io/k8s-ui'
|
|
26
26
|
import { SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
|
|
27
27
|
import { formatRelativeAgeTime } from '@skyhook-io/k8s-ui/utils/format'
|
|
28
|
-
import { ApiError } from '../../api/client'
|
|
28
|
+
import { ApiError, useCapabilities } from '../../api/client'
|
|
29
|
+
import { useAPIResources } from '../../api/apiResources'
|
|
29
30
|
import {
|
|
31
|
+
hasVulnerabilityReports,
|
|
32
|
+
JAVA4SHELL_CVE,
|
|
30
33
|
useVulnerabilities,
|
|
31
34
|
isKindUnknown,
|
|
32
35
|
parseWorkloadParam,
|
|
@@ -43,6 +46,7 @@ import {
|
|
|
43
46
|
import type { SelectedResource } from '../../types'
|
|
44
47
|
import { useConnection } from '../../context/ConnectionContext'
|
|
45
48
|
import { ChecksViewTabs } from './ChecksViewTabs'
|
|
49
|
+
import { Java4ShellPanel } from './Java4ShellPanel'
|
|
46
50
|
import {
|
|
47
51
|
SEVERITIES,
|
|
48
52
|
SeverityBadge,
|
|
@@ -79,6 +83,7 @@ const VIEWS: { key: VulnerabilityView; label: string }[] = [
|
|
|
79
83
|
|
|
80
84
|
const CHIP = 'min-h-8 rounded-full border px-3 text-xs font-medium transition-colors'
|
|
81
85
|
const CHIP_ON = 'selection-strong border-accent text-theme-text-primary'
|
|
86
|
+
const TRIVY_INSTALL_URL = 'https://aquasecurity.github.io/trivy-operator/latest/getting-started/installation/'
|
|
82
87
|
|
|
83
88
|
// Each table's columns, shared by its header, rows and expanded sub-rows so
|
|
84
89
|
// detail lines up under the column it belongs to. Short values get fixed
|
|
@@ -106,6 +111,10 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
|
|
|
106
111
|
const workload = parseWorkloadParam(params.get('workload'))
|
|
107
112
|
const query = useDebouncedValue(queryDraft.trim(), 300)
|
|
108
113
|
const { connection } = useConnection()
|
|
114
|
+
const { data: capabilities } = useCapabilities()
|
|
115
|
+
const { data: resources } = useAPIResources()
|
|
116
|
+
const java4ShellSupported = capabilities?.features?.runtimeAdvisoryChecks === true
|
|
117
|
+
const reportsAbsent = java4ShellSupported && resources !== undefined && !hasVulnerabilityReports(resources)
|
|
109
118
|
|
|
110
119
|
// Typing and chip toggles replace the entry; a new view or a drill-down
|
|
111
120
|
// pushes one, so Back returns to the list it came from.
|
|
@@ -114,7 +123,22 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
|
|
|
114
123
|
mutate(next)
|
|
115
124
|
setParams(next, { replace: !push })
|
|
116
125
|
}
|
|
117
|
-
const { data, isLoading, isFetching, isPlaceholderData, error, dataUpdatedAt, refetch } = useVulnerabilities({ view, namespaces, severities, fixableOnly, query, workload })
|
|
126
|
+
const { data, isLoading, isFetching, isPlaceholderData, error, dataUpdatedAt, refetch } = useVulnerabilities({ view, namespaces, severities, fixableOnly, query, workload }, !reportsAbsent)
|
|
127
|
+
const hasReports = !reportsAbsent && (hasVulnerabilityReports(resources) || !!data)
|
|
128
|
+
const trivySearch = new URLSearchParams({ by: 'cve', q: JAVA4SHELL_CVE })
|
|
129
|
+
for (const key of ['namespace', 'namespaces']) {
|
|
130
|
+
const value = params.get(key)
|
|
131
|
+
if (value) trivySearch.set(key, value)
|
|
132
|
+
}
|
|
133
|
+
const advisory = java4ShellSupported && (
|
|
134
|
+
<Java4ShellPanel
|
|
135
|
+
namespaces={namespaces}
|
|
136
|
+
context={connection.context}
|
|
137
|
+
connected={connection.state === 'connected'}
|
|
138
|
+
trivySearch={hasReports ? trivySearch.toString() : undefined}
|
|
139
|
+
onNavigateToResource={onNavigateToResource}
|
|
140
|
+
/>
|
|
141
|
+
)
|
|
118
142
|
|
|
119
143
|
const toggleSeverity = (s: VulnerabilitySeverity) => update((p) => {
|
|
120
144
|
const next = severities.includes(s) ? severities.filter((x) => x !== s) : [...severities, s]
|
|
@@ -122,19 +146,31 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
|
|
|
122
146
|
else p.delete('severity')
|
|
123
147
|
})
|
|
124
148
|
|
|
125
|
-
if (isLoading) {
|
|
149
|
+
if (isLoading && !reportsAbsent) {
|
|
126
150
|
return (
|
|
127
|
-
<div className="flex-1 flex flex-col min-h-0 p-4 gap-4">
|
|
151
|
+
<div className="flex-1 flex flex-col min-h-0 p-4 gap-4 overflow-auto">
|
|
128
152
|
<ChecksViewTabs />
|
|
153
|
+
{advisory && <PageHeader icon={ShieldAlert} title="Vulnerabilities" />}
|
|
154
|
+
{advisory}
|
|
129
155
|
<PaneLoader label="Reading vulnerability reports…" className="flex-1" />
|
|
130
156
|
</div>
|
|
131
157
|
)
|
|
132
158
|
}
|
|
133
|
-
if (!data) {
|
|
159
|
+
if (!data || reportsAbsent) {
|
|
160
|
+
const showInstallNote = advisory && (reportsAbsent || isKindUnknown(error))
|
|
134
161
|
return (
|
|
135
|
-
<div className="flex-1 flex flex-col min-h-0 p-4 gap-4">
|
|
162
|
+
<div className="flex-1 flex flex-col min-h-0 p-4 gap-4 overflow-auto">
|
|
136
163
|
<ChecksViewTabs />
|
|
137
|
-
<
|
|
164
|
+
{advisory && <PageHeader icon={ShieldAlert} title="Vulnerabilities" />}
|
|
165
|
+
{advisory}
|
|
166
|
+
{showInstallNote ? (
|
|
167
|
+
<p className="text-xs text-theme-text-secondary">
|
|
168
|
+
General image vulnerability scanning requires Trivy Operator.{' '}
|
|
169
|
+
<a href={TRIVY_INSTALL_URL} target="_blank" rel="noreferrer" className="text-accent-text hover:underline">Installation guide</a>
|
|
170
|
+
</p>
|
|
171
|
+
) : (
|
|
172
|
+
<div className="flex flex-1 items-center justify-center"><VulnerabilitiesError error={error} /></div>
|
|
173
|
+
)}
|
|
138
174
|
</div>
|
|
139
175
|
)
|
|
140
176
|
}
|
|
@@ -160,6 +196,7 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
|
|
|
160
196
|
description="Known CVEs in the images that run now, from Trivy Operator's reports."
|
|
161
197
|
actions={<FreshnessControl mode="auto" dataUpdatedAt={dataUpdatedAt} isFetching={isFetching} onRefresh={() => refetch()} connectionState={connection.state} />}
|
|
162
198
|
/>
|
|
199
|
+
{advisory}
|
|
163
200
|
|
|
164
201
|
{/* Triage header, as on Best practices: the headline, the severity
|
|
165
202
|
distribution, and its legend as the severity filters. */}
|
|
@@ -310,8 +347,8 @@ function VulnerabilitiesError({ error }: { error: unknown }) {
|
|
|
310
347
|
tone="neutral"
|
|
311
348
|
icon={ShieldAlert}
|
|
312
349
|
headline="No vulnerability reports in this cluster"
|
|
313
|
-
body="
|
|
314
|
-
action={<a href=
|
|
350
|
+
body="General image vulnerability scanning requires Trivy Operator. When installed, its reports appear here."
|
|
351
|
+
action={<a href={TRIVY_INSTALL_URL} target="_blank" rel="noreferrer" className="btn-brand px-3 py-1.5 text-xs font-medium">How to install Trivy Operator</a>}
|
|
315
352
|
/>
|
|
316
353
|
)
|
|
317
354
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { renderToString } from 'react-dom/server'
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
4
|
+
|
|
5
|
+
const state: { reports: any; options: Record<string, any> } = { reports: { data: undefined, error: null, isSuccess: false }, options: {} }
|
|
6
|
+
vi.mock('../../api/client', () => ({
|
|
7
|
+
useResources: (kind: string, _ns?: string, _group?: string, options?: any) => {
|
|
8
|
+
state.options[kind] = options
|
|
9
|
+
return kind === 'fluxreports' ? state.reports : { data: undefined, error: null, isSuccess: false }
|
|
10
|
+
},
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
import { FluxOperatorCard } from './FluxOperatorCard'
|
|
14
|
+
|
|
15
|
+
const render = () => renderToString(<MemoryRouter><FluxOperatorCard available /></MemoryRouter>).replace(/<!-- -->/g, '')
|
|
16
|
+
const report = { metadata: { namespace: 'flux-system', name: 'flux' }, spec: { distribution: { version: 'v2.7.5' }, components: [], reconcilers: [] } }
|
|
17
|
+
|
|
18
|
+
describe('FluxOperatorCard', () => {
|
|
19
|
+
it('shows nothing when the report list failed or is empty', () => {
|
|
20
|
+
state.reports = { data: undefined, error: new Error('forbidden'), isSuccess: false }
|
|
21
|
+
expect(render()).not.toContain('Flux v')
|
|
22
|
+
state.reports = { data: [], error: null, isSuccess: true }
|
|
23
|
+
expect(render()).toBe('')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('shows the card for a readable report', () => {
|
|
27
|
+
state.reports = { data: [report], error: null, isSuccess: true }
|
|
28
|
+
expect(render()).toContain('Flux v2.7.5')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('refreshes the report and its FluxInstance at the same interval', () => {
|
|
32
|
+
state.reports = { data: [report], error: null, isSuccess: true }
|
|
33
|
+
renderToString(<MemoryRouter><FluxOperatorCard available refetchInterval={120_000} /></MemoryRouter>)
|
|
34
|
+
expect(state.options.fluxreports.refetchInterval).toBe(120_000)
|
|
35
|
+
expect(state.options.fluxinstances.refetchInterval).toBe(120_000)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useNavigate } from 'react-router-dom'
|
|
2
|
+
import { FluxReportCard } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { pickFluxReport, summarizeFluxReport } from '@skyhook-io/k8s-ui/utils/flux-report'
|
|
4
|
+
import { useResources } from '../../api/client'
|
|
5
|
+
import { relatedResourcePath } from '../../utils/navigation'
|
|
6
|
+
|
|
7
|
+
const GROUP = 'fluxcd.controlplane.io'
|
|
8
|
+
|
|
9
|
+
// FluxOperatorCard shows Flux Operator's FluxReport above the GitOps table,
|
|
10
|
+
// read as the caller. No readable report means no card: never zeros for
|
|
11
|
+
// "couldn't read".
|
|
12
|
+
export function FluxOperatorCard({ available, refetchInterval }: { available: boolean; refetchInterval?: number }) {
|
|
13
|
+
const navigate = useNavigate()
|
|
14
|
+
const reports = useResources<any>('fluxreports', undefined, GROUP, { enabled: available, refetchInterval })
|
|
15
|
+
const picked = reports.isSuccess && !reports.error ? pickFluxReport(reports.data ?? []) : null
|
|
16
|
+
const namespace = picked?.report.metadata?.namespace
|
|
17
|
+
const instances = useResources<any>('fluxinstances', namespace, GROUP, { enabled: available && !!namespace, refetchInterval })
|
|
18
|
+
if (!picked) return null
|
|
19
|
+
const instance = instances.isSuccess ? instances.data?.[0] : undefined
|
|
20
|
+
return (
|
|
21
|
+
<FluxReportCard
|
|
22
|
+
summary={summarizeFluxReport(picked.report, picked.total)}
|
|
23
|
+
instance={instance ? { namespace: instance.metadata?.namespace, name: instance.metadata?.name, version: instance.spec?.distribution?.version } : null}
|
|
24
|
+
onOpenResource={(ref) => navigate(relatedResourcePath(ref))}
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { afterEach, expect, it, vi } from 'vitest'
|
|
7
|
+
import { GitOpsView } from './GitOpsView'
|
|
8
|
+
|
|
9
|
+
// The table polls every row kind, so each list must ask the server for the
|
|
10
|
+
// summary shape: full Applications and Kustomizations carry status.resources
|
|
11
|
+
// and status.inventory, which the rows never read.
|
|
12
|
+
|
|
13
|
+
const lists = vi.hoisted(() => vi.fn())
|
|
14
|
+
vi.mock('../../api/client', async (importOriginal) => ({
|
|
15
|
+
...(await importOriginal<typeof import('../../api/client')>()),
|
|
16
|
+
fetchResourceList: (kind: string, options: unknown) => {
|
|
17
|
+
lists(kind, options)
|
|
18
|
+
return Promise.resolve({ items: [], coverage: { status: 'complete' } })
|
|
19
|
+
},
|
|
20
|
+
}))
|
|
21
|
+
vi.mock('../../api/apiResources', async (importOriginal) => ({
|
|
22
|
+
...(await importOriginal<typeof import('../../api/apiResources')>()),
|
|
23
|
+
useAPIResources: () => ({
|
|
24
|
+
data: [
|
|
25
|
+
{ name: 'applications', group: 'argoproj.io' },
|
|
26
|
+
{ name: 'kustomizations', group: 'kustomize.toolkit.fluxcd.io' },
|
|
27
|
+
{ name: 'helmreleases', group: 'helm.toolkit.fluxcd.io' },
|
|
28
|
+
{ name: 'gitrepositories', group: 'source.toolkit.fluxcd.io' },
|
|
29
|
+
],
|
|
30
|
+
isLoading: false,
|
|
31
|
+
}),
|
|
32
|
+
}))
|
|
33
|
+
vi.mock('../ui/Toast', () => ({ useToast: () => ({ showError: vi.fn(), showSuccess: vi.fn(), showToast: vi.fn() }) }))
|
|
34
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected' } }) }))
|
|
35
|
+
vi.mock('../../context/RadarUpgradeHost', () => ({ useRadarUpgradeHost: () => ({}) }))
|
|
36
|
+
vi.mock('../useContextSwitchFlow', () => ({ useContextSwitchFlow: () => ({ confirmDialog: null, requestSwitch: vi.fn() }) }))
|
|
37
|
+
vi.mock('../../hooks/useKeyboardShortcuts', () => ({ useRegisterShortcut: () => {} }))
|
|
38
|
+
vi.mock('../../hooks/usePreviousIntegrationSettings', () => ({ usePreviousIntegrationSettings: () => ({}), previousSettingsNote: () => undefined }))
|
|
39
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
40
|
+
|
|
41
|
+
afterEach(() => { document.body.innerHTML = '' })
|
|
42
|
+
|
|
43
|
+
it('lists every GitOps row kind in the summary shape', async () => {
|
|
44
|
+
vi.stubGlobal('fetch', vi.fn(() => new Promise<Response>(() => {})))
|
|
45
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
46
|
+
const host = document.createElement('div')
|
|
47
|
+
document.body.append(host)
|
|
48
|
+
const root = createRoot(host)
|
|
49
|
+
await act(async () => root.render(
|
|
50
|
+
<MemoryRouter initialEntries={['/gitops']}>
|
|
51
|
+
<QueryClientProvider client={client}><GitOpsView namespaces={[]} onOpenResource={() => {}} /></QueryClientProvider>
|
|
52
|
+
</MemoryRouter>,
|
|
53
|
+
))
|
|
54
|
+
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)) })
|
|
55
|
+
expect(lists.mock.calls.map(([kind]) => kind).sort()).toEqual(['applications', 'gitrepositories', 'helmreleases', 'kustomizations'])
|
|
56
|
+
for (const [, options] of lists.mock.calls) expect(options).toMatchObject({ summary: true })
|
|
57
|
+
await act(async () => root.unmount())
|
|
58
|
+
client.clear()
|
|
59
|
+
})
|
|
@@ -59,6 +59,7 @@ import {
|
|
|
59
59
|
} from '@skyhook-io/k8s-ui'
|
|
60
60
|
import { useToast } from '../ui/Toast'
|
|
61
61
|
import { useContextSwitchFlow } from '../useContextSwitchFlow'
|
|
62
|
+
import { FluxOperatorCard } from './FluxOperatorCard'
|
|
62
63
|
import { useDestinationCluster } from './useDestinationCluster'
|
|
63
64
|
import { destinationToast } from './destination-toast'
|
|
64
65
|
|
|
@@ -103,9 +104,7 @@ type ArgoSyncDialogTarget =
|
|
|
103
104
|
|
|
104
105
|
const KIND_BY_NAME = new Map(GITOPS_KINDS.map((k) => [k.name, k]))
|
|
105
106
|
|
|
106
|
-
//
|
|
107
|
-
// freshness signal advertises ("Auto-refreshes every 2m"). Single source of
|
|
108
|
-
// truth so the signal can't drift from the actual refetchInterval below.
|
|
107
|
+
// Fallback poll for the rows; SSE changes to row kinds refetch them within 15s (App.tsx slow tier).
|
|
109
108
|
const GITOPS_ROWS_REFRESH_INTERVAL_MS = 120_000
|
|
110
109
|
|
|
111
110
|
interface ResourceCountsResponse {
|
|
@@ -137,6 +136,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
137
136
|
const { connection } = useConnection()
|
|
138
137
|
const namespacesParam = namespaces.join(',')
|
|
139
138
|
const { data: apiResources, isLoading: apiResourcesLoading } = useAPIResources()
|
|
139
|
+
const fluxReportsServed = !!apiResources?.some((r) => r.name === 'fluxreports' && r.group === 'fluxcd.controlplane.io')
|
|
140
140
|
|
|
141
141
|
const argoSync = useArgoSync()
|
|
142
142
|
const argoRefresh = useArgoRefresh()
|
|
@@ -202,7 +202,9 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
202
202
|
const failures: unknown[] = []
|
|
203
203
|
const fetchResourceList = async (kind: string, group: string, namespacesParam: string): Promise<any[]> => {
|
|
204
204
|
try {
|
|
205
|
-
|
|
205
|
+
// Summary drops status.resources / status.inventory, which the rows
|
|
206
|
+
// never read and which dominate the payload on large fleets.
|
|
207
|
+
const result = await fetchCoveredResourceList<any>(kind, { group, namespaces: namespacesParam ? namespacesParam.split(',') : [], summary: true })
|
|
206
208
|
coverage.push(result.coverage)
|
|
207
209
|
return result.items
|
|
208
210
|
} catch (error) {
|
|
@@ -337,6 +339,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
337
339
|
return (
|
|
338
340
|
<>
|
|
339
341
|
<SharedGitOpsTableView
|
|
342
|
+
headerSlot={fluxReportsServed ? <FluxOperatorCard available refetchInterval={GITOPS_ROWS_REFRESH_INTERVAL_MS} /> : undefined}
|
|
340
343
|
rows={rowsQuery.data?.rows ?? []}
|
|
341
344
|
coverageStatus={rowsQuery.data?.coverageStatus ?? 'unknown'}
|
|
342
345
|
loading={apiResourcesLoading || countsQuery.isLoading || rowsQuery.isLoading || coldRetrying}
|