@skyhook-io/radar-app 1.21.2 → 1.21.4

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.
Files changed (103) hide show
  1. package/README.md +11 -0
  2. package/package.json +2 -2
  3. package/src/App.tsx +53 -28
  4. package/src/api/actions.test.ts +11 -0
  5. package/src/api/actions.ts +5 -0
  6. package/src/api/apiResources.navigation.test.tsx +58 -0
  7. package/src/api/apiResources.ts +22 -16
  8. package/src/api/client.diagnostics.test.ts +52 -0
  9. package/src/api/client.triggerCronJob.test.tsx +49 -0
  10. package/src/api/client.ts +140 -120
  11. package/src/api/connectionBinding.test.tsx +82 -0
  12. package/src/api/connectionBinding.ts +52 -0
  13. package/src/api/contextSwitch.test.ts +11 -0
  14. package/src/api/contextSwitch.ts +58 -0
  15. package/src/api/radarFeatures.ts +6 -0
  16. package/src/api/vulnerabilities.export.test.ts +44 -0
  17. package/src/api/vulnerabilities.ts +73 -4
  18. package/src/components/ConnectionErrorView.tsx +13 -0
  19. package/src/components/ContextSwitchActions.tsx +43 -0
  20. package/src/components/ContextSwitcher.tsx +13 -6
  21. package/src/components/SwitchAwareConnectionError.tsx +2 -2
  22. package/src/components/audit/VulnerabilitiesView.test.tsx +177 -0
  23. package/src/components/audit/VulnerabilitiesView.tsx +197 -48
  24. package/src/components/cost/ApplicationCostTab.test.ts +16 -0
  25. package/src/components/cost/ApplicationCostTab.tsx +41 -9
  26. package/src/components/cost/CostTrendChart.tsx +25 -2
  27. package/src/components/cost/CostTrendWithheld.render.test.tsx +105 -0
  28. package/src/components/cost/CostView.tsx +10 -2
  29. package/src/components/cost/CostViewTabs.test.tsx +18 -0
  30. package/src/components/cost/CostViewTabs.tsx +14 -22
  31. package/src/components/cost/WorkloadCostTab.test.ts +15 -0
  32. package/src/components/cost/WorkloadCostTab.tsx +42 -8
  33. package/src/components/cost/source.test.ts +16 -1
  34. package/src/components/cost/source.ts +34 -0
  35. package/src/components/diagnose/investigationEvidence/adapters/diagnose.test.ts +35 -0
  36. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +16 -1
  37. package/src/components/dock/NodeTerminalTab.test.tsx +4 -2
  38. package/src/components/dock/NodeTerminalTab.tsx +8 -8
  39. package/src/components/dock/TerminalTab.test.tsx +12 -1
  40. package/src/components/dock/TerminalTab.tsx +6 -3
  41. package/src/components/home/CostCard.test.tsx +49 -0
  42. package/src/components/home/CostCard.tsx +98 -63
  43. package/src/components/home/mcpToolCatalog.ts +1 -0
  44. package/src/components/resource/DatadogRightsizingPanel.test.tsx +118 -0
  45. package/src/components/resource/DatadogRightsizingPanel.tsx +68 -0
  46. package/src/components/resource/DatadogWorkloadCharts.tsx +149 -0
  47. package/src/components/resource/HPACharts.render.test.tsx +42 -0
  48. package/src/components/resource/HPACharts.tsx +34 -1
  49. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +126 -3
  50. package/src/components/resource/PrometheusChartsGrid.tsx +58 -25
  51. package/src/components/resource/RestartChart.render.test.tsx +72 -0
  52. package/src/components/resource/RestartChart.tsx +31 -3
  53. package/src/components/resource/RightsizingPanel.access.test.tsx +24 -0
  54. package/src/components/resource/RightsizingStrip.render.test.tsx +44 -0
  55. package/src/components/resource/RightsizingStrip.test.ts +1 -188
  56. package/src/components/resource/RightsizingStrip.tsx +27 -300
  57. package/src/components/resource/WorkloadMetricsSection.render.test.tsx +22 -0
  58. package/src/components/resource/WorkloadMetricsSection.tsx +14 -4
  59. package/src/components/resource/nameMatchedScope.ts +39 -0
  60. package/src/components/resources/pod-file-upload.ts +3 -0
  61. package/src/components/resources/renderers/CAPIClusterRenderer.tsx +5 -2
  62. package/src/components/resources/renderers/LonghornVolumeRenderer.test.tsx +104 -0
  63. package/src/components/resources/renderers/LonghornVolumeRenderer.tsx +31 -0
  64. package/src/components/rightsizing/RightsizingScanLink.tsx +22 -0
  65. package/src/components/rightsizing/RightsizingScanView.tsx +65 -528
  66. package/src/components/rightsizing/model.test.ts +20 -9
  67. package/src/components/rightsizing/model.ts +17 -176
  68. package/src/components/rightsizing/notices.test.tsx +30 -29
  69. package/src/components/traffic/TrafficGraph.export.test.tsx +57 -0
  70. package/src/components/traffic/TrafficGraph.tsx +9 -4
  71. package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +1 -0
  72. package/src/components/traffic/TrafficView.tsx +17 -2
  73. package/src/components/ui/DiagnosticsOverlay.test.ts +3 -2
  74. package/src/components/ui/DiagnosticsOverlay.tsx +23 -13
  75. package/src/components/ui/command-items.ts +3 -4
  76. package/src/components/useContextSwitchFlow.test.tsx +9 -0
  77. package/src/components/useContextSwitchFlow.tsx +43 -5
  78. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.test.tsx +30 -1
  79. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +3 -2
  80. package/src/components/vulnerabilities/parts.test.ts +59 -3
  81. package/src/components/vulnerabilities/parts.tsx +199 -5
  82. package/src/components/workload/WorkloadRightsizingSource.test.tsx +83 -0
  83. package/src/components/workload/WorkloadView.test.ts +22 -1
  84. package/src/components/workload/WorkloadView.tsx +57 -16
  85. package/src/context/ConnectionContext.test.ts +1 -0
  86. package/src/context/ConnectionContext.tsx +58 -15
  87. package/src/context/ConnectionProvider.connectionId.test.tsx +92 -0
  88. package/src/context/ConnectionProvider.retry.test.tsx +174 -1
  89. package/src/context/ContextSwitchContext.tsx +15 -1
  90. package/src/context/NavCustomization.tsx +6 -3
  91. package/src/hooks/useDesktopDownload.test.tsx +57 -0
  92. package/src/hooks/useDesktopDownload.ts +31 -9
  93. package/src/hooks/useEventSource.test.tsx +85 -0
  94. package/src/hooks/useEventSource.ts +43 -16
  95. package/src/hooks/useResetViewsOnContextChange.test.tsx +34 -0
  96. package/src/hooks/useResetViewsOnContextChange.ts +27 -0
  97. package/src/index.ts +3 -0
  98. package/src/integrations/resourceHosts.test.tsx +1 -1
  99. package/src/integrations/resourceHosts.tsx +2 -0
  100. package/src/utils/navigation.ts +1 -15
  101. package/src/utils/page-links.ts +6 -0
  102. package/src/components/rightsizing/presentation.test.ts +0 -150
  103. package/src/components/rightsizing/presentation.ts +0 -109
@@ -1,8 +1,9 @@
1
1
  import { useState } from 'react'
2
+ import { useMutation } from '@tanstack/react-query'
2
3
  import { WithTooltip } from '../ui/Tooltip'
3
4
  import { useSearchParams } from 'react-router-dom'
4
5
  import { clsx } from 'clsx'
5
- import { AlertTriangle, CircleDashed, ExternalLink, Info, Search, ShieldAlert, ShieldCheck, X } from 'lucide-react'
6
+ import { AlertTriangle, ArrowDownWideNarrow, CircleDashed, FileSpreadsheet, ExternalLink, Info, Search, ShieldAlert, ShieldCheck, X } from 'lucide-react'
6
7
  import {
7
8
  Collapse,
8
9
  CollapseChevron,
@@ -22,21 +23,28 @@ import {
22
23
  DistributionLegendChip,
23
24
  FilterPill,
24
25
  Input,
26
+ RowActionMenu,
25
27
  } from '@skyhook-io/k8s-ui'
26
28
  import { SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
27
29
  import { formatRelativeAgeTime } from '@skyhook-io/k8s-ui/utils/format'
28
- import { ApiError, useCapabilities } from '../../api/client'
30
+ import { triggerDownload } from '@skyhook-io/k8s-ui/utils/download'
31
+ import { ApiError, useCapabilities, useRadarFeature } from '../../api/client'
29
32
  import { useAPIResources } from '../../api/apiResources'
30
33
  import {
34
+ fetchVulnerabilitiesCSV,
31
35
  hasVulnerabilityReports,
36
+ vulnerabilitiesCSVFilename,
32
37
  JAVA4SHELL_CVE,
33
38
  useVulnerabilities,
34
39
  isKindUnknown,
35
40
  parseWorkloadParam,
36
41
  workloadParam,
42
+ type VulnerabilitiesParams,
43
+ type VulnerabilityExportView,
37
44
  type VulnerabilitiesResponse,
38
45
  type VulnerabilityCVE,
39
46
  type VulnerabilityFix,
47
+ type VulnerabilityGap,
40
48
  type VulnerabilitySeverity,
41
49
  type VulnerabilityView,
42
50
  type VulnerabilityWorkload,
@@ -45,6 +53,7 @@ import {
45
53
  } from '../../api/vulnerabilities'
46
54
  import type { SelectedResource } from '../../types'
47
55
  import { useConnection } from '../../context/ConnectionContext'
56
+ import { useDesktopDownload } from '../../hooks/useDesktopDownload'
48
57
  import { ChecksViewTabs } from './ChecksViewTabs'
49
58
  import { Java4ShellPanel } from './Java4ShellPanel'
50
59
  import {
@@ -66,7 +75,18 @@ import {
66
75
  OTHER_BUILD_TIP,
67
76
  imageParts,
68
77
  gapSentence,
69
- workloadSummary,
78
+ WorkloadSummary,
79
+ ExposedMark,
80
+ exposureLookup,
81
+ routesFor,
82
+ routeText,
83
+ routesTip,
84
+ ExposedCount,
85
+ exposureUnknownIn,
86
+ exposureGapSentence,
87
+ uncheckedRoutesSentence,
88
+ EXPOSURE,
89
+ type ExposureLookup,
70
90
  } from '../vulnerabilities/parts'
71
91
 
72
92
  interface VulnerabilitiesViewProps {
@@ -75,8 +95,8 @@ interface VulnerabilitiesViewProps {
75
95
  }
76
96
 
77
97
  const VIEWS: { key: VulnerabilityView; label: string }[] = [
78
- { key: 'image', label: 'By image' },
79
98
  { key: 'fix', label: 'By fix' },
99
+ { key: 'image', label: 'By image' },
80
100
  { key: 'cve', label: 'By CVE' },
81
101
  { key: 'workload', label: 'By workload' },
82
102
  ]
@@ -92,6 +112,8 @@ const IMAGE_COLS = 'grid-cols-[minmax(220px,1.6fr)_minmax(180px,1.2fr)_88px_minm
92
112
  const FIX_COLS = 'grid-cols-[minmax(200px,1.2fr)_minmax(220px,1.5fr)_120px_minmax(0,1.6fr)_64px_80px]'
93
113
  const CVE_COLS = 'grid-cols-[minmax(260px,1.6fr)_80px_48px_minmax(200px,1.6fr)_56px_64px_80px]'
94
114
  const WORKLOAD_COLS = 'grid-cols-[minmax(200px,1.4fr)_minmax(180px,1.2fr)_minmax(0,2.4fr)]'
115
+ // With the route column, shown only when the answer reports exposure.
116
+ const WORKLOAD_ROUTE_COLS = 'grid-cols-[minmax(200px,1.4fr)_minmax(180px,1.2fr)_minmax(180px,1.2fr)_minmax(0,2fr)]'
95
117
  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'
96
118
  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'
97
119
  const SUB = 'grid items-baseline gap-4 py-1.5 pl-10 pr-3 text-xs'
@@ -104,9 +126,10 @@ const toResource = (w: VulnerabilityWorkloadRef): SelectedResource => ({ kind: w
104
126
  // describe the unfiltered scope.
105
127
  export function VulnerabilitiesView({ namespaces, onNavigateToResource }: VulnerabilitiesViewProps) {
106
128
  const [params, setParams] = useSearchParams()
107
- const view = (VIEWS.find((v) => v.key === params.get('by'))?.key ?? 'image') as VulnerabilityView
129
+ const view = (VIEWS.find((v) => v.key === params.get('by'))?.key ?? 'fix') as VulnerabilityView
108
130
  const severities = (params.get('severity') ?? '').split(',').filter((s): s is VulnerabilitySeverity => LEGEND.some((x) => x.key === s))
109
131
  const fixableOnly = params.get('fixable') === '1'
132
+ const exposedOnly = params.get('exposed') === '1'
110
133
  const queryDraft = params.get('q') ?? ''
111
134
  const workload = parseWorkloadParam(params.get('workload'))
112
135
  const query = useDebouncedValue(queryDraft.trim(), 300)
@@ -123,7 +146,8 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
123
146
  mutate(next)
124
147
  setParams(next, { replace: !push })
125
148
  }
126
- const { data, isLoading, isFetching, isPlaceholderData, error, dataUpdatedAt, refetch } = useVulnerabilities({ view, namespaces, severities, fixableOnly, query, workload }, !reportsAbsent)
149
+ const tableParams: VulnerabilitiesParams = { view, namespaces, severities, fixableOnly, exposed: exposedOnly, query, workload }
150
+ const { data, isLoading, isFetching, isPlaceholderData, error, dataUpdatedAt, refetch } = useVulnerabilities(tableParams, !reportsAbsent)
127
151
  const hasReports = !reportsAbsent && (hasVulnerabilityReports(resources) || !!data)
128
152
  const trivySearch = new URLSearchParams({ by: 'cve', q: JAVA4SHELL_CVE })
129
153
  for (const key of ['namespace', 'namespaces']) {
@@ -176,7 +200,9 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
176
200
  }
177
201
 
178
202
  // By fix lists only fixable findings, and hides the chip that says so.
179
- const filtered = severities.length > 0 || (fixableOnly && view !== 'fix') || query !== '' || !!workload
203
+ // An older Radar ignores exposed=1 and reports no exposure.
204
+ const exposure = data.exposure
205
+ const filtered = severities.length > 0 || (fixableOnly && view !== 'fix') || (exposedOnly && !!exposure) || query !== '' || !!workload
180
206
  // Narrowed only to a workload whose images are all clean or unscanned:
181
207
  // the folds below list them, so "nothing matches" would mislead.
182
208
  const workloadFolds = !!workload && (view === 'image' || view === 'workload') && severities.length === 0 && !fixableOnly && query === '' &&
@@ -186,7 +212,8 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
186
212
  // With nothing scanned or readable there are no counts to show or filter.
187
213
  const known = findingsCertainty(data) !== 'unknown'
188
214
  // A new view or filter starts again from the first page of rows.
189
- const pageKey = JSON.stringify([view, namespaces, severities, fixableOnly, query, workload])
215
+ const pageKey = JSON.stringify([view, namespaces, severities, fixableOnly, exposedOnly, query, workload])
216
+ const fixChip = known && view !== 'fix'
190
217
  return (
191
218
  <div aria-busy={isFetching} className="flex-1 flex flex-col min-h-0 p-4 gap-4 overflow-auto">
192
219
  <ChecksViewTabs />
@@ -194,7 +221,12 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
194
221
  icon={ShieldAlert}
195
222
  title="Vulnerabilities"
196
223
  description="Known CVEs in the images that run now, from Trivy Operator's reports."
197
- actions={<FreshnessControl mode="auto" dataUpdatedAt={dataUpdatedAt} isFetching={isFetching} onRefresh={() => refetch()} connectionState={connection.state} />}
224
+ actions={
225
+ <div className="flex items-center gap-2">
226
+ <FreshnessControl mode="auto" dataUpdatedAt={dataUpdatedAt} isFetching={isFetching} onRefresh={() => refetch()} connectionState={connection.state} />
227
+ <ExportMenu params={tableParams} cluster={connection.clusterName || connection.context} />
228
+ </div>
229
+ }
198
230
  />
199
231
  {advisory}
200
232
 
@@ -233,11 +265,16 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
233
265
  onClick={() => toggleSeverity(s.key)}
234
266
  />
235
267
  ))}
236
- {known && view !== 'fix' && (
237
- <>
238
- <span aria-hidden className="mx-1.5 h-5 w-px bg-theme-border" />
239
- <FilterPill label="Has a fix" active={fixableOnly} onClick={() => update((p) => (fixableOnly ? p.delete('fixable') : p.set('fixable', '1')))} />
240
- </>
268
+ {(fixChip || exposure) && <span aria-hidden className="mx-1.5 h-5 w-px bg-theme-border" />}
269
+ {fixChip && <FilterPill label="Fix available" tooltip="Only findings the scanner lists a fixed release for" active={fixableOnly} onClick={() => update((p) => (fixableOnly ? p.delete('fixable') : p.set('fixable', '1')))} />}
270
+ {exposure && (
271
+ <FilterPill
272
+ label={EXPOSURE.chip}
273
+ icon={EXPOSURE.icon}
274
+ tooltip={EXPOSURE.chipTip}
275
+ active={exposedOnly}
276
+ onClick={() => update((p) => (exposedOnly ? p.delete('exposed') : p.set('exposed', '1')))}
277
+ />
241
278
  )}
242
279
  {workload && (
243
280
  <>
@@ -257,7 +294,7 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
257
294
  key={v.key}
258
295
  type="button"
259
296
  aria-pressed={view === v.key}
260
- onClick={() => update((p) => (v.key === 'image' ? p.delete('by') : p.set('by', v.key)), true)}
297
+ onClick={() => update((p) => (v.key === 'fix' ? p.delete('by') : p.set('by', v.key)), true)}
261
298
  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')}
262
299
  >
263
300
  {v.label}
@@ -268,7 +305,7 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
268
305
  </div>
269
306
 
270
307
  <div className="flex flex-col gap-1.5">
271
- <CoverageNotes data={data} filtered={filtered} />
308
+ <CoverageNotes data={data} filtered={filtered} view={view} />
272
309
  {error && <p className="text-xs text-warning-text">Couldn't refresh: {error instanceof Error ? error.message : 'request failed'}. Showing the last answer.</p>}
273
310
  </div>
274
311
 
@@ -292,6 +329,7 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
292
329
  ) : view === 'workload' ? (
293
330
  <Paged key={pageKey} rows={data.workloads ?? []}>{(rows) => <WorkloadTable
294
331
  workloads={rows}
332
+ exposure={exposure}
295
333
  severities={severities}
296
334
  query={query}
297
335
  namespaces={namespaces}
@@ -320,6 +358,35 @@ export function VulnerabilitiesView({ namespaces, onNavigateToResource }: Vulner
320
358
  )
321
359
  }
322
360
 
361
+ const VIEW_NAMES: Partial<Record<VulnerabilityView, string>> = { fix: 'By fix', image: 'By image', cve: 'By CVE', workload: 'By workload' }
362
+
363
+ // The page's overflow menu: CSV of the view on screen with its filters, or
364
+ // of every finding (one row per CVE, image and workload, the shape a POA&M
365
+ // or a ticket import wants). Each lists every row and every value the table
366
+ // shortens.
367
+ function ExportMenu({ params, cluster }: { params: VulnerabilitiesParams; cluster: string }) {
368
+ const { support, guard } = useRadarFeature('vulnerabilitiesExport')
369
+ const desktopDownload = useDesktopDownload()
370
+ const download = useMutation({
371
+ // The file is named for the view and cluster the request was for.
372
+ mutationFn: ({ params, as }: { params: VulnerabilitiesParams; as: VulnerabilityExportView; cluster: string }) => guard(() => fetchVulnerabilitiesCSV(params, as)),
373
+ onSuccess: (csv, { as, cluster }) => triggerDownload(csv, 'text/csv;charset=utf-8', vulnerabilitiesCSVFilename(as, cluster), desktopDownload),
374
+ meta: { errorMessage: 'Could not download the CSV' },
375
+ })
376
+ if (support !== 'supported') return null
377
+ const pending = download.isPending ? download.variables?.as : undefined
378
+ return (
379
+ <RowActionMenu
380
+ compact={false}
381
+ ariaLabel="More actions"
382
+ items={[
383
+ { key: 'view', label: `Download ${VIEW_NAMES[params.view] ?? 'this view'} as CSV`, icon: FileSpreadsheet, pending: pending === params.view, disabled: !!pending, onClick: () => download.mutate({ params, as: params.view, cluster }) },
384
+ { key: 'findings', label: 'Download all findings as CSV', icon: FileSpreadsheet, pending: pending === 'findings', disabled: !!pending, onClick: () => download.mutate({ params, as: 'findings', cluster }) },
385
+ ]}
386
+ />
387
+ )
388
+ }
389
+
323
390
  function emptyHeadline(view: VulnerabilityView, filtered: boolean, data: VulnerabilitiesResponse, workload: { name: string } | null): string {
324
391
  // Narrowed to one workload, the folds below say what it runs.
325
392
  if (workload && (data.unscanned ?? []).length > 0) {
@@ -394,8 +461,16 @@ function SummaryHeadline({ data }: { data: VulnerabilitiesResponse }) {
394
461
  )
395
462
  }
396
463
 
397
- function CoverageNotes({ data, filtered }: { data: VulnerabilitiesResponse; filtered: boolean }) {
464
+ // How each view orders its rows, for the sort hint's tooltip.
465
+ function sortRule(view: VulnerabilityView): string {
466
+ const tiebreak = view === 'workload' ? '' : ' Then the most exposed workloads, then the most workloads.'
467
+ return `Most severe first. Within each severity, exposed rows come first, then those whose exposure is unknown.${tiebreak}`
468
+ }
469
+
470
+ function CoverageNotes({ data, filtered, view }: { data: VulnerabilitiesResponse; filtered: boolean; view: VulnerabilityView }) {
398
471
  const gaps = gapSentence(data.coverage.gaps)
472
+ const exposureNotes = [exposureGapSentence(data.exposure?.gaps), uncheckedRoutesSentence(data.exposure?.unchecked)].filter(Boolean).join(' ')
473
+ const unscannedExposed = (data.unscanned ?? []).reduce((n, u) => n + (u.exposedTotal ?? 0), 0)
399
474
  const scan = data.summary.newestScan
400
475
  ? data.summary.oldestScan && data.summary.oldestScan !== data.summary.newestScan
401
476
  ? `Scans from ${formatRelativeAgeTime(data.summary.oldestScan)} to ${formatRelativeAgeTime(data.summary.newestScan)}`
@@ -403,7 +478,7 @@ function CoverageNotes({ data, filtered }: { data: VulnerabilitiesResponse; filt
403
478
  : null
404
479
  return (
405
480
  <div className="flex flex-col gap-1.5 text-xs">
406
- <p className="flex items-center gap-1.5 text-theme-text-tertiary">
481
+ <p className="flex flex-wrap items-center gap-x-1.5 gap-y-1 text-theme-text-tertiary">
407
482
  {[scan, filtered ? 'Totals ignore the filters' : null].filter(Boolean).join(' · ')}
408
483
  {/* For someone comparing these numbers with Trivy's own: why they can differ. */}
409
484
  <WithTooltip tip={[
@@ -413,6 +488,30 @@ function CoverageNotes({ data, filtered }: { data: VulnerabilitiesResponse; filt
413
488
  ].filter(Boolean).join(' ')}>
414
489
  <Info className="h-3.5 w-3.5" aria-label="How these numbers relate to Trivy's" />
415
490
  </WithTooltip>
491
+ {data.exposure && (
492
+ <WithTooltip tip={sortRule(view)}>
493
+ <span className="inline-flex items-center gap-1 rounded px-1 hover:text-theme-text-secondary" tabIndex={0} aria-label={`Sort: ${sortRule(view)}`}>
494
+ <ArrowDownWideNarrow className="h-3.5 w-3.5" aria-hidden />
495
+ Severity, then exposure
496
+ </span>
497
+ </WithTooltip>
498
+ )}
499
+ {exposureNotes && (
500
+ <WithTooltip tip={exposureNotes}>
501
+ <span className="inline-flex items-center gap-1 text-warning-text" tabIndex={0} aria-label={exposureNotes}>
502
+ <AlertTriangle className="h-3.5 w-3.5" aria-hidden />
503
+ Exposure partly unknown
504
+ </span>
505
+ </WithTooltip>
506
+ )}
507
+ {unscannedExposed > 0 && (
508
+ <WithTooltip tip="Exposed workloads whose images Trivy hasn't scanned yet: their findings are unknown. They're listed under the table.">
509
+ <span className="inline-flex items-center gap-1 text-warning-text" tabIndex={0}>
510
+ <CircleDashed className="h-3.5 w-3.5" aria-hidden />
511
+ {unscannedExposed} exposed {unscannedExposed === 1 ? 'workload' : 'workloads'} not scanned
512
+ </span>
513
+ </WithTooltip>
514
+ )}
416
515
  </p>
417
516
  {gaps && <p className="text-warning-text">{gaps}</p>}
418
517
  {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>}
@@ -455,17 +554,21 @@ function Disclosure({ summary, children, flush = false }: { summary: React.React
455
554
  )
456
555
  }
457
556
 
458
- function WorkloadLinks({ workloads, onOpen, inline = false }: { workloads: VulnerabilityWorkloadRef[]; onOpen: (w: VulnerabilityWorkloadRef) => void; inline?: boolean }) {
557
+ function WorkloadLinks({ workloads, onOpen, inline = false, exposure }: { workloads: VulnerabilityWorkloadRef[]; onOpen: (w: VulnerabilityWorkloadRef) => void; inline?: boolean; exposure?: ExposureLookup }) {
459
558
  return (
460
559
  <ul className={clsx('flex min-w-0', inline ? 'flex-wrap gap-x-4 gap-y-0.5' : 'flex-col gap-0.5')}>
461
- {workloads.map((w) => (
462
- <li key={`${w.namespace}/${w.kind}/${w.name}/${w.container ?? ''}`} className="min-w-0">
560
+ {workloads.map((w) => {
561
+ const exposed = routesFor(exposure, w)
562
+ return (
563
+ <li key={`${w.namespace}/${w.kind}/${w.name}/${w.container ?? ''}`} className="flex min-w-0 items-baseline gap-1">
564
+ {exposed && <ExposedMark exposed={exposed} />}
463
565
  <button type="button" onClick={() => onOpen(w)} className="group flex min-w-0 items-baseline gap-1.5 text-left text-xs">
464
566
  <span className="truncate text-accent-text group-hover:underline">{w.name}</span>
465
567
  <span className="shrink-0 text-theme-text-tertiary">{w.kind} · {w.namespace}{w.container ? ` · ${w.container}` : ''}</span>
466
568
  </button>
467
569
  </li>
468
- ))}
570
+ )
571
+ })}
469
572
  </ul>
470
573
  )
471
574
  }
@@ -486,6 +589,7 @@ function ImageTable({ images, onOpen, onOpenReport }: { images: VulnerableImage[
486
589
  <span>Image</span><span>Findings</span><NumHead>With a fix</NumHead><span>Running in</span><NumHead>Scanned</NumHead>
487
590
  </div>
488
591
  {images.map((img) => {
592
+ const exposure = exposureLookup(img.exposed)
489
593
  const total = img.counts.critical + img.counts.high + img.counts.medium + img.counts.low + img.counts.unknown
490
594
  const fixable = img.fixable.critical + img.fixable.high + img.fixable.medium + img.fixable.low + img.fixable.unknown
491
595
  return (
@@ -503,8 +607,11 @@ function ImageTable({ images, onOpen, onOpenReport }: { images: VulnerableImage[
503
607
  <Num>{img.findingsUnread ? '—' : <>{fixable}<span className="text-theme-text-tertiary"> of {total}</span></>}</Num>
504
608
  </WithTooltip>
505
609
  <span className="flex min-w-0 flex-col">
506
- <span className="truncate text-theme-text-secondary">{workloadSummary(img.workloads)}{img.workloadsTotal > img.workloads.length ? ` and ${img.workloadsTotal - img.workloads.length} more` : ''}</span>
507
- <span className="text-xs text-theme-text-tertiary">{namespaceCount(img)}</span>
610
+ <WorkloadSummary workloads={img.workloads} exposure={exposure} suffix={img.workloadsTotal > img.workloads.length ? ` and ${img.workloadsTotal - img.workloads.length} more` : ''} />
611
+ <span className="flex flex-wrap items-center gap-x-2 text-xs text-theme-text-tertiary">
612
+ {namespaceCount(img)}
613
+ <ExposedCount exposed={img.exposed} total={img.exposedTotal} unknown={img.exposureUnknown} />
614
+ </span>
508
615
  </span>
509
616
  <span className="text-right text-xs text-theme-text-tertiary">{formatRelativeAgeTime(img.scannedAt)}</span>
510
617
  </div>
@@ -523,7 +630,7 @@ function ImageTable({ images, onOpen, onOpenReport }: { images: VulnerableImage[
523
630
  </div>
524
631
  <div className="col-span-2 flex min-w-0 flex-col gap-1.5">
525
632
  <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>
526
- <WorkloadLinks workloads={img.workloads} onOpen={onOpen} />
633
+ <WorkloadLinks workloads={img.workloads} onOpen={onOpen} exposure={exposure} />
527
634
  </div>
528
635
  </div>
529
636
  </Disclosure>
@@ -569,16 +676,14 @@ function FindingsList({ findings, total, unread }: { findings: VulnerableImage['
569
676
  function FixTable({ fixes, onOpen, onShowCVE }: { fixes: VulnerabilityFix[]; onOpen: (w: VulnerabilityWorkloadRef) => void; onShowCVE: (id: string) => void }) {
570
677
  return (
571
678
  <div className="flex shrink-0 flex-col gap-2">
572
- <p className="text-xs text-theme-text-tertiary">
573
- Upgrading a package means rebuilding the image that holds it.
574
- </p>
575
679
  <div className="overflow-x-auto overflow-y-hidden rounded-lg border border-theme-border bg-theme-surface">
576
680
  <div className="min-w-[960px]">
577
681
  <div className={clsx(HEAD, FIX_COLS)}>
578
- <span>Package</span><span>Upgrade</span><span>Clears</span><span>Running in</span><NumHead>Images</NumHead><NumHead>Workloads</NumHead>
682
+ <span>Package</span><WithTooltip tip="Upgrading a package means rebuilding the image that holds it."><span className="self-start underline decoration-dotted underline-offset-2">Upgrade</span></WithTooltip><span>Clears</span><span>Running in</span><NumHead>Images</NumHead><NumHead>Workloads</NumHead>
579
683
  </div>
580
684
  {fixes.map((f) => {
581
685
  const runners = f.affected.flatMap((a) => a.workloads)
686
+ const exposure = exposureLookup(f.exposed)
582
687
  const several = f.from.length > 1
583
688
  return (
584
689
  <Disclosure
@@ -601,9 +706,12 @@ function FixTable({ fixes, onOpen, onShowCVE }: { fixes: VulnerabilityFix[]; onO
601
706
  </span>
602
707
  </WithTooltip>
603
708
  <SeverityCounts counts={f.counts} />
604
- <span className="truncate text-theme-text-secondary">{workloadSummary(runners)}</span>
709
+ <WorkloadSummary workloads={runners} exposure={exposure} />
605
710
  <Num>{f.images}</Num>
606
- <Num strong>{f.workloads}</Num>
711
+ <span className="flex flex-col items-end">
712
+ <Num strong>{f.workloads}</Num>
713
+ <ExposedCount exposed={f.exposed} total={f.exposedTotal} workloads={f.workloads} unknown={f.exposureUnknown} />
714
+ </span>
607
715
  </div>
608
716
  }
609
717
  >
@@ -621,7 +729,7 @@ function FixTable({ fixes, onOpen, onShowCVE }: { fixes: VulnerabilityFix[]; onO
621
729
  <ImageName image={a.image} className="text-theme-text-primary" />
622
730
  <span className="truncate font-mono text-theme-text-tertiary">{several ? a.installedVersions.join(', ') : ''}</span>
623
731
  <span />
624
- <WorkloadLinks workloads={a.workloads} onOpen={onOpen} inline />
732
+ <WorkloadLinks workloads={a.workloads} onOpen={onOpen} inline exposure={exposure} />
625
733
  <span />
626
734
  <Num>{a.workloadsTotal}</Num>
627
735
  </div>
@@ -644,7 +752,9 @@ function CVETable({ cves, onOpen }: { cves: VulnerabilityCVE[]; onOpen: (w: Vuln
644
752
  <div className={clsx(HEAD, CVE_COLS)}>
645
753
  <span>CVE</span><span>Severity</span><NumHead>Score</NumHead><span>Package</span><span>Fix</span><NumHead>Images</NumHead><NumHead>Workloads</NumHead>
646
754
  </div>
647
- {cves.map((c) => (
755
+ {cves.map((c) => {
756
+ const exposure = exposureLookup(c.exposed)
757
+ return (
648
758
  <Disclosure
649
759
  key={c.id}
650
760
  flush
@@ -659,7 +769,10 @@ function CVETable({ cves, onOpen }: { cves: VulnerabilityCVE[]; onOpen: (w: Vuln
659
769
  <span className="truncate font-mono text-xs text-theme-text-secondary">{c.packages.join(', ')}</span>
660
770
  <CVEFix cve={c} />
661
771
  <Num>{c.images}</Num>
662
- <Num strong>{c.workloads}</Num>
772
+ <span className="flex flex-col items-end">
773
+ <Num strong>{c.workloads}</Num>
774
+ <ExposedCount exposed={c.exposed} total={c.exposedTotal} workloads={c.workloads} unknown={c.exposureUnknown} />
775
+ </span>
663
776
  </div>
664
777
  }
665
778
  >
@@ -667,7 +780,7 @@ function CVETable({ cves, onOpen }: { cves: VulnerabilityCVE[]; onOpen: (w: Vuln
667
780
  <div key={a.imageId} className={clsx(SUB, CVE_COLS)}>
668
781
  <span className="flex min-w-0 flex-col gap-0.5">
669
782
  <ImageName image={a.image} className="text-theme-text-primary" />
670
- <WorkloadLinks workloads={a.workloads} onOpen={onOpen} inline />
783
+ <WorkloadLinks workloads={a.workloads} onOpen={onOpen} inline exposure={exposure} />
671
784
  </span>
672
785
  <span className="col-span-2" />
673
786
  <span className="col-span-2 flex min-w-0 flex-col">
@@ -687,15 +800,18 @@ function CVETable({ cves, onOpen }: { cves: VulnerabilityCVE[]; onOpen: (w: Vuln
687
800
  {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>}
688
801
  </div>
689
802
  </Disclosure>
690
- ))}
803
+ )
804
+ })}
691
805
  </div>
692
806
  </div>
693
807
  </div>
694
808
  )
695
809
  }
696
810
 
697
- function WorkloadTable({ workloads, severities, query, namespaces, onOpen, onShow }: {
811
+ function WorkloadTable({ workloads, exposure, severities, query, namespaces, onOpen, onShow }: {
698
812
  workloads: VulnerabilityWorkload[]
813
+ /** Absent from an older Radar: the route column is left out, not shown empty. */
814
+ exposure: VulnerabilitiesResponse['exposure']
699
815
  severities: VulnerabilitySeverity[]
700
816
  query: string
701
817
  /** The table's namespace scope, so an expanded row reads what the row did. */
@@ -703,23 +819,25 @@ function WorkloadTable({ workloads, severities, query, namespaces, onOpen, onSho
703
819
  onOpen: (w: VulnerabilityWorkloadRef) => void
704
820
  onShow: (w: VulnerabilityWorkloadRef, by: VulnerabilityView) => void
705
821
  }) {
822
+ const cols = exposure ? WORKLOAD_ROUTE_COLS : WORKLOAD_COLS
706
823
  return (
707
824
  <div className="shrink-0 overflow-x-auto overflow-y-hidden rounded-lg border border-theme-border bg-theme-surface">
708
- <div className="min-w-[760px]">
709
- <div className={clsx(HEAD, WORKLOAD_COLS)}>
710
- <span>Workload</span><span>Findings across its images</span><span>Containers</span>
825
+ <div className={exposure ? 'min-w-[920px]' : 'min-w-[760px]'}>
826
+ <div className={clsx(HEAD, cols)}>
827
+ <span>Workload</span><span>Findings across its images</span>{exposure && <span>{EXPOSURE.column}</span>}<span>Containers</span>
711
828
  </div>
712
829
  {workloads.map((w) => (
713
830
  <Disclosure
714
831
  key={`${w.namespace}/${w.kind}/${w.name}`}
715
832
  flush
716
833
  summary={
717
- <div className={clsx('grid flex-1 items-start gap-4 text-sm', WORKLOAD_COLS)}>
834
+ <div className={clsx('grid flex-1 items-start gap-4 text-sm', cols)}>
718
835
  <span className="flex min-w-0 flex-col">
719
836
  <span className="truncate text-theme-text-primary">{w.name}</span>
720
837
  <span className="text-xs text-theme-text-tertiary">{w.kind} · {w.namespace}</span>
721
838
  </span>
722
839
  <WorkloadFindings workload={w} />
840
+ {exposure && <WorkloadRoute workload={w} gaps={exposure.gaps} />}
723
841
  <ul className="flex min-w-0 flex-col gap-1">
724
842
  {w.containers.map((c) => (
725
843
  <li key={`${c.name}/${c.image}`} className="flex min-w-0 flex-wrap items-baseline gap-x-2 text-xs">
@@ -732,7 +850,7 @@ function WorkloadTable({ workloads, severities, query, namespaces, onOpen, onSho
732
850
  </div>
733
851
  }
734
852
  >
735
- {(open) => <WorkloadUpgrades workload={w} active={open} severities={severities} query={query} namespaces={namespaces} onOpen={onOpen} onShow={onShow} />}
853
+ {(open) => <WorkloadUpgrades workload={w} routeColumn={!!exposure} active={open} severities={severities} query={query} namespaces={namespaces} onOpen={onOpen} onShow={onShow} />}
736
854
  </Disclosure>
737
855
  ))}
738
856
  </div>
@@ -740,6 +858,31 @@ function WorkloadTable({ workloads, severities, query, namespaces, onOpen, onSho
740
858
  )
741
859
  }
742
860
 
861
+ // The workload's routes from outside the cluster; empty when none was seen,
862
+ // Unknown where Radar couldn't read a route kind in its namespace.
863
+ function WorkloadRoute({ workload: w, gaps }: { workload: VulnerabilityWorkload; gaps?: VulnerabilityGap[] }) {
864
+ const routes = w.routes ?? []
865
+ const total = w.routesTotal ?? routes.length
866
+ if (routes.length > 0) {
867
+ return (
868
+ <WithTooltip tip={routesTip(routes, total)}>
869
+ <span className="flex min-w-0 items-center gap-1 truncate text-xs text-theme-text-secondary">
870
+ <ExposedMark tip={routesTip(routes, total)} />
871
+ {routeText(routes[0])}{total > 1 && <span className="text-theme-text-tertiary"> and {total - 1} more</span>}
872
+ </span>
873
+ </WithTooltip>
874
+ )
875
+ }
876
+ if (w.exposureUnknown || exposureUnknownIn(gaps, w.namespace)) {
877
+ return (
878
+ <WithTooltip tip={EXPOSURE.unknownTip}>
879
+ <span className="text-xs text-theme-text-tertiary">{EXPOSURE.unknown}</span>
880
+ </WithTooltip>
881
+ )
882
+ }
883
+ return <span />
884
+ }
885
+
743
886
  // Whether an upgrade clears the CVE: in every image, some, or none.
744
887
  function CVEFix({ cve: c }: { cve: VulnerabilityCVE }) {
745
888
  const all = c.fixableImages >= c.images
@@ -757,8 +900,10 @@ const MAX_WORKLOAD_UPGRADES = 8
757
900
 
758
901
  // What a workload's owner changes: the By fix rows narrowed to this
759
902
  // workload, read when the row opens.
760
- function WorkloadUpgrades({ workload: w, active, severities, query, namespaces, onOpen, onShow }: {
903
+ function WorkloadUpgrades({ workload: w, routeColumn, active, severities, query, namespaces, onOpen, onShow }: {
761
904
  workload: VulnerabilityWorkload
905
+ /** The table shows the route column; sub-rows keep a cell for it so detail lines up. */
906
+ routeColumn: boolean
762
907
  /** False once the row closes: its subtree stays mounted, its polling stops. */
763
908
  active: boolean
764
909
  severities: VulnerabilitySeverity[]
@@ -769,6 +914,8 @@ function WorkloadUpgrades({ workload: w, active, severities, query, namespaces,
769
914
  onShow: (w: VulnerabilityWorkloadRef, by: VulnerabilityView) => void
770
915
  }) {
771
916
  const ref = { kind: w.kind, group: w.group, namespace: w.namespace, name: w.name }
917
+ const cols = routeColumn ? WORKLOAD_ROUTE_COLS : WORKLOAD_COLS
918
+ const routeCell = routeColumn && <span />
772
919
  // The row's own scope: the newest report for an image wins across every
773
920
  // namespace read, so a narrower read could pick an older one.
774
921
  const { data, isLoading, error } = useVulnerabilities({ view: 'fix', namespaces, severities, query, workload: ref }, active)
@@ -804,20 +951,21 @@ function WorkloadUpgrades({ workload: w, active, severities, query, namespaces,
804
951
  )
805
952
  return (
806
953
  <>
807
- <div className={clsx(SUB, WORKLOAD_COLS)}>
808
- <span className="col-span-3">{lead}</span>
954
+ <div className={clsx(SUB, cols)}>
955
+ <span className="col-span-full">{lead}</span>
809
956
  </div>
810
957
  {fixes.length > 0 && (
811
- <div className={clsx(SUB, WORKLOAD_COLS, 'text-theme-text-tertiary')}>
958
+ <div className={clsx(SUB, cols, 'text-theme-text-tertiary')}>
812
959
  <span />
813
960
  <span className="grid min-w-0 grid-cols-[1.75rem_2.25rem_minmax(0,1fr)] gap-2">
814
961
  <span className="text-right">C</span><span className="text-right">H</span><span>Upgrade</span>
815
962
  </span>
963
+ {routeCell}
816
964
  <span />
817
965
  </div>
818
966
  )}
819
967
  {fixes.slice(0, MAX_WORKLOAD_UPGRADES).map((f) => (
820
- <div key={`${f.packageType ?? ''}/${f.package}/${f.to ?? (f.fixedVersions ?? []).join('|')}`} className={clsx(SUB, WORKLOAD_COLS)}>
968
+ <div key={`${f.packageType ?? ''}/${f.package}/${f.to ?? (f.fixedVersions ?? []).join('|')}`} className={clsx(SUB, cols)}>
821
969
  <span className="flex min-w-0 items-baseline gap-2">
822
970
  <span className="truncate font-mono text-theme-text-primary">{f.package}</span>
823
971
  {f.packageType && <span className="truncate text-theme-text-tertiary">{ecosystemLabel(f.packageType)}</span>}
@@ -830,6 +978,7 @@ function WorkloadUpgrades({ workload: w, active, severities, query, namespaces,
830
978
  ? <WithTooltip tip={`${f.from.join(', ')} → ${f.to}`}><FixVersion installed={installedLabel(f.from)} target={f.to} /></WithTooltip>
831
979
  : <span className="truncate font-mono text-theme-text-secondary">fixed in {(f.fixedVersions ?? []).join(', ')}</span>}
832
980
  </span>
981
+ {routeCell}
833
982
  <span className="flex min-w-0 flex-wrap gap-x-3">
834
983
  {several && f.affected.map((a) => <ImageName key={a.imageId} image={a.image} className="text-theme-text-tertiary" />)}
835
984
  </span>
@@ -932,7 +1081,7 @@ function UnscannedList({ data, onOpen }: { data: VulnerabilitiesResponse; onOpen
932
1081
  )}
933
1082
  </span>
934
1083
  <span className="flex min-w-0 flex-wrap items-baseline gap-x-4">
935
- <WorkloadLinks workloads={u.workloads} onOpen={onOpen} inline />
1084
+ <WorkloadLinks workloads={u.workloads} onOpen={onOpen} inline exposure={exposureLookup(u.exposed)} />
936
1085
  {u.workloadsTotal > u.workloads.length && <span className="text-theme-text-tertiary">and {u.workloadsTotal - u.workloads.length} more</span>}
937
1086
  </span>
938
1087
  </li>
@@ -260,3 +260,19 @@ describe('getApplicationCostState', () => {
260
260
  expect(getApplicationCostState(current, undefined, {})).toBe('configuration_mismatch')
261
261
  })
262
262
  })
263
+
264
+ describe('getApplicationCostState cluster scope', () => {
265
+ it.each(['cluster_scope', 'partial_data'] as const)('reports %s instead of no data', (reason) => {
266
+ const current: OpenCostApplicationCostResponse = {
267
+ available: false,
268
+ reason,
269
+ totals: {
270
+ hourlyCost: 0, cpuCost: 0, memoryCost: 0, replicas: 0,
271
+ cpuUsageAvailable: false, memoryUsageAvailable: false, cpuAllocationUse: 0, memoryAllocationUse: 0,
272
+ },
273
+ coverage: { total: 1, included: 0 },
274
+ clusterScope: { state: 'several_clusters', note: 'several' },
275
+ }
276
+ expect(getApplicationCostState(current, undefined, {})).toBe(reason)
277
+ })
278
+ })