@skyhook-io/radar-app 1.22.2 → 1.23.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 +8 -8
- package/src/App.tsx +49 -13
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +151 -27
- package/src/api/client.updateResource.secretExpiry.test.tsx +47 -0
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/poll.ts +78 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +16 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +315 -0
- package/src/api/workloadSource.ts +128 -12
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +128 -32
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/helm/HelmDrawerRouting.test.tsx +34 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -4
- package/src/components/helm/HelmView.tsx +4 -3
- package/src/components/helm/ObservedHelmNotice.tsx +39 -17
- package/src/components/helm/ObservedHelmRelease.test.tsx +62 -3
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +18 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +4 -2
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +3 -3
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +4 -4
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/issues/uncheckedSources.test.ts +8 -0
- package/src/components/issues/uncheckedSources.ts +3 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/nudges/activeNudges.test.ts +39 -0
- package/src/components/nudges/activeNudges.ts +76 -0
- package/src/components/poll/OssPoll.tsx +871 -0
- package/src/components/poll/mount.test.ts +12 -0
- package/src/components/poll/pollCloud.test.ts +23 -0
- package/src/components/poll/pollCloud.ts +6 -0
- package/src/components/poll/pollDefinition.ts +93 -0
- package/src/components/poll/pollFlow.test.ts +140 -0
- package/src/components/poll/pollFlow.ts +137 -0
- package/src/components/poll/pollSender.test.ts +137 -0
- package/src/components/poll/pollSender.ts +76 -0
- package/src/components/poll/pollStorage.test.ts +53 -0
- package/src/components/poll/pollStorage.ts +77 -0
- package/src/components/poll/round.json +350 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +2 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ImageFilesystemModal.test.tsx +21 -1
- package/src/components/resources/ImageFilesystemModal.tsx +42 -3
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +24 -11
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/ui/UpdateNotification.tsx +2 -0
- package/src/components/usage-data/UsageDataPrompt.tsx +2 -0
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/whats-new/WhatsNew.tsx +2 -0
- package/src/components/whats-new/releaseNotes.ts +75 -1
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +52 -13
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { createContext, useContext, type ReactNode } from 'react'
|
|
2
|
+
import { Tooltip } from '@skyhook-io/k8s-ui/components/ui/Tooltip'
|
|
3
|
+
import { WithTooltip } from '../ui/Tooltip'
|
|
4
|
+
import {
|
|
5
|
+
ownerLookup,
|
|
6
|
+
type OwnerLookup,
|
|
7
|
+
type VulnerabilitiesResponse,
|
|
8
|
+
type VulnerabilityOwnerManager,
|
|
9
|
+
type VulnerabilityOwnerRead,
|
|
10
|
+
type VulnerabilityWorkloadOwner,
|
|
11
|
+
} from '../../api/vulnerabilities'
|
|
12
|
+
|
|
13
|
+
/** The answer's owners, for any workload link on the page; absent from an older Radar. */
|
|
14
|
+
export interface OwnerInfo {
|
|
15
|
+
find: OwnerLookup
|
|
16
|
+
teamLabel: string
|
|
17
|
+
unavailable?: string
|
|
18
|
+
unchecked?: VulnerabilityOwnerRead[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const OwnerContext = createContext<OwnerInfo | undefined>(undefined)
|
|
22
|
+
|
|
23
|
+
export function ownerInfo(data: VulnerabilitiesResponse | undefined): OwnerInfo | undefined {
|
|
24
|
+
if (!data?.ownership) return undefined
|
|
25
|
+
return { find: ownerLookup(data.owners), teamLabel: data.ownership.teamLabel, unavailable: data.ownership.unavailable, unchecked: data.ownership.unchecked }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function OwnerProvider({ info, children }: { info: OwnerInfo | undefined; children: ReactNode }) {
|
|
29
|
+
return <OwnerContext.Provider value={info}>{children}</OwnerContext.Provider>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function useOwners(): OwnerInfo | undefined {
|
|
33
|
+
return useContext(OwnerContext)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const TOOL_LABEL: Record<VulnerabilityOwnerManager['tool'], string> = { helm: 'Helm release', argocd: 'Argo CD', fluxcd: 'Flux' }
|
|
37
|
+
|
|
38
|
+
export function managerLabel(m: VulnerabilityOwnerManager): string {
|
|
39
|
+
if (m.tool === 'fluxcd') return m.kind === 'Kustomization' ? 'Flux Kustomization' : 'Flux HelmRelease'
|
|
40
|
+
if (m.tool === 'argocd') return 'Argo CD Application'
|
|
41
|
+
return TOOL_LABEL[m.tool]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function readName(r: VulnerabilityOwnerRead): string {
|
|
45
|
+
if (r.group === 'argoproj.io' && r.kind === 'Application') return 'Argo CD Applications'
|
|
46
|
+
if (r.group?.endsWith('.toolkit.fluxcd.io')) return `Flux ${r.kind}s`
|
|
47
|
+
return `${r.kind} objects`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function orList(items: string[]): string {
|
|
51
|
+
return items.length <= 1 ? items.join('') : `${items.slice(0, -1).join(', ')} or ${items.at(-1)}`
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Which reads the caller's access kept Radar from, in a sentence or two; undefined when none. */
|
|
55
|
+
export function uncheckedReadsText(reads: VulnerabilityOwnerRead[] | undefined): string | undefined {
|
|
56
|
+
if (!reads?.length) return undefined
|
|
57
|
+
const isNamespace = (r: VulnerabilityOwnerRead) => r.kind === 'Namespace' && !r.group
|
|
58
|
+
const managers = reads.filter((r) => !isNamespace(r))
|
|
59
|
+
const full = managers.filter((r) => !r.partial).map(readName)
|
|
60
|
+
const partial = managers.filter((r) => r.partial).map(readName)
|
|
61
|
+
const missing: string[] = []
|
|
62
|
+
if (full.length) missing.push(orList(full))
|
|
63
|
+
if (partial.length) missing.push(`${orList(partial)} outside your namespaces`)
|
|
64
|
+
if (reads.some(isNamespace)) missing.push('namespaces, where a team label may be')
|
|
65
|
+
return missing.map((m, i) => `${i === 0 ? "With your access, Radar couldn't read" : "It also couldn't read"} ${m}.`).join(' ')
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A repository address without its scheme or .git, for a narrow cell. */
|
|
69
|
+
export function shortRepo(repo: string): string {
|
|
70
|
+
return repo.replace(/^[a-z][a-z0-9+.-]*:\/\//i, '').replace(/^git@([^:]+):/, '$1/').replace(/\.git$/, '')
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const UNCHECKED_LINE = "Radar couldn't check what deploys it with your access"
|
|
74
|
+
|
|
75
|
+
/** The owner's detail lines, for a tooltip. */
|
|
76
|
+
function OwnerDetail({ owner, teamLabel, unchecked }: { owner: VulnerabilityWorkloadOwner; teamLabel: string; unchecked?: VulnerabilityOwnerRead[] }) {
|
|
77
|
+
const m = owner.manager
|
|
78
|
+
return (
|
|
79
|
+
<span className="flex flex-col gap-1 text-left">
|
|
80
|
+
{m && (
|
|
81
|
+
<>
|
|
82
|
+
<span>{managerLabel(m)} <span className="font-mono">{m.namespace}/{m.name}</span></span>
|
|
83
|
+
{m.chart && <span>Chart <span className="font-mono">{m.chart}</span></span>}
|
|
84
|
+
{(m.sources ?? []).map((s) => (
|
|
85
|
+
<span key={`${s.repo}/${s.path ?? ''}`} className="break-all font-mono">{s.repo}{s.path ? ` (${s.path})` : ''}{s.chart ? `, chart ${s.chart}` : ''}</span>
|
|
86
|
+
))}
|
|
87
|
+
{m.tool === 'helm' && <span>Helm records no source repository.</span>}
|
|
88
|
+
{m.shared && <span>More than one Argo CD or Flux object manages it, or what runs it; this is the one Radar leads with.</span>}
|
|
89
|
+
</>
|
|
90
|
+
)}
|
|
91
|
+
{!m && owner.managerUnchecked && <span>{`${UNCHECKED_LINE}.`} {uncheckedReadsText(unchecked)}</span>}
|
|
92
|
+
{!m && owner.managerUnknown && !owner.managerUnchecked && <span>Radar couldn't tell what deploys it: the evidence disagrees or couldn't all be read.</span>}
|
|
93
|
+
{owner.team && <span>Team <span className="font-mono">{owner.team}</span>, from the {owner.teamFrom === 'namespace' ? "namespace's" : "workload's"} <span className="font-mono">{teamLabel}</span> label</span>}
|
|
94
|
+
{m && <span className="text-theme-text-tertiary">This is the app that deploys it. The image tag may be set by CI, an override or a values file.</span>}
|
|
95
|
+
</span>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The Owner column of By workload. Empty when Radar found nothing, never a guess. */
|
|
100
|
+
const TEAM_NOT_CHECKED = "Its namespace's team label couldn't be checked with your access."
|
|
101
|
+
|
|
102
|
+
export function OwnerCell({ workload }: { workload: { kind: string; group?: string; namespace: string; name: string } }) {
|
|
103
|
+
const info = useOwners()
|
|
104
|
+
if (!info) return <span />
|
|
105
|
+
if (info.unavailable) {
|
|
106
|
+
return (
|
|
107
|
+
<WithTooltip tip="Radar couldn't read owners for this answer: it is still loading the cluster or its connection changed. Try again shortly.">
|
|
108
|
+
<span className="text-xs text-theme-text-tertiary">Unknown</span>
|
|
109
|
+
</WithTooltip>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
const owner = info.find(workload)
|
|
113
|
+
// A namespace the viewer can't read may carry a team label: a missing team
|
|
114
|
+
// there is not checked, not none.
|
|
115
|
+
const teamUnchecked = !owner?.team && !!info.unchecked?.some((u) => u.kind === 'Namespace' && !u.group)
|
|
116
|
+
if (!owner) {
|
|
117
|
+
return teamUnchecked ? (
|
|
118
|
+
<WithTooltip tip={TEAM_NOT_CHECKED}>
|
|
119
|
+
<span className="text-xs text-theme-text-tertiary">team not checked</span>
|
|
120
|
+
</WithTooltip>
|
|
121
|
+
) : <span />
|
|
122
|
+
}
|
|
123
|
+
const m = owner.manager
|
|
124
|
+
const repo = m?.sources?.[0]?.repo
|
|
125
|
+
return (
|
|
126
|
+
<Tooltip content={<OwnerDetail owner={owner} teamLabel={info.teamLabel} unchecked={info.unchecked} />}>
|
|
127
|
+
<span className="flex min-w-0 flex-col text-xs">
|
|
128
|
+
{m ? (
|
|
129
|
+
<>
|
|
130
|
+
<span className="truncate text-theme-text-primary">{m.name}</span>
|
|
131
|
+
<span className="truncate text-theme-text-tertiary">
|
|
132
|
+
{m.tool === 'helm' ? (m.chart ? `Helm · ${m.chart}` : 'Helm release') : repo ? `${TOOL_LABEL[m.tool]} · ${shortRepo(repo)}` : managerLabel(m)}
|
|
133
|
+
</span>
|
|
134
|
+
</>
|
|
135
|
+
) : owner.managerUnchecked ? (
|
|
136
|
+
<span className="text-theme-text-tertiary">Not checked</span>
|
|
137
|
+
) : owner.managerUnknown ? (
|
|
138
|
+
<span className="text-theme-text-tertiary">Unknown</span>
|
|
139
|
+
) : null}
|
|
140
|
+
{owner.team && <span className="truncate text-theme-text-secondary">team: {owner.team}</span>}
|
|
141
|
+
{teamUnchecked && <span className="truncate text-theme-text-tertiary">team not checked</span>}
|
|
142
|
+
</span>
|
|
143
|
+
</Tooltip>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** One line for a workload link's tooltip, or undefined when nothing is known. */
|
|
148
|
+
export function ownerTip(owner: VulnerabilityWorkloadOwner | undefined): string | undefined {
|
|
149
|
+
if (!owner) return undefined
|
|
150
|
+
const parts: string[] = []
|
|
151
|
+
const m = owner.manager
|
|
152
|
+
if (m) {
|
|
153
|
+
const from = (m.sources ?? []).map((s) => `${shortRepo(s.repo)}${s.path ? ` (${s.path})` : ''}`).join(', ')
|
|
154
|
+
parts.push(`Deployed by ${managerLabel(m)} ${m.namespace}/${m.name}${m.chart ? `, chart ${m.chart}` : ''}${from ? `, from ${from}` : ''}`)
|
|
155
|
+
if (m.shared) parts.push('More than one Argo CD or Flux object manages it')
|
|
156
|
+
} else if (owner.managerUnchecked) {
|
|
157
|
+
parts.push(UNCHECKED_LINE)
|
|
158
|
+
} else if (owner.managerUnknown) {
|
|
159
|
+
parts.push("Radar couldn't tell what deploys it")
|
|
160
|
+
}
|
|
161
|
+
if (owner.team) parts.push(`Team ${owner.team}`)
|
|
162
|
+
return parts.length ? `${parts.join('. ')}.` : undefined
|
|
163
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
2
|
import { ApiError } from '../../api/client'
|
|
3
3
|
import { hasVulnerabilityReports, isKindUnknown, parseWorkloadParam, vulnerabilitiesPath, workloadParam } from '../../api/vulnerabilities'
|
|
4
|
-
import { exposedCountTip, exposureGapSentence,
|
|
4
|
+
import { exposedCountTip, exposureGapSentence, exposureUnknownIn, feedNote, feedStatusText, findingsCertainty, intelNotes, gapSentence, imageParts, riskBadgeLabel, riskBadgeSummary, riskEntries, riskEvidence, RISK_WHY, routesTip, workloadNamesTip } from './parts'
|
|
5
|
+
import { moreFiltersLabel, severityFilterLabel } from './filters'
|
|
6
|
+
import type { RiskyWorkload } from '../../api/vulnerabilities'
|
|
5
7
|
|
|
6
8
|
describe('vulnerabilities helpers', () => {
|
|
7
9
|
it('builds the request from filters', () => {
|
|
@@ -70,19 +72,102 @@ describe('vulnerabilities helpers', () => {
|
|
|
70
72
|
const w = (name: string, container = 'app', namespace = 'shop') => ({ kind: 'Deployment', group: 'apps', namespace, name, container })
|
|
71
73
|
const route = { via: 'LoadBalancer', namespace: 'kube-system', name: 'traefik' }
|
|
72
74
|
|
|
73
|
-
it('
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
expect(
|
|
75
|
+
it('names a row\'s workloads once each, for its count\'s tooltip', () => {
|
|
76
|
+
expect(workloadNamesTip([w('a'), w('a', 'sidecar'), w('b')])).toBe('a and b, in 1 namespace')
|
|
77
|
+
// Same name in another namespace is another workload.
|
|
78
|
+
expect(workloadNamesTip([w('a'), w('a', 'app', 'other')])).toBe('a and a, in 2 namespaces')
|
|
79
|
+
expect(workloadNamesTip([w('a'), w('b'), w('c')], { total: 8, listed: 2 })).toBe('a, b and 6 more, in at least 1 namespace')
|
|
80
|
+
expect(workloadNamesTip([w('a'), w('b')], { capped: true })).toBe('a, b and more, in at least 1 namespace')
|
|
81
|
+
expect(workloadNamesTip([])).toBeUndefined()
|
|
82
|
+
// Exposed first, then the ones behind the risk badge, so both are named.
|
|
83
|
+
const first = [(x: { name: string }) => x.name === 'd', (x: { name: string }) => x.name === 'e']
|
|
84
|
+
expect(workloadNamesTip([w('a'), w('b'), w('c'), w('d'), w('e')], { listed: 2, first })).toBe('d, e and 3 more, in 1 namespace')
|
|
77
85
|
})
|
|
78
86
|
|
|
79
|
-
it('
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
expect(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
expect(
|
|
87
|
+
it('leads the risk badge with the most serious factor and counts every other one', () => {
|
|
88
|
+
expect(riskBadgeLabel(['mayRunAsRoot', 'privileged', 'hostPort'])).toBe('Privileged +2')
|
|
89
|
+
expect(riskBadgeLabel(['runsAsRoot', 'hostAccess'])).toBe('Host access +1')
|
|
90
|
+
expect(riskBadgeLabel(['runsAsRoot'])).toBe('Runs as root')
|
|
91
|
+
// Common factors alone bring no badge, unless the risk filter selects one.
|
|
92
|
+
expect(riskBadgeLabel(['mayRunAsRoot', 'hostPort'])).toBeNull()
|
|
93
|
+
expect(riskBadgeLabel(['mayRunAsRoot', 'hostPort'], new Set(['hostPort']))).toBe('Host port +1')
|
|
94
|
+
expect(riskBadgeLabel(undefined)).toBeNull()
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('names the risk badge for what it holds, one factor or how many more', () => {
|
|
98
|
+
expect(riskBadgeSummary(['privileged'])).toBe('Privileged')
|
|
99
|
+
expect(riskBadgeSummary(['privileged', 'hostPort'])).toBe('Privileged and 1 more risky setting')
|
|
100
|
+
expect(riskBadgeSummary(['mayRunAsRoot', 'privileged', 'hostPort', 'hostAccess', 'runsAsRoot', 'privilegeEscalation'])).toBe('Privileged and 5 more risky settings')
|
|
101
|
+
expect(riskBadgeSummary(['mayRunAsRoot', 'hostPort'])).toBeNull()
|
|
102
|
+
expect(riskBadgeSummary(['mayRunAsRoot', 'hostPort'], new Set(['hostPort']))).toBe('Host port and 1 more risky setting')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// Settings in the words pkg/audit's PodRisks writes them.
|
|
106
|
+
const agent: RiskyWorkload = {
|
|
107
|
+
kind: 'DaemonSet', group: 'apps', namespace: 'kube-system', name: 'node-agent',
|
|
108
|
+
factors: ['privileged', 'hostAccess', 'runsAsRoot', 'dangerousCapabilities', 'privilegeEscalation', 'hostPort'],
|
|
109
|
+
settings: [
|
|
110
|
+
{ factor: 'privileged', check: 'privileged', message: 'Container "agent" runs in privileged mode' },
|
|
111
|
+
{ factor: 'hostAccess', check: 'hostNetwork', message: 'Pod uses host network' },
|
|
112
|
+
{ factor: 'hostAccess', check: 'hostPID', message: 'Pod uses host PID namespace' },
|
|
113
|
+
{ factor: 'hostAccess', check: 'dockerSocketMount', message: 'Volume "sock" mounts container runtime socket /var/run/docker.sock' },
|
|
114
|
+
{ factor: 'hostAccess', check: 'sensitiveHostPath', message: 'Volume "root" mounts the entire host root filesystem' },
|
|
115
|
+
{ factor: 'runsAsRoot', check: 'runAsRoot', message: 'Container "agent" runs as root (runAsUser: 0)' },
|
|
116
|
+
{ factor: 'dangerousCapabilities', check: 'dangerousCapabilities', message: 'Container "agent" adds dangerous capability SYS_ADMIN' },
|
|
117
|
+
{ factor: 'dangerousCapabilities', check: 'insecureCapabilities', message: 'Container "agent" adds insecure capability NET_RAW' },
|
|
118
|
+
{ factor: 'privilegeEscalation', check: 'privilegeEscalation', message: 'Container "agent" allows privilege escalation' },
|
|
119
|
+
{ factor: 'hostPort', message: 'Container "agent" binds host port 9100' },
|
|
120
|
+
],
|
|
121
|
+
}
|
|
122
|
+
const exporter: RiskyWorkload = {
|
|
123
|
+
kind: 'DaemonSet', group: 'apps', namespace: 'monitoring', name: 'node-exporter',
|
|
124
|
+
factors: ['hostAccess', 'mayRunAsRoot', 'dangerousCapabilities', 'hostPort'],
|
|
125
|
+
settings: [
|
|
126
|
+
{ factor: 'hostAccess', check: 'hostPID', message: 'Pod uses host PID namespace' },
|
|
127
|
+
{ factor: 'hostAccess', check: 'sensitiveHostPath', message: 'Volume "proc" mounts sensitive host path /proc' },
|
|
128
|
+
{ factor: 'hostPort', message: 'Container "exporter" binds host port 9100' },
|
|
129
|
+
],
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
it('shortens each setting behind a factor to its key setting', () => {
|
|
133
|
+
expect(riskEvidence('hostAccess', [agent])).toEqual(['hostNetwork', 'hostPID', 'hostPath /var/run/docker.sock', '+1 more'])
|
|
134
|
+
expect(riskEvidence('hostAccess', [exporter])).toEqual(['hostPID', 'hostPath /proc'])
|
|
135
|
+
expect(riskEvidence('dangerousCapabilities', [agent])).toEqual(['SYS_ADMIN', 'NET_RAW'])
|
|
136
|
+
expect(riskEvidence('hostPort', [agent, exporter])).toEqual(['9100'])
|
|
137
|
+
// What the factor's rule admits, with or without its settings.
|
|
138
|
+
expect(riskEvidence('runsAsRoot', [])).toEqual(['runAsUser 0'])
|
|
139
|
+
expect(riskEvidence('mayRunAsRoot', [])).toEqual(['runAsNonRoot not set'])
|
|
140
|
+
expect(riskEvidence('privilegeEscalation', [])).toEqual(['not disabled'])
|
|
141
|
+
// No settings sent (a common factor the filter doesn't select): nothing to say.
|
|
142
|
+
expect(riskEvidence('dangerousCapabilities', [exporter])).toEqual([])
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
it('lists every factor in the popover, serious first, with its evidence, workloads and why', () => {
|
|
146
|
+
const row = riskEntries(['hostPort', 'mayRunAsRoot', 'privileged', 'hostAccess', 'dangerousCapabilities'], [agent, exporter])
|
|
147
|
+
expect(row.map((e) => [e.label, e.evidence, e.workloads.map((w) => w.name), e.serious])).toEqual([
|
|
148
|
+
['Privileged', [], ['node-agent'], true],
|
|
149
|
+
['Host access', ['hostNetwork', 'hostPID', 'hostPath /var/run/docker.sock', '+2 more'], ['node-agent', 'node-exporter'], true],
|
|
150
|
+
['May run as root', ['runAsNonRoot not set'], ['node-exporter'], false],
|
|
151
|
+
['Dangerous capabilities', ['SYS_ADMIN', 'NET_RAW'], ['node-agent', 'node-exporter'], false],
|
|
152
|
+
['Host port', ['9100'], ['node-agent', 'node-exporter'], false],
|
|
153
|
+
])
|
|
154
|
+
// A workload's own popover names it only where nothing else says what was found.
|
|
155
|
+
const own = riskEntries(['privileged', 'dangerousCapabilities', 'privilegeEscalation'], [{ ...exporter, factors: ['privileged', 'dangerousCapabilities', 'privilegeEscalation'] }], true)
|
|
156
|
+
expect(own.map((e) => [e.label, e.evidence, e.workloads.map((w) => w.name)])).toEqual([
|
|
157
|
+
['Privileged', [], ['node-exporter']],
|
|
158
|
+
['Dangerous capabilities', [], ['node-exporter']],
|
|
159
|
+
['Privilege escalation', ['not disabled'], []],
|
|
160
|
+
])
|
|
161
|
+
expect(Object.values(RISK_WHY).map((r) => r.why).join(' ')).not.toMatch(/—/)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('labels the severity and More filters chips by what is on', () => {
|
|
165
|
+
expect(severityFilterLabel([])).toBe('Severity')
|
|
166
|
+
expect(severityFilterLabel(['critical'])).toBe('Critical')
|
|
167
|
+
expect(severityFilterLabel(['unknown'])).toBe('Unrated')
|
|
168
|
+
expect(severityFilterLabel(['high', 'critical'])).toBe('Severity: 2')
|
|
169
|
+
expect(moreFiltersLabel(0)).toBe('More filters')
|
|
170
|
+
expect(moreFiltersLabel(2)).toBe('More filters · 2')
|
|
86
171
|
})
|
|
87
172
|
|
|
88
173
|
it('says how many of a count have a route, listing the first few', () => {
|
|
@@ -126,3 +211,32 @@ describe('vulnerabilities helpers', () => {
|
|
|
126
211
|
expect(hidden).toContain('1 namespace')
|
|
127
212
|
})
|
|
128
213
|
})
|
|
214
|
+
|
|
215
|
+
describe('feed status', () => {
|
|
216
|
+
const age = (iso: string) => (iso === '2026-11-24T10:00:00Z' ? '3m ago' : '?')
|
|
217
|
+
it("says which of Radar Cloud's catalogs Radar holds and when it was checked", () => {
|
|
218
|
+
expect(feedStatusText({ kev: { state: 'ready', version: '2026.11.20', checkedAt: '2026-11-24T10:00:00Z' }, epss: { state: 'ready', version: '2026-11-22' } }, age))
|
|
219
|
+
.toBe("Radar Cloud's CISA catalog 2026.11.20, checked 3m ago. EPSS scores from 2026-11-22.")
|
|
220
|
+
})
|
|
221
|
+
it('says why a stale copy is stale', () => {
|
|
222
|
+
expect(feedStatusText({ kev: { state: 'ready', version: '2026.11.20', checkedAt: '2026-11-24T10:00:00Z', stale: true, error: 'the feed answered HTTP 503' }, epss: { state: 'unavailable' } }, age))
|
|
223
|
+
.toBe("Radar Cloud's CISA catalog 2026.11.20, checked 3m ago. Out of date: Radar Cloud couldn't refresh it (the feed answered HTTP 503).")
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
describe('without a feed', () => {
|
|
228
|
+
it("says why calmly, naming Radar Cloud's setting, never a cluster one", () => {
|
|
229
|
+
const missing = feedNote('KEV', { state: 'unavailable', error: "couldn't reach Radar Cloud: i/o timeout" })!
|
|
230
|
+
expect(missing).toContain("isn't available from Radar Cloud")
|
|
231
|
+
expect(missing).toContain('within the hour')
|
|
232
|
+
expect(feedNote('KEV', { state: 'disabled' })).toBe('KEV is turned off on this Radar Cloud (HUB_KEV_FEED).')
|
|
233
|
+
expect(feedNote('KEV', { state: 'disabled', downloadsOff: true })).toContain('HUB_KEV_FEED to a file')
|
|
234
|
+
for (const state of ['unavailable', 'disabled'] as const) {
|
|
235
|
+
const note = feedNote('KEV', { state })!
|
|
236
|
+
expect(note).not.toContain('--kev-feed')
|
|
237
|
+
expect(note).not.toContain('Helm')
|
|
238
|
+
}
|
|
239
|
+
expect(feedNote('KEV', { state: 'loading' })).toBe("Radar is loading CISA's Known Exploited Vulnerabilities catalog from Radar Cloud.")
|
|
240
|
+
expect(intelNotes({ kev: { state: 'unavailable' }, epss: { state: 'disabled' } })).toEqual([])
|
|
241
|
+
})
|
|
242
|
+
})
|