@skyhook-io/radar-app 1.20.0 → 1.20.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.
Files changed (41) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +6 -4
  3. package/src/api/client.ts +69 -10
  4. package/src/api/helmInventory.test.tsx +108 -0
  5. package/src/api/radarFeatures.ts +2 -0
  6. package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
  7. package/src/components/curl/ServiceCurlButton.tsx +2 -2
  8. package/src/components/diagnose/investigationCase.test.tsx +41 -0
  9. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
  10. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
  11. package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
  12. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
  13. package/src/components/helm/HelmDrawerFrame.tsx +101 -0
  14. package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
  15. package/src/components/helm/HelmReleaseDrawer.tsx +23 -86
  16. package/src/components/helm/HelmView.tsx +213 -71
  17. package/src/components/helm/ObservedHelmNotice.tsx +146 -0
  18. package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
  19. package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
  20. package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
  21. package/src/components/helm/OwnedResources.tsx +4 -2
  22. package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
  23. package/src/components/home/ClusterHealthCard.tsx +28 -5
  24. package/src/components/home/HelmSummary.tsx +23 -4
  25. package/src/components/home/HelmSummary.unread.test.ts +16 -0
  26. package/src/components/home/HomeAgentBlock.tsx +7 -0
  27. package/src/components/home/MCPSetupDialog.test.tsx +38 -12
  28. package/src/components/home/MCPSetupDialog.tsx +5 -2
  29. package/src/components/home/mcpToolCatalog.ts +44 -4
  30. package/src/components/issues/uncheckedSources.test.ts +2 -0
  31. package/src/components/issues/uncheckedSources.ts +3 -0
  32. package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
  33. package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
  34. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
  35. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
  36. package/src/components/whats-new/releaseNotes.ts +1 -1
  37. package/src/contexts/CapabilitiesContext.tsx +2 -0
  38. package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
  39. package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
  40. package/src/integrations/resourceHosts.test.tsx +1 -1
  41. package/src/integrations/resourceHosts.tsx +5 -0
@@ -0,0 +1,160 @@
1
+ import { renderToStaticMarkup } from 'react-dom/server'
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
3
+ import {
4
+ ValidatingAdmissionPolicyBindingRenderer,
5
+ ValidatingAdmissionPolicyRenderer,
6
+ } from './ValidatingAdmissionPolicyRenderer'
7
+
8
+ const mock = vi.hoisted(() => ({
9
+ query: {} as any,
10
+ reads: [] as any[],
11
+ policyQuery: {} as any,
12
+ policyReads: [] as any[],
13
+ }))
14
+
15
+ vi.mock('../../../api/client', () => ({
16
+ useResources: (...args: any[]) => {
17
+ mock.reads.push(args)
18
+ return mock.query
19
+ },
20
+ useResourceWithRelationships: (...args: any[]) => {
21
+ mock.policyReads.push(args)
22
+ return mock.policyQuery
23
+ },
24
+ }))
25
+
26
+ const policy = {
27
+ apiVersion: 'admissionregistration.k8s.io/v1',
28
+ kind: 'ValidatingAdmissionPolicy',
29
+ metadata: { name: 'require-owner', generation: 1 },
30
+ spec: { validations: [{ expression: 'true' }] },
31
+ }
32
+
33
+ const binding = (name: string, policyName: string) => ({
34
+ apiVersion: 'admissionregistration.k8s.io/v1',
35
+ kind: 'ValidatingAdmissionPolicyBinding',
36
+ metadata: { name },
37
+ spec: { policyName, validationActions: ['Deny'] },
38
+ })
39
+
40
+ const render = () => renderToStaticMarkup(<ValidatingAdmissionPolicyRenderer data={policy} onNavigate={() => {}} />)
41
+
42
+ beforeEach(() => {
43
+ mock.query = {}
44
+ mock.reads = []
45
+ mock.policyQuery = {}
46
+ mock.policyReads = []
47
+ })
48
+
49
+ describe('ValidatingAdmissionPolicy reverse binding lookup', () => {
50
+ it('lists only readable bindings that name this policy', () => {
51
+ mock.query = { data: [binding('owner-prod', 'require-owner'), binding('image-prod', 'require-images')], coverage: { status: 'complete' }, isLoading: false }
52
+ const html = render()
53
+ expect(mock.reads).toEqual([[
54
+ 'validatingadmissionpolicybindings',
55
+ undefined,
56
+ 'admissionregistration.k8s.io',
57
+ { enabled: true, refetchInterval: 30000 },
58
+ ]])
59
+ expect(html).toContain('Bindings (1)')
60
+ expect(html).toContain('owner-prod')
61
+ expect(html).not.toContain('image-prod')
62
+ })
63
+
64
+ it('reports no binding only when the list response establishes complete coverage', () => {
65
+ mock.query = { data: [], coverage: { status: 'complete' }, isLoading: false }
66
+ expect(render()).toContain('No readable bindings select this policy')
67
+ expect(render()).toContain('this policy has no effect')
68
+
69
+ mock.query = { data: [], coverage: { status: 'unknown' }, isLoading: false }
70
+ const unknown = render()
71
+ expect(unknown).toContain('Binding availability could not be established')
72
+ expect(unknown).not.toContain('this policy has no effect')
73
+ expect(unknown).not.toContain('Bindings (0)')
74
+
75
+ mock.query = { isLoading: true }
76
+ const loading = render()
77
+ expect(loading).toContain('Looking for readable bindings')
78
+ expect(loading).not.toContain('No readable bindings')
79
+ })
80
+
81
+ it('distinguishes forbidden from other list failures and never reports either as no bindings', () => {
82
+ mock.query = { error: { status: 403, message: 'Forbidden' }, isLoading: false }
83
+ const denied = render()
84
+ expect(denied).toContain('don’t have permission')
85
+ expect(denied).not.toContain('No readable bindings')
86
+ expect(denied).not.toContain('Bindings (0)')
87
+
88
+ mock.query = { error: new Error('binding list unavailable'), isLoading: false }
89
+ const failed = render()
90
+ expect(failed).toContain('Could not check')
91
+ expect(failed).toContain('binding list unavailable')
92
+ expect(failed).not.toContain('No readable bindings')
93
+ })
94
+
95
+ it('marks a non-empty partial binding list as incomplete', () => {
96
+ mock.query = { data: [binding('owner-prod', 'require-owner')], coverage: { status: 'partial' }, isLoading: false }
97
+ const partial = render()
98
+ expect(partial).toContain('Bindings (1+)')
99
+ expect(partial).toContain('This list may be incomplete')
100
+ })
101
+
102
+ it('stops reporting an exact count when a refresh fails after a complete list', () => {
103
+ mock.query = {
104
+ data: [binding('owner-prod', 'require-owner')],
105
+ coverage: { status: 'complete' },
106
+ error: new Error('binding list unavailable'),
107
+ isLoading: false,
108
+ }
109
+ const stale = render()
110
+ expect(stale).toContain('Bindings (1+)')
111
+ expect(stale).not.toContain('Bindings (1)')
112
+ expect(stale).toContain('This may be incomplete')
113
+ expect(stale).toContain('owner-prod')
114
+ })
115
+
116
+ it('keeps the binding wrapper declarative and free of parameter discovery reads', () => {
117
+ mock.policyQuery = { data: { resource: policy } }
118
+ const html = renderToStaticMarkup(<ValidatingAdmissionPolicyBindingRenderer data={{
119
+ ...binding('owner-prod', 'require-owner'),
120
+ spec: {
121
+ policyName: 'require-owner',
122
+ validationActions: ['Warn'],
123
+ paramRef: { selector: { matchLabels: { tier: 'strict' } }, parameterNotFoundAction: 'Allow' },
124
+ },
125
+ }} onNavigate={() => {}} />)
126
+ expect(html).toContain('tier')
127
+ expect(html).toContain('strict')
128
+ expect(mock.reads).toEqual([])
129
+ expect(mock.policyReads).toEqual([[
130
+ 'validatingadmissionpolicies',
131
+ '',
132
+ 'require-owner',
133
+ 'admissionregistration.k8s.io',
134
+ ]])
135
+ })
136
+
137
+ it('keeps policy loading, missing, denied, and failed reference checks distinct', () => {
138
+ const renderBinding = () => renderToStaticMarkup(<ValidatingAdmissionPolicyBindingRenderer
139
+ data={binding('owner-prod', 'require-owner')}
140
+ onNavigate={() => {}}
141
+ />)
142
+
143
+ mock.policyQuery = { isLoading: true }
144
+ expect(renderBinding()).toContain('Checking policy availability')
145
+
146
+ mock.policyQuery = { error: { status: 404, message: 'Not Found' } }
147
+ expect(renderBinding()).toContain('Referenced policy was not found')
148
+
149
+ mock.policyQuery = { error: { status: 403, message: 'Forbidden' } }
150
+ expect(renderBinding()).toContain('Not permitted to check policy availability')
151
+
152
+ mock.policyQuery = { error: new Error('policy read failed') }
153
+ expect(renderBinding()).toContain('Could not check policy availability')
154
+
155
+ mock.policyQuery = { data: { resource: policy } }
156
+ const present = renderBinding()
157
+ expect(present).not.toContain('availability')
158
+ expect(present).toContain('>require-owner</button>')
159
+ })
160
+ })
@@ -0,0 +1,128 @@
1
+ import { Link2 } from 'lucide-react'
2
+ import {
3
+ RelationshipGroup,
4
+ ResourceLink,
5
+ Section,
6
+ type ResourceRef,
7
+ } from '@skyhook-io/k8s-ui'
8
+ import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
9
+ import {
10
+ ValidatingAdmissionPolicyBindingRenderer as BaseBindingRenderer,
11
+ ValidatingAdmissionPolicyRenderer as BasePolicyRenderer,
12
+ } from '@skyhook-io/k8s-ui/components/resources/renderers/ValidatingAdmissionPolicyRenderers'
13
+ import { useResources, useResourceWithRelationships } from '../../../api/client'
14
+
15
+ const ADMISSION_REGISTRATION_GROUP = 'admissionregistration.k8s.io'
16
+
17
+ export function ValidatingAdmissionPolicyRenderer({
18
+ data,
19
+ onNavigate,
20
+ }: {
21
+ data: any
22
+ onNavigate?: (ref: ResourceRef) => void
23
+ }) {
24
+ const name = data?.metadata?.name
25
+ const query = useResources<any>(
26
+ 'validatingadmissionpolicybindings',
27
+ undefined,
28
+ ADMISSION_REGISTRATION_GROUP,
29
+ { enabled: Boolean(name), refetchInterval: 30000 },
30
+ )
31
+ const bindings = (query.data ?? []).filter(binding => binding?.spec?.policyName === name)
32
+ const bindingLookupComplete = query.coverage?.status === 'complete' && !query.error
33
+ const bindingTitle = bindingLookupComplete
34
+ ? `Bindings (${bindings.length})`
35
+ : bindings.length > 0 ? `Bindings (${bindings.length}+)` : 'Bindings'
36
+ const refs = bindings.map(binding => ({
37
+ kind: 'ValidatingAdmissionPolicyBinding',
38
+ namespace: '',
39
+ name: binding?.metadata?.name ?? '',
40
+ group: ADMISSION_REGISTRATION_GROUP,
41
+ }))
42
+
43
+ return (
44
+ <BasePolicyRenderer
45
+ data={data}
46
+ onNavigate={onNavigate}
47
+ bindings={
48
+ <Section title={bindingTitle} icon={Link2} defaultExpanded>
49
+ {query.isLoading ? (
50
+ <div className="text-sm text-theme-text-tertiary">Looking for readable bindings…</div>
51
+ ) : query.error && bindings.length === 0 ? (
52
+ <LookupFailureNote errors={[query.error]} what="which bindings select this policy" />
53
+ ) : bindings.length === 0 && bindingLookupComplete ? (
54
+ <div className="text-sm text-theme-text-tertiary">
55
+ No readable bindings select this policy; this policy has no effect.
56
+ </div>
57
+ ) : bindings.length === 0 ? (
58
+ <div className="text-sm text-theme-text-tertiary">
59
+ Binding availability could not be established; this policy may still have readable bindings.
60
+ </div>
61
+ ) : (
62
+ <div className="space-y-2">
63
+ {!bindingLookupComplete && !query.error && (
64
+ <div className="text-sm text-theme-text-tertiary">
65
+ This list may be incomplete; binding coverage could not be confirmed.
66
+ </div>
67
+ )}
68
+ <LookupFailureNote
69
+ errors={[query.error]}
70
+ what="which bindings select this policy"
71
+ incomplete
72
+ />
73
+ <RelationshipGroup label="Select this policy" refs={refs} onNavigate={onNavigate} />
74
+ </div>
75
+ )}
76
+ </Section>
77
+ }
78
+ />
79
+ )
80
+ }
81
+
82
+ export function ValidatingAdmissionPolicyBindingRenderer({
83
+ data,
84
+ onNavigate,
85
+ }: {
86
+ data: any
87
+ onNavigate?: (ref: ResourceRef) => void
88
+ }) {
89
+ const policyName = data?.spec?.policyName ?? ''
90
+ const query = useResourceWithRelationships<any>(
91
+ 'validatingadmissionpolicies',
92
+ '',
93
+ policyName,
94
+ ADMISSION_REGISTRATION_GROUP,
95
+ )
96
+ const status = typeof query.error === 'object' && query.error !== null && 'status' in query.error
97
+ ? (query.error as { status?: unknown }).status
98
+ : undefined
99
+ const reference = query.isLoading ? (
100
+ <ReferenceState name={policyName} note="Checking policy availability…" />
101
+ ) : status === 404 ? (
102
+ <ReferenceState name={policyName} note="Referenced policy was not found." />
103
+ ) : status === 403 ? (
104
+ <ReferenceState name={policyName} note="Not permitted to check policy availability." />
105
+ ) : query.error ? (
106
+ <ReferenceState name={policyName} note="Could not check policy availability." />
107
+ ) : query.data ? (
108
+ <ResourceLink
109
+ name={policyName}
110
+ kind="validatingadmissionpolicies"
111
+ namespace=""
112
+ group={ADMISSION_REGISTRATION_GROUP}
113
+ onNavigate={onNavigate}
114
+ />
115
+ ) : (
116
+ <ReferenceState name={policyName} note="Policy availability was not checked." />
117
+ )
118
+ return <BaseBindingRenderer data={data} onNavigate={onNavigate} policyReference={reference} />
119
+ }
120
+
121
+ function ReferenceState({ name, note }: { name: string; note: string }) {
122
+ return (
123
+ <span className="space-y-0.5">
124
+ <span className="block">{name || 'Not specified'}</span>
125
+ <span className="block text-xs text-theme-text-tertiary">{note}</span>
126
+ </span>
127
+ )
128
+ }
@@ -115,7 +115,7 @@ export const RELEASE_NOTES: ReleaseNotes[] = [
115
115
  'Limit what Radar can reach with rbac.namespaces, disableExec and --disable-auto-port-forward',
116
116
  'GitOps trees show operator-created workloads; drawers link webhooks, issuers and Secrets',
117
117
  'get_changes includes RBAC and Node edits; search finds resources by a pasted IP or ip:port',
118
- 'Issues link a missing Secret to its SealedSecret and report missing parent Gateways',
118
+ 'Issues link a missing Secret to its SealedSecret',
119
119
  ],
120
120
  },
121
121
  {
@@ -44,6 +44,8 @@ const restrictedCapabilities: Capabilities = {
44
44
  },
45
45
  mcpEnabled: false,
46
46
  mcpExecTools: false,
47
+ mcpHttpTools: false,
48
+ mcpHelmTools: false,
47
49
  deployment: { mode: 'local' },
48
50
  }
49
51
 
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { describeGitOpsOwnerSource } from './useResolvedGitOpsOwner'
3
+
4
+ const owner = { tool: 'fluxcd', kind: 'kustomizations', namespace: 'flux-system', name: 'apps' } as const
5
+ const nameKey = 'kustomize.toolkit.fluxcd.io/name'
6
+ const nsKey = 'kustomize.toolkit.fluxcd.io/namespace'
7
+
8
+ describe('GitOps owner evidence', () => {
9
+ it('shows only the paired labels that identify the resolved manager', () => {
10
+ expect(describeGitOpsOwnerSource(owner, { metadata: { labels: { [nameKey]: 'apps', [nsKey]: 'flux-system' } } })).toBe(`${nameKey}=apps, ${nsKey}=flux-system`)
11
+ })
12
+ it.each([
13
+ { [nameKey]: 'flux-system', [nsKey]: 'flux-system' },
14
+ { [nameKey]: 'apps', [nsKey]: 'other' },
15
+ { [nameKey]: 'apps' },
16
+ ])('does not cite stale or incomplete origin labels: %j', labels => {
17
+ expect(describeGitOpsOwnerSource(owner, { metadata: { labels } })).toBeNull()
18
+ })
19
+ it('does not cite an Argo annotation for a Flux manager', () => {
20
+ expect(describeGitOpsOwnerSource(owner, { metadata: { annotations: { 'argocd.argoproj.io/tracking-id': 'old:apps/Deployment:prod/web' } } })).toBeNull()
21
+ })
22
+ })
@@ -214,7 +214,7 @@ function isNativeHelmManager(ref: ResourceRef): boolean {
214
214
  return ref.kind === 'HelmRelease' && ref.group !== 'helm.toolkit.fluxcd.io'
215
215
  }
216
216
 
217
- function describeGitOpsOwnerSource(owner: GitOpsOwnerRef | null, resource: any): string | null {
217
+ export function describeGitOpsOwnerSource(owner: GitOpsOwnerRef | null, resource: any): string | null {
218
218
  if (!owner || !resource) return null
219
219
  const labels = resource.metadata?.labels ?? {}
220
220
  const annotations = resource.metadata?.annotations ?? {}
@@ -223,9 +223,12 @@ function describeGitOpsOwnerSource(owner: GitOpsOwnerRef | null, resource: any):
223
223
  const nameKey = owner.kind === 'helmreleases' ? 'helm.toolkit.fluxcd.io/name' : 'kustomize.toolkit.fluxcd.io/name'
224
224
  const nsKey =
225
225
  owner.kind === 'helmreleases' ? 'helm.toolkit.fluxcd.io/namespace' : 'kustomize.toolkit.fluxcd.io/namespace'
226
- if (labels[nameKey] || labels[nsKey]) {
227
- return `${nameKey}=${labels[nameKey] ?? ''}, ${nsKey}=${labels[nsKey] ?? ''}`
226
+ // Cite the origin labels only when they name the manager shown: labels a
227
+ // controller copied from an ancestor's metadata name a different one.
228
+ if (labels[nameKey] === owner.name && labels[nsKey] === owner.namespace) {
229
+ return `${nameKey}=${labels[nameKey]}, ${nsKey}=${labels[nsKey]}`
228
230
  }
231
+ return null
229
232
  }
230
233
 
231
234
  const trackingID = annotations['argocd.argoproj.io/tracking-id']
@@ -55,7 +55,7 @@ describe('application resource hosts', () => {
55
55
  'RolloutRenderer', 'KyvernoPolicyCoverage', 'KyvernoPolicyQueued', 'CNPGObjectStoreRenderer',
56
56
  'VeleroBSLRenderer', 'VeleroBackupRenderer', 'VeleroRestoreRenderer', 'CNPGClusterRenderer',
57
57
  'CNPGDatabaseRenderer', 'CNPGPublicationRenderer', 'CNPGSubscriptionRenderer', 'CNPGImageCatalogRenderer',
58
- 'FluxHelmReleaseRenderer', 'OpenTelemetryCollectorRenderer',
58
+ 'FluxHelmReleaseRenderer', 'OpenTelemetryCollectorRenderer', 'ValidatingAdmissionPolicyRenderer', 'ValidatingAdmissionPolicyBindingRenderer',
59
59
  ].sort())
60
60
  const inherited = [{ id: 'local', label: 'Local', render: () => null }]
61
61
  expect(resourceDetailSlots({ kind: 'Pod', group: '', namespace: 'db', name: 'pg-1' }, inherited).extraTabs).toEqual(inherited)
@@ -39,6 +39,10 @@ import { VeleroBSLRenderer } from '../components/resources/renderers/VeleroBSLRe
39
39
  import { VeleroBackupRenderer } from '../components/resources/renderers/VeleroBackupRenderer'
40
40
  import { VeleroRestoreRenderer } from '../components/resources/renderers/VeleroRestoreRenderer'
41
41
  import { FluxHelmReleaseRenderer } from '../components/resources/renderers/FluxHelmReleaseRenderer'
42
+ import {
43
+ ValidatingAdmissionPolicyBindingRenderer,
44
+ ValidatingAdmissionPolicyRenderer,
45
+ } from '../components/resources/renderers/ValidatingAdmissionPolicyRenderer'
42
46
 
43
47
  export const resourceHosts: readonly ResourceHost[] = [
44
48
  { id: 'kubernetes', renderers: { PodRenderer, NodeRenderer, ServiceRenderer, WorkloadRenderer, HPARenderer, PVCRenderer } },
@@ -60,6 +64,7 @@ export const resourceHosts: readonly ResourceHost[] = [
60
64
  { id: 'kyverno', renderers: { KyvernoPolicyCoverage, KyvernoPolicyQueued } },
61
65
  { id: 'velero', renderers: { VeleroBSLRenderer, VeleroBackupRenderer, VeleroRestoreRenderer } },
62
66
  { id: 'flux', renderers: { FluxHelmReleaseRenderer } },
67
+ { id: 'admission-policy', renderers: { ValidatingAdmissionPolicyRenderer, ValidatingAdmissionPolicyBindingRenderer } },
63
68
  cnpgResourceHost,
64
69
  crdResourceHost,
65
70
  ]