@skyhook-io/radar-app 1.20.3 → 1.21.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/package.json +10 -9
- package/src/App.tsx +54 -10
- package/src/api/client.audit-gating.test.tsx +105 -5
- package/src/api/client.auditBadgesSync.test.tsx +118 -0
- package/src/api/client.capabilitiesPoll.test.ts +61 -0
- package/src/api/client.ts +129 -5
- package/src/api/namespaceScopeRetry.test.ts +14 -0
- package/src/api/radarFeatures.ts +7 -0
- package/src/api/substrateHealth.ts +134 -0
- package/src/api/velero.test.ts +60 -0
- package/src/api/velero.ts +201 -0
- package/src/api/vulnerabilities.ts +255 -0
- package/src/components/NamespaceSwitcher.tsx +3 -1
- package/src/components/audit/AuditView.tsx +4 -0
- package/src/components/audit/ChecksViewTabs.test.tsx +33 -5
- package/src/components/audit/ChecksViewTabs.tsx +11 -1
- package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
- package/src/components/audit/UpgradeReadinessView.tsx +60 -2
- package/src/components/audit/VulnerabilitiesView.tsx +907 -0
- package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
- package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
- package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
- package/src/components/cnpg/CNPGView.tsx +43 -117
- package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
- package/src/components/cnpg/host.tsx +2 -2
- package/src/components/cnpg/routes.ts +3 -1
- package/src/components/cnpg/shared.tsx +5 -53
- package/src/components/cnpg/useCNPGNavigate.ts +1 -21
- package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
- package/src/components/community.tsx +42 -0
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
- package/src/components/diagnose/investigationMetrics.test.ts +20 -0
- package/src/components/diagnose/investigationMetrics.ts +2 -1
- package/src/components/dock/BottomDock.tsx +1 -0
- package/src/components/dock/LogsTab.tsx +3 -0
- package/src/components/gitops/GitOpsView.tsx +1 -1
- package/src/components/helm/HelmDrawerFrame.tsx +1 -1
- package/src/components/helm/HelmView.tsx +20 -16
- package/src/components/helm/OwnedResources.tsx +4 -3
- package/src/components/home/ClusterHealthCard.tsx +3 -1
- package/src/components/home/HomeAgentBlock.tsx +3 -0
- package/src/components/home/HomeView.tsx +7 -0
- package/src/components/home/MCPSetupDialog.test.tsx +19 -12
- package/src/components/home/MCPSetupDialog.tsx +4 -2
- package/src/components/home/mcpToolCatalog.ts +15 -2
- package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
- package/src/components/home/useVulnerabilitiesRow.ts +50 -0
- package/src/components/logs/LogsViewer.tsx +3 -1
- package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
- package/src/components/logs/MultiPodLogsTab.tsx +9 -5
- package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
- package/src/components/nav/PrimaryNavRail.tsx +174 -29
- package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
- package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
- package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
- package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
- package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
- package/src/components/resources/ResourcesView.tsx +12 -6
- package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
- package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
- package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
- package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
- package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +3 -2
- package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
- package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
- package/src/components/timeline/TimelineView.tsx +3 -1
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
- package/src/components/traffic/TrafficData.test.tsx +37 -0
- package/src/components/traffic/TrafficData.tsx +27 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -7
- package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
- package/src/components/traffic/TrafficGraph.test.tsx +269 -0
- package/src/components/traffic/TrafficGraph.tsx +135 -64
- package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
- package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
- package/src/components/traffic/TrafficView.tsx +46 -129
- package/src/components/traffic/trafficFilters.test.ts +172 -1
- package/src/components/traffic/trafficFilters.ts +139 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
- package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
- package/src/components/ui/UpdateNotification.test.tsx +31 -2
- package/src/components/ui/UpdateNotification.tsx +34 -17
- package/src/components/ui/command-items.ts +24 -1
- package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
- package/src/components/velero/VeleroBackupNow.tsx +143 -0
- package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
- package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
- package/src/components/velero/VeleroDetailPage.tsx +148 -0
- package/src/components/velero/VeleroKindLists.test.tsx +48 -0
- package/src/components/velero/VeleroKindLists.tsx +43 -0
- package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
- package/src/components/velero/VeleroLocations.test.tsx +86 -0
- package/src/components/velero/VeleroLocations.tsx +240 -0
- package/src/components/velero/VeleroOverview.test.tsx +311 -0
- package/src/components/velero/VeleroOverview.tsx +485 -0
- package/src/components/velero/VeleroPages.test.tsx +516 -0
- package/src/components/velero/VeleroPages.tsx +1056 -0
- package/src/components/velero/VeleroRunLists.tsx +309 -0
- package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
- package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
- package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
- package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
- package/src/components/velero/VeleroSchedules.tsx +255 -0
- package/src/components/velero/VeleroView.tsx +59 -0
- package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
- package/src/components/velero/attention.test.ts +178 -0
- package/src/components/velero/attention.ts +281 -0
- package/src/components/velero/backupDelete.test.tsx +91 -0
- package/src/components/velero/backupDelete.tsx +182 -0
- package/src/components/velero/coverage.test.ts +87 -0
- package/src/components/velero/coverage.ts +150 -0
- package/src/components/velero/host.tsx +86 -0
- package/src/components/velero/routes.ts +78 -0
- package/src/components/velero/runs.tsx +121 -0
- package/src/components/velero/shared.test.ts +84 -0
- package/src/components/velero/shared.tsx +423 -0
- package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
- package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
- package/src/components/velero/velero.fixtures.ts +61 -0
- package/src/components/velero/workspaceRoute.ts +21 -0
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +167 -0
- package/src/components/vulnerabilities/parts.test.ts +72 -0
- package/src/components/vulnerabilities/parts.tsx +291 -0
- package/src/components/workload/WorkloadView.tsx +64 -27
- package/src/components/workspace/DrawerTrailBack.tsx +32 -0
- package/src/components/workspace/WorkspaceFrame.tsx +71 -0
- package/src/components/workspace/coverage.ts +61 -0
- package/src/components/workspace/layout.test.tsx +29 -1
- package/src/components/workspace/layout.tsx +15 -5
- package/src/components/workspace/sidebar.ts +9 -0
- package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
- package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
- package/src/desktop/AboutDialog.test.ts +12 -0
- package/src/desktop/AboutDialog.tsx +151 -0
- package/src/desktop/WindowsTitleBar.tsx +359 -0
- package/src/desktop/titleBar.test.ts +61 -0
- package/src/desktop/titleBar.ts +45 -0
- package/src/index.css +19 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +14 -2
- package/src/integrations/resourceHosts.tsx +22 -6
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.test.ts +11 -0
- package/src/integrations/workspaceRoutes.ts +3 -1
- package/src/integrations/workspaceScreens.tsx +2 -0
- package/src/main.tsx +8 -0
- package/src/utils/desktop-zoom.test.ts +53 -0
- package/src/utils/desktop-zoom.ts +30 -0
- package/src/utils/staleAssetPrompt.test.tsx +76 -0
- package/src/utils/staleAssetPrompt.tsx +32 -0
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { WithTooltip } from '../ui/Tooltip'
|
|
3
|
+
import { useSearchParams } from 'react-router-dom'
|
|
4
|
+
import { clsx } from 'clsx'
|
|
5
|
+
import { AlertTriangle, CircleDashed, ExternalLink, Info, Search, ShieldAlert, ShieldCheck, X } from 'lucide-react'
|
|
6
|
+
import {
|
|
7
|
+
Collapse,
|
|
8
|
+
CollapseChevron,
|
|
9
|
+
EmptyState,
|
|
10
|
+
FreshnessControl,
|
|
11
|
+
getRadarUpgradeRequirement,
|
|
12
|
+
PageHeader,
|
|
13
|
+
PaneLoader,
|
|
14
|
+
RadarUpgradeAction,
|
|
15
|
+
radarUpgradeDetail,
|
|
16
|
+
radarUpgradeHeadline,
|
|
17
|
+
useDebouncedValue,
|
|
18
|
+
useDisclosure,
|
|
19
|
+
VULN_SEVERITY_TEXT,
|
|
20
|
+
VULN_SEVERITY_BAR,
|
|
21
|
+
DistributionBar,
|
|
22
|
+
DistributionLegendChip,
|
|
23
|
+
FilterPill,
|
|
24
|
+
Input,
|
|
25
|
+
} from '@skyhook-io/k8s-ui'
|
|
26
|
+
import { SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
|
|
27
|
+
import { formatRelativeAgeTime } from '@skyhook-io/k8s-ui/utils/format'
|
|
28
|
+
import { ApiError } from '../../api/client'
|
|
29
|
+
import {
|
|
30
|
+
useVulnerabilities,
|
|
31
|
+
isKindUnknown,
|
|
32
|
+
parseWorkloadParam,
|
|
33
|
+
workloadParam,
|
|
34
|
+
type VulnerabilitiesResponse,
|
|
35
|
+
type VulnerabilityCVE,
|
|
36
|
+
type VulnerabilityFix,
|
|
37
|
+
type VulnerabilitySeverity,
|
|
38
|
+
type VulnerabilityView,
|
|
39
|
+
type VulnerabilityWorkload,
|
|
40
|
+
type VulnerabilityWorkloadRef,
|
|
41
|
+
type VulnerableImage,
|
|
42
|
+
} from '../../api/vulnerabilities'
|
|
43
|
+
import type { SelectedResource } from '../../types'
|
|
44
|
+
import { useConnection } from '../../context/ConnectionContext'
|
|
45
|
+
import { ChecksViewTabs } from './ChecksViewTabs'
|
|
46
|
+
import {
|
|
47
|
+
SEVERITIES,
|
|
48
|
+
SeverityBadge,
|
|
49
|
+
SeverityBar,
|
|
50
|
+
SeverityCounts,
|
|
51
|
+
distinctNamespaces,
|
|
52
|
+
totalFindings,
|
|
53
|
+
FindingTotal,
|
|
54
|
+
installedLabel,
|
|
55
|
+
ImageName,
|
|
56
|
+
FixVersion,
|
|
57
|
+
ecosystemLabel,
|
|
58
|
+
findingsCertainty,
|
|
59
|
+
readsComplete,
|
|
60
|
+
workloadsByReplicaSet,
|
|
61
|
+
ClearedCount,
|
|
62
|
+
OTHER_BUILD_TIP,
|
|
63
|
+
imageParts,
|
|
64
|
+
gapSentence,
|
|
65
|
+
workloadSummary,
|
|
66
|
+
} from '../vulnerabilities/parts'
|
|
67
|
+
|
|
68
|
+
interface VulnerabilitiesViewProps {
|
|
69
|
+
namespaces: string[]
|
|
70
|
+
onNavigateToResource: (resource: SelectedResource) => void
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const VIEWS: { key: VulnerabilityView; label: string }[] = [
|
|
74
|
+
{ key: 'image', label: 'By image' },
|
|
75
|
+
{ key: 'fix', label: 'By fix' },
|
|
76
|
+
{ key: 'cve', label: 'By CVE' },
|
|
77
|
+
{ key: 'workload', label: 'By workload' },
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
const CHIP = 'min-h-8 rounded-full border px-3 text-xs font-medium transition-colors'
|
|
81
|
+
const CHIP_ON = 'selection-strong border-accent text-theme-text-primary'
|
|
82
|
+
|
|
83
|
+
// Each table's columns, shared by its header, rows and expanded sub-rows so
|
|
84
|
+
// detail lines up under the column it belongs to. Short values get fixed
|
|
85
|
+
// tracks; the text columns take the rest.
|
|
86
|
+
const IMAGE_COLS = 'grid-cols-[minmax(220px,1.6fr)_minmax(180px,1.2fr)_88px_minmax(0,2fr)_72px]'
|
|
87
|
+
const FIX_COLS = 'grid-cols-[minmax(200px,1.2fr)_minmax(220px,1.5fr)_120px_minmax(0,1.6fr)_64px_80px]'
|
|
88
|
+
const CVE_COLS = 'grid-cols-[minmax(260px,1.6fr)_80px_48px_minmax(200px,1.6fr)_56px_64px_80px]'
|
|
89
|
+
const WORKLOAD_COLS = 'grid-cols-[minmax(200px,1.4fr)_minmax(180px,1.2fr)_minmax(0,2.4fr)]'
|
|
90
|
+
const HEAD = 'grid gap-4 border-b border-theme-border py-2 pl-10 pr-3 text-[11px] font-semibold uppercase tracking-wider text-theme-text-tertiary'
|
|
91
|
+
const FOLD_ROW = 'grid grid-cols-[minmax(220px,1.6fr)_minmax(0,4fr)] items-baseline gap-4 py-1.5 pl-10 pr-3 text-xs'
|
|
92
|
+
const SUB = 'grid items-baseline gap-4 py-1.5 pl-10 pr-3 text-xs'
|
|
93
|
+
|
|
94
|
+
const toResource = (w: VulnerabilityWorkloadRef): SelectedResource => ({ kind: w.kind, group: w.group, namespace: w.namespace, name: w.name })
|
|
95
|
+
|
|
96
|
+
// The Checks › Vulnerabilities tab: scanner findings for the images that run
|
|
97
|
+
// now, from /api/vulnerabilities. Filters live in the URL so a filtered view
|
|
98
|
+
// is a shareable link; they run server-side, and the summary tiles always
|
|
99
|
+
// describe the unfiltered scope.
|
|
100
|
+
export function VulnerabilitiesView({ namespaces, onNavigateToResource }: VulnerabilitiesViewProps) {
|
|
101
|
+
const [params, setParams] = useSearchParams()
|
|
102
|
+
const view = (VIEWS.find((v) => v.key === params.get('by'))?.key ?? 'image') as VulnerabilityView
|
|
103
|
+
const severities = (params.get('severity') ?? '').split(',').filter((s): s is VulnerabilitySeverity => LEGEND.some((x) => x.key === s))
|
|
104
|
+
const fixableOnly = params.get('fixable') === '1'
|
|
105
|
+
const queryDraft = params.get('q') ?? ''
|
|
106
|
+
const workload = parseWorkloadParam(params.get('workload'))
|
|
107
|
+
const query = useDebouncedValue(queryDraft.trim(), 300)
|
|
108
|
+
const { connection } = useConnection()
|
|
109
|
+
|
|
110
|
+
// Typing and chip toggles replace the entry; a new view or a drill-down
|
|
111
|
+
// pushes one, so Back returns to the list it came from.
|
|
112
|
+
const update = (mutate: (p: URLSearchParams) => void, push = false) => {
|
|
113
|
+
const next = new URLSearchParams(params)
|
|
114
|
+
mutate(next)
|
|
115
|
+
setParams(next, { replace: !push })
|
|
116
|
+
}
|
|
117
|
+
const { data, isLoading, isFetching, isPlaceholderData, error, dataUpdatedAt, refetch } = useVulnerabilities({ view, namespaces, severities, fixableOnly, query, workload })
|
|
118
|
+
|
|
119
|
+
const toggleSeverity = (s: VulnerabilitySeverity) => update((p) => {
|
|
120
|
+
const next = severities.includes(s) ? severities.filter((x) => x !== s) : [...severities, s]
|
|
121
|
+
if (next.length > 0) p.set('severity', next.join(','))
|
|
122
|
+
else p.delete('severity')
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
if (isLoading) {
|
|
126
|
+
return (
|
|
127
|
+
<div className="flex-1 flex flex-col min-h-0 p-4 gap-4">
|
|
128
|
+
<ChecksViewTabs />
|
|
129
|
+
<PaneLoader label="Reading vulnerability reports…" className="flex-1" />
|
|
130
|
+
</div>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
if (!data) {
|
|
134
|
+
return (
|
|
135
|
+
<div className="flex-1 flex flex-col min-h-0 p-4 gap-4">
|
|
136
|
+
<ChecksViewTabs />
|
|
137
|
+
<div className="flex flex-1 items-center justify-center"><VulnerabilitiesError error={error} /></div>
|
|
138
|
+
</div>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// By fix lists only fixable findings, and hides the chip that says so.
|
|
143
|
+
const filtered = severities.length > 0 || (fixableOnly && view !== 'fix') || query !== '' || !!workload
|
|
144
|
+
// Narrowed only to a workload whose images are all clean or unscanned:
|
|
145
|
+
// the folds below list them, so "nothing matches" would mislead.
|
|
146
|
+
const workloadFolds = !!workload && (view === 'image' || view === 'workload') && severities.length === 0 && !fixableOnly && query === '' &&
|
|
147
|
+
((data.unscanned ?? []).length > 0 || (data.clean ?? []).length > 0 || (data.cleanWorkloads ?? []).length > 0)
|
|
148
|
+
const rows = view === 'cve' ? data.cves ?? [] : view === 'workload' ? data.workloads ?? [] : view === 'fix' ? data.fixes ?? [] : data.images ?? []
|
|
149
|
+
|
|
150
|
+
// With nothing scanned or readable there are no counts to show or filter.
|
|
151
|
+
const known = findingsCertainty(data) !== 'unknown'
|
|
152
|
+
// A new view or filter starts again from the first page of rows.
|
|
153
|
+
const pageKey = JSON.stringify([view, namespaces, severities, fixableOnly, query, workload])
|
|
154
|
+
return (
|
|
155
|
+
<div aria-busy={isFetching} className="flex-1 flex flex-col min-h-0 p-4 gap-4 overflow-auto">
|
|
156
|
+
<ChecksViewTabs />
|
|
157
|
+
<PageHeader
|
|
158
|
+
icon={ShieldAlert}
|
|
159
|
+
title="Vulnerabilities"
|
|
160
|
+
description="Known CVEs in the images that run now, from Trivy Operator's reports."
|
|
161
|
+
actions={<FreshnessControl mode="auto" dataUpdatedAt={dataUpdatedAt} isFetching={isFetching} onRefresh={() => refetch()} connectionState={connection.state} />}
|
|
162
|
+
/>
|
|
163
|
+
|
|
164
|
+
{/* Triage header, as on Best practices: the headline, the severity
|
|
165
|
+
distribution, and its legend as the severity filters. */}
|
|
166
|
+
<div className={clsx('flex flex-col gap-3.5 rounded-2xl border border-theme-border bg-theme-surface p-4 shadow-theme-sm transition-opacity', isPlaceholderData && 'opacity-60')}>
|
|
167
|
+
<div className="flex flex-wrap items-end justify-between gap-3">
|
|
168
|
+
<SummaryHeadline data={data} />
|
|
169
|
+
<div className="relative">
|
|
170
|
+
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-theme-text-tertiary" aria-hidden />
|
|
171
|
+
<Input
|
|
172
|
+
type="search"
|
|
173
|
+
aria-label="Search"
|
|
174
|
+
value={queryDraft}
|
|
175
|
+
onChange={(e) => update((p) => (e.target.value ? p.set('q', e.target.value) : p.delete('q')))}
|
|
176
|
+
placeholder="Image, CVE, package or workload"
|
|
177
|
+
className="w-72 rounded-lg border border-theme-border-light bg-theme-base py-1.5 pl-9 pr-3 text-sm text-theme-text-primary placeholder-theme-text-disabled focus:outline-none focus:ring-2 focus:ring-[var(--color-radar-accent,var(--accent))]"
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
{known && <DistributionBar
|
|
183
|
+
ariaLabel="Findings by severity"
|
|
184
|
+
segments={LEGEND.map((s) => ({ key: s.key, count: data.summary.counts[s.key], fillClass: VULN_SEVERITY_BAR[s.key.toUpperCase()] }))}
|
|
185
|
+
/>}
|
|
186
|
+
|
|
187
|
+
<div className="flex flex-wrap items-center gap-1.5">
|
|
188
|
+
{known && LEGEND.map((s) => (
|
|
189
|
+
<DistributionLegendChip
|
|
190
|
+
key={s.key}
|
|
191
|
+
label={s.label}
|
|
192
|
+
count={data.summary.counts[s.key]}
|
|
193
|
+
fillClass={VULN_SEVERITY_BAR[s.key.toUpperCase()]}
|
|
194
|
+
textClass={VULN_SEVERITY_TEXT[s.key.toUpperCase()]}
|
|
195
|
+
active={severities.includes(s.key)}
|
|
196
|
+
onClick={() => toggleSeverity(s.key)}
|
|
197
|
+
/>
|
|
198
|
+
))}
|
|
199
|
+
{known && view !== 'fix' && (
|
|
200
|
+
<>
|
|
201
|
+
<span aria-hidden className="mx-1.5 h-5 w-px bg-theme-border" />
|
|
202
|
+
<FilterPill label="Has a fix" active={fixableOnly} onClick={() => update((p) => (fixableOnly ? p.delete('fixable') : p.set('fixable', '1')))} />
|
|
203
|
+
</>
|
|
204
|
+
)}
|
|
205
|
+
{workload && (
|
|
206
|
+
<>
|
|
207
|
+
<span aria-hidden className="mx-1.5 h-5 w-px bg-theme-border" />
|
|
208
|
+
<span className={clsx(CHIP, CHIP_ON, 'inline-flex items-center gap-1.5 pr-1.5')}>
|
|
209
|
+
{workload.name}
|
|
210
|
+
<span className="font-normal text-theme-text-tertiary">{workload.kind} · {workload.namespace}</span>
|
|
211
|
+
<button type="button" aria-label="Show every workload" onClick={() => update((p) => p.delete('workload'))} className="rounded-full p-0.5 hover:bg-theme-hover">
|
|
212
|
+
<X className="h-3 w-3" aria-hidden />
|
|
213
|
+
</button>
|
|
214
|
+
</span>
|
|
215
|
+
</>
|
|
216
|
+
)}
|
|
217
|
+
<div role="group" aria-label="Group by" className="ml-auto flex rounded-md border border-theme-border bg-theme-elevated p-0.5">
|
|
218
|
+
{VIEWS.map((v) => (
|
|
219
|
+
<button
|
|
220
|
+
key={v.key}
|
|
221
|
+
type="button"
|
|
222
|
+
aria-pressed={view === v.key}
|
|
223
|
+
onClick={() => update((p) => (v.key === 'image' ? p.delete('by') : p.set('by', v.key)), true)}
|
|
224
|
+
className={clsx('min-h-7 rounded px-3 text-xs font-medium transition-colors', view === v.key ? 'bg-theme-hover text-theme-text-primary' : 'text-theme-text-secondary hover:text-theme-text-primary')}
|
|
225
|
+
>
|
|
226
|
+
{v.label}
|
|
227
|
+
</button>
|
|
228
|
+
))}
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<div className="flex flex-col gap-1.5">
|
|
234
|
+
<CoverageNotes data={data} filtered={filtered} />
|
|
235
|
+
{error && <p className="text-xs text-warning-text">Couldn't refresh: {error instanceof Error ? error.message : 'request failed'}. Showing the last answer.</p>}
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
{/* A view switched to for the first time shows the last answer's
|
|
239
|
+
header while its own rows load. */}
|
|
240
|
+
{data.view !== view ? (
|
|
241
|
+
<PaneLoader label="Reading vulnerability reports…" className="min-h-48" />
|
|
242
|
+
) : (
|
|
243
|
+
<>
|
|
244
|
+
{rows.length === 0 ? (
|
|
245
|
+
<EmptyState
|
|
246
|
+
tone="neutral"
|
|
247
|
+
icon={ShieldAlert}
|
|
248
|
+
headline={emptyHeadline(view, filtered, data, workloadFolds ? workload : null)}
|
|
249
|
+
body={filtered && !workloadFolds ? 'Clear a filter to see more.' : data.summary.imagesScanned === 0 && (data.unscanned ?? []).length > 0 ? 'No report covers a running image yet. Trivy Operator scans workloads as they appear; if this persists, check that it is running and that its target namespaces include these.' : undefined}
|
|
250
|
+
/>
|
|
251
|
+
) : view === 'fix' ? (
|
|
252
|
+
<Paged key={pageKey} rows={data.fixes ?? []}>{(rows) => <FixTable fixes={rows} onOpen={(w) => onNavigateToResource(toResource(w))} onShowCVE={(id) => update((p) => { p.set('by', 'cve'); p.set('q', id) }, true)} />}</Paged>
|
|
253
|
+
) : view === 'cve' ? (
|
|
254
|
+
<Paged key={pageKey} rows={data.cves ?? []}>{(rows) => <CVETable cves={rows} onOpen={(w) => onNavigateToResource(toResource(w))} />}</Paged>
|
|
255
|
+
) : view === 'workload' ? (
|
|
256
|
+
<Paged key={pageKey} rows={data.workloads ?? []}>{(rows) => <WorkloadTable
|
|
257
|
+
workloads={rows}
|
|
258
|
+
severities={severities}
|
|
259
|
+
query={query}
|
|
260
|
+
namespaces={namespaces}
|
|
261
|
+
onOpen={(w) => onNavigateToResource(toResource(w))}
|
|
262
|
+
onShow={(w, by) => update((p) => { p.set('by', by); p.set('workload', workloadParam(w)); p.delete('q') }, true)}
|
|
263
|
+
/>}</Paged>
|
|
264
|
+
) : (
|
|
265
|
+
<Paged key={pageKey} rows={data.images ?? []}>{(rows) => <ImageTable
|
|
266
|
+
images={rows}
|
|
267
|
+
onOpen={(w) => onNavigateToResource(toResource(w))}
|
|
268
|
+
onOpenReport={(img) => onNavigateToResource({ kind: img.report.kind, group: img.report.group, namespace: img.report.namespace ?? '', name: img.report.name })}
|
|
269
|
+
/>}</Paged>
|
|
270
|
+
)}
|
|
271
|
+
|
|
272
|
+
{(data.coverage.rowsOmitted ?? 0) > 0 && (
|
|
273
|
+
<p className="text-xs text-theme-text-tertiary">{data.coverage.rowsOmitted} more rows not shown. Narrow with a filter or the namespace picker.</p>
|
|
274
|
+
)}
|
|
275
|
+
|
|
276
|
+
{!severities.length && !fixableOnly && (view === 'image' || view === 'workload') && (
|
|
277
|
+
<CleanList data={data} view={view} onOpen={(w) => onNavigateToResource(toResource(w))} />
|
|
278
|
+
)}
|
|
279
|
+
<UnscannedList data={data} onOpen={(w) => onNavigateToResource(toResource(w))} />
|
|
280
|
+
</>
|
|
281
|
+
)}
|
|
282
|
+
</div>
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function emptyHeadline(view: VulnerabilityView, filtered: boolean, data: VulnerabilitiesResponse, workload: { name: string } | null): string {
|
|
287
|
+
// Narrowed to one workload, the folds below say what it runs.
|
|
288
|
+
if (workload && (data.unscanned ?? []).length > 0) {
|
|
289
|
+
const scanned = (data.clean ?? []).length > 0 || (data.cleanWorkloads ?? []).length > 0
|
|
290
|
+
return scanned ? `No reported CVEs for ${workload.name}, and not every image it runs is scanned yet` : `No report yet for the images ${workload.name} runs`
|
|
291
|
+
}
|
|
292
|
+
if (workload && ((data.clean ?? []).length > 0 || (data.cleanWorkloads ?? []).length > 0)) return `No CVEs reported for ${workload.name}`
|
|
293
|
+
if (filtered) return 'Nothing matches these filters'
|
|
294
|
+
const s = data.summary
|
|
295
|
+
if (!readsComplete(data.coverage) && totalFindings(s.counts) === 0 && s.imagesClean === 0) return 'No findings could be read in this scope'
|
|
296
|
+
if (s.imagesScanned === 0) return 'No scanned images run in this scope'
|
|
297
|
+
if (view === 'fix' && totalFindings(s.counts) > 0) return `None of the ${totalFindings(s.counts)} reported findings has a fixed release yet`
|
|
298
|
+
return `No CVEs reported for the ${s.imagesScanned} scanned ${s.imagesScanned === 1 ? 'image' : 'images'} that run`
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function VulnerabilitiesError({ error }: { error: unknown }) {
|
|
302
|
+
const upgrade = getRadarUpgradeRequirement(error)
|
|
303
|
+
if (upgrade) {
|
|
304
|
+
return <EmptyState tone="neutral" icon={ShieldAlert} headline={radarUpgradeHeadline('Vulnerability views')} body={radarUpgradeDetail(upgrade)} action={<RadarUpgradeAction requirement={upgrade} />} />
|
|
305
|
+
}
|
|
306
|
+
// A cluster without the report kind: nothing failed, there is no scanner.
|
|
307
|
+
if (isKindUnknown(error)) {
|
|
308
|
+
return (
|
|
309
|
+
<EmptyState
|
|
310
|
+
tone="neutral"
|
|
311
|
+
icon={ShieldAlert}
|
|
312
|
+
headline="No vulnerability reports in this cluster"
|
|
313
|
+
body="Radar doesn't scan images itself. It reads the VulnerabilityReports Trivy Operator writes, and this cluster doesn't serve that kind."
|
|
314
|
+
action={<a href="https://aquasecurity.github.io/trivy-operator/latest/getting-started/installation/" target="_blank" rel="noreferrer" className="btn-brand px-3 py-1.5 text-xs font-medium">How to install Trivy Operator</a>}
|
|
315
|
+
/>
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
return (
|
|
319
|
+
<EmptyState
|
|
320
|
+
tone="neutral"
|
|
321
|
+
icon={AlertTriangle}
|
|
322
|
+
headline="Couldn't read vulnerability reports"
|
|
323
|
+
body={error instanceof ApiError ? error.message : 'Failed to read vulnerability reports.'}
|
|
324
|
+
/>
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Severities in the legend, unrated last: each is also a filter.
|
|
329
|
+
const LEGEND: { key: VulnerabilitySeverity; label: string }[] = [...SEVERITIES.map(({ key, label }) => ({ key, label })), { key: 'unknown', label: 'Unrated' }]
|
|
330
|
+
|
|
331
|
+
// The headline: images with Critical CVEs, then the other totals in a line.
|
|
332
|
+
// Every total is a lower bound while anything is unscanned or unread.
|
|
333
|
+
function SummaryHeadline({ data }: { data: VulnerabilitiesResponse }) {
|
|
334
|
+
const s = data.summary
|
|
335
|
+
const certainty = findingsCertainty(data)
|
|
336
|
+
if (certainty === 'unknown') {
|
|
337
|
+
// Unknown because reports couldn't be read is not the same as unscanned;
|
|
338
|
+
// the coverage notes below say what couldn't be read.
|
|
339
|
+
const unread = data.coverage.gaps.length > 0
|
|
340
|
+
return <span className="text-sm text-theme-text-secondary">{unread ? 'Findings unknown' : 'No running image is scanned yet'}{!unread && s.imagesUnscanned > 0 ? ` · ${s.imagesUnscanned} not scanned` : ''}</span>
|
|
341
|
+
}
|
|
342
|
+
const bound = certainty === 'lower_bound' ? '≥ ' : ''
|
|
343
|
+
return (
|
|
344
|
+
<div className="flex min-w-0 flex-col gap-0.5">
|
|
345
|
+
<div className="flex flex-wrap items-baseline gap-x-2">
|
|
346
|
+
<FindingTotal value={s.imagesWithCritical} certainty={certainty} className="text-2xl font-semibold text-theme-text-primary" />
|
|
347
|
+
<span className="text-sm text-theme-text-secondary">
|
|
348
|
+
{s.imagesWithCritical === 1 ? 'image' : 'images'} with Critical CVEs
|
|
349
|
+
<span className="text-theme-text-tertiary">{` · of ${s.imagesScanned} scanned${s.imagesUnscanned > 0 ? `, ${s.imagesUnscanned} not scanned yet` : ''}`}</span>
|
|
350
|
+
</span>
|
|
351
|
+
</div>
|
|
352
|
+
<span className="text-xs text-theme-text-tertiary">
|
|
353
|
+
{`${bound}${s.fixableCriticalHighCves} Critical and High CVEs with a fix · ${bound}${s.workloadsWithCriticalOrHigh} of ${s.workloads} workloads with Critical or High`}
|
|
354
|
+
{workloadsByReplicaSet(data.coverage) && ' (a Deployment may count once per ReplicaSet)'}
|
|
355
|
+
</span>
|
|
356
|
+
</div>
|
|
357
|
+
)
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function CoverageNotes({ data, filtered }: { data: VulnerabilitiesResponse; filtered: boolean }) {
|
|
361
|
+
const gaps = gapSentence(data.coverage.gaps)
|
|
362
|
+
const scan = data.summary.newestScan
|
|
363
|
+
? data.summary.oldestScan && data.summary.oldestScan !== data.summary.newestScan
|
|
364
|
+
? `Scans from ${formatRelativeAgeTime(data.summary.oldestScan)} to ${formatRelativeAgeTime(data.summary.newestScan)}`
|
|
365
|
+
: `Scanned ${formatRelativeAgeTime(data.summary.newestScan)}`
|
|
366
|
+
: null
|
|
367
|
+
return (
|
|
368
|
+
<div className="flex flex-col gap-1.5 text-xs">
|
|
369
|
+
<p className="flex items-center gap-1.5 text-theme-text-tertiary">
|
|
370
|
+
{[scan, filtered ? 'Totals ignore the filters' : null].filter(Boolean).join(' · ')}
|
|
371
|
+
{/* For someone comparing these numbers with Trivy's own: why they can differ. */}
|
|
372
|
+
<WithTooltip tip={[
|
|
373
|
+
"Reports list what was known when each image was scanned, after Trivy's own filters.",
|
|
374
|
+
'A CVE counts once per package version in an image, and findings Trivy left unrated are rated from their CVSS score, so totals can differ from the summaries in Trivy\'s reports.',
|
|
375
|
+
data.coverage.inactiveReports > 0 ? `${data.coverage.inactiveReports} ${data.coverage.inactiveReports === 1 ? 'report is' : 'reports are'} about older revisions or builds that don't run now, and ${data.coverage.inactiveReports === 1 ? "isn't" : "aren't"} counted.` : '',
|
|
376
|
+
].filter(Boolean).join(' ')}>
|
|
377
|
+
<Info className="h-3.5 w-3.5" aria-label="How these numbers relate to Trivy's" />
|
|
378
|
+
</WithTooltip>
|
|
379
|
+
</p>
|
|
380
|
+
{gaps && <p className="text-warning-text">{gaps}</p>}
|
|
381
|
+
{data.coverage.truncated && <p className="text-warning-text">This request reached its findings limit, so some images' findings weren't read and are marked unread. Narrow with the namespace picker.</p>}
|
|
382
|
+
</div>
|
|
383
|
+
)
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Rows drawn at a time: a pivot can return 2,000, and drawing them all makes
|
|
387
|
+
// switching views slow. The worst rows come first.
|
|
388
|
+
const PAGE_ROWS = 100
|
|
389
|
+
|
|
390
|
+
function Paged<T>({ rows, children }: { rows: T[]; children: (rows: T[]) => React.ReactNode }) {
|
|
391
|
+
const [shown, setShown] = useState(PAGE_ROWS)
|
|
392
|
+
const rest = rows.length - shown
|
|
393
|
+
return (
|
|
394
|
+
<>
|
|
395
|
+
{children(rows.slice(0, shown))}
|
|
396
|
+
{rest > 0 && (
|
|
397
|
+
<button type="button" onClick={() => setShown(shown + PAGE_ROWS)} className="self-start text-xs text-accent-text hover:underline">
|
|
398
|
+
Show {Math.min(PAGE_ROWS, rest)} more ({rest} not shown)
|
|
399
|
+
</button>
|
|
400
|
+
)}
|
|
401
|
+
</>
|
|
402
|
+
)
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function Disclosure({ summary, children, flush = false }: { summary: React.ReactNode; children: React.ReactNode | ((open: boolean) => React.ReactNode); flush?: boolean }) {
|
|
406
|
+
const [open, setOpen] = useState(false)
|
|
407
|
+
const { panelId, buttonProps } = useDisclosure(open)
|
|
408
|
+
return (
|
|
409
|
+
<div className="border-b border-theme-border last:border-0">
|
|
410
|
+
<button {...buttonProps} type="button" onClick={() => setOpen(!open)} className="flex w-full items-center gap-3 px-3 py-2.5 text-left hover:bg-theme-hover">
|
|
411
|
+
<CollapseChevron open={open} className="h-4 w-4 shrink-0 text-theme-text-tertiary" />
|
|
412
|
+
{summary}
|
|
413
|
+
</button>
|
|
414
|
+
<Collapse open={open} id={panelId} mountLazily>
|
|
415
|
+
<div className={clsx('border-t border-theme-border bg-theme-base', flush ? 'py-2' : 'px-3 py-3 pl-10')}>{typeof children === 'function' ? children(open) : children}</div>
|
|
416
|
+
</Collapse>
|
|
417
|
+
</div>
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function WorkloadLinks({ workloads, onOpen, inline = false }: { workloads: VulnerabilityWorkloadRef[]; onOpen: (w: VulnerabilityWorkloadRef) => void; inline?: boolean }) {
|
|
422
|
+
return (
|
|
423
|
+
<ul className={clsx('flex min-w-0', inline ? 'flex-wrap gap-x-4 gap-y-0.5' : 'flex-col gap-0.5')}>
|
|
424
|
+
{workloads.map((w) => (
|
|
425
|
+
<li key={`${w.namespace}/${w.kind}/${w.name}/${w.container ?? ''}`} className="min-w-0">
|
|
426
|
+
<button type="button" onClick={() => onOpen(w)} className="group flex min-w-0 items-baseline gap-1.5 text-left text-xs">
|
|
427
|
+
<span className="truncate text-accent-text group-hover:underline">{w.name}</span>
|
|
428
|
+
<span className="shrink-0 text-theme-text-tertiary">{w.kind} · {w.namespace}{w.container ? ` · ${w.container}` : ''}</span>
|
|
429
|
+
</button>
|
|
430
|
+
</li>
|
|
431
|
+
))}
|
|
432
|
+
</ul>
|
|
433
|
+
)
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function NumHead({ children }: { children: React.ReactNode }) {
|
|
437
|
+
return <span className="text-right">{children}</span>
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function Num({ children, strong = false }: { children: React.ReactNode; strong?: boolean }) {
|
|
441
|
+
return <span className={clsx('text-right font-mono text-xs tabular-nums', strong ? 'font-medium text-theme-text-primary' : 'text-theme-text-secondary')}>{children}</span>
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function ImageTable({ images, onOpen, onOpenReport }: { images: VulnerableImage[]; onOpen: (w: VulnerabilityWorkloadRef) => void; onOpenReport: (img: VulnerableImage) => void }) {
|
|
445
|
+
return (
|
|
446
|
+
<div className="shrink-0 overflow-x-auto overflow-y-hidden rounded-lg border border-theme-border bg-theme-surface">
|
|
447
|
+
<div className="min-w-[860px]">
|
|
448
|
+
<div className={clsx(HEAD, IMAGE_COLS)}>
|
|
449
|
+
<span>Image</span><span>Findings</span><NumHead>With a fix</NumHead><span>Running in</span><NumHead>Scanned</NumHead>
|
|
450
|
+
</div>
|
|
451
|
+
{images.map((img) => {
|
|
452
|
+
const total = img.counts.critical + img.counts.high + img.counts.medium + img.counts.low + img.counts.unknown
|
|
453
|
+
const fixable = img.fixable.critical + img.fixable.high + img.fixable.medium + img.fixable.low + img.fixable.unknown
|
|
454
|
+
return (
|
|
455
|
+
<Disclosure
|
|
456
|
+
key={img.id}
|
|
457
|
+
flush
|
|
458
|
+
summary={
|
|
459
|
+
<div className={clsx('grid flex-1 items-center gap-4 text-sm', IMAGE_COLS)}>
|
|
460
|
+
<span className="flex min-w-0 flex-col">
|
|
461
|
+
<ImageName image={img.image} className="text-theme-text-primary" />
|
|
462
|
+
<span className="truncate font-mono text-xs text-theme-text-tertiary">{[imageParts(img.image).path, img.os].filter(Boolean).join(' · ')}</span>
|
|
463
|
+
</span>
|
|
464
|
+
{img.findingsUnread ? <span className="text-xs text-warning-text">Findings not read</span> : <SeverityBar counts={img.counts} className="max-w-[280px]" />}
|
|
465
|
+
<WithTooltip tip={img.findingsUnread ? undefined : `${fixable} of ${total} findings have a fixed release`}>
|
|
466
|
+
<Num>{img.findingsUnread ? '—' : <>{fixable}<span className="text-theme-text-tertiary"> of {total}</span></>}</Num>
|
|
467
|
+
</WithTooltip>
|
|
468
|
+
<span className="flex min-w-0 flex-col">
|
|
469
|
+
<span className="truncate text-theme-text-secondary">{workloadSummary(img.workloads)}{img.workloadsTotal > img.workloads.length ? ` and ${img.workloadsTotal - img.workloads.length} more` : ''}</span>
|
|
470
|
+
<span className="text-xs text-theme-text-tertiary">{namespaceCount(img)}</span>
|
|
471
|
+
</span>
|
|
472
|
+
<span className="text-right text-xs text-theme-text-tertiary">{formatRelativeAgeTime(img.scannedAt)}</span>
|
|
473
|
+
</div>
|
|
474
|
+
}
|
|
475
|
+
>
|
|
476
|
+
<div className={clsx('grid gap-4 py-1.5 pl-10 pr-3', IMAGE_COLS)}>
|
|
477
|
+
<div className="col-span-3 flex min-w-0 flex-col gap-1.5">
|
|
478
|
+
<span className="text-xs font-medium text-theme-text-secondary">
|
|
479
|
+
{img.matching === img.findingsTotal ? 'Findings, worst first' : `${img.matching} of ${img.findingsTotal} findings match`}
|
|
480
|
+
</span>
|
|
481
|
+
<FindingsList findings={img.findings} total={img.findingsTotal} unread={img.findingsUnread} />
|
|
482
|
+
<span className="flex gap-3 text-xs">
|
|
483
|
+
{img.matching > img.findings.length && <span className="text-theme-text-tertiary">{img.matching - img.findings.length} more in the report.</span>}
|
|
484
|
+
<button type="button" onClick={() => onOpenReport(img)} className="text-accent-text hover:underline">Open the scan report</button>
|
|
485
|
+
</span>
|
|
486
|
+
</div>
|
|
487
|
+
<div className="col-span-2 flex min-w-0 flex-col gap-1.5">
|
|
488
|
+
<span className="text-xs font-medium text-theme-text-secondary">{img.workloadsTotal} {img.workloadsTotal === 1 ? 'container' : 'containers'}{img.workloadsTotal > img.workloads.length ? ` (first ${img.workloads.length})` : ''}</span>
|
|
489
|
+
<WorkloadLinks workloads={img.workloads} onOpen={onOpen} />
|
|
490
|
+
</div>
|
|
491
|
+
</div>
|
|
492
|
+
</Disclosure>
|
|
493
|
+
)
|
|
494
|
+
})}
|
|
495
|
+
</div>
|
|
496
|
+
</div>
|
|
497
|
+
)
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// The listed workloads are capped, so past the cap their namespaces are a floor.
|
|
501
|
+
function namespaceCount(img: VulnerableImage): string {
|
|
502
|
+
const n = distinctNamespaces(img.workloads)
|
|
503
|
+
const partial = img.workloadsTotal > img.workloads.length
|
|
504
|
+
return `${partial ? 'at least ' : ''}${n} ${n === 1 ? 'namespace' : 'namespaces'}`
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function FindingsList({ findings, total, unread }: { findings: VulnerableImage['findings']; total: number; unread?: boolean }) {
|
|
508
|
+
if (unread) {
|
|
509
|
+
return <span className="text-xs text-warning-text">Not read: this request reached its findings limit before this image. Narrow with the namespace picker.</span>
|
|
510
|
+
}
|
|
511
|
+
if (findings.length === 0) {
|
|
512
|
+
return <span className="text-xs text-theme-text-tertiary">{total === 0 ? 'No CVEs reported for this image.' : 'No findings match the filters.'}</span>
|
|
513
|
+
}
|
|
514
|
+
return (
|
|
515
|
+
<div className="flex flex-col divide-y divide-theme-border border-y border-theme-border">
|
|
516
|
+
{findings.map((f, i) => (
|
|
517
|
+
<div key={`${f.id}/${f.package}/${f.installedVersion}/${i}`} className="grid grid-cols-[136px_72px_minmax(0,0.8fr)_minmax(0,1.4fr)] items-center gap-3 py-1 text-xs">
|
|
518
|
+
{f.link ? (
|
|
519
|
+
<WithTooltip tip={f.title}><a href={f.link} target="_blank" rel="noreferrer" className="truncate font-mono text-accent-text hover:underline">{f.id}</a></WithTooltip>
|
|
520
|
+
) : (
|
|
521
|
+
<WithTooltip tip={f.title}><span className="truncate font-mono text-theme-text-primary">{f.id}</span></WithTooltip>
|
|
522
|
+
)}
|
|
523
|
+
<SeverityBadge severity={f.severity} fromScore={f.severityFromScore} score={f.score} />
|
|
524
|
+
<span className="truncate font-mono text-theme-text-secondary">{f.package}</span>
|
|
525
|
+
<FixVersion installed={f.installedVersion} fixed={f.fixedVersion} target={f.fixTarget} />
|
|
526
|
+
</div>
|
|
527
|
+
))}
|
|
528
|
+
</div>
|
|
529
|
+
)
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function FixTable({ fixes, onOpen, onShowCVE }: { fixes: VulnerabilityFix[]; onOpen: (w: VulnerabilityWorkloadRef) => void; onShowCVE: (id: string) => void }) {
|
|
533
|
+
return (
|
|
534
|
+
<div className="flex shrink-0 flex-col gap-2">
|
|
535
|
+
<p className="text-xs text-theme-text-tertiary">
|
|
536
|
+
Upgrading a package means rebuilding the image that holds it.
|
|
537
|
+
</p>
|
|
538
|
+
<div className="overflow-x-auto overflow-y-hidden rounded-lg border border-theme-border bg-theme-surface">
|
|
539
|
+
<div className="min-w-[960px]">
|
|
540
|
+
<div className={clsx(HEAD, FIX_COLS)}>
|
|
541
|
+
<span>Package</span><span>Upgrade</span><span>Clears</span><span>Running in</span><NumHead>Images</NumHead><NumHead>Workloads</NumHead>
|
|
542
|
+
</div>
|
|
543
|
+
{fixes.map((f) => {
|
|
544
|
+
const runners = f.affected.flatMap((a) => a.workloads)
|
|
545
|
+
const several = f.from.length > 1
|
|
546
|
+
return (
|
|
547
|
+
<Disclosure
|
|
548
|
+
key={`${f.packageType ?? ''}/${f.package}/${f.to ?? (f.fixedVersions ?? []).join('|')}`}
|
|
549
|
+
flush
|
|
550
|
+
summary={
|
|
551
|
+
<div className={clsx('grid flex-1 items-center gap-4 text-sm', FIX_COLS)}>
|
|
552
|
+
<span className="flex min-w-0 flex-col">
|
|
553
|
+
<span className="truncate font-mono text-theme-text-primary">{f.package}</span>
|
|
554
|
+
{f.packageType && <span className="truncate text-xs text-theme-text-tertiary">{ecosystemLabel(f.packageType)}</span>}
|
|
555
|
+
</span>
|
|
556
|
+
<WithTooltip tip={f.to ? `${f.from.join(', ')} → ${f.to}` : "Radar can't pick one release that fixes every CVE here: it can't order this package's versions, or no listed release is above the installed one. These are the fixed releases the scanner lists."}>
|
|
557
|
+
{/* The installed side gives way first: the target is what to act on. */}
|
|
558
|
+
<span className="flex min-w-0 items-baseline font-mono text-xs">
|
|
559
|
+
<span className="min-w-0 shrink-[100] truncate text-theme-text-tertiary">{installedLabel(f.from)}</span>
|
|
560
|
+
<span className="shrink-0 whitespace-pre text-theme-text-tertiary">{f.to ? ' → ' : ' · '}</span>
|
|
561
|
+
{f.to
|
|
562
|
+
? <span className={clsx('min-w-0 truncate', SEVERITY_TEXT.success)}>{f.to}</span>
|
|
563
|
+
: <span className="min-w-0 truncate text-theme-text-secondary">fixed in {(f.fixedVersions ?? []).join(', ')}</span>}
|
|
564
|
+
</span>
|
|
565
|
+
</WithTooltip>
|
|
566
|
+
<SeverityCounts counts={f.counts} />
|
|
567
|
+
<span className="truncate text-theme-text-secondary">{workloadSummary(runners)}</span>
|
|
568
|
+
<Num>{f.images}</Num>
|
|
569
|
+
<Num strong>{f.workloads}</Num>
|
|
570
|
+
</div>
|
|
571
|
+
}
|
|
572
|
+
>
|
|
573
|
+
<div className={clsx(SUB, FIX_COLS)}>
|
|
574
|
+
<span className="text-theme-text-tertiary">{f.cvesTotal} {f.cvesTotal === 1 ? 'CVE' : 'CVEs'}{f.to ? ' cleared' : ''}</span>
|
|
575
|
+
<span className="col-span-5 flex flex-wrap gap-1.5">
|
|
576
|
+
{f.cves.map((id) => (
|
|
577
|
+
<button key={id} type="button" onClick={() => onShowCVE(id)} className="badge-sm bg-theme-elevated font-mono text-theme-text-secondary hover:bg-theme-hover hover:text-theme-text-primary">{id}</button>
|
|
578
|
+
))}
|
|
579
|
+
{f.cvesTotal > f.cves.length && <span className="text-theme-text-tertiary">and {f.cvesTotal - f.cves.length} more</span>}
|
|
580
|
+
</span>
|
|
581
|
+
</div>
|
|
582
|
+
{f.affected.map((a) => (
|
|
583
|
+
<div key={a.imageId} className={clsx(SUB, FIX_COLS)}>
|
|
584
|
+
<ImageName image={a.image} className="text-theme-text-primary" />
|
|
585
|
+
<span className="truncate font-mono text-theme-text-tertiary">{several ? a.installedVersions.join(', ') : ''}</span>
|
|
586
|
+
<span />
|
|
587
|
+
<WorkloadLinks workloads={a.workloads} onOpen={onOpen} inline />
|
|
588
|
+
<span />
|
|
589
|
+
<Num>{a.workloadsTotal}</Num>
|
|
590
|
+
</div>
|
|
591
|
+
))}
|
|
592
|
+
{f.images > f.affected.length && <p className={clsx(SUB, 'text-theme-text-tertiary')}>{f.images - f.affected.length} more images.</p>}
|
|
593
|
+
</Disclosure>
|
|
594
|
+
)
|
|
595
|
+
})}
|
|
596
|
+
</div>
|
|
597
|
+
</div>
|
|
598
|
+
</div>
|
|
599
|
+
)
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function CVETable({ cves, onOpen }: { cves: VulnerabilityCVE[]; onOpen: (w: VulnerabilityWorkloadRef) => void }) {
|
|
603
|
+
return (
|
|
604
|
+
<div className="flex shrink-0 flex-col gap-2">
|
|
605
|
+
<div className="shrink-0 overflow-x-auto overflow-y-hidden rounded-lg border border-theme-border bg-theme-surface">
|
|
606
|
+
<div className="min-w-[960px]">
|
|
607
|
+
<div className={clsx(HEAD, CVE_COLS)}>
|
|
608
|
+
<span>CVE</span><span>Severity</span><NumHead>Score</NumHead><span>Package</span><span>Fix</span><NumHead>Images</NumHead><NumHead>Workloads</NumHead>
|
|
609
|
+
</div>
|
|
610
|
+
{cves.map((c) => (
|
|
611
|
+
<Disclosure
|
|
612
|
+
key={c.id}
|
|
613
|
+
flush
|
|
614
|
+
summary={
|
|
615
|
+
<div className={clsx('grid flex-1 items-center gap-4 text-sm', CVE_COLS)}>
|
|
616
|
+
<span className="flex min-w-0 flex-col">
|
|
617
|
+
<span className="truncate font-mono text-theme-text-primary">{c.id}</span>
|
|
618
|
+
{c.title && <span className="truncate text-xs text-theme-text-tertiary">{c.title}</span>}
|
|
619
|
+
</span>
|
|
620
|
+
<SeverityBadge severity={c.severity} />
|
|
621
|
+
<Num>{c.score?.toFixed(1) ?? '—'}</Num>
|
|
622
|
+
<span className="truncate font-mono text-xs text-theme-text-secondary">{c.packages.join(', ')}</span>
|
|
623
|
+
<CVEFix cve={c} />
|
|
624
|
+
<Num>{c.images}</Num>
|
|
625
|
+
<Num strong>{c.workloads}</Num>
|
|
626
|
+
</div>
|
|
627
|
+
}
|
|
628
|
+
>
|
|
629
|
+
{c.affected.map((a) => (
|
|
630
|
+
<div key={a.imageId} className={clsx(SUB, CVE_COLS)}>
|
|
631
|
+
<span className="flex min-w-0 flex-col gap-0.5">
|
|
632
|
+
<ImageName image={a.image} className="text-theme-text-primary" />
|
|
633
|
+
<WorkloadLinks workloads={a.workloads} onOpen={onOpen} inline />
|
|
634
|
+
</span>
|
|
635
|
+
<span className="col-span-2" />
|
|
636
|
+
<span className="col-span-2 flex min-w-0 flex-col">
|
|
637
|
+
{a.packages.map((p) => (
|
|
638
|
+
<span key={`${p.package}/${p.installedVersion}`} className="flex min-w-0 gap-1.5">
|
|
639
|
+
<span className="shrink-0 font-mono text-theme-text-secondary">{p.package}</span>
|
|
640
|
+
<FixVersion installed={p.installedVersion} fixed={p.fixedVersion} target={p.fixTarget} />
|
|
641
|
+
</span>
|
|
642
|
+
))}
|
|
643
|
+
</span>
|
|
644
|
+
<span />
|
|
645
|
+
<Num>{a.workloadsTotal}</Num>
|
|
646
|
+
</div>
|
|
647
|
+
))}
|
|
648
|
+
<div className={clsx(SUB, 'flex gap-4')}>
|
|
649
|
+
{c.images > c.affected.length && <span className="text-theme-text-tertiary">{c.images - c.affected.length} more images.</span>}
|
|
650
|
+
{c.link && <a href={c.link} target="_blank" rel="noreferrer" className="inline-flex items-center gap-1 text-accent-text hover:underline">Advisory <ExternalLink className="h-3 w-3" aria-hidden /></a>}
|
|
651
|
+
</div>
|
|
652
|
+
</Disclosure>
|
|
653
|
+
))}
|
|
654
|
+
</div>
|
|
655
|
+
</div>
|
|
656
|
+
</div>
|
|
657
|
+
)
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function WorkloadTable({ workloads, severities, query, namespaces, onOpen, onShow }: {
|
|
661
|
+
workloads: VulnerabilityWorkload[]
|
|
662
|
+
severities: VulnerabilitySeverity[]
|
|
663
|
+
query: string
|
|
664
|
+
/** The table's namespace scope, so an expanded row reads what the row did. */
|
|
665
|
+
namespaces: string[]
|
|
666
|
+
onOpen: (w: VulnerabilityWorkloadRef) => void
|
|
667
|
+
onShow: (w: VulnerabilityWorkloadRef, by: VulnerabilityView) => void
|
|
668
|
+
}) {
|
|
669
|
+
return (
|
|
670
|
+
<div className="shrink-0 overflow-x-auto overflow-y-hidden rounded-lg border border-theme-border bg-theme-surface">
|
|
671
|
+
<div className="min-w-[760px]">
|
|
672
|
+
<div className={clsx(HEAD, WORKLOAD_COLS)}>
|
|
673
|
+
<span>Workload</span><span>Findings across its images</span><span>Containers</span>
|
|
674
|
+
</div>
|
|
675
|
+
{workloads.map((w) => (
|
|
676
|
+
<Disclosure
|
|
677
|
+
key={`${w.namespace}/${w.kind}/${w.name}`}
|
|
678
|
+
flush
|
|
679
|
+
summary={
|
|
680
|
+
<div className={clsx('grid flex-1 items-start gap-4 text-sm', WORKLOAD_COLS)}>
|
|
681
|
+
<span className="flex min-w-0 flex-col">
|
|
682
|
+
<span className="truncate text-theme-text-primary">{w.name}</span>
|
|
683
|
+
<span className="text-xs text-theme-text-tertiary">{w.kind} · {w.namespace}</span>
|
|
684
|
+
</span>
|
|
685
|
+
<WorkloadFindings workload={w} />
|
|
686
|
+
<ul className="flex min-w-0 flex-col gap-1">
|
|
687
|
+
{w.containers.map((c) => (
|
|
688
|
+
<li key={`${c.name}/${c.image}`} className="flex min-w-0 flex-wrap items-baseline gap-x-2 text-xs">
|
|
689
|
+
<span className="shrink-0 text-theme-text-secondary">{c.name}</span>
|
|
690
|
+
<ImageName image={c.image} className="text-theme-text-tertiary" />
|
|
691
|
+
{c.scanned && c.counts ? <SeverityCounts counts={c.counts} /> : c.findingsUnread ? <span className="text-warning-text">findings not read</span> : <span className="text-warning-text">not scanned yet</span>}
|
|
692
|
+
</li>
|
|
693
|
+
))}
|
|
694
|
+
</ul>
|
|
695
|
+
</div>
|
|
696
|
+
}
|
|
697
|
+
>
|
|
698
|
+
{(open) => <WorkloadUpgrades workload={w} active={open} severities={severities} query={query} namespaces={namespaces} onOpen={onOpen} onShow={onShow} />}
|
|
699
|
+
</Disclosure>
|
|
700
|
+
))}
|
|
701
|
+
</div>
|
|
702
|
+
</div>
|
|
703
|
+
)
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// Whether an upgrade clears the CVE: in every image, some, or none.
|
|
707
|
+
function CVEFix({ cve: c }: { cve: VulnerabilityCVE }) {
|
|
708
|
+
const all = c.fixableImages >= c.images
|
|
709
|
+
const text = c.fixableImages === 0 ? 'No' : all ? 'Yes' : `${c.fixableImages} of ${c.images}`
|
|
710
|
+
return (
|
|
711
|
+
<WithTooltip tip={c.fixableImages > 0 && !all ? `A fixed release is reported in ${c.fixableImages} of the ${c.images} images` : undefined}>
|
|
712
|
+
<span className={clsx('text-xs', c.fixableImages === 0 ? 'text-theme-text-tertiary' : all ? SEVERITY_TEXT.success : 'text-theme-text-secondary')}>
|
|
713
|
+
{text}
|
|
714
|
+
</span>
|
|
715
|
+
</WithTooltip>
|
|
716
|
+
)
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
const MAX_WORKLOAD_UPGRADES = 8
|
|
720
|
+
|
|
721
|
+
// What a workload's owner changes: the By fix rows narrowed to this
|
|
722
|
+
// workload, read when the row opens.
|
|
723
|
+
function WorkloadUpgrades({ workload: w, active, severities, query, namespaces, onOpen, onShow }: {
|
|
724
|
+
workload: VulnerabilityWorkload
|
|
725
|
+
/** False once the row closes: its subtree stays mounted, its polling stops. */
|
|
726
|
+
active: boolean
|
|
727
|
+
severities: VulnerabilitySeverity[]
|
|
728
|
+
query: string
|
|
729
|
+
/** The table's namespace scope, so an expanded row reads what the row did. */
|
|
730
|
+
namespaces: string[]
|
|
731
|
+
onOpen: (w: VulnerabilityWorkloadRef) => void
|
|
732
|
+
onShow: (w: VulnerabilityWorkloadRef, by: VulnerabilityView) => void
|
|
733
|
+
}) {
|
|
734
|
+
const ref = { kind: w.kind, group: w.group, namespace: w.namespace, name: w.name }
|
|
735
|
+
// The row's own scope: the newest report for an image wins across every
|
|
736
|
+
// namespace read, so a narrower read could pick an older one.
|
|
737
|
+
const { data, isLoading, error } = useVulnerabilities({ view: 'fix', namespaces, severities, query, workload: ref }, active)
|
|
738
|
+
const total = totalFindings(w.counts)
|
|
739
|
+
const fixable = totalFindings(w.fixable)
|
|
740
|
+
const fixes = data?.fixes ?? []
|
|
741
|
+
const several = w.containers.length > 1
|
|
742
|
+
const filtered = severities.length > 0 || query !== ''
|
|
743
|
+
// Containers whose findings weren't read: their upgrades are unknown.
|
|
744
|
+
const unknown = w.containers.filter((c) => !c.scanned || c.findingsUnread).length
|
|
745
|
+
const actions = (
|
|
746
|
+
<span className="flex flex-wrap gap-x-4">
|
|
747
|
+
<button type="button" onClick={() => onOpen(ref)} className="text-accent-text hover:underline">Open {w.name}</button>
|
|
748
|
+
{total > 0 && <button type="button" onClick={() => onShow(ref, 'cve')} className="text-accent-text hover:underline">{filtered ? 'Its CVEs' : 'All its CVEs'}</button>}
|
|
749
|
+
{fixes.length > MAX_WORKLOAD_UPGRADES && <button type="button" onClick={() => onShow(ref, 'fix')} className="text-accent-text hover:underline">All {fixes.length} upgrades</button>}
|
|
750
|
+
</span>
|
|
751
|
+
)
|
|
752
|
+
let lead: React.ReactNode
|
|
753
|
+
if (isLoading) lead = <span className="text-theme-text-tertiary">Reading its upgrades…</span>
|
|
754
|
+
else if (error) lead = <span className="text-warning-text">Couldn't read its upgrades: {error instanceof Error ? error.message : 'request failed'}.</span>
|
|
755
|
+
else if (total === 0 && unknown > 0) lead = <span className="text-warning-text">{unknown === w.containers.length ? "No findings were read for its containers: not scanned yet, or too many to read." : 'Its other containers have no reported CVEs; the rest weren\'t read.'}</span>
|
|
756
|
+
// The workload's counts cover its whole images; under a filter only the
|
|
757
|
+
// upgrade rows follow it, so the sentence leaves the counts out.
|
|
758
|
+
else if (filtered) lead = <span className="text-theme-text-secondary">{fixes.length === 0 ? 'None of the findings that match has a fixed release yet.' : `${fixes.length} ${fixes.length === 1 ? 'upgrade' : 'upgrades'} for the findings that match`}</span>
|
|
759
|
+
else if (fixes.length === 0) lead = <span className="text-theme-text-tertiary">None of its {total} findings has a fixed release yet.</span>
|
|
760
|
+
else lead = (
|
|
761
|
+
<span className="text-theme-text-secondary">
|
|
762
|
+
{/* Without a confirmed version for every upgrade, they don't promise to clear. */}
|
|
763
|
+
{fixes.length} {fixes.every((f) => f.to) ? (fixes.length === 1 ? 'upgrade clears' : 'upgrades clear') : (fixes.length === 1 ? 'upgrade listed for' : 'upgrades listed for')} {fixable} of its {total} findings
|
|
764
|
+
{total > fixable && <span className="text-theme-text-tertiary">; {total - fixable} have no fix yet</span>}
|
|
765
|
+
{unknown > 0 && <span className="text-warning-text">. {unknown} {unknown === 1 ? "container's" : "containers'"} findings weren't read</span>}
|
|
766
|
+
</span>
|
|
767
|
+
)
|
|
768
|
+
return (
|
|
769
|
+
<>
|
|
770
|
+
<div className={clsx(SUB, WORKLOAD_COLS)}>
|
|
771
|
+
<span className="col-span-3">{lead}</span>
|
|
772
|
+
</div>
|
|
773
|
+
{fixes.length > 0 && (
|
|
774
|
+
<div className={clsx(SUB, WORKLOAD_COLS, 'text-theme-text-tertiary')}>
|
|
775
|
+
<span />
|
|
776
|
+
<span className="grid min-w-0 grid-cols-[1.75rem_2.25rem_minmax(0,1fr)] gap-2">
|
|
777
|
+
<span className="text-right">C</span><span className="text-right">H</span><span>Upgrade</span>
|
|
778
|
+
</span>
|
|
779
|
+
<span />
|
|
780
|
+
</div>
|
|
781
|
+
)}
|
|
782
|
+
{fixes.slice(0, MAX_WORKLOAD_UPGRADES).map((f) => (
|
|
783
|
+
<div key={`${f.packageType ?? ''}/${f.package}/${f.to ?? (f.fixedVersions ?? []).join('|')}`} className={clsx(SUB, WORKLOAD_COLS)}>
|
|
784
|
+
<span className="flex min-w-0 items-baseline gap-2">
|
|
785
|
+
<span className="truncate font-mono text-theme-text-primary">{f.package}</span>
|
|
786
|
+
{f.packageType && <span className="truncate text-theme-text-tertiary">{ecosystemLabel(f.packageType)}</span>}
|
|
787
|
+
</span>
|
|
788
|
+
{/* Critical and High cleared, in fixed columns so rows line up. */}
|
|
789
|
+
<span className="grid min-w-0 grid-cols-[1.75rem_2.25rem_minmax(0,1fr)] items-baseline gap-2">
|
|
790
|
+
<ClearedCount count={f.counts.critical} severity="critical" />
|
|
791
|
+
<ClearedCount count={f.counts.high} severity="high" />
|
|
792
|
+
{f.to
|
|
793
|
+
? <WithTooltip tip={`${f.from.join(', ')} → ${f.to}`}><FixVersion installed={installedLabel(f.from)} target={f.to} /></WithTooltip>
|
|
794
|
+
: <span className="truncate font-mono text-theme-text-secondary">fixed in {(f.fixedVersions ?? []).join(', ')}</span>}
|
|
795
|
+
</span>
|
|
796
|
+
<span className="flex min-w-0 flex-wrap gap-x-3">
|
|
797
|
+
{several && f.affected.map((a) => <ImageName key={a.imageId} image={a.image} className="text-theme-text-tertiary" />)}
|
|
798
|
+
</span>
|
|
799
|
+
</div>
|
|
800
|
+
))}
|
|
801
|
+
<div className={clsx(SUB, 'flex')}>{actions}</div>
|
|
802
|
+
</>
|
|
803
|
+
)
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// A workload's counts cover only its scanned containers: with none scanned
|
|
807
|
+
// they are unknown, never "no reported CVEs".
|
|
808
|
+
function WorkloadFindings({ workload }: { workload: VulnerabilityWorkload }) {
|
|
809
|
+
const unscanned = workload.containers.filter((c) => !c.scanned).length
|
|
810
|
+
const unread = workload.containers.filter((c) => c.scanned && c.findingsUnread).length
|
|
811
|
+
if (unscanned + unread === workload.containers.length) {
|
|
812
|
+
return <span className="text-xs text-warning-text">{unread === 0 ? 'Not scanned yet' : 'Findings not read'}</span>
|
|
813
|
+
}
|
|
814
|
+
const containers = (n: number) => `${n} ${n === 1 ? 'container' : 'containers'}`
|
|
815
|
+
const notCounted = [
|
|
816
|
+
unscanned > 0 && `${containers(unscanned)} not scanned yet`,
|
|
817
|
+
unread > 0 && `${containers(unread)} with findings not read`,
|
|
818
|
+
].filter(Boolean).join(', ')
|
|
819
|
+
return (
|
|
820
|
+
<div className="flex min-w-0 flex-col gap-1">
|
|
821
|
+
<SeverityBar counts={workload.counts} className="max-w-[280px]" />
|
|
822
|
+
{notCounted && <span className="text-xs text-warning-text">Not counted: {notCounted}</span>}
|
|
823
|
+
</div>
|
|
824
|
+
)
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// Scanned and clean, folded away so the rows are the ones that need work.
|
|
828
|
+
function CleanList({ data, view, onOpen }: { data: VulnerabilitiesResponse; view: VulnerabilityView; onOpen: (w: VulnerabilityWorkloadRef) => void }) {
|
|
829
|
+
const images = view === 'image' ? data.clean ?? [] : []
|
|
830
|
+
const workloads = view === 'workload' ? data.cleanWorkloads ?? [] : []
|
|
831
|
+
if (images.length + workloads.length === 0) return null
|
|
832
|
+
const count = images.length + workloads.length + (data.coverage.cleanOmitted ?? 0)
|
|
833
|
+
return (
|
|
834
|
+
<div className="shrink-0 rounded-lg border border-theme-border bg-theme-surface">
|
|
835
|
+
<Disclosure
|
|
836
|
+
flush
|
|
837
|
+
summary={
|
|
838
|
+
<span className="flex items-center gap-2 text-sm text-theme-text-secondary">
|
|
839
|
+
<ShieldCheck className={clsx('h-4 w-4', SEVERITY_TEXT.success)} aria-hidden />
|
|
840
|
+
{view === 'image'
|
|
841
|
+
? `${count} scanned ${count === 1 ? 'image has' : 'images have'} no reported CVEs`
|
|
842
|
+
: `${count} ${count === 1 ? 'workload runs' : 'workloads run'} only images with no reported CVEs`}
|
|
843
|
+
</span>
|
|
844
|
+
}
|
|
845
|
+
>
|
|
846
|
+
{view === 'image' ? (
|
|
847
|
+
<ul className="flex flex-col">
|
|
848
|
+
{images.map((c) => (
|
|
849
|
+
<li key={c.id} className={FOLD_ROW}>
|
|
850
|
+
<span className="flex min-w-0 items-baseline gap-2">
|
|
851
|
+
<ImageName image={c.image} className="text-theme-text-primary" />
|
|
852
|
+
<span className="shrink-0 text-theme-text-tertiary">scanned {formatRelativeAgeTime(c.scannedAt)}</span>
|
|
853
|
+
</span>
|
|
854
|
+
<span className="flex min-w-0 flex-wrap items-baseline gap-x-4">
|
|
855
|
+
<WorkloadLinks workloads={c.workloads} onOpen={onOpen} inline />
|
|
856
|
+
{c.workloadsTotal > c.workloads.length && <span className="text-theme-text-tertiary">and {c.workloadsTotal - c.workloads.length} more</span>}
|
|
857
|
+
</span>
|
|
858
|
+
</li>
|
|
859
|
+
))}
|
|
860
|
+
</ul>
|
|
861
|
+
) : (
|
|
862
|
+
<div className="py-1.5 pl-10 pr-3"><WorkloadLinks workloads={workloads} onOpen={onOpen} inline /></div>
|
|
863
|
+
)}
|
|
864
|
+
</Disclosure>
|
|
865
|
+
</div>
|
|
866
|
+
)
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// The rows follow a search or workload filter, so they're counted here, not
|
|
870
|
+
// by the summary's unfiltered total.
|
|
871
|
+
function UnscannedList({ data, onOpen }: { data: VulnerabilitiesResponse; onOpen: (w: VulnerabilityWorkloadRef) => void }) {
|
|
872
|
+
const unscanned = data.unscanned ?? []
|
|
873
|
+
if (unscanned.length === 0) return null
|
|
874
|
+
const count = unscanned.length + (data.coverage.unscannedOmitted ?? 0)
|
|
875
|
+
return (
|
|
876
|
+
<div className="shrink-0 rounded-lg border border-theme-border bg-theme-surface">
|
|
877
|
+
<Disclosure
|
|
878
|
+
flush
|
|
879
|
+
summary={
|
|
880
|
+
<span className="flex items-center gap-2 text-sm text-theme-text-secondary">
|
|
881
|
+
<CircleDashed className="h-4 w-4 text-theme-text-tertiary" aria-hidden />
|
|
882
|
+
{count} running {count === 1 ? 'image has' : 'images have'} no report yet: unknown, not clean
|
|
883
|
+
</span>
|
|
884
|
+
}
|
|
885
|
+
>
|
|
886
|
+
<ul className="flex flex-col">
|
|
887
|
+
{unscanned.map((u) => (
|
|
888
|
+
<li key={u.image} className={FOLD_ROW}>
|
|
889
|
+
<span className="flex min-w-0 flex-col">
|
|
890
|
+
<ImageName image={u.image} className="text-theme-text-primary" />
|
|
891
|
+
{u.otherBuildScanned && (
|
|
892
|
+
<WithTooltip tip={OTHER_BUILD_TIP}>
|
|
893
|
+
<span className="self-start text-xs text-theme-text-tertiary underline decoration-dotted underline-offset-2">Trivy scanned another build of this tag</span>
|
|
894
|
+
</WithTooltip>
|
|
895
|
+
)}
|
|
896
|
+
</span>
|
|
897
|
+
<span className="flex min-w-0 flex-wrap items-baseline gap-x-4">
|
|
898
|
+
<WorkloadLinks workloads={u.workloads} onOpen={onOpen} inline />
|
|
899
|
+
{u.workloadsTotal > u.workloads.length && <span className="text-theme-text-tertiary">and {u.workloadsTotal - u.workloads.length} more</span>}
|
|
900
|
+
</span>
|
|
901
|
+
</li>
|
|
902
|
+
))}
|
|
903
|
+
</ul>
|
|
904
|
+
</Disclosure>
|
|
905
|
+
</div>
|
|
906
|
+
)
|
|
907
|
+
}
|