@skyhook-io/radar-app 1.20.3 → 1.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -9
- package/src/App.tsx +67 -15
- 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 +11 -0
- package/src/api/substrateHealth.ts +134 -0
- package/src/api/velero.test.ts +60 -0
- package/src/api/velero.ts +377 -0
- package/src/api/vulnerabilities.ts +313 -0
- package/src/components/NamespaceSwitcher.tsx +3 -1
- package/src/components/audit/AuditView.tsx +4 -0
- package/src/components/audit/ChecksViewTabs.test.tsx +35 -5
- package/src/components/audit/ChecksViewTabs.tsx +12 -1
- package/src/components/audit/Java4ShellPanel.test.tsx +31 -0
- package/src/components/audit/Java4ShellPanel.tsx +313 -0
- package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
- package/src/components/audit/UpgradeReadinessView.tsx +60 -2
- package/src/components/audit/VulnerabilitiesView.tsx +944 -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/FluxOperatorCard.test.tsx +37 -0
- package/src/components/gitops/FluxOperatorCard.tsx +27 -0
- package/src/components/gitops/GitOpsView.rowsSummary.test.tsx +59 -0
- package/src/components/gitops/GitOpsView.tsx +8 -5
- package/src/components/gitops/gitopsRowEvents.test.ts +48 -0
- package/src/components/gitops/gitopsRowEvents.ts +31 -0
- 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 +158 -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/VeleroRunArtifacts.test.tsx +241 -0
- package/src/components/velero/VeleroRunArtifacts.tsx +112 -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/VeleroRunVolumes.test.tsx +247 -0
- package/src/components/velero/VeleroRunVolumes.tsx +122 -0
- package/src/components/velero/VeleroSchedulePause.test.tsx +211 -0
- package/src/components/velero/VeleroSchedulePause.tsx +191 -0
- package/src/components/velero/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 +92 -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 +179 -0
- package/src/components/vulnerabilities/parts.test.ts +72 -0
- package/src/components/vulnerabilities/parts.tsx +291 -0
- package/src/components/whats-new/WhatsNewDialog.test.tsx +6 -4
- package/src/components/whats-new/releaseNotes.ts +67 -1
- 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
|
@@ -33,7 +33,9 @@ export const NamespaceSwitcher = forwardRef<NamespaceSwitcherHandle, NamespaceSw
|
|
|
33
33
|
// per-user RBAC filter on a shared install, where neither applies.
|
|
34
34
|
const canConfigureNamespaces = capabilities?.deployment?.mode === 'local' && authMe?.authEnabled === false
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
// A failed list is a transient read error, retried by the scope query; it
|
|
37
|
+
// says nothing about which namespaces the user can configure.
|
|
38
|
+
const limitedListHelp = canConfigureNamespaces && !scope?.listFailed ? (
|
|
37
39
|
<a href={NAMESPACES_HELP_URL} target="_blank" rel="noreferrer" className="text-accent-text hover:underline">
|
|
38
40
|
How to add namespaces
|
|
39
41
|
</a>
|
|
@@ -9,6 +9,7 @@ import { Tooltip } from '../ui/Tooltip'
|
|
|
9
9
|
import { useConnection } from '../../context/ConnectionContext'
|
|
10
10
|
import { ChecksViewTabs } from './ChecksViewTabs'
|
|
11
11
|
import { UpgradeReadinessView } from './UpgradeReadinessView'
|
|
12
|
+
import { VulnerabilitiesView } from './VulnerabilitiesView'
|
|
12
13
|
|
|
13
14
|
interface AuditViewProps {
|
|
14
15
|
namespaces: string[]
|
|
@@ -26,6 +27,9 @@ export function AuditView({ namespaces, onNavigateToResource }: AuditViewProps)
|
|
|
26
27
|
if (pathname.startsWith('/checks/upgrade')) {
|
|
27
28
|
return <UpgradeReadinessView namespaces={namespaces} onNavigateToResource={onNavigateToResource} />
|
|
28
29
|
}
|
|
30
|
+
if (pathname.startsWith('/checks/vulnerabilities')) {
|
|
31
|
+
return <VulnerabilitiesView namespaces={namespaces} onNavigateToResource={onNavigateToResource} />
|
|
32
|
+
}
|
|
29
33
|
return <BestPracticesView namespaces={namespaces} onNavigateToResource={onNavigateToResource} />
|
|
30
34
|
}
|
|
31
35
|
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
2
|
import { MemoryRouter } from 'react-router-dom'
|
|
3
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
3
4
|
import { describe, expect, it } from 'vitest'
|
|
5
|
+
import type { APIResource } from '../../types'
|
|
4
6
|
import { ChecksViewTabs } from './ChecksViewTabs'
|
|
5
7
|
|
|
8
|
+
const vulnerabilityReports: APIResource = {
|
|
9
|
+
name: 'vulnerabilityreports', kind: 'VulnerabilityReport', group: 'aquasecurity.github.io', version: 'v1alpha1',
|
|
10
|
+
namespaced: true, verbs: ['list', 'get'], isCrd: true,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function render(path: string, resources: APIResource[] = [], runtimeAdvisoryChecks = false) {
|
|
14
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
15
|
+
client.setQueryData(['api-resources'], resources)
|
|
16
|
+
client.setQueryData(['capabilities'], { features: { runtimeAdvisoryChecks } })
|
|
17
|
+
return renderToStaticMarkup(
|
|
18
|
+
<QueryClientProvider client={client}>
|
|
19
|
+
<MemoryRouter initialEntries={[path]}>
|
|
20
|
+
<ChecksViewTabs />
|
|
21
|
+
</MemoryRouter>
|
|
22
|
+
</QueryClientProvider>,
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
6
26
|
describe('ChecksViewTabs', () => {
|
|
7
27
|
it('keeps browsing scope across tabs without leaking upgrade-only target state', () => {
|
|
8
|
-
const html =
|
|
9
|
-
<MemoryRouter initialEntries={['/checks/upgrade?namespaces=shop%2Cprod&target=1.36&resource=shop%2Fapi']}>
|
|
10
|
-
<ChecksViewTabs />
|
|
11
|
-
</MemoryRouter>,
|
|
12
|
-
)
|
|
28
|
+
const html = render('/checks/upgrade?namespaces=shop%2Cprod&target=1.36&resource=shop%2Fapi')
|
|
13
29
|
|
|
14
30
|
expect(html).toContain('href="/checks?namespaces=shop%2Cprod"')
|
|
15
31
|
expect(html).toContain('href="/checks/upgrade?namespaces=shop%2Cprod&target=1.36"')
|
|
@@ -17,4 +33,18 @@ describe('ChecksViewTabs', () => {
|
|
|
17
33
|
expect(html).toContain('aria-current="page"')
|
|
18
34
|
expect(html).not.toContain('role="tab"')
|
|
19
35
|
})
|
|
36
|
+
|
|
37
|
+
it('shows Vulnerabilities for scanner reports or the on-demand check', () => {
|
|
38
|
+
expect(render('/checks')).not.toContain('Vulnerabilities')
|
|
39
|
+
|
|
40
|
+
const html = render('/checks?namespaces=shop', [vulnerabilityReports])
|
|
41
|
+
expect(html).toContain('href="/checks/vulnerabilities?namespaces=shop"')
|
|
42
|
+
expect(html).toContain('Vulnerabilities')
|
|
43
|
+
expect(render('/checks?namespaces=shop', [], true)).toContain('href="/checks/vulnerabilities?namespaces=shop"')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('marks Vulnerabilities as the current tab on its route', () => {
|
|
47
|
+
const html = render('/checks/vulnerabilities', [vulnerabilityReports])
|
|
48
|
+
expect(html).toMatch(/aria-current="page"[^>]*href="\/checks\/vulnerabilities"|href="\/checks\/vulnerabilities"[^>]*aria-current="page"/)
|
|
49
|
+
})
|
|
20
50
|
})
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { clsx } from 'clsx'
|
|
2
2
|
import { Link, useLocation, type To } from 'react-router-dom'
|
|
3
|
+
import { useAPIResources } from '../../api/apiResources'
|
|
4
|
+
import { useCapabilities } from '../../api/client'
|
|
5
|
+
import { hasVulnerabilityReports } from '../../api/vulnerabilities'
|
|
3
6
|
|
|
4
7
|
export function ChecksViewTabs() {
|
|
5
8
|
const { pathname, search } = useLocation()
|
|
9
|
+
const { data: resources } = useAPIResources()
|
|
10
|
+
const { data: capabilities } = useCapabilities()
|
|
6
11
|
const upgrade = pathname.startsWith('/checks/upgrade')
|
|
12
|
+
const vulnerabilities = pathname.startsWith('/checks/vulnerabilities')
|
|
7
13
|
const current = new URLSearchParams(search)
|
|
8
14
|
const browsing = new URLSearchParams()
|
|
9
15
|
for (const key of ['namespace', 'namespaces']) {
|
|
@@ -16,12 +22,17 @@ export function ChecksViewTabs() {
|
|
|
16
22
|
|
|
17
23
|
return (
|
|
18
24
|
<nav className="flex items-center gap-1 border-b border-theme-border" aria-label="Check views">
|
|
19
|
-
<ChecksTab to={{ pathname: '/checks', search: browsing.toString() }} active={!upgrade}>
|
|
25
|
+
<ChecksTab to={{ pathname: '/checks', search: browsing.toString() }} active={!upgrade && !vulnerabilities}>
|
|
20
26
|
Best practices
|
|
21
27
|
</ChecksTab>
|
|
22
28
|
<ChecksTab to={{ pathname: '/checks/upgrade', search: upgradeSearch.toString() }} active={upgrade}>
|
|
23
29
|
Upgrade impact
|
|
24
30
|
</ChecksTab>
|
|
31
|
+
{(vulnerabilities || capabilities?.features?.runtimeAdvisoryChecks || hasVulnerabilityReports(resources)) && (
|
|
32
|
+
<ChecksTab to={{ pathname: '/checks/vulnerabilities', search: browsing.toString() }} active={vulnerabilities}>
|
|
33
|
+
Vulnerabilities
|
|
34
|
+
</ChecksTab>
|
|
35
|
+
)}
|
|
25
36
|
</nav>
|
|
26
37
|
)
|
|
27
38
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
|
+
import { expect, it } from 'vitest'
|
|
4
|
+
import { getApiBase } from '../../api/config'
|
|
5
|
+
import type { Java4ShellResult } from '../../api/vulnerabilities'
|
|
6
|
+
import { Java4ShellPanel } from './Java4ShellPanel'
|
|
7
|
+
|
|
8
|
+
it('shows the Java home count before opening details and counts other failures once', () => {
|
|
9
|
+
const result: Java4ShellResult = {
|
|
10
|
+
findings: [],
|
|
11
|
+
containers: 6,
|
|
12
|
+
matches: 0,
|
|
13
|
+
findingGroups: 0,
|
|
14
|
+
unassessed: { java_home_declared: 3, auth_required: 2, no_java_declaration: 1 },
|
|
15
|
+
unassessedRows: [],
|
|
16
|
+
unassessedGroups: 3,
|
|
17
|
+
coverage: { status: 'complete', scope: { type: 'all_namespaces' }, read: { type: 'all_namespaces' }, gaps: [] },
|
|
18
|
+
}
|
|
19
|
+
const client = new QueryClient({ defaultOptions: { queries: { enabled: false } } })
|
|
20
|
+
client.setQueryData(['java4shell', getApiBase(), 'fixture', '/vulnerabilities/java4shell'], result)
|
|
21
|
+
const html = renderToStaticMarkup(
|
|
22
|
+
<QueryClientProvider client={client}>
|
|
23
|
+
<Java4ShellPanel context="fixture" connected onNavigateToResource={() => {}} />
|
|
24
|
+
</QueryClientProvider>,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
expect(html).toContain('Images for 3 containers set <code>JAVA_HOME</code>. Verify the installed Java version.')
|
|
28
|
+
expect(html).toContain('Java version unassessed in 2 containers.')
|
|
29
|
+
expect(html).toContain('aria-expanded="false"')
|
|
30
|
+
expect(html).not.toContain('aria-label="Unassessed containers by workload"')
|
|
31
|
+
})
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Link } from 'react-router-dom'
|
|
3
|
+
import { Download } from 'lucide-react'
|
|
4
|
+
import { Collapse, CollapseChevron, TimeValue, useDisclosure } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { JAVA4SHELL_CVE, useJava4ShellCheck, type Java4ShellFinding, type Java4ShellResult, type VulnerabilityWorkloadRef } from '../../api/vulnerabilities'
|
|
6
|
+
import type { SelectedResource } from '../../types'
|
|
7
|
+
import { triggerDownload } from '@skyhook-io/k8s-ui/utils/download'
|
|
8
|
+
import { resourceCoverageNotice, resourceNarrowedNotice } from '@skyhook-io/k8s-ui/utils/resource-coverage'
|
|
9
|
+
import { pluralize } from '@skyhook-io/k8s-ui/utils/pluralize'
|
|
10
|
+
import { resourceRefKey } from '@skyhook-io/k8s-ui/utils/resource-refs'
|
|
11
|
+
import { ImageName } from '../vulnerabilities/parts'
|
|
12
|
+
import { Tooltip } from '../ui/Tooltip'
|
|
13
|
+
|
|
14
|
+
const advisoryURL = 'https://github.com/advisories/GHSA-6g7j-4xh3-xq2q'
|
|
15
|
+
|
|
16
|
+
interface Java4ShellPanelProps {
|
|
17
|
+
namespaces?: string[]
|
|
18
|
+
context: string
|
|
19
|
+
connected: boolean
|
|
20
|
+
trivySearch?: string
|
|
21
|
+
workload?: VulnerabilityWorkloadRef
|
|
22
|
+
onNavigateToResource?: (resource: SelectedResource) => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Java4ShellPanel({ namespaces = [], context, connected, trivySearch, workload, onNavigateToResource }: Java4ShellPanelProps) {
|
|
26
|
+
const { data, dataUpdatedAt, isFetching, error, refetch } = useJava4ShellCheck(namespaces, context, workload)
|
|
27
|
+
const checkedAt = new Date(dataUpdatedAt).toISOString()
|
|
28
|
+
return (
|
|
29
|
+
<section aria-label="Java4Shell check" className={`rounded-xl border border-theme-border bg-theme-surface ${workload ? 'p-3' : 'p-4'}`}>
|
|
30
|
+
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
31
|
+
<div className="flex min-w-0 flex-col gap-1">
|
|
32
|
+
<h2 className="text-sm font-semibold text-theme-text-primary">Java4Shell</h2>
|
|
33
|
+
<p className="text-xs text-theme-text-secondary">
|
|
34
|
+
{workload
|
|
35
|
+
? 'Check the running images in this workload for affected Java versions.'
|
|
36
|
+
: 'Check running workloads for affected Java versions and prioritize patching with current node evidence.'}
|
|
37
|
+
</p>
|
|
38
|
+
<p className="text-xs text-theme-text-tertiary">Radar reads image metadata using the registry credentials your access allows.</p>
|
|
39
|
+
<div className="flex flex-wrap gap-x-4 gap-y-1 text-xs">
|
|
40
|
+
<a className="text-accent-text hover:underline" href={advisoryURL} target="_blank" rel="noreferrer">{JAVA4SHELL_CVE} advisory</a>
|
|
41
|
+
{trivySearch && <Link className="text-accent-text hover:underline" to={{ search: trivySearch }}>Find in Trivy reports</Link>}
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
45
|
+
{data && (
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
className="btn-secondary inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium"
|
|
49
|
+
onClick={() => triggerDownload(
|
|
50
|
+
JSON.stringify({ cve: JAVA4SHELL_CVE, checkedAt, ...data }, null, 2),
|
|
51
|
+
'application/json',
|
|
52
|
+
`java4shell-${checkedAt.replace(/[:.]/g, '-')}.json`,
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
<Download className="h-3.5 w-3.5" /> Download JSON
|
|
56
|
+
</button>
|
|
57
|
+
)}
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
className="btn-brand shrink-0 px-3 py-1.5 text-xs font-medium"
|
|
61
|
+
onClick={() => void refetch()}
|
|
62
|
+
disabled={!connected || isFetching}
|
|
63
|
+
>
|
|
64
|
+
{isFetching ? (workload ? 'Checking workload…' : 'Checking workloads…') : data ? 'Run check again' : 'Check for Java4Shell'}
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
{isFetching && <p role="status" className="mt-3 text-xs text-theme-text-secondary">Reading running Pods and image metadata. This can take up to 40 seconds after the Pods are read.</p>}
|
|
69
|
+
{error && <p role="alert" className="mt-3 text-xs text-warning-text">{error.message}{data && ' Showing the previous result.'}</p>}
|
|
70
|
+
{data && <Java4ShellResults data={data} checkedAt={checkedAt} onOpen={onNavigateToResource} />}
|
|
71
|
+
</section>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const reasonLabels: Record<string, string> = {
|
|
76
|
+
image_identity_unknown: 'Running image digest unavailable',
|
|
77
|
+
version_unknown: 'Unrecognized Java version',
|
|
78
|
+
platform_unknown: 'Image platform unknown',
|
|
79
|
+
auth_required: 'Registry authentication required',
|
|
80
|
+
not_found: 'Image missing or private',
|
|
81
|
+
blocked: 'Registry address blocked',
|
|
82
|
+
rate_limited: 'Registry rate limit',
|
|
83
|
+
error: 'Registry read failed',
|
|
84
|
+
not_checked: 'Check limit reached',
|
|
85
|
+
java_home_declared: 'Image sets JAVA_HOME. Java version unknown',
|
|
86
|
+
no_java_declaration: 'Image declares no Java version',
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function Java4ShellResults({ data, checkedAt, onOpen }: { data: Java4ShellResult; checkedAt: string; onOpen?: (resource: SelectedResource) => void }) {
|
|
90
|
+
const missingDeclaration = data.unassessed.no_java_declaration ?? 0
|
|
91
|
+
const javaHomeDeclared = data.unassessed.java_home_declared ?? 0
|
|
92
|
+
const unassessed = Object.values(data.unassessed).reduce((count, n) => count + n, 0)
|
|
93
|
+
const otherUnassessed = unassessed - missingDeclaration - javaHomeDeclared
|
|
94
|
+
const coverage = resourceCoverageNotice(data.coverage, 'Pods') ?? resourceNarrowedNotice(data.coverage)
|
|
95
|
+
const namespaces = data.coverage.read?.namespaces
|
|
96
|
+
const scope = data.workload?.name ?? (
|
|
97
|
+
namespaces?.names && namespaces.names.length <= 3
|
|
98
|
+
? namespaces.names.join(', ')
|
|
99
|
+
: namespaces ? pluralize(namespaces.count, 'namespace') : 'all namespaces'
|
|
100
|
+
)
|
|
101
|
+
const groups = new Map<string, Java4ShellFinding[]>()
|
|
102
|
+
for (const row of data.findings) {
|
|
103
|
+
const key = resourceRefKey(row.workload)
|
|
104
|
+
const rows = groups.get(key)
|
|
105
|
+
if (rows) rows.push(row)
|
|
106
|
+
else groups.set(key, [row])
|
|
107
|
+
}
|
|
108
|
+
const summary = data.matches > 0
|
|
109
|
+
? `${pluralize(data.matches, 'container')} with a declared Java version in an affected range`
|
|
110
|
+
: data.containers === 0
|
|
111
|
+
? data.workload ? 'Radar found no running containers in this workload' : 'Radar found no running containers in the scope it read'
|
|
112
|
+
: missingDeclaration === data.containers
|
|
113
|
+
? 'Images checked declared no Java version'
|
|
114
|
+
: unassessed === data.containers
|
|
115
|
+
? 'Radar could not assess the Java version of any running container'
|
|
116
|
+
: 'No matches among containers whose declared Java version Radar could assess'
|
|
117
|
+
return (
|
|
118
|
+
<div className="mt-3 flex flex-col gap-2 border-t border-theme-border pt-3 text-xs">
|
|
119
|
+
<div className="flex flex-wrap justify-between gap-x-3 gap-y-1">
|
|
120
|
+
<p role="status" className="font-medium text-theme-text-primary">{summary}</p>
|
|
121
|
+
<p className="text-theme-text-tertiary">Checked <TimeValue timestamp={checkedAt} /> · {scope}</p>
|
|
122
|
+
</div>
|
|
123
|
+
{coverage && <p className="text-warning-text">{coverage}</p>}
|
|
124
|
+
{javaHomeDeclared > 0 && (
|
|
125
|
+
<p className="text-theme-text-secondary">
|
|
126
|
+
Images for {pluralize(javaHomeDeclared, 'container')} set <code>JAVA_HOME</code>. Verify the installed Java version.
|
|
127
|
+
</p>
|
|
128
|
+
)}
|
|
129
|
+
{otherUnassessed > 0 && (
|
|
130
|
+
<p className="text-theme-text-secondary">
|
|
131
|
+
Java version unassessed in {pluralize(otherUnassessed, 'container')}.
|
|
132
|
+
</p>
|
|
133
|
+
)}
|
|
134
|
+
{missingDeclaration > 0 && (
|
|
135
|
+
<p className="text-theme-text-secondary">
|
|
136
|
+
Images for {pluralize(missingDeclaration, 'container')} had no Java version declaration.
|
|
137
|
+
</p>
|
|
138
|
+
)}
|
|
139
|
+
{data.findings.length > 0 && (
|
|
140
|
+
<p className="text-theme-text-secondary">Image metadata describes the declared Java version. Confirm the deployed JVM and the fix from its vendor.</p>
|
|
141
|
+
)}
|
|
142
|
+
{data.workload && <WorkloadJava4ShellRows data={data} />}
|
|
143
|
+
{!data.workload && onOpen && data.findings.length > 0 && (
|
|
144
|
+
<>
|
|
145
|
+
<div role="region" aria-label="Matching containers by workload" tabIndex={0} className="max-h-96 overflow-auto rounded-lg border border-theme-border">
|
|
146
|
+
<table className="w-full min-w-[40rem] text-left">
|
|
147
|
+
<thead className="sticky top-0 bg-theme-elevated text-theme-text-secondary">
|
|
148
|
+
<tr>
|
|
149
|
+
<th scope="col" className="px-3 py-2 font-medium">Workload</th>
|
|
150
|
+
<th scope="col" className="px-3 py-2 font-medium">Container</th>
|
|
151
|
+
<th scope="col" className="px-3 py-2 font-medium">Declared Java</th>
|
|
152
|
+
<th scope="col" className="px-3 py-2 font-medium">Node evidence at check time</th>
|
|
153
|
+
</tr>
|
|
154
|
+
</thead>
|
|
155
|
+
{[...groups.entries()].map(([key, rows]) => (
|
|
156
|
+
<tbody key={key} className="divide-y divide-theme-border border-t border-theme-border">
|
|
157
|
+
{rows.map((row, index) => (
|
|
158
|
+
<tr key={JSON.stringify([row.container, row.digest, row.version])} className="align-top">
|
|
159
|
+
{index === 0 && (
|
|
160
|
+
<th rowSpan={rows.length} scope="rowgroup" className="px-3 py-2 font-medium">
|
|
161
|
+
<WorkloadLink workload={row.workload} onOpen={onOpen} />
|
|
162
|
+
</th>
|
|
163
|
+
)}
|
|
164
|
+
<td className="px-3 py-2">
|
|
165
|
+
<div className="text-theme-text-primary">{row.container}</div>
|
|
166
|
+
<div className="max-w-48 truncate text-theme-text-tertiary"><ImageName image={row.image} /></div>
|
|
167
|
+
<div className="text-theme-text-tertiary">{pluralize(row.pods, 'Pod')}</div>
|
|
168
|
+
</td>
|
|
169
|
+
<td className="px-3 py-2">
|
|
170
|
+
<div className="font-mono text-theme-text-primary">{row.version}</div>
|
|
171
|
+
<div className="text-theme-text-secondary">{row.fixedIn ? `Upstream fix ${row.fixedIn}` : 'Check the vendor for an upgrade'}</div>
|
|
172
|
+
</td>
|
|
173
|
+
<td className="px-3 py-2">
|
|
174
|
+
<JavaPlacement row={row} />
|
|
175
|
+
</td>
|
|
176
|
+
</tr>
|
|
177
|
+
))}
|
|
178
|
+
</tbody>
|
|
179
|
+
))}
|
|
180
|
+
</table>
|
|
181
|
+
</div>
|
|
182
|
+
</>
|
|
183
|
+
)}
|
|
184
|
+
{data.findingGroups > data.findings.length && (
|
|
185
|
+
<p className="text-theme-text-secondary">Showing {data.findings.length} of {data.findingGroups} matching groups.{!data.workload && ' Narrow the namespace scope to see more.'}</p>
|
|
186
|
+
)}
|
|
187
|
+
{!data.workload && onOpen && data.unassessedGroups > 0 && <UnassessedDetails data={data} onOpen={onOpen} />}
|
|
188
|
+
</div>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function WorkloadJava4ShellRows({ data }: { data: Java4ShellResult }) {
|
|
193
|
+
return (
|
|
194
|
+
<>
|
|
195
|
+
{data.findings.length > 0 && (
|
|
196
|
+
<ul aria-label="Matching containers" className="divide-y divide-theme-border rounded-md border border-theme-border">
|
|
197
|
+
{data.findings.map(row => (
|
|
198
|
+
<li key={JSON.stringify([row.container, row.digest, row.version])} className="space-y-1 p-2">
|
|
199
|
+
<div className="flex flex-wrap items-baseline gap-x-2">
|
|
200
|
+
<span className="font-medium text-theme-text-primary">{row.container}</span>
|
|
201
|
+
<ImageName image={row.image} className="text-theme-text-tertiary" />
|
|
202
|
+
<span className="text-theme-text-tertiary">{pluralize(row.pods, 'Pod')}</span>
|
|
203
|
+
</div>
|
|
204
|
+
<div className="flex flex-wrap items-baseline gap-x-2">
|
|
205
|
+
<span className="font-mono text-theme-text-primary">{row.version}</span>
|
|
206
|
+
<span className="text-theme-text-secondary">{row.fixedIn ? `Upstream fix ${row.fixedIn}` : 'Check the vendor for an upgrade'}</span>
|
|
207
|
+
</div>
|
|
208
|
+
<JavaPlacement row={row} />
|
|
209
|
+
</li>
|
|
210
|
+
))}
|
|
211
|
+
</ul>
|
|
212
|
+
)}
|
|
213
|
+
{data.unassessedRows.length > 0 && (
|
|
214
|
+
<>
|
|
215
|
+
<div className="font-medium text-theme-text-secondary">Unassessed containers</div>
|
|
216
|
+
<ul aria-label="Unassessed containers" className="divide-y divide-theme-border rounded-md border border-theme-border">
|
|
217
|
+
{data.unassessedRows.map(row => (
|
|
218
|
+
<li key={JSON.stringify([row.container, row.image, row.digest, row.reason])} className="space-y-1 p-2">
|
|
219
|
+
<div className="flex flex-wrap items-baseline gap-x-2">
|
|
220
|
+
<span className="font-medium text-theme-text-primary">{row.container}</span>
|
|
221
|
+
<ImageName image={row.image} className="text-theme-text-tertiary" />
|
|
222
|
+
<span className="text-theme-text-tertiary">{pluralize(row.pods, 'Pod')}</span>
|
|
223
|
+
</div>
|
|
224
|
+
<div className="text-theme-text-secondary">{reasonLabels[row.reason] ?? row.reason}</div>
|
|
225
|
+
</li>
|
|
226
|
+
))}
|
|
227
|
+
</ul>
|
|
228
|
+
{data.unassessedGroups > data.unassessedRows.length && (
|
|
229
|
+
<p className="text-theme-text-secondary">Showing {data.unassessedRows.length} of {data.unassessedGroups} unassessed groups.</p>
|
|
230
|
+
)}
|
|
231
|
+
</>
|
|
232
|
+
)}
|
|
233
|
+
</>
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function WorkloadLink({ workload, onOpen }: { workload: Java4ShellFinding['workload']; onOpen: (resource: SelectedResource) => void }) {
|
|
238
|
+
return (
|
|
239
|
+
<>
|
|
240
|
+
<button type="button" onClick={() => onOpen(workload)} className="text-left text-accent-text hover:underline">{workload.name}</button>
|
|
241
|
+
<div className="text-theme-text-tertiary">{workload.kind} · {workload.namespace}</div>
|
|
242
|
+
</>
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function UnassessedDetails({ data, onOpen }: { data: Java4ShellResult; onOpen: (resource: SelectedResource) => void }) {
|
|
247
|
+
const [open, setOpen] = useState(false)
|
|
248
|
+
const { panelId, buttonProps } = useDisclosure(open)
|
|
249
|
+
const { unassessedRows, unassessedGroups } = data
|
|
250
|
+
const reasonTotals = Object.entries(data.unassessed).sort(([, a], [, b]) => b - a)
|
|
251
|
+
return (
|
|
252
|
+
<div>
|
|
253
|
+
<button {...buttonProps} type="button" onClick={() => setOpen(!open)} className="inline-flex items-center gap-1.5 py-1 font-medium text-accent-text hover:underline">
|
|
254
|
+
<CollapseChevron open={open} className="h-3.5 w-3.5" />
|
|
255
|
+
Unassessed containers
|
|
256
|
+
</button>
|
|
257
|
+
<Collapse open={open} id={panelId} mountLazily>
|
|
258
|
+
{reasonTotals.length > 1 && (
|
|
259
|
+
<ul aria-label="Totals by reason" className="mt-1 flex flex-wrap gap-x-4 gap-y-1 text-theme-text-secondary">
|
|
260
|
+
{reasonTotals.map(([reason, count]) => (
|
|
261
|
+
<li key={reason}>{reasonLabels[reason] ?? reason} · <span className="tabular-nums">{count}</span></li>
|
|
262
|
+
))}
|
|
263
|
+
</ul>
|
|
264
|
+
)}
|
|
265
|
+
<div role="region" aria-label="Unassessed containers by workload" tabIndex={0} className="mt-1 max-h-64 overflow-auto rounded-lg border border-theme-border">
|
|
266
|
+
<table className="w-full min-w-[32rem] text-left">
|
|
267
|
+
<thead className="sticky top-0 bg-theme-elevated text-theme-text-secondary">
|
|
268
|
+
<tr>
|
|
269
|
+
<th scope="col" className="px-3 py-2 font-medium">Workload</th>
|
|
270
|
+
<th scope="col" className="px-3 py-2 font-medium">Container</th>
|
|
271
|
+
<th scope="col" className="px-3 py-2 font-medium">Reason</th>
|
|
272
|
+
<th scope="col" className="px-3 py-2 text-right font-medium">Pods</th>
|
|
273
|
+
</tr>
|
|
274
|
+
</thead>
|
|
275
|
+
<tbody className="divide-y divide-theme-border border-t border-theme-border">
|
|
276
|
+
{unassessedRows.map(row => (
|
|
277
|
+
<tr key={JSON.stringify([resourceRefKey(row.workload), row.container, row.image, row.digest, row.reason])} className="align-top">
|
|
278
|
+
<th scope="row" className="px-3 py-2 font-medium"><WorkloadLink workload={row.workload} onOpen={onOpen} /></th>
|
|
279
|
+
<td className="px-3 py-2">
|
|
280
|
+
<div className="text-theme-text-primary">{row.container}</div>
|
|
281
|
+
<div className="max-w-48 truncate text-theme-text-tertiary"><ImageName image={row.image} /></div>
|
|
282
|
+
{row.digest && (
|
|
283
|
+
<Tooltip content={row.digest}>
|
|
284
|
+
<span className="font-mono text-theme-text-tertiary">{row.digest.replace(/^sha256:/, '').slice(0, 12)}</span>
|
|
285
|
+
</Tooltip>
|
|
286
|
+
)}
|
|
287
|
+
</td>
|
|
288
|
+
<td className="px-3 py-2 text-theme-text-secondary">{reasonLabels[row.reason] ?? row.reason}</td>
|
|
289
|
+
<td className="px-3 py-2 text-right tabular-nums text-theme-text-secondary">{row.pods}</td>
|
|
290
|
+
</tr>
|
|
291
|
+
))}
|
|
292
|
+
</tbody>
|
|
293
|
+
</table>
|
|
294
|
+
</div>
|
|
295
|
+
{unassessedGroups > unassessedRows.length && (
|
|
296
|
+
<p className="mt-2 text-theme-text-secondary">Showing {unassessedRows.length} of {unassessedGroups} workload or Pod groups. Narrow the namespace scope to see more.</p>
|
|
297
|
+
)}
|
|
298
|
+
</Collapse>
|
|
299
|
+
</div>
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function JavaPlacement({ row }: { row: Java4ShellFinding }) {
|
|
304
|
+
const other = row.pods - row.vbmiPods - row.unknownCPUPods
|
|
305
|
+
return (
|
|
306
|
+
<>
|
|
307
|
+
{row.vbmiPods > 0 && <div className="font-medium text-warning-text">Prioritize patching · {pluralize(row.vbmiPods, 'Pod')} on nodes reporting AVX-512 VBMI</div>}
|
|
308
|
+
{row.unknownCPUPods > 0 && <div className="text-theme-text-secondary">CPU capability unknown for {pluralize(row.unknownCPUPods, 'Pod')}</div>}
|
|
309
|
+
{other > 0 && <div className="text-theme-text-secondary">{pluralize(other, 'Pod')} on non-x86 nodes at check time</div>}
|
|
310
|
+
{row.mitigationDeclaredPods > 0 && <div className="text-theme-text-tertiary">Mitigation flag declared in {pluralize(row.mitigationDeclaredPods, 'Pod spec')}</div>}
|
|
311
|
+
</>
|
|
312
|
+
)
|
|
313
|
+
}
|
|
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
|
|
|
2
2
|
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
3
|
import { ApiError } from '../../api/client'
|
|
4
4
|
import { RadarFeatureUnsupportedError } from '../../api/radarFeatures'
|
|
5
|
-
import { UPGRADE_IMPACT_DOCS_URL, UpgradeReadinessError, groupFindings, incompleteUpgradeCheckCount, issueSpecificReferences, summaryMeta, upgradeEvaluationSummary, upgradeEvidenceCoverageLabel, upgradeUnavailableKindsMessage } from './UpgradeReadinessView'
|
|
5
|
+
import { UPGRADE_IMPACT_DOCS_URL, UpgradePlansNotice, distributionUpgradePlans, planCountIsLowerBound, UpgradeReadinessError, groupFindings, incompleteUpgradeCheckCount, issueSpecificReferences, summaryMeta, upgradeEvaluationSummary, upgradeEvidenceCoverageLabel, upgradeUnavailableKindsMessage } from './UpgradeReadinessView'
|
|
6
6
|
|
|
7
7
|
describe('UpgradeReadinessError', () => {
|
|
8
8
|
it('maps an unsupported-feature error to the v1.9 upgrade message', () => {
|
|
@@ -160,3 +160,37 @@ describe('issueSpecificReferences', () => {
|
|
|
160
160
|
expect(issueSpecificReferences(checkReferences, findingReferences)).toEqual([findingReferences[1]])
|
|
161
161
|
})
|
|
162
162
|
})
|
|
163
|
+
|
|
164
|
+
describe('upgrade Plans notice', () => {
|
|
165
|
+
const plan = (name: string, image: string, conditions: any[] = []) => ({
|
|
166
|
+
apiVersion: 'upgrade.cattle.io/v1', kind: 'Plan', metadata: { name, namespace: 'system-upgrade' },
|
|
167
|
+
spec: { version: 'v1.32.1+k3s1', upgrade: { image } }, status: { conditions },
|
|
168
|
+
})
|
|
169
|
+
it('lists only k3s and rke2 upgrade Plans', () => {
|
|
170
|
+
expect(distributionUpgradePlans([
|
|
171
|
+
plan('k3s-server', 'rancher/k3s-upgrade', [{ type: 'Complete', status: 'True' }]),
|
|
172
|
+
plan('system-agent-upgrader', 'rancher/system-agent:v0.3.13-suc'),
|
|
173
|
+
])).toEqual([{ namespace: 'system-upgrade', name: 'k3s-server', version: 'v1.32.1+k3s1', state: 'Complete' }])
|
|
174
|
+
})
|
|
175
|
+
it('returns nothing for no Plans or an unread list', () => {
|
|
176
|
+
expect(distributionUpgradePlans(undefined)).toEqual([])
|
|
177
|
+
expect(distributionUpgradePlans([])).toEqual([])
|
|
178
|
+
})
|
|
179
|
+
it('renders the notice with a link per Plan', () => {
|
|
180
|
+
const html = renderToStaticMarkup(UpgradePlansNotice({ plans: [{ namespace: 'system-upgrade', name: 'k3s-server', version: 'v1.32.1+k3s1', state: 'Complete' }], onNavigateToResource: () => {} }))
|
|
181
|
+
expect(html).toContain('1 upgrade Plan is defined for this cluster')
|
|
182
|
+
expect(html).toContain('k3s-server')
|
|
183
|
+
expect(html).toContain('v1.32.1+k3s1')
|
|
184
|
+
})
|
|
185
|
+
it('says at least N when the caller could list only some Plans', () => {
|
|
186
|
+
const html = renderToStaticMarkup(UpgradePlansNotice({ partial: true, plans: [{ namespace: 'system-upgrade', name: 'k3s-server', version: 'v1', state: 'Complete' }], onNavigateToResource: () => {} }))
|
|
187
|
+
expect(html).toContain('At least 1 upgrade Plan is defined for this cluster')
|
|
188
|
+
})
|
|
189
|
+
it('counts Plans exactly only when the list covers the cluster', () => {
|
|
190
|
+
expect(planCountIsLowerBound({ status: 'complete' } as any)).toBe(false)
|
|
191
|
+
expect(planCountIsLowerBound({ status: 'partial' } as any)).toBe(true)
|
|
192
|
+
expect(planCountIsLowerBound({ status: 'complete', narrowedBy: ['namespace_collection'] } as any)).toBe(true)
|
|
193
|
+
expect(planCountIsLowerBound({ status: 'unknown' } as any)).toBe(true)
|
|
194
|
+
expect(planCountIsLowerBound(undefined)).toBe(true)
|
|
195
|
+
})
|
|
196
|
+
})
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
} from '@skyhook-io/k8s-ui'
|
|
30
30
|
import {
|
|
31
31
|
ApiError,
|
|
32
|
+
useResources,
|
|
32
33
|
useUpgradeReadiness,
|
|
33
34
|
type UpgradeReadinessCheck,
|
|
34
35
|
type UpgradeReadinessCheckStatus,
|
|
@@ -38,6 +39,10 @@ import {
|
|
|
38
39
|
} from '../../api/client'
|
|
39
40
|
import type { SelectedResource } from '../../types'
|
|
40
41
|
import { useConnection } from '../../context/ConnectionContext'
|
|
42
|
+
import { useAPIResources } from '../../api/apiResources'
|
|
43
|
+
import { getUpgradePlanStatus, isDistributionUpgradePlan, upgradePlanTarget } from '@skyhook-io/k8s-ui/components/resources/resource-utils-upgrade-plan'
|
|
44
|
+
import { isLowerBound } from '@skyhook-io/k8s-ui/utils/resource-coverage'
|
|
45
|
+
import type { ResourceCoverage } from '@skyhook-io/k8s-ui/types/resource-coverage'
|
|
41
46
|
import { ChecksViewTabs } from './ChecksViewTabs'
|
|
42
47
|
|
|
43
48
|
interface UpgradeReadinessViewProps {
|
|
@@ -81,6 +86,13 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
|
|
|
81
86
|
const requestedTarget = new URLSearchParams(location.search).get('target') ?? undefined
|
|
82
87
|
const { data, isLoading, isFetching, isPlaceholderData, error, dataUpdatedAt, refreshScan } = useUpgradeReadiness(requestedTarget)
|
|
83
88
|
const { connection } = useConnection()
|
|
89
|
+
const { data: apiResources } = useAPIResources()
|
|
90
|
+
const plansServed = !!apiResources?.some((r) => r.group === 'upgrade.cattle.io' && r.name === 'plans')
|
|
91
|
+
const plansQuery = useResources<any>('plans', undefined, 'upgrade.cattle.io', { enabled: plansServed })
|
|
92
|
+
// An unreadable Plan list shows no notice: absence of Plans is not claimed.
|
|
93
|
+
const upgradePlans = useMemo(() => (plansQuery.error ? [] : distributionUpgradePlans(plansQuery.data)), [plansQuery.error, plansQuery.data])
|
|
94
|
+
const plansPartial = planCountIsLowerBound(plansQuery.coverage)
|
|
95
|
+
const plansNotice = upgradePlans.length > 0 ? <UpgradePlansNotice plans={upgradePlans} partial={plansPartial} onNavigateToResource={onNavigateToResource} /> : null
|
|
84
96
|
const targetOptions = useMemo(
|
|
85
97
|
() => buildTargetOptions(data?.currentVersion, data?.reviewedThrough, requestedTarget ?? data?.targetVersion),
|
|
86
98
|
[data?.currentVersion, data?.reviewedThrough, data?.targetVersion, requestedTarget],
|
|
@@ -104,6 +116,7 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
|
|
|
104
116
|
return (
|
|
105
117
|
<div className="flex-1 flex flex-col min-h-0 p-4 gap-4">
|
|
106
118
|
<ChecksViewTabs />
|
|
119
|
+
{plansNotice}
|
|
107
120
|
<PaneLoader label="Analyzing upgrade impact…" className="flex-1" />
|
|
108
121
|
</div>
|
|
109
122
|
)
|
|
@@ -112,6 +125,7 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
|
|
|
112
125
|
return (
|
|
113
126
|
<div className="flex-1 flex flex-col min-h-0 p-4 gap-4">
|
|
114
127
|
<ChecksViewTabs />
|
|
128
|
+
{plansNotice}
|
|
115
129
|
<div className="flex flex-1 items-center justify-center">
|
|
116
130
|
<UpgradeReadinessError error={error} onResetTarget={resetTarget} />
|
|
117
131
|
</div>
|
|
@@ -217,6 +231,7 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
|
|
|
217
231
|
{data.coverage.state === 'partial' && !data.coverage.scopedNamespaces?.length && !data.coverage.unavailableKinds?.length && scopedKinds.length === 0 && (
|
|
218
232
|
<CoverageNotice headline="Some evidence is incomplete" body="Evidence labels on affected rows explain what Radar could not verify." />
|
|
219
233
|
)}
|
|
234
|
+
{plansNotice}
|
|
220
235
|
{data.coverage.state === 'no_access' ? (
|
|
221
236
|
<section className="shrink-0">
|
|
222
237
|
<EmptyState
|
|
@@ -236,7 +251,7 @@ export function UpgradeReadinessView({ namespaces, onNavigateToResource }: Upgra
|
|
|
236
251
|
<span className="text-right text-xs tabular-nums text-theme-text-tertiary">{upgradeEvaluationSummary(data.checks.length, data.summary, incompleteUpgradeCheckCount(data.checks))}</span>
|
|
237
252
|
</div>
|
|
238
253
|
<CoverageMethodology data={data} />
|
|
239
|
-
<div className="hidden grid-cols-[minmax(230px,0.9fr)_minmax(320px,1.6fr)_160px] gap-4 border-b-subtle bg-theme-elevated px-
|
|
254
|
+
<div className="hidden grid-cols-[minmax(230px,0.9fr)_minmax(320px,1.6fr)_160px] gap-4 border-b-subtle bg-theme-elevated px-3.5 py-2 text-[11px] font-medium uppercase tracking-wide text-theme-text-tertiary md:grid">
|
|
240
255
|
<span>Check</span>
|
|
241
256
|
<span>Result</span>
|
|
242
257
|
<span>Status</span>
|
|
@@ -422,6 +437,49 @@ export function summaryMeta(
|
|
|
422
437
|
}
|
|
423
438
|
}
|
|
424
439
|
|
|
440
|
+
// The visible Plans are a lower bound unless the list covers the whole
|
|
441
|
+
// cluster: a partial read, a list narrowed to the namespaces Radar collects,
|
|
442
|
+
// or an older Radar that reports no coverage can't establish a total.
|
|
443
|
+
export function planCountIsLowerBound(coverage: ResourceCoverage | undefined): boolean {
|
|
444
|
+
return !coverage || coverage.status === 'unknown' || isLowerBound(coverage)
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// system-upgrade-controller Plans that upgrade the distribution itself (k3s,
|
|
448
|
+
// RKE2). Other Plans (Rancher's system-agent upgrader, OS packages) don't
|
|
449
|
+
// change the Kubernetes version, so they aren't listed here.
|
|
450
|
+
export function distributionUpgradePlans(plans: any[] | undefined): { namespace: string; name: string; version: string; state: string }[] {
|
|
451
|
+
return (plans ?? []).filter(isDistributionUpgradePlan).map((p) => ({
|
|
452
|
+
namespace: p.metadata?.namespace ?? '',
|
|
453
|
+
name: p.metadata?.name ?? '',
|
|
454
|
+
version: upgradePlanTarget(p),
|
|
455
|
+
state: getUpgradePlanStatus(p).text,
|
|
456
|
+
}))
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export function UpgradePlansNotice({ plans, partial, onNavigateToResource }: { plans: ReturnType<typeof distributionUpgradePlans>; partial?: boolean; onNavigateToResource: (resource: SelectedResource) => void }) {
|
|
460
|
+
return (
|
|
461
|
+
<div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs">
|
|
462
|
+
<FileSearch className="mt-0.5 h-4 w-4 shrink-0 text-theme-text-tertiary" />
|
|
463
|
+
<div>
|
|
464
|
+
<span className="font-medium text-theme-text-secondary">
|
|
465
|
+
{partial ? 'At least ' : ''}{plans.length} upgrade {plans.length === 1 ? 'Plan is' : 'Plans are'} defined for this cluster.
|
|
466
|
+
</span>{' '}
|
|
467
|
+
<span className="text-theme-text-tertiary">system-upgrade-controller upgrades the nodes it selects:</span>
|
|
468
|
+
<ul className="mt-1 space-y-0.5">
|
|
469
|
+
{plans.map((p) => (
|
|
470
|
+
<li key={`${p.namespace}/${p.name}`} className="text-theme-text-tertiary">
|
|
471
|
+
<button type="button" className="text-accent hover:underline" onClick={() => onNavigateToResource({ kind: 'plans', group: 'upgrade.cattle.io', namespace: p.namespace, name: p.name })}>
|
|
472
|
+
{p.namespace}/{p.name}
|
|
473
|
+
</button>{' '}
|
|
474
|
+
· {p.version} · {p.state}
|
|
475
|
+
</li>
|
|
476
|
+
))}
|
|
477
|
+
</ul>
|
|
478
|
+
</div>
|
|
479
|
+
</div>
|
|
480
|
+
)
|
|
481
|
+
}
|
|
482
|
+
|
|
425
483
|
function CoverageNotice({ headline, body }: { headline: string; body: string }) {
|
|
426
484
|
return (
|
|
427
485
|
<div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs">
|
|
@@ -446,7 +504,7 @@ function CheckRow({ check, onNavigateToResource }: { check: UpgradeReadinessChec
|
|
|
446
504
|
type="button"
|
|
447
505
|
aria-expanded={open}
|
|
448
506
|
onClick={() => setOpen((value) => !value)}
|
|
449
|
-
className=
|
|
507
|
+
className={clsx('grid w-full cursor-pointer items-center gap-3 text-left transition-colors hover:bg-theme-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-theme-text-primary/20 md:grid-cols-[minmax(230px,0.9fr)_minmax(320px,1.6fr)_160px] md:gap-4', 'px-3.5 py-2.5' /* TABLE_DENSITY.cellClass in k8s-ui */)}
|
|
450
508
|
>
|
|
451
509
|
<div className="flex min-w-0 items-center gap-2.5">
|
|
452
510
|
<Icon className={clsx('h-4 w-4 shrink-0', meta.iconClass)} />
|