@skyhook-io/radar-app 1.21.3 → 1.21.5
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 +1 -1
- package/src/App.tsx +3 -0
- package/src/api/client.ts +42 -2
- package/src/api/radarFeatures.ts +2 -0
- package/src/api/vulnerabilities.export.test.ts +44 -0
- package/src/api/vulnerabilities.ts +73 -4
- package/src/components/applications/ApplicationsView.tsx +38 -8
- package/src/components/applications/ArgoSyncDetails.tsx +32 -0
- package/src/components/applications/RenderedChanges.test.tsx +179 -0
- package/src/components/applications/RenderedChanges.tsx +233 -0
- package/src/components/audit/AuditView.tsx +2 -1
- package/src/components/audit/VulnerabilitiesView.test.tsx +177 -0
- package/src/components/audit/VulnerabilitiesView.tsx +197 -48
- package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +30 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +21 -1
- package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +9 -0
- package/src/components/diagnose/investigationEvidence/types.ts +12 -0
- package/src/components/helm/HelmReleaseDrawer.test.ts +27 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +24 -3
- package/src/components/helm/HelmView.tsx +16 -6
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +3 -0
- package/src/components/helm/releaseController.test.tsx +26 -0
- package/src/components/helm/releaseController.tsx +98 -0
- package/src/components/resources/renderers/K3sHelmChartRenderer.tsx +18 -0
- package/src/components/traffic/TrafficGraph.export.test.tsx +57 -0
- package/src/components/traffic/TrafficGraph.tsx +11 -20
- package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +1 -0
- package/src/components/traffic/TrafficView.tsx +17 -2
- package/src/components/traffic/traffic-export.test.ts +51 -0
- package/src/components/traffic/traffic-export.ts +114 -0
- package/src/components/traffic/trafficFilters.ts +16 -0
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.test.tsx +30 -1
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +3 -2
- package/src/components/vulnerabilities/parts.test.ts +59 -3
- package/src/components/vulnerabilities/parts.tsx +199 -5
- package/src/components/workload/WorkloadRevisionsButton.test.tsx +34 -0
- package/src/components/workload/WorkloadRevisionsButton.tsx +31 -0
- package/src/components/workload/WorkloadView.tsx +11 -3
- package/src/hooks/useDesktopDownload.test.tsx +57 -0
- package/src/hooks/useDesktopDownload.ts +31 -9
- package/src/integrations/resourceHosts.test.tsx +1 -1
- package/src/integrations/resourceHosts.tsx +2 -0
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -49,6 +49,7 @@ import { currentPageLabel } from './utils/page-links'
|
|
|
49
49
|
import { navigateFromPrimaryRail } from './components/nav/navigation'
|
|
50
50
|
import { useNavRailPinned } from './hooks/useNavRailPinned'
|
|
51
51
|
import { useMediaQuery } from './hooks/useMediaQuery'
|
|
52
|
+
import { useDesktopBlobDownload } from './hooks/useDesktopDownload'
|
|
52
53
|
import { ContextSwitchProvider, useContextSwitch } from './context/ContextSwitchContext'
|
|
53
54
|
import { ConnectionProvider, useConnection, refreshQueriesAfterReconnect } from './context/ConnectionContext'
|
|
54
55
|
import { DisconnectedView, FailedSwitchView } from './components/SwitchAwareConnectionError'
|
|
@@ -649,6 +650,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
649
650
|
|
|
650
651
|
// Topology live-update pause state
|
|
651
652
|
const [topologyPaused, setTopologyPaused] = useState(false)
|
|
653
|
+
const desktopBlobDownload = useDesktopBlobDownload()
|
|
652
654
|
const [displayedTopology, setDisplayedTopology] = useState<typeof topology>(null)
|
|
653
655
|
const pendingTopologyRef = useRef<typeof topology>(null)
|
|
654
656
|
|
|
@@ -2318,6 +2320,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
2318
2320
|
hideGroupHeader={hideGroupHeader}
|
|
2319
2321
|
onNodeClick={handleNodeClick}
|
|
2320
2322
|
selectedNodeId={selectedNodeId}
|
|
2323
|
+
onDownloadBlob={desktopBlobDownload}
|
|
2321
2324
|
paused={topologyPaused}
|
|
2322
2325
|
onTogglePause={handleTogglePause}
|
|
2323
2326
|
onMaximizeNamespace={(ns) => setActiveNamespace.mutate({ namespaces: [ns] })}
|
package/src/api/client.ts
CHANGED
|
@@ -589,6 +589,7 @@ export interface AuditResponse {
|
|
|
589
589
|
missingInputs?: string[];
|
|
590
590
|
// Absent on a Radar that predates the per-resource opt-out.
|
|
591
591
|
ignoreChecksAnnotation?: string;
|
|
592
|
+
namespaceIgnoreChecks?: boolean;
|
|
592
593
|
// checkID → namespace → resources whose findings the annotation hid.
|
|
593
594
|
annotationIgnoredByNamespace?: Record<string, Record<string, number>>;
|
|
594
595
|
summary: DashboardAudit;
|
|
@@ -2993,6 +2994,40 @@ export function useArgoResourceDiff(
|
|
|
2993
2994
|
});
|
|
2994
2995
|
}
|
|
2995
2996
|
|
|
2997
|
+
export interface RenderedFieldChange {
|
|
2998
|
+
path: string[];
|
|
2999
|
+
before?: unknown;
|
|
3000
|
+
after?: unknown;
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
export interface RenderedResourceChange {
|
|
3004
|
+
group?: string;
|
|
3005
|
+
kind: string;
|
|
3006
|
+
namespace?: string;
|
|
3007
|
+
name: string;
|
|
3008
|
+
operation: "added" | "removed" | "modified";
|
|
3009
|
+
fields: RenderedFieldChange[];
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
export interface RenderedSyncDiff {
|
|
3013
|
+
changes: RenderedResourceChange[];
|
|
3014
|
+
partial?: boolean;
|
|
3015
|
+
secretsMasked?: boolean;
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
export function useArgoSyncDiff(namespace: string, name: string, syncID: string, previous: string, revision: string) {
|
|
3019
|
+
const params = new URLSearchParams({ syncID, previous, revision });
|
|
3020
|
+
return useQuery<RenderedSyncDiff>({
|
|
3021
|
+
queryKey: ["argo-sync-diff", getApiBase(), namespace, name, syncID, previous, revision],
|
|
3022
|
+
queryFn: ({ signal }) => fetchJSON(`/argo/applications/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}/sync-diff?${params}`, signal),
|
|
3023
|
+
// Results depend on today's render settings and the viewer's access.
|
|
3024
|
+
gcTime: 0,
|
|
3025
|
+
staleTime: 0,
|
|
3026
|
+
retry: false,
|
|
3027
|
+
refetchOnWindowFocus: false,
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
|
|
2996
3031
|
// Git commit metadata for one deployed revision of an Argo CD Application.
|
|
2997
3032
|
// Enabled only when a revision is known and the caller passes `enabled` (gated
|
|
2998
3033
|
// on capabilities.revisionMetadataAvailable). Cached long — a resolved SHA's
|
|
@@ -5728,6 +5763,10 @@ export interface WorkloadRevision {
|
|
|
5728
5763
|
// (serving traffic, what an abort reverts to) are different revisions.
|
|
5729
5764
|
isStable?: boolean;
|
|
5730
5765
|
podHash?: string;
|
|
5766
|
+
readyReplicas?: number;
|
|
5767
|
+
serving?: boolean;
|
|
5768
|
+
changeCause?: string;
|
|
5769
|
+
matchesDesired?: boolean;
|
|
5731
5770
|
}
|
|
5732
5771
|
|
|
5733
5772
|
export function useWorkloadRevisions(
|
|
@@ -5738,8 +5777,9 @@ export function useWorkloadRevisions(
|
|
|
5738
5777
|
) {
|
|
5739
5778
|
return useQuery<WorkloadRevision[]>({
|
|
5740
5779
|
queryKey: ["workload-revisions", kind, namespace, name],
|
|
5741
|
-
queryFn: () =>
|
|
5742
|
-
|
|
5780
|
+
queryFn: async () => (await fetchJSON<WorkloadRevision[] | null>(
|
|
5781
|
+
`/workloads/${kind}/${namespace}/${name}/revisions`,
|
|
5782
|
+
)) ?? [],
|
|
5743
5783
|
enabled: Boolean(kind && namespace && name && enabled),
|
|
5744
5784
|
});
|
|
5745
5785
|
}
|
package/src/api/radarFeatures.ts
CHANGED
|
@@ -51,6 +51,7 @@ export const RADAR_FEATURES = {
|
|
|
51
51
|
substrateHealthMetrics: { label: 'Agent Substrate charts', flag: 'substrateHealthMetrics', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
|
|
52
52
|
cnpgWorkspace: { label: 'CloudNativePG views', flag: 'cnpgWorkspace', flagShippedWithEndpoint: true },
|
|
53
53
|
sealedSecretsController: { label: 'Sealed Secrets controller status', flag: 'sealedSecretsController', flagShippedWithEndpoint: true },
|
|
54
|
+
sealedSecretsCert: { label: 'Sealed Secrets sealing certificate', flag: 'sealedSecretsCert', flagShippedWithEndpoint: true },
|
|
54
55
|
cnpgProtectionSetup: { label: 'CloudNativePG backup setup', flag: 'cnpgProtectionSetup', flagShippedWithEndpoint: true },
|
|
55
56
|
veleroWorkspace: { label: 'Velero views', flag: 'veleroWorkspace', flagShippedWithEndpoint: true },
|
|
56
57
|
veleroBackupNow: { label: 'Back up now', flag: 'veleroBackupNow', flagShippedWithEndpoint: true },
|
|
@@ -85,6 +86,7 @@ export const RADAR_FEATURES = {
|
|
|
85
86
|
agentSigninCheck: { label: 'Agent sign-in checks', flag: 'agentSigninCheck', flagShippedWithEndpoint: true },
|
|
86
87
|
podFileUpload: { label: 'Pod file uploads', flag: 'podFileUpload', flagShippedWithEndpoint: true },
|
|
87
88
|
vulnerabilities: { label: 'Vulnerability views', flag: 'vulnerabilities', flagShippedWithEndpoint: true },
|
|
89
|
+
vulnerabilitiesExport: { label: 'Vulnerability CSV downloads', flag: 'vulnerabilitiesExport', flagShippedWithEndpoint: true },
|
|
88
90
|
runtimeAdvisoryChecks: { label: 'Java4Shell checks', flag: 'runtimeAdvisoryChecks', flagShippedWithEndpoint: true },
|
|
89
91
|
runtimeAdvisoryProgress: { label: 'Java4Shell scan progress', flag: 'runtimeAdvisoryProgress', flagShippedWithEndpoint: true },
|
|
90
92
|
// Never blocks a control: an older Radar ignores the request body and names
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { ApiError } from './client'
|
|
3
|
+
import { fetchVulnerabilitiesCSV, vulnerabilitiesCSVFilename } from './vulnerabilities'
|
|
4
|
+
|
|
5
|
+
afterEach(() => vi.unstubAllGlobals())
|
|
6
|
+
|
|
7
|
+
describe('fetchVulnerabilitiesCSV', () => {
|
|
8
|
+
it('asks for the view and filters the table shows', async () => {
|
|
9
|
+
const fetch = vi.fn(async () => new Response('cluster,scanned,status\r\n', { status: 200 }))
|
|
10
|
+
vi.stubGlobal('fetch', fetch)
|
|
11
|
+
const csv = await fetchVulnerabilitiesCSV({
|
|
12
|
+
view: 'fix', namespaces: ['demo', 'prod'], severities: ['critical'], fixableOnly: true, query: ' nginx ',
|
|
13
|
+
workload: { kind: 'Deployment', group: 'apps', namespace: 'demo', name: 'web' },
|
|
14
|
+
})
|
|
15
|
+
expect(csv).toBe('cluster,scanned,status\r\n')
|
|
16
|
+
const url = new URL(String((fetch.mock.calls[0] as unknown[])[0]), 'http://radar')
|
|
17
|
+
expect(url.pathname).toMatch(/\/vulnerabilities\/export$/)
|
|
18
|
+
expect(Object.fromEntries(url.searchParams)).toEqual({
|
|
19
|
+
view: 'fix', namespaces: 'demo,prod', severity: 'critical', fixable: '1', q: 'nginx',
|
|
20
|
+
workloadKind: 'Deployment', workloadNamespace: 'demo', workloadName: 'web', workloadGroup: 'apps',
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('fails with the server message instead of saving an error page', async () => {
|
|
25
|
+
vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify({ error: 'vulnerability reports aren\'t ready yet', error_code: 'kind_sync_pending' }), {
|
|
26
|
+
status: 503, headers: { 'Content-Type': 'application/json' },
|
|
27
|
+
})))
|
|
28
|
+
const err = await fetchVulnerabilitiesCSV({ view: 'cve' }).catch((e: unknown) => e)
|
|
29
|
+
expect(err).toBeInstanceOf(ApiError)
|
|
30
|
+
expect((err as ApiError).status).toBe(503)
|
|
31
|
+
expect((err as ApiError).message).toBe('vulnerability reports aren\'t ready yet')
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('vulnerabilitiesCSVFilename', () => {
|
|
36
|
+
const day = new Date(2026, 0, 5, 23, 30)
|
|
37
|
+
it('names the view, the cluster and the local date', () => {
|
|
38
|
+
expect(vulnerabilitiesCSVFilename('cve', 'k8sbox-rvuln', day)).toBe('vulnerabilities-by-cve-k8sbox-rvuln-2026-01-05.csv')
|
|
39
|
+
})
|
|
40
|
+
it('keeps the name filesystem-safe', () => {
|
|
41
|
+
expect(vulnerabilitiesCSVFilename('image', 'arn:aws:eks:us-east-1:123:cluster/prod', day)).toBe('vulnerabilities-by-image-arn-aws-eks-us-east-1-123-cluster-prod-2026-01-05.csv')
|
|
42
|
+
expect(vulnerabilitiesCSVFilename('fix', '../..', day)).toBe('vulnerabilities-by-fix-cluster-2026-01-05.csv')
|
|
43
|
+
})
|
|
44
|
+
})
|
|
@@ -30,6 +30,35 @@ export interface VulnerabilityWorkloadRef {
|
|
|
30
30
|
container?: string
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/** A route from outside the cluster to a workload. via: LoadBalancer, NodePort, Ingress or a Gateway API route kind. */
|
|
34
|
+
export interface VulnerabilityRoute {
|
|
35
|
+
via: string
|
|
36
|
+
namespace: string
|
|
37
|
+
name: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A workload with a route from outside the cluster; never a container. */
|
|
41
|
+
export interface ExposedWorkload {
|
|
42
|
+
kind: string
|
|
43
|
+
group: string
|
|
44
|
+
namespace: string
|
|
45
|
+
name: string
|
|
46
|
+
/** At most three in a list read; routesTotal counts them all. */
|
|
47
|
+
routes: VulnerabilityRoute[]
|
|
48
|
+
routesTotal?: number
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The row's workloads with a route from outside the cluster, capped in a list
|
|
53
|
+
* read; exposedTotal is the full count.
|
|
54
|
+
*/
|
|
55
|
+
export interface VulnerabilityExposure {
|
|
56
|
+
exposed?: ExposedWorkload[]
|
|
57
|
+
exposedTotal?: number
|
|
58
|
+
/** None of the row's workloads is known exposed, but some are where Radar couldn't read every route kind. */
|
|
59
|
+
exposureUnknown?: boolean
|
|
60
|
+
}
|
|
61
|
+
|
|
33
62
|
export interface VulnerabilityFinding {
|
|
34
63
|
id: string
|
|
35
64
|
severity: VulnerabilitySeverity
|
|
@@ -46,7 +75,7 @@ export interface VulnerabilityFinding {
|
|
|
46
75
|
link?: string
|
|
47
76
|
}
|
|
48
77
|
|
|
49
|
-
export interface VulnerableImage {
|
|
78
|
+
export interface VulnerableImage extends VulnerabilityExposure {
|
|
50
79
|
id: string
|
|
51
80
|
image: string
|
|
52
81
|
digest?: string
|
|
@@ -72,7 +101,7 @@ export interface VulnerabilityCVEImage {
|
|
|
72
101
|
workloadsTotal: number
|
|
73
102
|
}
|
|
74
103
|
|
|
75
|
-
export interface VulnerabilityCVE {
|
|
104
|
+
export interface VulnerabilityCVE extends VulnerabilityExposure {
|
|
76
105
|
id: string
|
|
77
106
|
severity: VulnerabilitySeverity
|
|
78
107
|
score?: number
|
|
@@ -87,7 +116,7 @@ export interface VulnerabilityCVE {
|
|
|
87
116
|
affected: VulnerabilityCVEImage[]
|
|
88
117
|
}
|
|
89
118
|
|
|
90
|
-
export interface VulnerabilityFix {
|
|
119
|
+
export interface VulnerabilityFix extends VulnerabilityExposure {
|
|
91
120
|
package: string
|
|
92
121
|
packageType?: string
|
|
93
122
|
/** The lowest listed release that fixes every listed CVE; absent when none can be chosen from the scanner's versions. */
|
|
@@ -123,6 +152,10 @@ export interface VulnerabilityWorkload {
|
|
|
123
152
|
counts: VulnerabilityCounts
|
|
124
153
|
fixable: VulnerabilityCounts
|
|
125
154
|
containers: VulnerabilityWorkloadContainer[]
|
|
155
|
+
routes?: VulnerabilityRoute[]
|
|
156
|
+
routesTotal?: number
|
|
157
|
+
/** No route seen, but Radar couldn't read every route kind that could reach it. */
|
|
158
|
+
exposureUnknown?: boolean
|
|
126
159
|
}
|
|
127
160
|
|
|
128
161
|
export interface VulnerabilitySummary {
|
|
@@ -154,7 +187,16 @@ export interface VulnerabilitiesResponse {
|
|
|
154
187
|
/** Workloads whose every container is scanned and clean. */
|
|
155
188
|
cleanWorkloads?: VulnerabilityWorkloadRef[]
|
|
156
189
|
/** otherBuildScanned: Trivy's report is of another build of this tag, as after the tag moved. */
|
|
157
|
-
unscanned?: { image: string; otherBuildScanned?: boolean; workloads: VulnerabilityWorkloadRef[]; workloadsTotal: number }[]
|
|
190
|
+
unscanned?: ({ image: string; otherBuildScanned?: boolean; workloads: VulnerabilityWorkloadRef[]; workloadsTotal: number } & VulnerabilityExposure)[]
|
|
191
|
+
/**
|
|
192
|
+
* Present when this Radar checks exposure; absent from an older Radar, where
|
|
193
|
+
* exposure is unknown, never none. gaps: route kinds Radar couldn't read.
|
|
194
|
+
*/
|
|
195
|
+
exposure?: {
|
|
196
|
+
gaps?: VulnerabilityGap[]
|
|
197
|
+
/** Route kinds this cluster serves that Radar doesn't follow (Istio, Traefik IngressRoute, Contour, Knative). */
|
|
198
|
+
unchecked?: { kind: string; group?: string }[]
|
|
199
|
+
}
|
|
158
200
|
coverage: {
|
|
159
201
|
complete: boolean
|
|
160
202
|
gaps: VulnerabilityGap[]
|
|
@@ -171,6 +213,8 @@ export interface VulnerabilitiesParams {
|
|
|
171
213
|
namespaces?: string[]
|
|
172
214
|
severities?: VulnerabilitySeverity[]
|
|
173
215
|
fixableOnly?: boolean
|
|
216
|
+
/** Only rows affecting a workload with a route from outside the cluster. */
|
|
217
|
+
exposed?: boolean
|
|
174
218
|
query?: string
|
|
175
219
|
workload?: { kind: string; group?: string; namespace: string; name: string }
|
|
176
220
|
}
|
|
@@ -340,6 +384,7 @@ export function vulnerabilitiesPath(p: VulnerabilitiesParams): string {
|
|
|
340
384
|
if (p.namespaces && p.namespaces.length > 0) params.set('namespaces', p.namespaces.join(','))
|
|
341
385
|
if (p.severities && p.severities.length > 0) params.set('severity', p.severities.join(','))
|
|
342
386
|
if (p.fixableOnly) params.set('fixable', '1')
|
|
387
|
+
if (p.exposed) params.set('exposed', '1')
|
|
343
388
|
if (p.query?.trim()) params.set('q', p.query.trim())
|
|
344
389
|
if (p.workload) {
|
|
345
390
|
params.set('workloadKind', p.workload.kind)
|
|
@@ -350,6 +395,30 @@ export function vulnerabilitiesPath(p: VulnerabilitiesParams): string {
|
|
|
350
395
|
return `/vulnerabilities?${params.toString()}`
|
|
351
396
|
}
|
|
352
397
|
|
|
398
|
+
// GET /api/vulnerabilities/export: the same view and filters as CSV, listing
|
|
399
|
+
// every row and every value the table shortens.
|
|
400
|
+
/** What a CSV export lists: a view's rows, or every finding (one row per CVE, image and workload). */
|
|
401
|
+
export type VulnerabilityExportView = VulnerabilityView | 'findings'
|
|
402
|
+
|
|
403
|
+
export async function fetchVulnerabilitiesCSV(p: VulnerabilitiesParams, as: VulnerabilityExportView = p.view): Promise<string> {
|
|
404
|
+
const query = new URLSearchParams(vulnerabilitiesPath(p).split('?')[1])
|
|
405
|
+
query.set('view', as)
|
|
406
|
+
const path = `/vulnerabilities/export?${query.toString()}`
|
|
407
|
+
const response = await apiFetch(`${getApiBase()}${path}`, { cache: 'no-store' })
|
|
408
|
+
if (!response.ok) {
|
|
409
|
+
const { body, unknownRoute } = await readErrorResponse(response)
|
|
410
|
+
throw new ApiError(body.error || httpStatusMessage(response.status, response.statusText), response.status, body, { unknownRoute })
|
|
411
|
+
}
|
|
412
|
+
return response.text()
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// vulnerabilities-by-<view>-<cluster>-<YYYY-MM-DD>.csv, on the local date.
|
|
416
|
+
export function vulnerabilitiesCSVFilename(view: VulnerabilityExportView, cluster: string, now = new Date()): string {
|
|
417
|
+
const safe = cluster.replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^[-.]+|-+$/g, '') || 'cluster'
|
|
418
|
+
const pad = (n: number) => String(n).padStart(2, '0')
|
|
419
|
+
return `vulnerabilities-${view === 'findings' ? 'findings' : `by-${view}`}-${safe}-${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}.csv`
|
|
420
|
+
}
|
|
421
|
+
|
|
353
422
|
// GET /api/vulnerabilities. Filters run server-side so the summary always
|
|
354
423
|
// describes the unfiltered scope and every surface (REST, MCP) filters alike.
|
|
355
424
|
export function useVulnerabilities(p: VulnerabilitiesParams, enabled = true) {
|
|
@@ -3,6 +3,9 @@ import { useNavigate, useSearchParams } from "react-router-dom";
|
|
|
3
3
|
import {
|
|
4
4
|
ApplicationsList,
|
|
5
5
|
ApplicationDetail,
|
|
6
|
+
ArgoSyncDetailsContext,
|
|
7
|
+
ApplicationDeploys,
|
|
8
|
+
applicationDeliveryRecords,
|
|
6
9
|
CenteredEmpty,
|
|
7
10
|
getRadarUpgradeRequirement,
|
|
8
11
|
PageHeader,
|
|
@@ -55,6 +58,8 @@ import { useTimelineSource } from "../../context/TimelineSource";
|
|
|
55
58
|
import { apiVersionToGroup, kindToPluralWithGroup, relatedResourcePath, withCrossViewParams } from "../../utils/navigation";
|
|
56
59
|
import { WorkloadView } from "../workload/WorkloadView";
|
|
57
60
|
import { ApplicationCostTab } from "../cost/ApplicationCostTab";
|
|
61
|
+
import { ArgoSyncDetails } from "./ArgoSyncDetails";
|
|
62
|
+
import { WorkloadRevisionsButton } from "../workload/WorkloadRevisionsButton";
|
|
58
63
|
import { useTimelineRetentionNote } from "../../context/TimelineCustomization";
|
|
59
64
|
import { isOpenCostWorkloadKind } from "../cost/kinds";
|
|
60
65
|
|
|
@@ -75,9 +80,10 @@ const APPLICATION_TIMELINE_FOCUS_MS = 60 * 60 * 1000;
|
|
|
75
80
|
const APPLICATION_TIMELINE_AFTER_MS = 45 * 60 * 1000;
|
|
76
81
|
|
|
77
82
|
const APPLICATION_VIEWS: ReadonlySet<ApplicationRouteView> =
|
|
78
|
-
new Set<ApplicationRouteView>(["overview", "topology", "history", "cost"]);
|
|
83
|
+
new Set<ApplicationRouteView>(["overview", "deploys", "topology", "history", "cost"]);
|
|
79
84
|
|
|
80
85
|
function parseApplicationView(value: string | null): ApplicationRouteView {
|
|
86
|
+
if (value === "timeline") return "history";
|
|
81
87
|
if (!value || !APPLICATION_VIEWS.has(value as ApplicationRouteView))
|
|
82
88
|
return "overview";
|
|
83
89
|
return value as ApplicationRouteView;
|
|
@@ -278,8 +284,13 @@ function AppDetailRoute({
|
|
|
278
284
|
const applicationCostSelected =
|
|
279
285
|
selectedRouteView === "cost" && applicationCostAvailable;
|
|
280
286
|
const historyQuery = useApplicationHistory(app.key, appHistoryNamespaces, {
|
|
281
|
-
enabled: !selectedWorkloadKey,
|
|
287
|
+
enabled: !selectedWorkloadKey || Boolean(app.sourceRef),
|
|
282
288
|
});
|
|
289
|
+
const readableHistory = historyQuery.isError ? undefined : historyQuery.data;
|
|
290
|
+
const deliveryRecords = useMemo(() => applicationDeliveryRecords(historyQuery.data), [historyQuery.data]);
|
|
291
|
+
const deliverySource = readableHistory?.sourceRef ?? app.sourceRef;
|
|
292
|
+
const requestedDeploys = selectedView === "deploys" || searchParams.get("tab") === "deploys";
|
|
293
|
+
const showDeploys = deliveryRecords.length > 0 || (requestedDeploys && Boolean(deliverySource));
|
|
283
294
|
const [retainedHistoryRange, setRetainedHistoryRange] =
|
|
284
295
|
useState<ApplicationHistoryRange>("7d");
|
|
285
296
|
const historyRangeOptions = useMemo(
|
|
@@ -355,8 +366,8 @@ function AppDetailRoute({
|
|
|
355
366
|
[historyMembership, historyTimelineQuery.data, topology],
|
|
356
367
|
);
|
|
357
368
|
const historyItems = useMemo(
|
|
358
|
-
() => buildApplicationHistoryItems(
|
|
359
|
-
[applicationEvents,
|
|
369
|
+
() => buildApplicationHistoryItems(readableHistory, applicationEvents),
|
|
370
|
+
[applicationEvents, readableHistory],
|
|
360
371
|
);
|
|
361
372
|
const sourceInventoryEnabled =
|
|
362
373
|
!selectedWorkloadKey && selectedView === "topology";
|
|
@@ -383,16 +394,28 @@ function AppDetailRoute({
|
|
|
383
394
|
[deploymentTreeQuery.data, helmReleaseQuery.data?.resources],
|
|
384
395
|
);
|
|
385
396
|
useEffect(() => {
|
|
397
|
+
// Deploys belongs to the app scope, including its single-workload shell.
|
|
398
|
+
if (requestedDeploys && (!deliverySource || (!singleWorkloadKey && selectedWorkloadParam))) {
|
|
399
|
+
const params = new URLSearchParams(searchParams);
|
|
400
|
+
if (viewParam === "deploys") params.delete("view");
|
|
401
|
+
if (params.get("tab") === "deploys") params.delete("tab");
|
|
402
|
+
if (singleWorkloadKey) params.set("workload", singleWorkloadKey);
|
|
403
|
+
setSearchParams(params, { replace: true });
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
386
406
|
if (!singleWorkloadKey) return;
|
|
387
407
|
if (selectedWorkloadParam === singleWorkloadKey && !viewParam) return;
|
|
388
408
|
const params = new URLSearchParams(searchParams);
|
|
389
409
|
params.delete("view");
|
|
390
410
|
params.delete("run");
|
|
391
411
|
params.set("workload", singleWorkloadKey);
|
|
392
|
-
if (selectedRouteView === "cost") params.set("tab",
|
|
412
|
+
if (selectedRouteView === "cost" || selectedRouteView === "deploys") params.set("tab", selectedRouteView);
|
|
413
|
+
if (selectedRouteView === "history") params.set("tab", "timeline");
|
|
393
414
|
setSearchParams(params, { replace: true });
|
|
394
415
|
}, [
|
|
395
416
|
searchParams,
|
|
417
|
+
requestedDeploys,
|
|
418
|
+
deliverySource,
|
|
396
419
|
selectedRouteView,
|
|
397
420
|
selectedWorkloadParam,
|
|
398
421
|
setSearchParams,
|
|
@@ -431,7 +454,7 @@ function AppDetailRoute({
|
|
|
431
454
|
params.delete("view");
|
|
432
455
|
params.delete("workload");
|
|
433
456
|
} else {
|
|
434
|
-
params.set("view", view);
|
|
457
|
+
params.set("view", view === "history" ? "timeline" : view);
|
|
435
458
|
params.delete("workload");
|
|
436
459
|
}
|
|
437
460
|
setSearchParams(params);
|
|
@@ -642,6 +665,7 @@ function AppDetailRoute({
|
|
|
642
665
|
|
|
643
666
|
return (
|
|
644
667
|
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
|
668
|
+
<ArgoSyncDetailsContext.Provider value={ArgoSyncDetails}>
|
|
645
669
|
<ApplicationDetail
|
|
646
670
|
app={app}
|
|
647
671
|
onBack={onBack}
|
|
@@ -653,8 +677,9 @@ function AppDetailRoute({
|
|
|
653
677
|
discoveredEnvs={discoveredEnvs}
|
|
654
678
|
onNavigateToResource={onOpenResource}
|
|
655
679
|
onSelectWorkloadRun={selectWorkloadRun}
|
|
656
|
-
history={
|
|
680
|
+
history={readableHistory}
|
|
657
681
|
historyLoading={historyQuery.isLoading}
|
|
682
|
+
historySourceError={historyQuery.isError}
|
|
658
683
|
historyItems={historyItems}
|
|
659
684
|
historyRuntimeLoading={historyTimelineQuery.isLoading}
|
|
660
685
|
historyRuntimeError={historyTimelineQuery.isError}
|
|
@@ -672,6 +697,9 @@ function AppDetailRoute({
|
|
|
672
697
|
onSelectWorkload={selectWorkload}
|
|
673
698
|
selectedView={selectedView}
|
|
674
699
|
onSelectView={selectView}
|
|
700
|
+
renderDeploys={deliverySource && showDeploys ? () =>
|
|
701
|
+
<ApplicationDeploys source={deliverySource} records={historyQuery.isError ? [] : deliveryRecords} loading={historyQuery.isLoading} unavailable={historyQuery.isError} partialSources={historyQuery.data?.partialSources} onOpenSource={openSource} /> : undefined}
|
|
702
|
+
renderWorkloadRevisions={(workload) => <WorkloadRevisionsButton {...workload} />}
|
|
675
703
|
costViewSelected={applicationCostSelected}
|
|
676
704
|
onSelectCostView={() => selectView("cost")}
|
|
677
705
|
renderCostView={
|
|
@@ -697,9 +725,10 @@ function AppDetailRoute({
|
|
|
697
725
|
/>
|
|
698
726
|
)}
|
|
699
727
|
hasOverviewIssues={appIssues.length > 0}
|
|
700
|
-
renderWorkload={(workload: SelectedAppWorkload) => (
|
|
728
|
+
renderWorkload={(workload: SelectedAppWorkload, context) => (
|
|
701
729
|
<div className="h-full overflow-hidden">
|
|
702
730
|
<WorkloadView
|
|
731
|
+
{...context}
|
|
703
732
|
kind={kindToPluralWithGroup(workload.kind, workload.group ?? "")}
|
|
704
733
|
group={workload.group}
|
|
705
734
|
namespace={workload.namespace}
|
|
@@ -713,6 +742,7 @@ function AppDetailRoute({
|
|
|
713
742
|
</div>
|
|
714
743
|
)}
|
|
715
744
|
/>
|
|
745
|
+
</ArgoSyncDetailsContext.Provider>
|
|
716
746
|
</div>
|
|
717
747
|
);
|
|
718
748
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ArgoSyncDetailsProps } from "@skyhook-io/k8s-ui";
|
|
2
|
+
import { useArgoStatus, useArgoSyncDiff, useGitOpsInsights } from "../../api/client";
|
|
3
|
+
import { RevisionMetaChip } from "../gitops/RevisionMetaChip";
|
|
4
|
+
import { RenderedChanges } from "./RenderedChanges";
|
|
5
|
+
|
|
6
|
+
function SyncComparison({ namespace, name, syncID, previous, revision }: {
|
|
7
|
+
namespace: string; name: string; syncID: string; previous: string; revision: string;
|
|
8
|
+
}) {
|
|
9
|
+
const query = useArgoSyncDiff(namespace, name, syncID, previous, revision);
|
|
10
|
+
if (query.isError) return <p role="status">Rendered changes unavailable. {query.error.message}</p>;
|
|
11
|
+
if (query.isFetching || !query.data) return <p role="status">Comparing rendered resources…</p>;
|
|
12
|
+
return <RenderedChanges diff={query.data} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function ArgoSyncDetails({ source, revision, git }: ArgoSyncDetailsProps) {
|
|
16
|
+
const status = useArgoStatus();
|
|
17
|
+
const connected = !status.isError && status.data?.connected;
|
|
18
|
+
const insights = useGitOpsInsights("applications", source.namespace, connected ? source.name : "", source.group);
|
|
19
|
+
const commitAvailable = connected && !insights.isError && insights.data?.capabilities?.revisionMetadataAvailable &&
|
|
20
|
+
insights.data.summary?.source?.split(" · ")[0] === git.repoURL;
|
|
21
|
+
return <>
|
|
22
|
+
{git.historyID && git.previousRevision && git.previousRevision !== revision && (
|
|
23
|
+
connected
|
|
24
|
+
? <SyncComparison namespace={source.namespace} name={source.name} syncID={git.historyID} previous={git.previousRevision} revision={revision} />
|
|
25
|
+
: <p className="text-xs" role="status">{status.isPending ? "Checking Argo CD connection…" :
|
|
26
|
+
status.isError ? "Rendered changes unavailable. Radar could not check the Argo CD connection." :
|
|
27
|
+
<>To compare rendered resources, <button type="button" className="font-medium text-accent-text hover:underline"
|
|
28
|
+
onClick={() => window.dispatchEvent(new CustomEvent("radar:open-settings", { detail: { section: "argocd" } }))}>connect the Argo CD API in Settings</button>.</>}</p>
|
|
29
|
+
)}
|
|
30
|
+
{commitAvailable && <div className="flex flex-wrap items-center gap-2"><RevisionMetaChip appNamespace={source.namespace} appName={source.name} revision={revision} /></div>}
|
|
31
|
+
</>;
|
|
32
|
+
}
|