@skyhook-io/radar-app 1.22.1 → 1.23.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 +8 -8
- package/src/App.tsx +131 -38
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/RadarApp.tsx +5 -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 +128 -25
- 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/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +13 -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 +1172 -0
- package/src/api/workloadSource.ts +408 -0
- package/src/components/APIUnreachableBanner.test.tsx +19 -0
- package/src/components/APIUnreachableBanner.tsx +20 -0
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +127 -32
- package/src/components/ConnectionErrorView.test.tsx +63 -2
- package/src/components/ConnectionErrorView.tsx +88 -68
- 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/ActivityTurn.tsx +6 -4
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -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/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +10 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.tsx +120 -23
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
- package/src/components/diagnose/investigationState.ts +9 -0
- package/src/components/diagnose/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/ActivitySummary.tsx +3 -8
- package/src/components/home/ClusterHealthCard.tsx +91 -17
- package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +9 -29
- 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/TopologyPreview.test.tsx +31 -30
- package/src/components/home/TopologyPreview.tsx +19 -28
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +7 -7
- 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/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/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/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +2 -6
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +4 -1
- 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/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/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +119 -14
- package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
- 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/context/ConnectionContext.tsx +24 -5
- package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
- package/src/context/ConnectionProvider.handover.test.tsx +94 -0
- package/src/context/DiagnoseCustomization.tsx +20 -2
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/hooks/useEventSource.test.tsx +275 -4
- package/src/hooks/useEventSource.ts +278 -51
- package/src/index.ts +1 -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
- package/src/utils/navigation.test.ts +1 -6
- package/src/utils/navigation.ts +9 -44
- package/src/utils/network-policy-navigation.test.ts +21 -36
|
@@ -4,17 +4,26 @@ import { createRoot, type Root } from 'react-dom/client'
|
|
|
4
4
|
import { MemoryRouter, useLocation } from 'react-router-dom'
|
|
5
5
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
6
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
7
|
-
import { useVulnerabilities, type VulnerabilitiesResponse, type VulnerabilityWorkloadRef } from '../../api/vulnerabilities'
|
|
7
|
+
import { readSettles, useVulnerabilities, vulnerabilitiesRefetchInterval, type VulnerabilitiesResponse, type VulnerabilityWorkloadRef } from '../../api/vulnerabilities'
|
|
8
8
|
import { VulnerabilitiesView } from './VulnerabilitiesView'
|
|
9
|
+
import { ApiError } from '../../api/client'
|
|
9
10
|
|
|
11
|
+
// A Radar with the KEV filter unless a test says otherwise; deployment is
|
|
12
|
+
// the Radar's mode ('cloud' when Radar Cloud embeds it).
|
|
13
|
+
const features = vi.hoisted(() => ({ current: { vulnerabilityIntel: true } as Record<string, boolean>, mode: 'in-cluster' }))
|
|
10
14
|
vi.mock('../../api/client', async (importOriginal) => ({
|
|
11
15
|
...await importOriginal<typeof import('../../api/client')>(),
|
|
12
|
-
useCapabilities: () => ({ data: { features: {} } }),
|
|
13
|
-
useRadarFeature: (
|
|
16
|
+
useCapabilities: () => ({ data: { features: features.current, deployment: { mode: features.mode } } }),
|
|
17
|
+
useRadarFeature: (feature: string) => ({
|
|
18
|
+
support: features.current[feature] ? 'supported' : 'unsupported',
|
|
19
|
+
upgrade: features.current[feature] ? null : { feature: 'Known exploited CVEs and EPSS scores' },
|
|
20
|
+
guard: <T,>(fn: () => T) => fn(),
|
|
21
|
+
}),
|
|
14
22
|
}))
|
|
15
23
|
vi.mock('../../api/apiResources', () => ({ useAPIResources: () => ({ data: [{ group: 'aquasecurity.github.io', name: 'vulnerabilityreports' }] }) }))
|
|
16
24
|
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { context: 'test', clusterName: 'test', state: 'connected' } }) }))
|
|
17
25
|
vi.mock('../../hooks/useDesktopDownload', () => ({ useDesktopDownload: () => undefined }))
|
|
26
|
+
vi.mock('../../api/traffic', () => ({ useTrafficAvailable: (enabled = true) => enabled }))
|
|
18
27
|
vi.mock('./ChecksViewTabs', () => ({ ChecksViewTabs: () => null }))
|
|
19
28
|
vi.mock('../../api/vulnerabilities', async (importOriginal) => ({
|
|
20
29
|
...await importOriginal<typeof import('../../api/vulnerabilities')>(),
|
|
@@ -27,12 +36,16 @@ const zero = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0 }
|
|
|
27
36
|
const ref = (name: string, namespace = 'shop'): VulnerabilityWorkloadRef => ({ kind: 'Deployment', group: 'apps', namespace, name, container: 'app' })
|
|
28
37
|
const route = { via: 'LoadBalancer', namespace: 'shop', name: 'web' }
|
|
29
38
|
|
|
30
|
-
|
|
39
|
+
const kev = { dateAdded: '2023-10-10', dueDate: '2023-10-31', ransomwareUse: 'unknown' as const }
|
|
40
|
+
const readyIntel: NonNullable<VulnerabilitiesResponse['intel']> = { kev: { state: 'ready', count: 1790 }, epss: { state: 'ready', count: 411000 } }
|
|
41
|
+
|
|
42
|
+
function response(view: VulnerabilitiesResponse['view'], withExposure: boolean, intel?: VulnerabilitiesResponse['intel']): VulnerabilitiesResponse {
|
|
31
43
|
const base: VulnerabilitiesResponse = {
|
|
32
44
|
source: 'trivy',
|
|
33
45
|
view,
|
|
34
46
|
summary: { imagesScanned: 1, imagesClean: 0, imagesUnscanned: 0, imagesWithCritical: 1, fixableCriticalHighCves: 1, workloadsWithCriticalOrHigh: 2, workloads: 3, counts: { ...zero, critical: 1 } },
|
|
35
47
|
coverage: { complete: true, gaps: [], inactiveReports: 0 },
|
|
48
|
+
...(intel ? { intel } : {}),
|
|
36
49
|
}
|
|
37
50
|
const exposed = withExposure ? { exposed: [{ kind: 'Deployment', group: 'apps', namespace: 'shop', name: 'web', routes: [route] }], exposedTotal: 1 } : {}
|
|
38
51
|
const image = {
|
|
@@ -48,6 +61,10 @@ function response(view: VulnerabilitiesResponse['view'], withExposure: boolean):
|
|
|
48
61
|
package: 'zlib', from: ['1.0'], to: '1.1', severity: 'critical', counts: { ...zero, critical: 1 }, cves: ['CVE-1'], cvesTotal: 1, images: 1, workloads: 2,
|
|
49
62
|
affected: [{ imageId: 'img', image: image.image, installedVersions: ['1.0'], workloads: image.workloads, workloadsTotal: 2 }], ...exposed,
|
|
50
63
|
}],
|
|
64
|
+
cves: [{
|
|
65
|
+
id: 'CVE-2023-44487', severity: 'critical', packages: ['golang.org/x/net'], fixable: true, fixableImages: 1, images: 1, workloads: 2,
|
|
66
|
+
affected: [], ...(intel ? { kev, epss: { score: 0.94, percentile: 0.998 } } : {}),
|
|
67
|
+
}],
|
|
51
68
|
workloads: [
|
|
52
69
|
{ kind: 'Deployment', group: 'apps', namespace: 'shop', name: 'web', counts: { ...zero, critical: 1 }, fixable: zero, containers: [], ...(withExposure ? { routes: [route, { via: 'Ingress', namespace: 'shop', name: 'web' }] } : {}) },
|
|
53
70
|
{ kind: 'Deployment', group: 'apps', namespace: 'hidden', name: 'secret', counts: { ...zero, critical: 1 }, fixable: zero, containers: [] },
|
|
@@ -64,9 +81,9 @@ function Probe() {
|
|
|
64
81
|
|
|
65
82
|
const urlParams = () => new URLSearchParams(container.querySelector('[data-testid="location"]')!.textContent ?? '')
|
|
66
83
|
|
|
67
|
-
function render(path: string, withExposure = true) {
|
|
84
|
+
function render(path: string, withExposure = true, intel?: VulnerabilitiesResponse['intel']) {
|
|
68
85
|
vi.mocked(useVulnerabilities).mockImplementation((p) => ({
|
|
69
|
-
data: response(p.view, withExposure), isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 0, refetch: vi.fn(),
|
|
86
|
+
data: response(p.view, withExposure, intel), isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 0, refetch: vi.fn(),
|
|
70
87
|
} as unknown as ReturnType<typeof useVulnerabilities>))
|
|
71
88
|
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
72
89
|
act(() => root.render(
|
|
@@ -82,6 +99,53 @@ function render(path: string, withExposure = true) {
|
|
|
82
99
|
const button = (label: string) => Array.from(container.querySelectorAll('button')).find((b) => b.textContent?.trim() === label)
|
|
83
100
|
const lastParams = () => vi.mocked(useVulnerabilities).mock.calls.at(-1)![0]
|
|
84
101
|
const marks = () => container.querySelectorAll('svg[aria-label^="Exposed via"]')
|
|
102
|
+
// Table rows, not the filter chips that open a panel.
|
|
103
|
+
// A table row's summary: a click anywhere on it, off its controls, toggles the row.
|
|
104
|
+
const rowButtons = () => Array.from(container.querySelectorAll<HTMLElement>('[data-row-summary]'))
|
|
105
|
+
const panelLabels = () => Array.from(document.body.querySelectorAll('[role="dialog"] label')).map((l) => l.textContent)
|
|
106
|
+
const check = (label: string) => Array.from(document.body.querySelectorAll('[role="dialog"] label')).find((l) => l.textContent?.startsWith(label))!.querySelector<HTMLInputElement>('input[type="checkbox"]')!
|
|
107
|
+
// What a tooltip says, brought up the way a pointer does.
|
|
108
|
+
function tipOf(el: Element): string | undefined {
|
|
109
|
+
vi.useFakeTimers()
|
|
110
|
+
try {
|
|
111
|
+
act(() => { el.dispatchEvent(new MouseEvent('mouseover', { bubbles: true })) })
|
|
112
|
+
act(() => { vi.advanceTimersByTime(1_000) })
|
|
113
|
+
return document.body.querySelector('[role="tooltip"]')?.textContent ?? undefined
|
|
114
|
+
} finally {
|
|
115
|
+
act(() => { el.dispatchEvent(new MouseEvent('mouseout', { bubbles: true })) })
|
|
116
|
+
act(() => { vi.advanceTimersByTime(1_000) })
|
|
117
|
+
vi.useRealTimers()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Elements Tab stops on inside an element: none may sit inside a row's toggle.
|
|
121
|
+
const tabStops = (el: Element) => Array.from(el.querySelectorAll<HTMLElement>('*')).filter((e) => e.tabIndex >= 0)
|
|
122
|
+
const toggleOf = (row: Element) => row.querySelector<HTMLButtonElement>('button[aria-expanded]:not([aria-haspopup])')!
|
|
123
|
+
const VIEW_KEYS = ['image', 'fix', 'cve', 'workload'] as const
|
|
124
|
+
// Every view with a KEV pill and a privileged workload on each row.
|
|
125
|
+
function renderWithBadges(by: string) {
|
|
126
|
+
const container3 = (name: string) => ({ name, image: `example.com/shop/${name}:1`, scanned: true, counts: { ...zero, critical: 1 } })
|
|
127
|
+
vi.mocked(useVulnerabilities).mockImplementation((p) => {
|
|
128
|
+
const data = response(p.view, true, readyIntel)
|
|
129
|
+
data.images = data.images!.map((i) => ({ ...i, kevCves: 1, riskFactors: ['privileged' as const] }))
|
|
130
|
+
data.cves = data.cves!.map((c) => ({ ...c, exposureUnknown: true, riskFactors: ['privileged' as const], affected: [{ imageId: 'img', image: 'example.com/shop/app:1', packages: [], workloads: [ref('web')], workloadsTotal: 1 }] }))
|
|
131
|
+
data.fixes = data.fixes!.map((f) => ({ ...f, kevCves: 1, riskFactors: ['privileged' as const] }))
|
|
132
|
+
data.workloads = data.workloads!.map((w) => ({ ...w, kevCves: 1, riskFactors: ['privileged' as const], containers: [container3('a'), container3('b'), container3('c')] }))
|
|
133
|
+
data.podRisk = {
|
|
134
|
+
counts: { privileged: 1, hostAccess: 0, runsAsRoot: 0, mayRunAsRoot: 0, dangerousCapabilities: 0, privilegeEscalation: 0, hostPort: 0 },
|
|
135
|
+
workloads: data.workloads.map((w) => ({ kind: w.kind, group: w.group, namespace: w.namespace, name: w.name, factors: ['privileged' as const], settings: [] })),
|
|
136
|
+
}
|
|
137
|
+
return { data, isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 0, refetch: vi.fn() } as unknown as ReturnType<typeof useVulnerabilities>
|
|
138
|
+
})
|
|
139
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
140
|
+
act(() => root.render(
|
|
141
|
+
<QueryClientProvider client={client}>
|
|
142
|
+
<MemoryRouter key={by} initialEntries={[`/checks/vulnerabilities?by=${by}`]}>
|
|
143
|
+
<VulnerabilitiesView namespaces={[]} onNavigateToResource={vi.fn()} />
|
|
144
|
+
</MemoryRouter>
|
|
145
|
+
</QueryClientProvider>,
|
|
146
|
+
))
|
|
147
|
+
}
|
|
148
|
+
const chip = (prefix: string) => Array.from(container.querySelectorAll<HTMLButtonElement>('button[aria-haspopup="dialog"]')).find((b) => b.textContent?.startsWith(prefix))
|
|
85
149
|
|
|
86
150
|
beforeEach(() => {
|
|
87
151
|
container = document.createElement('div')
|
|
@@ -120,13 +184,16 @@ describe('VulnerabilitiesView', () => {
|
|
|
120
184
|
expect(urlParams().has('exposed')).toBe(false)
|
|
121
185
|
})
|
|
122
186
|
|
|
123
|
-
it('marks only the exposed
|
|
187
|
+
it('puts a row\'s workloads on one line, the names on hover, and marks only the exposed one when expanded', () => {
|
|
124
188
|
render('/checks/vulnerabilities?by=image')
|
|
125
|
-
// Collapsed
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
189
|
+
// Collapsed: how many, how many exposed, and no names or per-name marks.
|
|
190
|
+
const count = Array.from(rowButtons()[0].querySelectorAll('span.font-mono')).find((e) => e.textContent === '2')!
|
|
191
|
+
expect(tipOf(count)).toBe('web and worker, in 1 namespace')
|
|
192
|
+
const cell = count.closest('span.flex')!
|
|
193
|
+
expect(cell.textContent).toBe('2·1 exposed')
|
|
194
|
+
expect(marks()).toHaveLength(0)
|
|
195
|
+
expect(rowButtons()[0].textContent).not.toContain('worker')
|
|
196
|
+
act(() => rowButtons()[0].click())
|
|
130
197
|
// Expanded: the mark sits beside web's link only.
|
|
131
198
|
const marked = Array.from(marks()).map((m) => m.closest('li')?.textContent ?? '').filter(Boolean)
|
|
132
199
|
expect(marked).toHaveLength(1)
|
|
@@ -134,6 +201,166 @@ describe('VulnerabilitiesView', () => {
|
|
|
134
201
|
expect(marked[0]).not.toContain('worker')
|
|
135
202
|
})
|
|
136
203
|
|
|
204
|
+
it('says exposure unknown after the count when no workload is known exposed but some may be', () => {
|
|
205
|
+
vi.mocked(useVulnerabilities).mockImplementation((p) => {
|
|
206
|
+
const data = response(p.view, true)
|
|
207
|
+
data.cves = data.cves!.map((c) => ({ ...c, exposureUnknown: true }))
|
|
208
|
+
return { data, isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 0, refetch: vi.fn() } as unknown as ReturnType<typeof useVulnerabilities>
|
|
209
|
+
})
|
|
210
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
211
|
+
act(() => root.render(
|
|
212
|
+
<QueryClientProvider client={client}>
|
|
213
|
+
<MemoryRouter initialEntries={['/checks/vulnerabilities?by=cve']}>
|
|
214
|
+
<VulnerabilitiesView namespaces={[]} onNavigateToResource={vi.fn()} />
|
|
215
|
+
</MemoryRouter>
|
|
216
|
+
</QueryClientProvider>,
|
|
217
|
+
))
|
|
218
|
+
expect(rowButtons()[0].textContent).toContain('2·exposure unknown')
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it('filters by severity from one dropdown, kept in the URL, and names what is selected', () => {
|
|
222
|
+
render('/checks/vulnerabilities?by=cve')
|
|
223
|
+
expect(chip('Severity')!.textContent).toBe('Severity')
|
|
224
|
+
act(() => chip('Severity')!.click())
|
|
225
|
+
// Counts inside, unrated last, and the first checkbox takes focus.
|
|
226
|
+
expect(panelLabels()).toEqual(['Critical(1)', 'High(0)', 'Medium(0)', 'Low(0)', 'Unrated(0)'])
|
|
227
|
+
expect(document.activeElement).toBe(check('Critical'))
|
|
228
|
+
act(() => check('Critical').click())
|
|
229
|
+
expect(urlParams().get('severity')).toBe('critical')
|
|
230
|
+
expect(lastParams().severities).toEqual(['critical'])
|
|
231
|
+
expect(chip('Critical')).toBeDefined()
|
|
232
|
+
act(() => check('Unrated').click())
|
|
233
|
+
expect(urlParams().get('severity')).toBe('critical,unknown')
|
|
234
|
+
expect(chip('Severity: 2')).toBeDefined()
|
|
235
|
+
// Escape closes it and gives focus back to the chip.
|
|
236
|
+
act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })) })
|
|
237
|
+
expect(document.activeElement).toBe(chip('Severity: 2'))
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('moves focus into the severity panel on every open, and back to its first checkbox after Clear all', () => {
|
|
241
|
+
render('/checks/vulnerabilities?by=cve&severity=critical')
|
|
242
|
+
vi.useFakeTimers()
|
|
243
|
+
try {
|
|
244
|
+
act(() => chip('Critical')!.click())
|
|
245
|
+
expect(document.activeElement).toBe(check('Critical'))
|
|
246
|
+
act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })) })
|
|
247
|
+
// Let the exit finish, so the panel unmounts before the next open.
|
|
248
|
+
act(() => { vi.advanceTimersByTime(1_000) })
|
|
249
|
+
expect(document.body.querySelector('[role="dialog"]')).toBeNull()
|
|
250
|
+
act(() => chip('Critical')!.click())
|
|
251
|
+
act(() => { vi.advanceTimersByTime(1_000) })
|
|
252
|
+
expect(document.activeElement).toBe(check('Critical'))
|
|
253
|
+
|
|
254
|
+
const clear = document.body.querySelector<HTMLButtonElement>('button[aria-label="Clear severities"]')!
|
|
255
|
+
act(() => clear.focus())
|
|
256
|
+
act(() => clear.click())
|
|
257
|
+
expect(urlParams().has('severity')).toBe(false)
|
|
258
|
+
expect(clear.disabled).toBe(true)
|
|
259
|
+
expect(document.activeElement).toBe(check('Critical'))
|
|
260
|
+
} finally {
|
|
261
|
+
vi.useRealTimers()
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
it('gives each row one toggle, a real button that holds no control, with the risk badge beside it, in every view', () => {
|
|
266
|
+
localStorage.setItem('radar-vulnerability-columns', JSON.stringify(['cve.epss']))
|
|
267
|
+
try {
|
|
268
|
+
for (const by of VIEW_KEYS) {
|
|
269
|
+
renderWithBadges(by)
|
|
270
|
+
const rows = rowButtons()
|
|
271
|
+
expect(rows.length).toBeGreaterThan(0)
|
|
272
|
+
for (const row of rows) {
|
|
273
|
+
const toggle = toggleOf(row)
|
|
274
|
+
expect(toggle.tagName, by).toBe('BUTTON')
|
|
275
|
+
expect(toggle.getAttribute('aria-expanded'), by).toBe('false')
|
|
276
|
+
// No control inside a button.
|
|
277
|
+
expect(row.querySelectorAll('button button, button a, button input, button [tabindex]'), by).toHaveLength(0)
|
|
278
|
+
// Tab stops on the toggle, then only on the row's controls: its risk badge.
|
|
279
|
+
const stops = tabStops(row)
|
|
280
|
+
expect(stops[0], by).toBe(toggle)
|
|
281
|
+
expect(stops.slice(1).every((e) => e.hasAttribute('data-risk-badge')), by).toBe(true)
|
|
282
|
+
expect(stops.slice(1), by).toHaveLength(1)
|
|
283
|
+
// Tooltips in the summary carry no label, so the toggle's name is the row's text.
|
|
284
|
+
expect(row.querySelector('[aria-label]:not(svg):not([data-risk-badge])'), by).toBeNull()
|
|
285
|
+
}
|
|
286
|
+
const name = document.getElementById(toggleOf(rows[0]).getAttribute('aria-labelledby')!)!.textContent
|
|
287
|
+
expect(name).toContain(by === 'workload' ? 'and 2 more containers' : by === 'cve' ? 'KEV' : 'Privileged')
|
|
288
|
+
if (by === 'image') {
|
|
289
|
+
// Expanded, a workload's badge takes focus too.
|
|
290
|
+
act(() => toggleOf(rows[0]).click())
|
|
291
|
+
const expanded = document.getElementById(toggleOf(rows[0]).getAttribute('aria-controls')!)!
|
|
292
|
+
expect(tabStops(expanded).some((e) => e.hasAttribute('data-risk-badge'))).toBe(true)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
} finally {
|
|
296
|
+
localStorage.removeItem('radar-vulnerability-columns')
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
it('puts the KEV pill and the risk badge right after the name on its first line, in every view', () => {
|
|
301
|
+
const names: Record<string, string> = { image: 'app:1', fix: 'zlib', cve: 'CVE-2023-44487', workload: 'web' }
|
|
302
|
+
for (const by of VIEW_KEYS) {
|
|
303
|
+
renderWithBadges(by)
|
|
304
|
+
const row = rowButtons()[0]
|
|
305
|
+
const cells = row.querySelector('div.grid')!.children
|
|
306
|
+
const nameLine = cells[0].firstElementChild!
|
|
307
|
+
const parts = Array.from(nameLine.children)
|
|
308
|
+
expect(parts[0].textContent, by).toContain(names[by])
|
|
309
|
+
// The name gives way first; the badges keep their width.
|
|
310
|
+
expect(parts[0].className, by).toMatch(/min-w-0|truncate/)
|
|
311
|
+
expect(parts.at(-2)!.textContent, by).toMatch(/KEV/)
|
|
312
|
+
expect(parts.at(-2)!.className, by).toContain('shrink-0')
|
|
313
|
+
expect(parts.at(-1)!.hasAttribute('data-risk-badge'), by).toBe(true)
|
|
314
|
+
expect(parts.at(-1)!.textContent, by).toBe('Privileged')
|
|
315
|
+
expect(parts.at(-1)!.className, by).toContain('shrink-0')
|
|
316
|
+
// No taller than the line, so rows with badges line up with rows without.
|
|
317
|
+
for (const badge of parts.slice(-2)) expect(badge.className, by).toContain('h-4')
|
|
318
|
+
// Nowhere else in the row: not in the Workloads cell, not on the line below.
|
|
319
|
+
expect(row.querySelectorAll('[data-risk-badge]'), by).toHaveLength(1)
|
|
320
|
+
expect(Array.from(row.querySelectorAll('.badge-sm')).filter((b) => b.textContent?.includes('KEV')), by).toHaveLength(1)
|
|
321
|
+
expect(cells[0].children[1]?.textContent ?? '', by).not.toMatch(/KEV|Privileged/)
|
|
322
|
+
}
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
it('toggles a row from a click anywhere on its summary, but not after a drag that selected text, nor from its expanded part', () => {
|
|
326
|
+
render('/checks/vulnerabilities?by=workload')
|
|
327
|
+
const row = rowButtons()[0]
|
|
328
|
+
const toggle = toggleOf(row)
|
|
329
|
+
const expanded = () => toggle.getAttribute('aria-expanded')
|
|
330
|
+
const findings = row.querySelector('div.grid')!.children[1]
|
|
331
|
+
const click = (el: Element) => act(() => { el.dispatchEvent(new MouseEvent('click', { bubbles: true })) })
|
|
332
|
+
click(findings)
|
|
333
|
+
expect(expanded()).toBe('true')
|
|
334
|
+
click(findings)
|
|
335
|
+
expect(expanded()).toBe('false')
|
|
336
|
+
// The chevron toggles once per click, not once for it and once for the row.
|
|
337
|
+
act(() => toggle.click())
|
|
338
|
+
expect(expanded()).toBe('true')
|
|
339
|
+
act(() => toggle.click())
|
|
340
|
+
expect(expanded()).toBe('false')
|
|
341
|
+
// A drag that selected text in the row leaves it as it was.
|
|
342
|
+
const selection = vi.spyOn(window, 'getSelection').mockReturnValue({ isCollapsed: false, toString: () => 'web', anchorNode: findings, focusNode: findings } as unknown as Selection)
|
|
343
|
+
try {
|
|
344
|
+
click(findings)
|
|
345
|
+
expect(expanded()).toBe('false')
|
|
346
|
+
} finally {
|
|
347
|
+
selection.mockRestore()
|
|
348
|
+
}
|
|
349
|
+
// Links and text in the expanded part keep their own action.
|
|
350
|
+
click(findings)
|
|
351
|
+
expect(expanded()).toBe('true')
|
|
352
|
+
act(() => button('Open web')!.click())
|
|
353
|
+
expect(expanded()).toBe('true')
|
|
354
|
+
click(document.getElementById(toggle.getAttribute('aria-controls')!)!.querySelector('span')!)
|
|
355
|
+
expect(expanded()).toBe('true')
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
it('reads a shared link\'s severities into the dropdown', () => {
|
|
359
|
+
render('/checks/vulnerabilities?severity=high')
|
|
360
|
+
expect(chip('High')).toBeDefined()
|
|
361
|
+
expect(lastParams().severities).toEqual(['high'])
|
|
362
|
+
})
|
|
363
|
+
|
|
137
364
|
it('counts the exposed workloads beside the mark on rows that span workloads', () => {
|
|
138
365
|
render('/checks/vulnerabilities')
|
|
139
366
|
expect(container.textContent).toContain('1 exposed')
|
|
@@ -144,13 +371,22 @@ describe('VulnerabilitiesView', () => {
|
|
|
144
371
|
|
|
145
372
|
it('shows the route, nothing, or Exposure unknown per workload', () => {
|
|
146
373
|
render('/checks/vulnerabilities?by=workload')
|
|
147
|
-
const rows =
|
|
374
|
+
const rows = rowButtons()
|
|
148
375
|
const cell = (i: number) => rows[i].querySelector('div.grid')!.children[2].textContent
|
|
149
376
|
expect(cell(0)).toBe('LoadBalancer shop/web and 1 more')
|
|
150
377
|
expect(cell(1)).toBe('Exposure unknown')
|
|
151
378
|
expect(cell(2)).toBe('')
|
|
152
379
|
})
|
|
153
380
|
|
|
381
|
+
it('offers See traffic in an exposed workload\'s expanded row, never inside the row\'s toggle', () => {
|
|
382
|
+
render('/checks/vulnerabilities?by=workload')
|
|
383
|
+
expect(button('See traffic')).toBeUndefined()
|
|
384
|
+
act(() => rowButtons()[0].click())
|
|
385
|
+
const link = button('See traffic')
|
|
386
|
+
expect(link).toBeDefined()
|
|
387
|
+
expect(link!.parentElement!.closest('button')).toBeNull()
|
|
388
|
+
})
|
|
389
|
+
|
|
154
390
|
it('leaves out the chip, sort hint, mark and route column when Radar reports no exposure', () => {
|
|
155
391
|
render('/checks/vulnerabilities', false)
|
|
156
392
|
expect(button('Exposed')).toBeUndefined()
|
|
@@ -162,6 +398,18 @@ describe('VulnerabilitiesView', () => {
|
|
|
162
398
|
expect(container.textContent).not.toContain('Exposure unknown')
|
|
163
399
|
})
|
|
164
400
|
|
|
401
|
+
it('says how many rows match the filters and clears them, keeping the view', () => {
|
|
402
|
+
render('/checks/vulnerabilities?by=cve&severity=critical&exposed=1&resource=Deployment%2Fshop%2Fweb')
|
|
403
|
+
expect(container.textContent).toMatch(/\d+ CVEs? match/)
|
|
404
|
+
expect(container.textContent).not.toContain('Totals ignore the filters')
|
|
405
|
+
act(() => button('Clear filters')!.click())
|
|
406
|
+
expect(urlParams().get('by')).toBe('cve')
|
|
407
|
+
expect(urlParams().get('resource')).toBe('Deployment/shop/web')
|
|
408
|
+
expect(urlParams().has('severity')).toBe(false)
|
|
409
|
+
expect(urlParams().has('exposed')).toBe(false)
|
|
410
|
+
expect(button('Clear filters')).toBeUndefined()
|
|
411
|
+
})
|
|
412
|
+
|
|
165
413
|
it('keeps the sort rule in a hint, not a line above the table', () => {
|
|
166
414
|
render('/checks/vulnerabilities')
|
|
167
415
|
expect(container.textContent).toContain('Severity, then exposure')
|
|
@@ -174,4 +422,201 @@ describe('VulnerabilitiesView', () => {
|
|
|
174
422
|
expect(container.textContent).not.toContain('Upgrading a package')
|
|
175
423
|
})
|
|
176
424
|
|
|
425
|
+
it('filters to known exploited CVEs and marks them with the catalog dates', () => {
|
|
426
|
+
render('/checks/vulnerabilities?by=cve', true, readyIntel)
|
|
427
|
+
expect(lastParams().kev).toBe(false)
|
|
428
|
+
act(() => button('Known exploited')!.click())
|
|
429
|
+
expect(urlParams().get('kev')).toBe('1')
|
|
430
|
+
expect(lastParams().kev).toBe(true)
|
|
431
|
+
const badge = Array.from(rowButtons()[0].querySelectorAll('.badge-sm')).find((b) => b.textContent === 'KEV')!
|
|
432
|
+
const tip = tipOf(badge)
|
|
433
|
+
expect(tip).toContain('Federal due date')
|
|
434
|
+
expect(tip).toContain('Ransomware use: not known')
|
|
435
|
+
// EPSS is an optional column, off until turned on in Columns.
|
|
436
|
+
expect(container.textContent).not.toContain('94%')
|
|
437
|
+
})
|
|
438
|
+
|
|
439
|
+
it('shows EPSS on By CVE once its column is turned on', () => {
|
|
440
|
+
localStorage.setItem('radar-vulnerability-columns', JSON.stringify(['cve.epss']))
|
|
441
|
+
try {
|
|
442
|
+
render('/checks/vulnerabilities?by=cve', true, readyIntel)
|
|
443
|
+
expect(container.textContent).toContain('EPSS')
|
|
444
|
+
expect(container.textContent).toContain('94%')
|
|
445
|
+
} finally {
|
|
446
|
+
localStorage.removeItem('radar-vulnerability-columns')
|
|
447
|
+
}
|
|
448
|
+
})
|
|
449
|
+
|
|
450
|
+
it("shows a calm no-data chip, not a filter that would read as none, when Radar Cloud's catalog isn't available", () => {
|
|
451
|
+
render('/checks/vulnerabilities?by=cve', true, { kev: { state: 'unavailable', error: 'couldn\'t reach Radar Cloud' }, epss: { state: 'unavailable' } })
|
|
452
|
+
expect(button('Known exploited')).toBeUndefined()
|
|
453
|
+
const chip = container.querySelector('[aria-label^="Known exploited:"]')
|
|
454
|
+
expect(chip?.textContent).toContain('no data')
|
|
455
|
+
expect(chip?.getAttribute('aria-label')).toContain("isn't available from Radar Cloud")
|
|
456
|
+
expect(chip?.getAttribute('aria-label')).not.toContain('kevFeed')
|
|
457
|
+
expect(chip?.getAttribute('href')).toBeNull()
|
|
458
|
+
// Nothing on the page reads as a failure, and there is no EPSS to show.
|
|
459
|
+
expect(container.textContent).not.toContain('unavailable')
|
|
460
|
+
expect(container.textContent).not.toContain('EPSS')
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
it('keeps a shared Known exploited filter while Radar Cloud\'s catalog loads', () => {
|
|
464
|
+
vi.mocked(useVulnerabilities).mockImplementation((p) => (p.kev
|
|
465
|
+
? { data: undefined, isLoading: false, isFetching: true, isPlaceholderData: false, error: new ApiError('still loading', 503, { error_code: 'kev_loading' }), dataUpdatedAt: 0, refetch: vi.fn() }
|
|
466
|
+
: { data: response(p.view, true), isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 0, refetch: vi.fn() }
|
|
467
|
+
) as unknown as ReturnType<typeof useVulnerabilities>)
|
|
468
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
469
|
+
act(() => root.render(
|
|
470
|
+
<QueryClientProvider client={client}>
|
|
471
|
+
<MemoryRouter initialEntries={['/checks/vulnerabilities?by=cve&kev=1']}>
|
|
472
|
+
<VulnerabilitiesView namespaces={[]} onNavigateToResource={vi.fn()} />
|
|
473
|
+
<Probe />
|
|
474
|
+
</MemoryRouter>
|
|
475
|
+
</QueryClientProvider>,
|
|
476
|
+
))
|
|
477
|
+
expect(urlParams().get('kev')).toBe('1')
|
|
478
|
+
expect(lastParams().kev).toBe(true)
|
|
479
|
+
expect(readSettles(new ApiError('still loading', 503, { error_code: 'kev_loading' }))).toBe(true)
|
|
480
|
+
expect(readSettles(new ApiError('none', 503, { error_code: 'kev_unavailable' }))).toBe(false)
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
it('keeps a refused Known exploited link, says why, and refuses the CSV', () => {
|
|
484
|
+
const unavailable = { kev: { state: 'unavailable' as const, error: "couldn't reach Radar Cloud: this Radar hasn't connected to it yet" }, epss: { state: 'unavailable' as const } }
|
|
485
|
+
vi.mocked(useVulnerabilities).mockImplementation((p) => (p.kev
|
|
486
|
+
? { data: undefined, isLoading: false, isFetching: false, isPlaceholderData: false, error: new ApiError('KEV data unavailable', 503, { error_code: 'kev_unavailable' }), dataUpdatedAt: 0, refetch: vi.fn() }
|
|
487
|
+
: { data: response(p.view, true, unavailable), isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 0, refetch: vi.fn() }
|
|
488
|
+
) as unknown as ReturnType<typeof useVulnerabilities>)
|
|
489
|
+
features.current = { vulnerabilityIntel: true, vulnerabilitiesExport: true }
|
|
490
|
+
try {
|
|
491
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
492
|
+
act(() => root.render(
|
|
493
|
+
<QueryClientProvider client={client}>
|
|
494
|
+
<MemoryRouter initialEntries={['/checks/vulnerabilities?by=cve&kev=1']}>
|
|
495
|
+
<VulnerabilitiesView namespaces={[]} onNavigateToResource={vi.fn()} />
|
|
496
|
+
<Probe />
|
|
497
|
+
</MemoryRouter>
|
|
498
|
+
</QueryClientProvider>,
|
|
499
|
+
))
|
|
500
|
+
// The link's filter stays; the rows are read without it, and the page says so.
|
|
501
|
+
expect(urlParams().get('kev')).toBe('1')
|
|
502
|
+
expect(lastParams().kev).toBe(false)
|
|
503
|
+
expect(container.textContent).toContain("The Known exploited filter can't be applied, so every row is listed.")
|
|
504
|
+
expect(container.textContent).toContain("couldn't reach Radar Cloud")
|
|
505
|
+
// Neither download would honour the filter.
|
|
506
|
+
act(() => container.querySelector<HTMLButtonElement>('button[aria-label="More actions"]')!.click())
|
|
507
|
+
const downloads = Array.from(document.querySelectorAll('[role="menuitem"]')).filter((el) => el.textContent?.includes('as CSV'))
|
|
508
|
+
expect(downloads).toHaveLength(2)
|
|
509
|
+
for (const d of downloads) {
|
|
510
|
+
expect(d.getAttribute('aria-disabled')).toBe('true')
|
|
511
|
+
expect(document.getElementById(d.getAttribute('aria-describedby') ?? '')?.textContent).toContain('the file would list every row')
|
|
512
|
+
}
|
|
513
|
+
act(() => button('Remove the filter')!.click())
|
|
514
|
+
expect(urlParams().get('kev')).toBeNull()
|
|
515
|
+
expect(container.textContent).not.toContain("can't be applied")
|
|
516
|
+
} finally {
|
|
517
|
+
features.current = { vulnerabilityIntel: true }
|
|
518
|
+
}
|
|
519
|
+
})
|
|
520
|
+
|
|
521
|
+
it('applies a refused Known exploited link again once a newer answer has the catalog, without looping', () => {
|
|
522
|
+
vi.mocked(useVulnerabilities).mockImplementation((p) => (p.kev
|
|
523
|
+
? { data: undefined, isLoading: false, isFetching: true, isPlaceholderData: false, error: new ApiError('KEV data unavailable', 503, { error_code: 'kev_unavailable' }), errorUpdatedAt: 100, dataUpdatedAt: 0, refetch: vi.fn() }
|
|
524
|
+
: { data: response(p.view, true, readyIntel), isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 200, refetch: vi.fn() }
|
|
525
|
+
) as unknown as ReturnType<typeof useVulnerabilities>)
|
|
526
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
527
|
+
act(() => root.render(
|
|
528
|
+
<QueryClientProvider client={client}>
|
|
529
|
+
<MemoryRouter initialEntries={['/checks/vulnerabilities?by=cve&kev=1']}>
|
|
530
|
+
<VulnerabilitiesView namespaces={[]} onNavigateToResource={vi.fn()} />
|
|
531
|
+
<Probe />
|
|
532
|
+
</MemoryRouter>
|
|
533
|
+
</QueryClientProvider>,
|
|
534
|
+
))
|
|
535
|
+
// Refused at 100, read without it, ready at 200: asked again, and the
|
|
536
|
+
// cached refusal from 100 doesn't count a second time.
|
|
537
|
+
expect(lastParams().kev).toBe(true)
|
|
538
|
+
expect(urlParams().get('kev')).toBe('1')
|
|
539
|
+
expect(container.textContent).not.toContain("can't be applied")
|
|
540
|
+
})
|
|
541
|
+
|
|
542
|
+
it('waits for a scan before showing the Known exploited chip and its count', () => {
|
|
543
|
+
vi.mocked(useVulnerabilities).mockImplementation((p) => {
|
|
544
|
+
const data = response(p.view, true, readyIntel)
|
|
545
|
+
data.summary = { ...data.summary, imagesScanned: 0, imagesUnscanned: 2, kevCves: 0 }
|
|
546
|
+
return { data, isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 0, refetch: vi.fn() } as unknown as ReturnType<typeof useVulnerabilities>
|
|
547
|
+
})
|
|
548
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
549
|
+
act(() => root.render(
|
|
550
|
+
<QueryClientProvider client={client}>
|
|
551
|
+
<MemoryRouter initialEntries={['/checks/vulnerabilities?by=cve']}>
|
|
552
|
+
<VulnerabilitiesView namespaces={[]} onNavigateToResource={vi.fn()} />
|
|
553
|
+
<Probe />
|
|
554
|
+
</MemoryRouter>
|
|
555
|
+
</QueryClientProvider>,
|
|
556
|
+
))
|
|
557
|
+
expect(container.textContent).not.toContain('Known exploited')
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
it("says the Known exploited count comes from Trivy's findings", () => {
|
|
561
|
+
vi.useFakeTimers()
|
|
562
|
+
try {
|
|
563
|
+
render('/checks/vulnerabilities?by=cve', true, readyIntel)
|
|
564
|
+
act(() => button('Known exploited')!.focus())
|
|
565
|
+
act(() => { vi.advanceTimersByTime(1_000) })
|
|
566
|
+
expect(document.body.textContent).toContain("The count comes from Trivy's findings, so it can miss some.")
|
|
567
|
+
} finally {
|
|
568
|
+
vi.useRealTimers()
|
|
569
|
+
}
|
|
570
|
+
})
|
|
571
|
+
|
|
572
|
+
it('leaves out the KEV chip and EPSS column for a Radar that predates them', () => {
|
|
573
|
+
localStorage.setItem('radar-vulnerability-columns', JSON.stringify(['cve.epss']))
|
|
574
|
+
features.current = { vulnerabilities: true }
|
|
575
|
+
try {
|
|
576
|
+
render('/checks/vulnerabilities?by=cve&kev=1')
|
|
577
|
+
} finally {
|
|
578
|
+
features.current = { vulnerabilityIntel: true }
|
|
579
|
+
localStorage.removeItem('radar-vulnerability-columns')
|
|
580
|
+
}
|
|
581
|
+
// A shared link's kev=1 isn't sent to a Radar that would ignore it, and
|
|
582
|
+
// the page says the filter isn't applied, naming no product.
|
|
583
|
+
expect(lastParams().kev).toBe(false)
|
|
584
|
+
expect(button('Known exploited')).toBeUndefined()
|
|
585
|
+
expect(container.textContent).not.toContain('EPSS')
|
|
586
|
+
expect(container.textContent).not.toContain('KEV')
|
|
587
|
+
expect(container.textContent).toContain("The Known exploited filter can't be applied, so every row is listed. This Radar has no data on known exploited CVEs.")
|
|
588
|
+
// Outside Radar Cloud there is nothing to upgrade to for KEV.
|
|
589
|
+
expect(container.textContent).not.toContain('Radar Cloud')
|
|
590
|
+
})
|
|
591
|
+
|
|
592
|
+
it('shows nothing about KEV on a Radar without Radar Cloud', () => {
|
|
593
|
+
render('/checks/vulnerabilities?by=cve')
|
|
594
|
+
expect(button('Known exploited')).toBeUndefined()
|
|
595
|
+
expect(container.querySelector('[aria-label^="Known exploited:"]')).toBeNull()
|
|
596
|
+
for (const word of ['KEV', 'EPSS', 'Known exploited', 'Radar Cloud']) expect(container.textContent).not.toContain(word)
|
|
597
|
+
})
|
|
598
|
+
|
|
599
|
+
it('asks for a newer Radar in Radar Cloud when the cluster\'s Radar predates KEV', () => {
|
|
600
|
+
features.current = { vulnerabilities: true }
|
|
601
|
+
features.mode = 'cloud'
|
|
602
|
+
try {
|
|
603
|
+
render('/checks/vulnerabilities?by=cve')
|
|
604
|
+
} finally {
|
|
605
|
+
features.current = { vulnerabilityIntel: true }
|
|
606
|
+
features.mode = 'in-cluster'
|
|
607
|
+
}
|
|
608
|
+
expect(container.textContent).toContain('Known exploited CVEs and EPSS scores need')
|
|
609
|
+
expect(container.textContent).toContain('on this cluster')
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
it('never polls for KEV: a loading answer gets one look, then the usual interval', () => {
|
|
613
|
+
const loading = response('cve', false, { kev: { state: 'loading' }, epss: { state: 'loading' } })
|
|
614
|
+
const ready = response('cve', false, readyIntel)
|
|
615
|
+
expect(vulnerabilitiesRefetchInterval({ view: 'cve' }, ready, 1)).toBe(300_000)
|
|
616
|
+
expect(vulnerabilitiesRefetchInterval({ view: 'cve' }, loading, 1)).toBe(45_000)
|
|
617
|
+
expect(vulnerabilitiesRefetchInterval({ view: 'cve' }, loading, 2)).toBe(300_000)
|
|
618
|
+
expect(vulnerabilitiesRefetchInterval({ view: 'summary' }, loading, 1)).toBe(45_000)
|
|
619
|
+
expect(vulnerabilitiesRefetchInterval({ view: 'summary' }, loading, 2)).toBe(60_000)
|
|
620
|
+
expect(vulnerabilitiesRefetchInterval({ view: 'cve' }, response('cve', false), 1)).toBe(300_000)
|
|
621
|
+
})
|
|
177
622
|
})
|