@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
|
@@ -258,7 +258,8 @@ function producerRelatives(
|
|
|
258
258
|
};
|
|
259
259
|
if (!sameResource(ref, subject)) break;
|
|
260
260
|
const uses = data.resourceContext?.uses;
|
|
261
|
-
|
|
261
|
+
// A reference the caller may not read is named only; its history isn't theirs to follow.
|
|
262
|
+
relatives.push(...[...(uses?.configMaps ?? []), ...(uses?.secrets ?? [])].filter((r) => !r.state));
|
|
262
263
|
if (data.resourceContext?.owner) {
|
|
263
264
|
relatives.push(data.resourceContext.owner);
|
|
264
265
|
}
|
|
@@ -5,6 +5,7 @@ interface LogsTabProps {
|
|
|
5
5
|
podName: string
|
|
6
6
|
containers: string[]
|
|
7
7
|
initialContainer?: string
|
|
8
|
+
initContainers?: string[]
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export function LogsTab({
|
|
@@ -12,6 +13,7 @@ export function LogsTab({
|
|
|
12
13
|
podName,
|
|
13
14
|
containers,
|
|
14
15
|
initialContainer,
|
|
16
|
+
initContainers,
|
|
15
17
|
}: LogsTabProps) {
|
|
16
18
|
return (
|
|
17
19
|
<div className="h-full">
|
|
@@ -20,6 +22,7 @@ export function LogsTab({
|
|
|
20
22
|
podName={podName}
|
|
21
23
|
containers={containers}
|
|
22
24
|
initialContainer={initialContainer}
|
|
25
|
+
initContainers={initContainers}
|
|
23
26
|
/>
|
|
24
27
|
</div>
|
|
25
28
|
)
|
|
@@ -563,7 +563,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
563
563
|
if (node?.missing) {
|
|
564
564
|
const nextStep = node.sync === 'Synced'
|
|
565
565
|
? 'Argo reports it as synced. Refresh the application to check its status.'
|
|
566
|
-
: '
|
|
566
|
+
: 'Review the desired changes and sync policy before deciding whether to sync.'
|
|
567
567
|
showToast(`${ref.kind} ${ref.name} is not present in this cluster. ${nextStep}`, { type: 'info' })
|
|
568
568
|
return
|
|
569
569
|
}
|
|
@@ -84,7 +84,7 @@ export function HelmDrawerFrame({ onClose, isOpen, rightInset, children }: HelmD
|
|
|
84
84
|
TRANSITION_DRAWER,
|
|
85
85
|
isOpen ? 'translate-x-0 opacity-100' : 'translate-x-full opacity-0'
|
|
86
86
|
)}
|
|
87
|
-
style={{ width: renderedDrawerWidth, top: HEADER_HEIGHT, right: rightInset, height: `calc(100vh - ${HEADER_HEIGHT}px - ${dockInset}px)` }}
|
|
87
|
+
style={{ width: renderedDrawerWidth, top: `calc(${HEADER_HEIGHT}px + var(--radar-titlebar-h, 0px))`, right: rightInset, height: `calc(100vh - var(--radar-titlebar-h, 0px) - ${HEADER_HEIGHT}px - ${dockInset}px)` }}
|
|
88
88
|
>
|
|
89
89
|
{/* Resize handle */}
|
|
90
90
|
<div
|
|
@@ -14,6 +14,10 @@ import { InstallWizard } from './InstallWizard'
|
|
|
14
14
|
import { ObservedHelmNotice } from './ObservedHelmNotice'
|
|
15
15
|
import { NotCheckedBadge } from './NotCheckedBadge'
|
|
16
16
|
|
|
17
|
+
// The list tables' density (TABLE_DENSITY in k8s-ui's table-density.ts), repeated:
|
|
18
|
+
// radar-app supports k8s-ui releases older than that module.
|
|
19
|
+
const HELM_CELL = 'px-3.5 py-2.5'
|
|
20
|
+
|
|
17
21
|
type ViewTab = 'releases' | 'charts'
|
|
18
22
|
|
|
19
23
|
interface HelmViewProps {
|
|
@@ -255,7 +259,7 @@ export function HelmView({ namespaces, selectedRelease, onReleaseClick }: HelmVi
|
|
|
255
259
|
{activeTab === 'releases' ? (
|
|
256
260
|
<>
|
|
257
261
|
{/* Releases Toolbar */}
|
|
258
|
-
<div className=
|
|
262
|
+
<div className={clsx('flex items-center gap-4 border-b border-theme-border bg-theme-surface/50 shrink-0', 'px-4 py-2.5')}>
|
|
259
263
|
<div className="flex-1 relative">
|
|
260
264
|
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-theme-text-tertiary" />
|
|
261
265
|
<Input
|
|
@@ -263,7 +267,7 @@ export function HelmView({ namespaces, selectedRelease, onReleaseClick }: HelmVi
|
|
|
263
267
|
placeholder="Search releases..."
|
|
264
268
|
value={searchTerm}
|
|
265
269
|
onChange={(e) => setSearchTerm(e.target.value)}
|
|
266
|
-
className=
|
|
270
|
+
className={clsx('w-full max-w-md pl-10 pr-4 bg-theme-elevated border border-theme-border-light rounded-lg text-sm text-theme-text-primary placeholder-theme-text-disabled focus:outline-none focus:ring-2 focus:ring-blue-500', 'py-1.5')}
|
|
267
271
|
/>
|
|
268
272
|
</div>
|
|
269
273
|
</div>
|
|
@@ -608,7 +612,7 @@ const ObservedReleaseRow = forwardRef<HTMLTableRowElement, ObservedReleaseRowPro
|
|
|
608
612
|
: 'hover:bg-theme-surface/50'
|
|
609
613
|
)}
|
|
610
614
|
>
|
|
611
|
-
<td className=
|
|
615
|
+
<td className={clsx(HELM_CELL, 'phone:px-3')}>
|
|
612
616
|
<div className="flex min-w-0 items-center gap-2 phone:flex-wrap phone:gap-y-1">
|
|
613
617
|
<Package className="w-4 h-4 text-theme-text-tertiary shrink-0" />
|
|
614
618
|
<span className="min-w-0 truncate text-sm font-medium text-theme-text-primary phone:max-w-[calc(100%-1.5rem)] phone:shrink-0">{release.name}</span>
|
|
@@ -617,17 +621,17 @@ const ObservedReleaseRow = forwardRef<HTMLTableRowElement, ObservedReleaseRowPro
|
|
|
617
621
|
</div>
|
|
618
622
|
<span className="hidden truncate pl-6 text-xs text-theme-text-tertiary phone:block">{release.namespace}</span>
|
|
619
623
|
</td>
|
|
620
|
-
<td className=
|
|
624
|
+
<td className={clsx(HELM_CELL, 'w-[18%] phone:hidden')}>
|
|
621
625
|
<Tooltip content={release.namespace}>
|
|
622
626
|
<span className="block truncate text-sm text-theme-text-secondary">{release.namespace}</span>
|
|
623
627
|
</Tooltip>
|
|
624
628
|
</td>
|
|
625
|
-
<td className=
|
|
629
|
+
<td className={clsx(HELM_CELL, 'w-[22%] phone:hidden')}>
|
|
626
630
|
<Tooltip content={chart.tooltip}>
|
|
627
631
|
<span className={clsx('text-sm truncate block', chart.known ? 'text-theme-text-secondary' : 'text-theme-text-tertiary')}>{chart.text}</span>
|
|
628
632
|
</Tooltip>
|
|
629
633
|
</td>
|
|
630
|
-
<td className=
|
|
634
|
+
<td className={clsx(HELM_CELL, 'w-24 hidden xl:table-cell')}>
|
|
631
635
|
{release.appVersion ? (
|
|
632
636
|
<span className="text-sm text-theme-text-secondary">{release.appVersion}</span>
|
|
633
637
|
) : release.appVersions?.length ? (
|
|
@@ -640,7 +644,7 @@ const ObservedReleaseRow = forwardRef<HTMLTableRowElement, ObservedReleaseRowPro
|
|
|
640
644
|
</Tooltip>
|
|
641
645
|
)}
|
|
642
646
|
</td>
|
|
643
|
-
<td className=
|
|
647
|
+
<td className={clsx(HELM_CELL, 'w-40 phone:w-[6.5rem] phone:px-3')}>
|
|
644
648
|
<div className="flex flex-wrap items-center gap-1">
|
|
645
649
|
<Tooltip content={UNREAD_FROM_HELM}>
|
|
646
650
|
<span className={clsx('badge', SEVERITY_BADGE.neutral)}>Unknown</span>
|
|
@@ -654,10 +658,10 @@ const ObservedReleaseRow = forwardRef<HTMLTableRowElement, ObservedReleaseRowPro
|
|
|
654
658
|
</td>
|
|
655
659
|
{showHelmColumns && (
|
|
656
660
|
<>
|
|
657
|
-
<td className=
|
|
661
|
+
<td className={clsx(HELM_CELL, 'w-16 phone:hidden')}>
|
|
658
662
|
<CertaintyGlyph certainty="unknown" title={UNREAD_FROM_HELM} />
|
|
659
663
|
</td>
|
|
660
|
-
<td className=
|
|
664
|
+
<td className={clsx(HELM_CELL, 'w-24 phone:hidden')}>
|
|
661
665
|
<CertaintyGlyph certainty="unknown" title={UNREAD_FROM_HELM} />
|
|
662
666
|
</td>
|
|
663
667
|
</>
|
|
@@ -695,7 +699,7 @@ const ReleaseRow = forwardRef<HTMLTableRowElement, ReleaseRowProps>(
|
|
|
695
699
|
: 'hover:bg-theme-surface/50'
|
|
696
700
|
)}
|
|
697
701
|
>
|
|
698
|
-
<td className=
|
|
702
|
+
<td className={clsx(HELM_CELL, 'phone:px-3')}>
|
|
699
703
|
<div className="flex min-w-0 items-center gap-2 phone:flex-wrap phone:gap-y-1">
|
|
700
704
|
<Package className="w-4 h-4 text-theme-text-tertiary shrink-0" />
|
|
701
705
|
<span className="min-w-0 truncate text-sm font-medium text-theme-text-primary phone:max-w-[calc(100%-1.5rem)] phone:shrink-0">{release.name}</span>
|
|
@@ -713,19 +717,19 @@ const ReleaseRow = forwardRef<HTMLTableRowElement, ReleaseRowProps>(
|
|
|
713
717
|
</div>
|
|
714
718
|
<span className="hidden truncate pl-6 text-xs text-theme-text-tertiary phone:block">{release.namespace}</span>
|
|
715
719
|
</td>
|
|
716
|
-
<td className=
|
|
720
|
+
<td className={clsx(HELM_CELL, 'w-[18%] phone:hidden')}>
|
|
717
721
|
<Tooltip content={release.namespace}>
|
|
718
722
|
<span className="block truncate text-sm text-theme-text-secondary">{release.namespace}</span>
|
|
719
723
|
</Tooltip>
|
|
720
724
|
</td>
|
|
721
|
-
<td className=
|
|
725
|
+
<td className={clsx(HELM_CELL, 'w-[22%] phone:hidden')}>
|
|
722
726
|
<Tooltip content={`${release.chart}-${release.chartVersion}`}>
|
|
723
727
|
<span className="text-sm text-theme-text-secondary truncate block">
|
|
724
728
|
{release.chart}-{release.chartVersion}
|
|
725
729
|
</span>
|
|
726
730
|
</Tooltip>
|
|
727
731
|
</td>
|
|
728
|
-
<td className=
|
|
732
|
+
<td className={clsx(HELM_CELL, 'w-24 hidden xl:table-cell')}>
|
|
729
733
|
{release.appVersion ? (
|
|
730
734
|
<span className="text-sm text-theme-text-secondary">{release.appVersion}</span>
|
|
731
735
|
) : (
|
|
@@ -734,7 +738,7 @@ const ReleaseRow = forwardRef<HTMLTableRowElement, ReleaseRowProps>(
|
|
|
734
738
|
</Tooltip>
|
|
735
739
|
)}
|
|
736
740
|
</td>
|
|
737
|
-
<td className=
|
|
741
|
+
<td className={clsx(HELM_CELL, 'w-40 phone:w-[6.5rem] phone:px-3')}>
|
|
738
742
|
{isHelmReleaseActionable(release.status) ? (
|
|
739
743
|
<Tooltip content="Click row to view rollback / history / logs and recover">
|
|
740
744
|
<span
|
|
@@ -755,10 +759,10 @@ const ReleaseRow = forwardRef<HTMLTableRowElement, ReleaseRowProps>(
|
|
|
755
759
|
</span>
|
|
756
760
|
)}
|
|
757
761
|
</td>
|
|
758
|
-
<td className=
|
|
762
|
+
<td className={clsx(HELM_CELL, 'w-16 phone:hidden')}>
|
|
759
763
|
<span className="text-sm text-theme-text-secondary">{release.revision}</span>
|
|
760
764
|
</td>
|
|
761
|
-
<td className=
|
|
765
|
+
<td className={clsx(HELM_CELL, 'w-24 phone:hidden')}>
|
|
762
766
|
<Tooltip content={release.updated}>
|
|
763
767
|
<span className="text-sm text-theme-text-secondary">
|
|
764
768
|
{formatAge(release.updated)}
|
|
@@ -12,7 +12,7 @@ import { PortForwardInlineButton } from '../portforward/PortForwardButton'
|
|
|
12
12
|
import { useAvailablePorts } from '../../api/client'
|
|
13
13
|
import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
|
|
14
14
|
import { useNamespacedCapabilities, useIsLocalDeployment } from '../../contexts/CapabilitiesContext'
|
|
15
|
-
import { pluralize, getExecContainerNames } from '@skyhook-io/k8s-ui'
|
|
15
|
+
import { pluralize, getExecContainerNames, getLogContainerNames, getDefaultLogContainerName, getInitContainerNames } from '@skyhook-io/k8s-ui'
|
|
16
16
|
import { readActionFor } from '@skyhook-io/k8s-ui/utils/read-actions'
|
|
17
17
|
import { Tooltip } from '../ui/Tooltip'
|
|
18
18
|
import { notCheckedTooltip, type NotCheckedReason } from './NotCheckedBadge'
|
|
@@ -431,11 +431,12 @@ function PodQuickActions({ namespace, podName, isRunning }: PodQuickActionsProps
|
|
|
431
431
|
setIsLoadingAction(true)
|
|
432
432
|
try {
|
|
433
433
|
const data = await fetchPodData()
|
|
434
|
-
const containers = data.resource?.spec?.containers || []
|
|
435
434
|
openLogs({
|
|
436
435
|
namespace,
|
|
437
436
|
podName,
|
|
438
|
-
containers:
|
|
437
|
+
containers: getLogContainerNames(data.resource),
|
|
438
|
+
containerName: getDefaultLogContainerName(data.resource),
|
|
439
|
+
initContainers: getInitContainerNames(data.resource),
|
|
439
440
|
})
|
|
440
441
|
} catch (error) {
|
|
441
442
|
console.error('Failed to open logs:', error)
|
|
@@ -42,6 +42,7 @@ interface ClusterHealthCardProps {
|
|
|
42
42
|
// cluster metadata so the overview carries a freshness signal without a band.
|
|
43
43
|
freshness?: ReactNode
|
|
44
44
|
radarVersion?: ReactNode
|
|
45
|
+
vulnerabilityTools?: boolean
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
function getMetricsInstallHint(platform: string): string {
|
|
@@ -145,6 +146,7 @@ export function ClusterHealthCard({
|
|
|
145
146
|
onIssuesClick,
|
|
146
147
|
freshness,
|
|
147
148
|
radarVersion,
|
|
149
|
+
vulnerabilityTools,
|
|
148
150
|
}: ClusterHealthCardProps) {
|
|
149
151
|
void _topCRDs // Reserved for future CRD display
|
|
150
152
|
|
|
@@ -304,7 +306,7 @@ export function ClusterHealthCard({
|
|
|
304
306
|
(org-wide endpoint, PAT-authed) rather than per-cluster, so this
|
|
305
307
|
localhost/no-auth entry would mislead a Cloud user. */}
|
|
306
308
|
{showLocalMcpCard && (
|
|
307
|
-
<HomeAgentBlock mcpUrl={mcpUrl} readOnly={caps.mcpReadOnly} execTools={caps.mcpExecTools} httpTools={caps.mcpHttpTools} helmTools={caps.mcpHelmTools} applicationEvidenceAvailable={caps.mcpApplicationEvidence} />
|
|
309
|
+
<HomeAgentBlock mcpUrl={mcpUrl} readOnly={caps.mcpReadOnly} execTools={caps.mcpExecTools} httpTools={caps.mcpHttpTools} helmTools={caps.mcpHelmTools} vulnerabilityTools={vulnerabilityTools} applicationEvidenceAvailable={caps.mcpApplicationEvidence} />
|
|
308
310
|
)}
|
|
309
311
|
</div>
|
|
310
312
|
|
|
@@ -16,6 +16,7 @@ export function HomeAgentBlock({
|
|
|
16
16
|
execTools,
|
|
17
17
|
httpTools,
|
|
18
18
|
helmTools,
|
|
19
|
+
vulnerabilityTools,
|
|
19
20
|
applicationEvidenceAvailable,
|
|
20
21
|
}: {
|
|
21
22
|
mcpUrl: string
|
|
@@ -24,6 +25,7 @@ export function HomeAgentBlock({
|
|
|
24
25
|
httpTools?: boolean
|
|
25
26
|
/** Whether the native Helm MCP tool is registered; target Kubernetes permissions still required. */
|
|
26
27
|
helmTools?: boolean
|
|
28
|
+
vulnerabilityTools?: boolean
|
|
27
29
|
applicationEvidenceAvailable?: boolean
|
|
28
30
|
}) {
|
|
29
31
|
const [mcpDialogOpen, setMcpDialogOpen] = useState(false)
|
|
@@ -61,6 +63,7 @@ export function HomeAgentBlock({
|
|
|
61
63
|
execTools={execTools}
|
|
62
64
|
httpTools={httpTools}
|
|
63
65
|
helmTools={helmTools}
|
|
66
|
+
vulnerabilityTools={vulnerabilityTools}
|
|
64
67
|
onInvestigate={showInvestigate && d.available ? () => openComposer(d) : undefined}
|
|
65
68
|
applicationEvidenceAvailable={applicationEvidenceAvailable}
|
|
66
69
|
/>
|
|
@@ -11,6 +11,9 @@ import { CertificateHealthCard } from './CertificateHealthCard'
|
|
|
11
11
|
import { NetworkPolicyCoverageCard } from './NetworkPolicyCoverageCard'
|
|
12
12
|
import { CostCard } from './CostCard'
|
|
13
13
|
import { GitOpsControllersCard } from './GitOpsControllersCard'
|
|
14
|
+
import { useVulnerabilitiesRow } from './useVulnerabilitiesRow'
|
|
15
|
+
import { useAPIResources } from '../../api/apiResources'
|
|
16
|
+
import { hasVulnerabilityReports } from '../../api/vulnerabilities'
|
|
14
17
|
import { CapacityCard } from './CapacityCard'
|
|
15
18
|
import { useCapabilitiesContext } from '../../contexts/CapabilitiesContext'
|
|
16
19
|
import { Tooltip } from '../ui/Tooltip'
|
|
@@ -69,6 +72,8 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
69
72
|
const capacityCardPossible =
|
|
70
73
|
karpenterState === 'available' || karpenterState === 'denied' || karpenterState === 'not_detected'
|
|
71
74
|
const { data, isLoading, error, dataUpdatedAt, refetch } = useDashboard(namespaces)
|
|
75
|
+
const vulnerabilitiesRow = useVulnerabilitiesRow(namespaces)
|
|
76
|
+
const { data: apiResources } = useAPIResources()
|
|
72
77
|
const { connection } = useConnection()
|
|
73
78
|
const { data: issuesData, isLoading: issuesLoading, isFetching: issuesFetching, error: issuesError, refetch: refetchIssues } = useIssues(namespaces)
|
|
74
79
|
const issues = issuesData?.issues ?? []
|
|
@@ -143,6 +148,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
143
148
|
)}
|
|
144
149
|
{/* Row 1: Cluster Health Card (combined health + resource counts) */}
|
|
145
150
|
<ClusterHealthCard
|
|
151
|
+
vulnerabilityTools={hasVulnerabilityReports(apiResources)}
|
|
146
152
|
// A local install shows its version in Settings and upgrades through
|
|
147
153
|
// the update notification; an in-cluster one is upgraded by whoever
|
|
148
154
|
// manages it, and this line is where they confirm the new version.
|
|
@@ -264,6 +270,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
264
270
|
<AuditCard
|
|
265
271
|
data={data.audit}
|
|
266
272
|
onNavigate={() => onNavigateToView('checks')}
|
|
273
|
+
vulnerabilities={vulnerabilitiesRow}
|
|
267
274
|
/>
|
|
268
275
|
</BandItem>
|
|
269
276
|
)}
|
|
@@ -20,7 +20,7 @@ describe('MCP setup in read-only mode', () => {
|
|
|
20
20
|
setBasename('/radar')
|
|
21
21
|
try {
|
|
22
22
|
const url = mcpEndpointUrl(true)
|
|
23
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools readOnly applicationEvidenceAvailable mcpUrl={url} onClose={() => {}} />)
|
|
23
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools readOnly applicationEvidenceAvailable mcpUrl={url} onClose={() => {}} />)
|
|
24
24
|
expect(html).toContain(`claude mcp add --transport http radar ${url}`)
|
|
25
25
|
expect(html).toContain(`codex mcp add radar --url ${url}`)
|
|
26
26
|
expect(html).toContain('/radar/mcp-readonly')
|
|
@@ -37,7 +37,7 @@ describe('MCP setup in read-only mode', () => {
|
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
it('explains disabled exec without including it in the available tool count', () => {
|
|
40
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools execTools={false} mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
40
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools execTools={false} mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
41
41
|
expect(html).toContain('apply_resource')
|
|
42
42
|
expect(html).toContain('in_cluster')
|
|
43
43
|
expect(html).toContain('exec_pod')
|
|
@@ -47,14 +47,21 @@ describe('MCP setup in read-only mode', () => {
|
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
it('does not suggest an unsupported flag when the capability is absent', () => {
|
|
50
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
50
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
51
51
|
expect(html).not.toContain('exec_pod')
|
|
52
52
|
expect(html).not.toContain('curl_service')
|
|
53
53
|
expect(html).not.toContain('--mcp-exec-tools')
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
+
it('lists list_vulnerabilities only where Trivy reports are served', () => {
|
|
57
|
+
const without = renderToStaticMarkup(<MCPSetupDialog open helmTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
58
|
+
expect(without).not.toContain('list_vulnerabilities')
|
|
59
|
+
const withReports = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
60
|
+
expect(withReports).toContain('list_vulnerabilities')
|
|
61
|
+
})
|
|
62
|
+
|
|
56
63
|
it('shows exec without enabling HTTP', () => {
|
|
57
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools execTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
64
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools execTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
58
65
|
expect(html).toContain('exec_pod')
|
|
59
66
|
expect(html).not.toContain('curl_service')
|
|
60
67
|
expect(html).toContain(`${MCP_TOOL_CATALOG.length - 2} tools`)
|
|
@@ -62,21 +69,21 @@ describe('MCP setup in read-only mode', () => {
|
|
|
62
69
|
})
|
|
63
70
|
|
|
64
71
|
it('hides exec in read-only mode even if exec is requested', () => {
|
|
65
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools readOnly execTools mcpUrl={mcpEndpointUrl(true)} onClose={() => {}} />)
|
|
72
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools readOnly execTools mcpUrl={mcpEndpointUrl(true)} onClose={() => {}} />)
|
|
66
73
|
expect(html).not.toContain('exec_pod')
|
|
67
74
|
expect(html).not.toContain('curl_service')
|
|
68
75
|
expect(html).toContain(`${MCP_TOOL_CATALOG.filter((tool) => !tool.write && !tool.localOnly).length} tools`)
|
|
69
76
|
})
|
|
70
77
|
|
|
71
78
|
it('keeps the full catalog in default mode', () => {
|
|
72
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools applicationEvidenceAvailable mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
79
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools applicationEvidenceAvailable mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
73
80
|
expect(html).toContain('apply_resource')
|
|
74
81
|
expect(html).toContain('in_cluster')
|
|
75
82
|
expect(html).toContain('collect_application_evidence')
|
|
76
83
|
})
|
|
77
84
|
|
|
78
85
|
it('hides local-only tools unless the server advertises availability', () => {
|
|
79
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
86
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
80
87
|
expect(html).toContain('apply_resource')
|
|
81
88
|
expect(html).not.toContain('collect_application_evidence')
|
|
82
89
|
})
|
|
@@ -85,7 +92,7 @@ describe('MCP setup in read-only mode', () => {
|
|
|
85
92
|
describe('MCP setup prompt tip', () => {
|
|
86
93
|
it('tips to name Radar under the client setups, as plain text, without the in-Radar link when no handler is given', () => {
|
|
87
94
|
const host = document.createElement('div')
|
|
88
|
-
host.innerHTML = renderToStaticMarkup(<MCPSetupDialog open helmTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
95
|
+
host.innerHTML = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
89
96
|
const tip = [...host.querySelectorAll('p')].find((p) => p.textContent?.startsWith('Tip:'))
|
|
90
97
|
expect(tip?.textContent).toBe(
|
|
91
98
|
"Tip: name Radar in your prompt so your agent uses Radar instead of kubectl, e.g. Use Radar to find what's broken in my cluster and why.",
|
|
@@ -135,7 +142,7 @@ describe('MCP setup prompt tip', () => {
|
|
|
135
142
|
document.body.appendChild(host)
|
|
136
143
|
const root = createRoot(host)
|
|
137
144
|
try {
|
|
138
|
-
act(() => root.render(<MCPSetupDialog open helmTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />))
|
|
145
|
+
act(() => root.render(<MCPSetupDialog open helmTools vulnerabilityTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />))
|
|
139
146
|
const endpoint = [...host.querySelectorAll('code')].find((c) => c.textContent === mcpEndpointUrl())!
|
|
140
147
|
const copy = endpoint.closest('.relative')!.querySelector('button')!
|
|
141
148
|
await act(async () => copy.click())
|
|
@@ -149,11 +156,11 @@ describe('MCP setup prompt tip', () => {
|
|
|
149
156
|
})
|
|
150
157
|
|
|
151
158
|
it('shows HTTP independently of exec', () => {
|
|
152
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools httpTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
159
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools httpTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
153
160
|
expect(html).toContain('curl_service')
|
|
154
161
|
expect(html).not.toContain('exec_pod')
|
|
155
162
|
expect(html).toContain(`${MCP_TOOL_CATALOG.length - 2} tools`)
|
|
156
|
-
const readOnly = renderToStaticMarkup(<MCPSetupDialog open helmTools readOnly httpTools mcpUrl={mcpEndpointUrl(true)} onClose={() => {}} />)
|
|
163
|
+
const readOnly = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools readOnly httpTools mcpUrl={mcpEndpointUrl(true)} onClose={() => {}} />)
|
|
157
164
|
expect(readOnly).not.toContain('curl_service')
|
|
158
165
|
})
|
|
159
166
|
|
|
@@ -166,6 +173,6 @@ it('hides disabled Helm writes while retaining release reads and other writes',
|
|
|
166
173
|
})
|
|
167
174
|
|
|
168
175
|
it('shows registered Helm tools independently of target namespace permissions', () => {
|
|
169
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
176
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
170
177
|
expect(html).toContain('manage_helm')
|
|
171
178
|
})
|
|
@@ -16,6 +16,8 @@ interface MCPSetupDialogProps {
|
|
|
16
16
|
httpTools?: boolean
|
|
17
17
|
/** Whether the native Helm MCP tool is registered; target Kubernetes permissions still required. */
|
|
18
18
|
helmTools?: boolean
|
|
19
|
+
/** Whether the cluster serves Trivy's reports, the only place list_vulnerabilities is listed. */
|
|
20
|
+
vulnerabilityTools?: boolean
|
|
19
21
|
applicationEvidenceAvailable?: boolean
|
|
20
22
|
mcpUrl: string
|
|
21
23
|
/** Opens Radar's own investigation composer. Omit where investigations can't run. */
|
|
@@ -59,7 +61,7 @@ function CodeBlock({ children }: { children: string }) {
|
|
|
59
61
|
)
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTools, httpTools, helmTools, onInvestigate, applicationEvidenceAvailable = false }: MCPSetupDialogProps) {
|
|
64
|
+
export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTools, httpTools, helmTools, vulnerabilityTools = false, onInvestigate, applicationEvidenceAvailable = false }: MCPSetupDialogProps) {
|
|
63
65
|
const dialogRef = useRef<HTMLDivElement>(null)
|
|
64
66
|
const [isDesktop, setIsDesktop] = useState(false)
|
|
65
67
|
const [portPinned, setPortPinned] = useState(false)
|
|
@@ -133,7 +135,7 @@ export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTo
|
|
|
133
135
|
const currentPort = Number(window.location.port) || 80
|
|
134
136
|
|
|
135
137
|
const tools = MCP_TOOL_CATALOG
|
|
136
|
-
.filter((tool) => (!readOnly || !tool.write) && (tool.name !== 'exec_pod' || execTools) && (tool.name !== 'curl_service' || httpTools) && (tool.name !== 'manage_helm' || helmTools) && (!tool.localOnly || (!readOnly && applicationEvidenceAvailable)))
|
|
138
|
+
.filter((tool) => (!readOnly || !tool.write) && (tool.name !== 'exec_pod' || execTools) && (tool.name !== 'curl_service' || httpTools) && (tool.name !== 'manage_helm' || helmTools) && (tool.name !== 'list_vulnerabilities' || vulnerabilityTools) && (!tool.localOnly || (!readOnly && applicationEvidenceAvailable)))
|
|
137
139
|
.map((tool) => readOnly && tool.name === 'diagnose'
|
|
138
140
|
? { ...tool, params: tool.params.filter((param) => param.arg !== 'in_cluster') }
|
|
139
141
|
: tool)
|
|
@@ -38,7 +38,7 @@ export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
|
|
|
38
38
|
{ arg: 'kind', desc: 'pods (default), workloads, or nodes' },
|
|
39
39
|
{ arg: 'namespace', desc: 'filter pods/workloads to a namespace' },
|
|
40
40
|
{ arg: 'sort', desc: 'cpu (default) or memory' },
|
|
41
|
-
{ arg: 'limit', desc: 'max rows (default
|
|
41
|
+
{ arg: 'limit', desc: 'max rows (default 10, max 100)' },
|
|
42
42
|
],
|
|
43
43
|
},
|
|
44
44
|
{
|
|
@@ -161,6 +161,19 @@ export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
|
|
|
161
161
|
{ arg: 'refresh', desc: 'bypass the cached scan after changing something' },
|
|
162
162
|
],
|
|
163
163
|
},
|
|
164
|
+
{
|
|
165
|
+
name: 'list_vulnerabilities',
|
|
166
|
+
desc: 'Which running images carry known CVEs and which workloads run them, from Trivy Operator reports: by image, by CVE, by package upgrade (fix), or by workload. Running images without a report are listed as unscanned, not clean. Listed only where Trivy Operator runs.',
|
|
167
|
+
params: [
|
|
168
|
+
{ arg: 'view', desc: 'image (default), cve, fix, workload, or summary' },
|
|
169
|
+
{ arg: 'namespace', desc: 'limit to one namespace' },
|
|
170
|
+
{ arg: 'severity', desc: 'comma-separated: critical, high, medium, low, unknown' },
|
|
171
|
+
{ arg: 'fixable', desc: 'only findings with a fixed version' },
|
|
172
|
+
{ arg: 'query', desc: 'image, CVE ID, package, or workload substring' },
|
|
173
|
+
{ arg: 'workload', desc: 'one workload as Kind/namespace/name' },
|
|
174
|
+
{ arg: 'limit', desc: 'max rows (default 10, max 100)' },
|
|
175
|
+
],
|
|
176
|
+
},
|
|
164
177
|
{
|
|
165
178
|
name: 'get_runtime_versions',
|
|
166
179
|
desc: 'Which running workloads use which runtime version (PHP, Node, Python, Go, Java, …), read from the version each running image declares in its config, for runtime CVEs. Declared, not proof; misses runtimes installed from distro packages.',
|
|
@@ -286,7 +299,7 @@ export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
|
|
|
286
299
|
{ arg: 'name', desc: 'workloads: exact workload name (needs kind); nodes: exact node name' },
|
|
287
300
|
{ arg: 'range', desc: 'trend only: 6h, 24h (default), or 7d' },
|
|
288
301
|
{ arg: 'include_points', desc: 'trend only: include raw points (default false); summaries are always returned' },
|
|
289
|
-
{ arg: 'limit', desc: 'max rows (default
|
|
302
|
+
{ arg: 'limit', desc: 'max rows (default 10, max 100)' },
|
|
290
303
|
],
|
|
291
304
|
},
|
|
292
305
|
{
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { ApiError } from '../../api/client'
|
|
3
|
+
import { rowOnError } from './useVulnerabilitiesRow'
|
|
4
|
+
|
|
5
|
+
describe('rowOnError', () => {
|
|
6
|
+
const api = (status: number, code?: string) => new ApiError('x', status, code ? { error: 'x', error_code: code } : { error: 'x' })
|
|
7
|
+
|
|
8
|
+
it('keeps the last answer while Radar settles', () => {
|
|
9
|
+
expect(rowOnError(api(409, 'connection_changed'))).toBe('keep')
|
|
10
|
+
expect(rowOnError(api(503, 'kind_sync_pending'))).toBe('keep')
|
|
11
|
+
expect(rowOnError(api(503, 'cluster_connecting'))).toBe('keep')
|
|
12
|
+
expect(rowOnError(api(503))).toBe('keep')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it("says the read failed when Radar's own identity can't read the reports", () => {
|
|
16
|
+
expect(rowOnError(api(503, 'radar_forbidden'))).toBe('failed')
|
|
17
|
+
expect(rowOnError(api(503, 'list_too_large'))).toBe('failed')
|
|
18
|
+
expect(rowOnError(api(500))).toBe('failed')
|
|
19
|
+
expect(rowOnError(new Error('network'))).toBe('failed')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('hides the row when it has nothing to say', () => {
|
|
23
|
+
expect(rowOnError(api(404, 'kind_unknown'))).toBe('hide')
|
|
24
|
+
expect(rowOnError(api(403, 'user_forbidden'))).toBe('hide')
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useNavigate } from 'react-router-dom'
|
|
2
|
+
import type { AuditCardVulnerabilities } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { useAPIResources } from '../../api/apiResources'
|
|
4
|
+
import { ApiError, useRadarFeature } from '../../api/client'
|
|
5
|
+
import { isRadarFeatureUnsupported } from '../../api/radarFeatures'
|
|
6
|
+
import { hasVulnerabilityReports, isKindUnknown, readSettles, useVulnerabilities } from '../../api/vulnerabilities'
|
|
7
|
+
import { findingsCertainty } from '../vulnerabilities/parts'
|
|
8
|
+
|
|
9
|
+
// The Vulnerabilities row of the Home Checks card: present only where a
|
|
10
|
+
// scanner writes VulnerabilityReports and this Radar serves the rollup.
|
|
11
|
+
export function useVulnerabilitiesRow(namespaces: string[]): AuditCardVulnerabilities | undefined {
|
|
12
|
+
const navigate = useNavigate()
|
|
13
|
+
const { data: resources } = useAPIResources()
|
|
14
|
+
const { support } = useRadarFeature('vulnerabilities')
|
|
15
|
+
const available = hasVulnerabilityReports(resources) && support !== 'unsupported'
|
|
16
|
+
// Only the totals: the rows would be the whole tab's payload, every minute.
|
|
17
|
+
const { data, error } = useVulnerabilities({ view: 'summary', namespaces }, available)
|
|
18
|
+
if (!available) return undefined
|
|
19
|
+
const onNavigate = () => {
|
|
20
|
+
const params = new URLSearchParams()
|
|
21
|
+
if (namespaces.length > 0) params.set('namespaces', namespaces.join(','))
|
|
22
|
+
navigate({ pathname: '/checks/vulnerabilities', search: params.toString() })
|
|
23
|
+
}
|
|
24
|
+
// The query keeps its last answer through a failed poll; a failure that
|
|
25
|
+
// persists decides the row over it.
|
|
26
|
+
const failure = error ? rowOnError(error) : 'keep'
|
|
27
|
+
if (failure === 'failed') return { imagesWithCritical: 0, fixableCriticalHigh: 0, certainty: 'unknown', readFailed: true, onNavigate }
|
|
28
|
+
if (failure === 'hide') return undefined
|
|
29
|
+
if (!data) return undefined
|
|
30
|
+
const s = data.summary
|
|
31
|
+
if (s.imagesScanned === 0 && s.imagesUnscanned === 0) return undefined
|
|
32
|
+
return {
|
|
33
|
+
imagesWithCritical: s.imagesWithCritical,
|
|
34
|
+
fixableCriticalHigh: s.fixableCriticalHighCves,
|
|
35
|
+
certainty: findingsCertainty(data),
|
|
36
|
+
onNavigate,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// What a failed read does to the row: keep the last answer through one that
|
|
41
|
+
// settles by itself (Radar still loading, its connection just changed), hide
|
|
42
|
+
// the row when it has nothing to say (an older Radar, Trivy removed, no
|
|
43
|
+
// access to the reports), and otherwise say the read failed. A 503 naming
|
|
44
|
+
// something to fix, such as Radar's own identity denied the reports, doesn't
|
|
45
|
+
// settle by itself.
|
|
46
|
+
export function rowOnError(error: unknown): 'keep' | 'hide' | 'failed' {
|
|
47
|
+
if (isRadarFeatureUnsupported(error) || isKindUnknown(error)) return 'hide'
|
|
48
|
+
if (readSettles(error)) return 'keep'
|
|
49
|
+
return error instanceof ApiError && error.status === 403 ? 'hide' : 'failed'
|
|
50
|
+
}
|
|
@@ -10,11 +10,12 @@ interface LogsViewerProps {
|
|
|
10
10
|
podName: string
|
|
11
11
|
containers: string[]
|
|
12
12
|
initialContainer?: string
|
|
13
|
+
initContainers?: string[]
|
|
13
14
|
/** Start streaming on mount. Default true — callers pass false for terminal (completed/failed) pods. */
|
|
14
15
|
autoStream?: boolean
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export function LogsViewer({ namespace, podName, containers, initialContainer, autoStream = true }: LogsViewerProps) {
|
|
18
|
+
export function LogsViewer({ namespace, podName, containers, initialContainer, initContainers, autoStream = true }: LogsViewerProps) {
|
|
18
19
|
const desktopDownload = useDesktopDownload()
|
|
19
20
|
const { theme } = useTheme()
|
|
20
21
|
|
|
@@ -40,6 +41,7 @@ export function LogsViewer({ namespace, podName, containers, initialContainer, a
|
|
|
40
41
|
podName={podName}
|
|
41
42
|
containers={containers}
|
|
42
43
|
initialContainer={initialContainer}
|
|
44
|
+
initContainers={initContainers}
|
|
43
45
|
fetchLogs={fetchLogs}
|
|
44
46
|
createStream={makeStream}
|
|
45
47
|
overrideDownload={desktopDownload}
|
|
@@ -3,13 +3,13 @@ import { act } from 'react'
|
|
|
3
3
|
import { createRoot } from 'react-dom/client'
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
5
|
|
|
6
|
-
const state = vi.hoisted(() => ({ logs: {} as Record<string, { data?: unknown; error?: unknown }>, viewer: [] as string[], requested: [] as string[] }))
|
|
6
|
+
const state = vi.hoisted(() => ({ logs: {} as Record<string, { data?: unknown; error?: unknown }>, viewer: [] as string[], requested: [] as string[], resource: undefined as { data?: unknown; isLoading?: boolean } | undefined, viewerProps: [] as Record<string, unknown>[] }))
|
|
7
7
|
vi.mock('../../api/client', async (original) => ({
|
|
8
8
|
...await original<typeof import('../../api/client')>(),
|
|
9
9
|
usePodLogs: (_ns: string, pod: string) => { if (pod) state.requested.push(pod); return state.logs[pod] ?? {} },
|
|
10
|
-
useResource: () =>
|
|
10
|
+
useResource: () => state.resource ?? { data: { status: { phase: 'Running' } } },
|
|
11
11
|
}))
|
|
12
|
-
vi.mock('./LogsViewer', () => ({ LogsViewer: (
|
|
12
|
+
vi.mock('./LogsViewer', () => ({ LogsViewer: (props: { podName: string }) => { state.viewer.push(props.podName); state.viewerProps.push(props); return <div>viewer:{props.podName}</div> } }))
|
|
13
13
|
|
|
14
14
|
const { ApiError } = await import('../../api/client')
|
|
15
15
|
const { MultiPodLogsTab } = await import('./MultiPodLogsTab')
|
|
@@ -18,7 +18,7 @@ const { MultiPodLogsTab } = await import('./MultiPodLogsTab')
|
|
|
18
18
|
const pods = [{ kind: 'Pod', namespace: 'ml', name: 'gone-pod' }, { kind: 'Pod', namespace: 'ml', name: 'live-pod' }]
|
|
19
19
|
let host: HTMLDivElement
|
|
20
20
|
let root: ReturnType<typeof createRoot>
|
|
21
|
-
beforeEach(() => { state.logs = {}; state.viewer = []; state.requested = []; host = document.createElement('div'); root = createRoot(host) })
|
|
21
|
+
beforeEach(() => { state.logs = {}; state.viewer = []; state.requested = []; state.resource = undefined; state.viewerProps = []; host = document.createElement('div'); root = createRoot(host) })
|
|
22
22
|
afterEach(() => act(() => root.unmount()))
|
|
23
23
|
|
|
24
24
|
function render(selected: string, onSelectPod = vi.fn()) {
|
|
@@ -84,6 +84,26 @@ describe('MultiPodLogsTab', () => {
|
|
|
84
84
|
expect(host.textContent).toContain('This RayCluster has no Pods right now.')
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
+
it('lists init containers in run order and opens the one the Pod is stuck on', () => {
|
|
88
|
+
state.logs['live-pod'] = { data: { containers: ['job', 'fetch-config', 'migrate'] } }
|
|
89
|
+
state.resource = { isLoading: true }
|
|
90
|
+
render('live-pod')
|
|
91
|
+
expect(state.viewer).toEqual([])
|
|
92
|
+
|
|
93
|
+
state.resource = { data: {
|
|
94
|
+
spec: { initContainers: [{ name: 'fetch-config' }, { name: 'migrate' }], containers: [{ name: 'job' }] },
|
|
95
|
+
status: { phase: 'Pending', initContainerStatuses: [
|
|
96
|
+
{ name: 'fetch-config', state: { terminated: { exitCode: 0 } } },
|
|
97
|
+
{ name: 'migrate', state: { waiting: { reason: 'CrashLoopBackOff' } } },
|
|
98
|
+
] },
|
|
99
|
+
} }
|
|
100
|
+
render('live-pod')
|
|
101
|
+
expect(state.viewerProps.at(-1)).toMatchObject({ containers: ['fetch-config', 'migrate', 'job'], initialContainer: 'migrate', initContainers: ['fetch-config', 'migrate'] })
|
|
102
|
+
|
|
103
|
+
act(() => root.render(<MultiPodLogsTab pods={pods} namespace="ml" selectedPod="live-pod" onSelectPod={vi.fn()} initialContainer="job" />))
|
|
104
|
+
expect(state.viewerProps.at(-1)).toMatchObject({ initialContainer: 'job' })
|
|
105
|
+
})
|
|
106
|
+
|
|
87
107
|
it('keeps the viewer for a Pod whose containers loaded even if a later refetch fails', () => {
|
|
88
108
|
state.logs['live-pod'] = { data: { containers: ['app'] }, error: new ApiError('Pod not found', 404) }
|
|
89
109
|
render('live-pod')
|