@intentius/chant-lexicon-k8s 0.124.96 → 0.124.98

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 (228) hide show
  1. package/dist/application-paths.d.ts +4 -0
  2. package/dist/application-paths.d.ts.map +1 -0
  3. package/dist/application-paths.js +95 -0
  4. package/dist/application-set.d.ts +46 -0
  5. package/dist/application-set.d.ts.map +1 -0
  6. package/dist/application-set.js +303 -0
  7. package/dist/cluster-secret.d.ts +36 -0
  8. package/dist/cluster-secret.d.ts.map +1 -0
  9. package/dist/cluster-secret.js +55 -0
  10. package/dist/components/kustomize-apply.d.ts +6 -0
  11. package/dist/components/kustomize-apply.d.ts.map +1 -1
  12. package/dist/components/kustomize-apply.js +1 -1
  13. package/dist/config-schema.d.ts +8 -0
  14. package/dist/config-schema.d.ts.map +1 -1
  15. package/dist/config-schema.js +6 -2
  16. package/dist/config.d.ts +26 -3
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/helm-references.d.ts +113 -0
  19. package/dist/helm-references.d.ts.map +1 -0
  20. package/dist/helm-references.js +389 -0
  21. package/dist/import/generator.d.ts +11 -2
  22. package/dist/import/generator.d.ts.map +1 -1
  23. package/dist/import/generator.js +37 -55
  24. package/dist/import/parser.d.ts.map +1 -1
  25. package/dist/import/parser.js +34 -5
  26. package/dist/import/typed-classes.d.ts +57 -0
  27. package/dist/import/typed-classes.d.ts.map +1 -0
  28. package/dist/import/typed-classes.js +126 -0
  29. package/dist/integrity.json +41 -41
  30. package/dist/kustomize/render.d.ts +41 -2
  31. package/dist/kustomize/render.d.ts.map +1 -1
  32. package/dist/kustomize/render.js +114 -7
  33. package/dist/kustomize/root.d.ts +3 -3
  34. package/dist/kustomize/root.d.ts.map +1 -1
  35. package/dist/kustomize/root.js +6 -1
  36. package/dist/lint/post-synth/argo-helpers.d.ts +3 -0
  37. package/dist/lint/post-synth/argo-helpers.d.ts.map +1 -1
  38. package/dist/lint/post-synth/argo-helpers.js +8 -2
  39. package/dist/lint/post-synth/argo002.d.ts.map +1 -1
  40. package/dist/lint/post-synth/argo002.js +2 -1
  41. package/dist/lint/post-synth/argo003.d.ts.map +1 -1
  42. package/dist/lint/post-synth/argo003.js +2 -1
  43. package/dist/lint/post-synth/argo005.d.ts.map +1 -1
  44. package/dist/lint/post-synth/argo005.js +36 -9
  45. package/dist/lint/post-synth/crd-schema-helpers.d.ts +1 -1
  46. package/dist/lint/post-synth/crd-schema-helpers.d.ts.map +1 -1
  47. package/dist/lint/post-synth/crd-schema-helpers.js +3 -3
  48. package/dist/lint/post-synth/flux002.d.ts.map +1 -1
  49. package/dist/lint/post-synth/flux002.js +2 -1
  50. package/dist/lint/post-synth/flux003.d.ts.map +1 -1
  51. package/dist/lint/post-synth/flux003.js +2 -1
  52. package/dist/lint/post-synth/k8s-helpers.d.ts +32 -0
  53. package/dist/lint/post-synth/k8s-helpers.d.ts.map +1 -1
  54. package/dist/lint/post-synth/k8s-helpers.js +57 -10
  55. package/dist/lint/post-synth/wk8005.d.ts +9 -0
  56. package/dist/lint/post-synth/wk8005.d.ts.map +1 -1
  57. package/dist/lint/post-synth/wk8005.js +53 -3
  58. package/dist/lint/post-synth/wk8006.d.ts.map +1 -1
  59. package/dist/lint/post-synth/wk8006.js +4 -2
  60. package/dist/lint/post-synth/wk8041.d.ts.map +1 -1
  61. package/dist/lint/post-synth/wk8041.js +3 -2
  62. package/dist/lint/post-synth/wk8042.js +2 -2
  63. package/dist/lint/post-synth/wk8101.js +2 -2
  64. package/dist/lint/post-synth/wk8102.d.ts.map +1 -1
  65. package/dist/lint/post-synth/wk8102.js +7 -3
  66. package/dist/lint/post-synth/wk8103.d.ts.map +1 -1
  67. package/dist/lint/post-synth/wk8103.js +3 -2
  68. package/dist/lint/post-synth/wk8104.d.ts.map +1 -1
  69. package/dist/lint/post-synth/wk8104.js +3 -2
  70. package/dist/lint/post-synth/wk8105.d.ts.map +1 -1
  71. package/dist/lint/post-synth/wk8105.js +3 -2
  72. package/dist/lint/post-synth/wk8201.d.ts.map +1 -1
  73. package/dist/lint/post-synth/wk8201.js +3 -2
  74. package/dist/lint/post-synth/wk8202.d.ts.map +1 -1
  75. package/dist/lint/post-synth/wk8202.js +3 -2
  76. package/dist/lint/post-synth/wk8203.d.ts.map +1 -1
  77. package/dist/lint/post-synth/wk8203.js +3 -2
  78. package/dist/lint/post-synth/wk8204.d.ts.map +1 -1
  79. package/dist/lint/post-synth/wk8204.js +5 -2
  80. package/dist/lint/post-synth/wk8205.d.ts.map +1 -1
  81. package/dist/lint/post-synth/wk8205.js +3 -2
  82. package/dist/lint/post-synth/wk8207.js +2 -2
  83. package/dist/lint/post-synth/wk8208.js +2 -2
  84. package/dist/lint/post-synth/wk8209.js +2 -2
  85. package/dist/lint/post-synth/wk8301.d.ts.map +1 -1
  86. package/dist/lint/post-synth/wk8301.js +3 -2
  87. package/dist/lint/post-synth/wk8302.js +2 -2
  88. package/dist/lint/post-synth/wk8303.js +2 -2
  89. package/dist/lint/post-synth/wk8304.js +2 -2
  90. package/dist/lint/post-synth/wk8305.js +2 -2
  91. package/dist/lint/post-synth/wk8306.d.ts.map +1 -1
  92. package/dist/lint/post-synth/wk8306.js +3 -2
  93. package/dist/lint/post-synth/wk8401.js +2 -2
  94. package/dist/lint/post-synth/wk8402.js +2 -2
  95. package/dist/lint/post-synth/wk8403.js +2 -2
  96. package/dist/lint/post-synth/wk8404.d.ts.map +1 -1
  97. package/dist/lint/post-synth/wk8404.js +2 -2
  98. package/dist/lint/post-synth/wk8405.js +2 -2
  99. package/dist/lint/post-synth/wk8406.d.ts.map +1 -1
  100. package/dist/lint/post-synth/wk8406.js +3 -2
  101. package/dist/lint/post-synth/wk8407.js +2 -2
  102. package/dist/lint/post-synth/wk8503.js +2 -2
  103. package/dist/manifest.json +1 -1
  104. package/dist/reference-catalog.d.ts +3 -1
  105. package/dist/reference-catalog.d.ts.map +1 -1
  106. package/dist/reference-catalog.js +283 -15
  107. package/dist/rules/argo-helpers.ts +9 -2
  108. package/dist/rules/argo002.ts +2 -1
  109. package/dist/rules/argo003.ts +2 -1
  110. package/dist/rules/argo005.ts +36 -10
  111. package/dist/rules/crd-schema-helpers.ts +3 -3
  112. package/dist/rules/flux002.ts +2 -1
  113. package/dist/rules/flux003.ts +2 -1
  114. package/dist/rules/k8s-helpers.ts +56 -11
  115. package/dist/rules/wk8005.ts +56 -3
  116. package/dist/rules/wk8006.ts +4 -2
  117. package/dist/rules/wk8041.ts +3 -2
  118. package/dist/rules/wk8042.ts +2 -2
  119. package/dist/rules/wk8101.ts +2 -2
  120. package/dist/rules/wk8102.ts +7 -3
  121. package/dist/rules/wk8103.ts +3 -2
  122. package/dist/rules/wk8104.ts +3 -2
  123. package/dist/rules/wk8105.ts +3 -2
  124. package/dist/rules/wk8201.ts +3 -2
  125. package/dist/rules/wk8202.ts +3 -2
  126. package/dist/rules/wk8203.ts +3 -2
  127. package/dist/rules/wk8204.ts +5 -2
  128. package/dist/rules/wk8205.ts +3 -2
  129. package/dist/rules/wk8207.ts +2 -2
  130. package/dist/rules/wk8208.ts +2 -2
  131. package/dist/rules/wk8209.ts +2 -2
  132. package/dist/rules/wk8301.ts +3 -2
  133. package/dist/rules/wk8302.ts +2 -2
  134. package/dist/rules/wk8303.ts +2 -2
  135. package/dist/rules/wk8304.ts +2 -2
  136. package/dist/rules/wk8305.ts +2 -2
  137. package/dist/rules/wk8306.ts +3 -2
  138. package/dist/rules/wk8401.ts +2 -2
  139. package/dist/rules/wk8402.ts +2 -2
  140. package/dist/rules/wk8403.ts +2 -2
  141. package/dist/rules/wk8404.ts +2 -1
  142. package/dist/rules/wk8405.ts +2 -2
  143. package/dist/rules/wk8406.ts +3 -2
  144. package/dist/rules/wk8407.ts +2 -2
  145. package/dist/rules/wk8503.ts +2 -2
  146. package/dist/workspace-member.d.ts +15 -3
  147. package/dist/workspace-member.d.ts.map +1 -1
  148. package/dist/workspace-member.js +151 -21
  149. package/package.json +5 -5
  150. package/src/application-paths.ts +96 -0
  151. package/src/application-set.test.ts +130 -0
  152. package/src/application-set.ts +336 -0
  153. package/src/cluster-secret.test.ts +117 -0
  154. package/src/cluster-secret.ts +76 -0
  155. package/src/components/kustomize-apply.ts +7 -1
  156. package/src/config-schema.ts +6 -2
  157. package/src/config.ts +24 -4
  158. package/src/helm-references.test.ts +149 -0
  159. package/src/helm-references.ts +425 -0
  160. package/src/import/generator.test.ts +57 -0
  161. package/src/import/generator.ts +35 -61
  162. package/src/import/parser.test.ts +59 -0
  163. package/src/import/parser.ts +38 -5
  164. package/src/import/roundtrip-build.test.ts +91 -0
  165. package/src/import/typed-classes.ts +168 -0
  166. package/src/kustomize/helm.test.ts +183 -0
  167. package/src/kustomize/render.ts +142 -6
  168. package/src/kustomize/root.ts +8 -3
  169. package/src/lint/post-synth/argo-helpers.ts +9 -2
  170. package/src/lint/post-synth/argo002.ts +2 -1
  171. package/src/lint/post-synth/argo003.ts +2 -1
  172. package/src/lint/post-synth/argo005.ts +36 -10
  173. package/src/lint/post-synth/audit-identity.test.ts +65 -0
  174. package/src/lint/post-synth/crd-schema-helpers.ts +3 -3
  175. package/src/lint/post-synth/flux002.ts +2 -1
  176. package/src/lint/post-synth/flux003.ts +2 -1
  177. package/src/lint/post-synth/k8s-helpers.ts +56 -11
  178. package/src/lint/post-synth/post-synth.test.ts +144 -0
  179. package/src/lint/post-synth/wk8005.ts +56 -3
  180. package/src/lint/post-synth/wk8006.ts +4 -2
  181. package/src/lint/post-synth/wk8041.ts +3 -2
  182. package/src/lint/post-synth/wk8042.ts +2 -2
  183. package/src/lint/post-synth/wk8101.ts +2 -2
  184. package/src/lint/post-synth/wk8102.ts +7 -3
  185. package/src/lint/post-synth/wk8103.ts +3 -2
  186. package/src/lint/post-synth/wk8104.ts +3 -2
  187. package/src/lint/post-synth/wk8105.ts +3 -2
  188. package/src/lint/post-synth/wk8201.ts +3 -2
  189. package/src/lint/post-synth/wk8202.ts +3 -2
  190. package/src/lint/post-synth/wk8203.ts +3 -2
  191. package/src/lint/post-synth/wk8204.ts +5 -2
  192. package/src/lint/post-synth/wk8205.ts +3 -2
  193. package/src/lint/post-synth/wk8207.ts +2 -2
  194. package/src/lint/post-synth/wk8208.ts +2 -2
  195. package/src/lint/post-synth/wk8209.ts +2 -2
  196. package/src/lint/post-synth/wk8301.ts +3 -2
  197. package/src/lint/post-synth/wk8302.ts +2 -2
  198. package/src/lint/post-synth/wk8303.ts +2 -2
  199. package/src/lint/post-synth/wk8304.ts +2 -2
  200. package/src/lint/post-synth/wk8305.ts +2 -2
  201. package/src/lint/post-synth/wk8306.ts +3 -2
  202. package/src/lint/post-synth/wk8401.ts +2 -2
  203. package/src/lint/post-synth/wk8402.ts +2 -2
  204. package/src/lint/post-synth/wk8403.ts +2 -2
  205. package/src/lint/post-synth/wk8404.ts +2 -1
  206. package/src/lint/post-synth/wk8405.ts +2 -2
  207. package/src/lint/post-synth/wk8406.ts +3 -2
  208. package/src/lint/post-synth/wk8407.ts +2 -2
  209. package/src/lint/post-synth/wk8503.ts +2 -2
  210. package/src/reference-catalog.test.ts +78 -0
  211. package/src/reference-catalog.ts +297 -16
  212. package/src/testdata/helm-chart-missing/kustomization.yaml +8 -0
  213. package/src/testdata/helm-chart-root/charts/webchart/Chart.yaml +3 -0
  214. package/src/testdata/helm-chart-root/charts/webchart/templates/configmap.yaml +6 -0
  215. package/src/testdata/helm-chart-root/charts/webchart/values.yaml +1 -0
  216. package/src/testdata/helm-chart-root/kustomization.yaml +9 -0
  217. package/src/testdata/helm-chart-root/values.yaml +1 -0
  218. package/src/testdata/workspace-members/argo-clusters/clusters.yaml +34 -0
  219. package/src/testdata/workspace-members/argo-set/all.yaml +43 -0
  220. package/src/testdata/workspace-members/plain/deploy.yaml +27 -0
  221. package/src/testdata/workspace-members/plain/es.yaml +15 -0
  222. package/src/testdata/workspace-members/templated/block.yaml +6 -0
  223. package/src/testdata/workspace-members/templated/chart-cm.yaml +4 -0
  224. package/src/testdata/workspace-members/templated/cm.yaml +6 -0
  225. package/src/workspace-kinds.test.ts +9 -1
  226. package/src/workspace-member.test.ts +69 -3
  227. package/src/workspace-member.ts +165 -24
  228. package/workspace-kinds.json +45 -6
@@ -6,8 +6,12 @@
6
6
  * Excluded from check auto-discovery by the "helper" filename filter.
7
7
  */
8
8
  import type { PostSynthContext } from "@intentius/chant/lint/post-synth";
9
+ import { MASKED } from "@intentius/chant/deep-observation";
9
10
  import { docsToManifests, type K8sManifest } from "./k8s-helpers";
10
11
 
12
+ /** What the live lister (`<masked>`) and the deep observation (`[REDACTED]`) leave where a value was. */
13
+ const MASKED_VALUES: ReadonlySet<string> = new Set([MASKED, "<masked>"]);
14
+
11
15
  /** The always-present, in-cluster Argo destination. */
12
16
  export const IN_CLUSTER_SERVER = "https://kubernetes.default.svc";
13
17
  export const IN_CLUSTER_NAME = "in-cluster";
@@ -28,14 +32,17 @@ export function manifestsOfKind(manifests: K8sManifest[], kind: string): K8sMani
28
32
  /**
29
33
  * Read a string field from a Secret's stringData or data block.
30
34
  * (Argo cluster Secrets conventionally use stringData.)
35
+ *
36
+ * A value the live reader masked is not a value: it reads as absent, so a
37
+ * masked `name` or `server` never registers a cluster called "<masked>" or "[REDACTED]".
31
38
  */
32
39
  export function secretField(manifest: K8sManifest, key: string): string | undefined {
33
40
  const stringData = manifest.stringData as Record<string, unknown> | undefined;
34
41
  const data = manifest.data as Record<string, unknown> | undefined;
35
42
  const fromStringData = stringData?.[key];
36
- if (typeof fromStringData === "string") return fromStringData;
43
+ if (typeof fromStringData === "string" && !MASKED_VALUES.has(fromStringData)) return fromStringData;
37
44
  const fromData = data?.[key];
38
- if (typeof fromData === "string") return fromData;
45
+ if (typeof fromData === "string" && !MASKED_VALUES.has(fromData)) return fromData;
39
46
  return undefined;
40
47
  }
41
48
 
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
11
11
  import { allManifests, manifestsOfKind } from "./argo-helpers";
12
+ import { nameOf } from "./k8s-helpers";
12
13
 
13
14
  export const argo002: PostSynthCheck = {
14
15
  id: "ARGO002",
@@ -28,7 +29,7 @@ export const argo002: PostSynthCheck = {
28
29
 
29
30
  for (const app of manifestsOfKind(manifests, "Application")) {
30
31
  const project = app.spec?.project;
31
- const name = app.metadata?.name ?? "Application";
32
+ const name = nameOf(app, "Application");
32
33
  // No project set → defaults to `default` at sync time; not this check's job.
33
34
  if (typeof project !== "string" || project === "") continue;
34
35
  if (declaredProjects.has(project)) continue;
@@ -18,6 +18,7 @@ import {
18
18
  IN_CLUSTER_SERVER,
19
19
  IN_CLUSTER_NAME,
20
20
  } from "./argo-helpers";
21
+ import { nameOf } from "./k8s-helpers";
21
22
 
22
23
  export const argo003: PostSynthCheck = {
23
24
  id: "ARGO003",
@@ -37,7 +38,7 @@ export const argo003: PostSynthCheck = {
37
38
  }
38
39
 
39
40
  for (const app of manifestsOfKind(manifests, "Application")) {
40
- const name = app.metadata?.name ?? "Application";
41
+ const name = nameOf(app, "Application");
41
42
  const destination = app.spec?.destination as
42
43
  | { server?: unknown; name?: unknown }
43
44
  | undefined;
@@ -2,10 +2,23 @@
2
2
  * ARGO005: Application source.path should point at an existing directory (warn)
3
3
  *
4
4
  * When an Argo `Application` syncs from a git source it names a `source.path`
5
- * inside the repo. In the common monorepo layout — Argo watches the same repo
6
- * Chant builds — that path is relative to the build root, so a typo'd or moved
7
- * path surfaces as a sync error only after deploy. This check warns when the
8
- * path doesn't resolve to a directory under the build root.
5
+ * inside the repository `source.repoURL` names. This check warns when the path
6
+ * does not resolve to a directory in the tree being read.
7
+ *
8
+ * Which tree depends on the command:
9
+ *
10
+ * - `chant build` and `chant lint` read the project, so a relative path
11
+ * resolves against the project root (the directory of the project config).
12
+ * The common monorepo layout, where Argo watches the same repo Chant builds,
13
+ * is the one this assumes.
14
+ * - `chant audit <dir>` reads a tree that need not be the working directory.
15
+ * The path resolves against the root of the checkout the audited directory
16
+ * is in, never the working directory, and only when that checkout's `origin`
17
+ * remote is the repository `repoURL` names. When the remote names another
18
+ * repository the path lives in a tree that is not on disk and the check is
19
+ * silent. A tree with no `origin` (an extracted archive) resolves against
20
+ * the audited directory. A remote tree fetch has nothing on disk and gets no
21
+ * findings. The resolution is `resolveRepoPath` in core.
9
22
  *
10
23
  * It is a warning, not an error: Applications that sync from a *different*
11
24
  * remote repo legitimately reference paths that don't exist locally. Helm chart
@@ -14,11 +27,13 @@
14
27
  import { existsSync, statSync } from "fs";
15
28
  import { isAbsolute, resolve } from "path";
16
29
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
30
+ import { resolveRepoPath } from "@intentius/chant/repo-path";
17
31
  import { allManifests, manifestsOfKind } from "./argo-helpers";
32
+ import { nameOf } from "./k8s-helpers";
18
33
 
19
- function dirExists(path: string): boolean {
34
+ function dirExists(base: string, path: string): boolean {
20
35
  try {
21
- const full = isAbsolute(path) ? path : resolve(process.cwd(), path);
36
+ const full = isAbsolute(path) ? path : resolve(base, path);
22
37
  return existsSync(full) && statSync(full).isDirectory();
23
38
  } catch {
24
39
  return false;
@@ -33,9 +48,9 @@ export const argo005: PostSynthCheck = {
33
48
  const diagnostics: PostSynthDiagnostic[] = [];
34
49
 
35
50
  for (const app of manifestsOfKind(allManifests(ctx), "Application")) {
36
- const name = app.metadata?.name ?? "Application";
51
+ const name = nameOf(app, "Application");
37
52
  const source = app.spec?.source as
38
- | { path?: unknown; chart?: unknown }
53
+ | { path?: unknown; chart?: unknown; repoURL?: unknown }
39
54
  | undefined;
40
55
  if (!source) continue;
41
56
  // Helm chart sources have no filesystem path.
@@ -43,12 +58,23 @@ export const argo005: PostSynthCheck = {
43
58
 
44
59
  const path = source.path;
45
60
  if (typeof path !== "string" || path === "") continue;
46
- if (dirExists(path)) continue;
61
+
62
+ let where = "under the build root";
63
+ if (ctx.audit) {
64
+ // No tree on disk (a remote fetch): nothing to resolve against.
65
+ if (ctx.audit.root === undefined) continue;
66
+ const repoURL = typeof source.repoURL === "string" ? source.repoURL : undefined;
67
+ const found = resolveRepoPath(ctx.audit.root, repoURL, path);
68
+ if (found.status !== "missing") continue;
69
+ where = found.path === path ? "in the audited repository" : `in the audited repository (looked for "${found.path}" from its root)`;
70
+ } else if (dirExists(ctx.projectDir ?? process.cwd(), path)) {
71
+ continue;
72
+ }
47
73
 
48
74
  diagnostics.push({
49
75
  checkId: "ARGO005",
50
76
  severity: "warning",
51
- message: `Application "${name}" source.path "${path}" does not resolve to a directory under the build root. Confirm the path (or ignore if it lives in a different repo).`,
77
+ message: `Application "${name}" source.path "${path}" does not resolve to a directory ${where}. Confirm the path (or ignore if it lives in a different repo).`,
52
78
  entity: name,
53
79
  lexicon: "k8s",
54
80
  });
@@ -15,7 +15,7 @@ import { createRequire } from "module";
15
15
  import { moduleSourceUrl } from "@intentius/chant/module-source";
16
16
  import type { PostSynthContext } from "@intentius/chant/lint/post-synth";
17
17
  import type { CrdFieldSchema } from "../../spec/parse";
18
- import { docsToManifests, type K8sManifest } from "./k8s-helpers";
18
+ import { docsToManifests, nameOf, type K8sManifest } from "./k8s-helpers";
19
19
  import { projectSpecSchema } from "../../project-kinds";
20
20
 
21
21
  export type { CrdFieldSchema };
@@ -229,7 +229,7 @@ export function suggestField(unknown: string, known: string[]): string | undefin
229
229
  return best;
230
230
  }
231
231
 
232
- /** `metadata.name` or the kind, for diagnostics. */
232
+ /** `metadata.name` when it is a string, else the kind, for diagnostics. */
233
233
  export function resourceLabel(manifest: K8sManifest): string {
234
- return manifest.metadata?.name ?? manifest.kind ?? "resource";
234
+ return nameOf(manifest, manifest.kind ?? "resource");
235
235
  }
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
13
13
  import { allManifests, manifestsOfKind } from "./argo-helpers";
14
+ import { nameOf } from "./k8s-helpers";
14
15
 
15
16
  /** Source kinds the kustomize-controller can reconcile from. */
16
17
  const SOURCE_KINDS = ["GitRepository", "OCIRepository", "Bucket"] as const;
@@ -43,7 +44,7 @@ export const flux002: PostSynthCheck = {
43
44
  const apiVersion = kustomization.apiVersion;
44
45
  if (typeof apiVersion === "string" && !apiVersion.startsWith("kustomize.toolkit.fluxcd.io/")) continue;
45
46
 
46
- const name = kustomization.metadata?.name ?? "Kustomization";
47
+ const name = nameOf(kustomization, "Kustomization");
47
48
  const sourceRef = kustomization.spec?.sourceRef as
48
49
  | { kind?: unknown; name?: unknown }
49
50
  | undefined;
@@ -15,6 +15,7 @@
15
15
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
16
16
  import { allManifests, manifestsOfKind } from "./argo-helpers";
17
17
  import type { K8sManifest } from "./k8s-helpers";
18
+ import { nameOf } from "./k8s-helpers";
18
19
 
19
20
  /** Flux Kustomizations only — the kustomize.config.k8s.io kind shares the name. */
20
21
  function fluxKustomizations(manifests: K8sManifest[]): K8sManifest[] {
@@ -39,7 +40,7 @@ export const flux003: PostSynthCheck = {
39
40
  );
40
41
 
41
42
  for (const kustomization of kustomizations) {
42
- const name = kustomization.metadata?.name ?? "Kustomization";
43
+ const name = nameOf(kustomization, "Kustomization");
43
44
  const dependsOn = kustomization.spec?.dependsOn;
44
45
  if (!Array.isArray(dependsOn)) continue;
45
46
 
@@ -77,6 +77,43 @@ export function docsToManifests(ctx: PostSynthContext): K8sManifest[] {
77
77
  .map((d) => d.value as K8sManifest);
78
78
  }
79
79
 
80
+ /**
81
+ * What a `metadata.name` that is not a string is, in words a finding can use.
82
+ * Undefined when the name is absent or a string.
83
+ *
84
+ * The usual cause is a template placeholder: `name: {{name}}` is a YAML flow
85
+ * mapping whose key is another mapping, so the parser hands back a map whose
86
+ * only key is the stringified inner map. A shell script or a templating step
87
+ * fills those files in; the file is not a manifest until it has run.
88
+ */
89
+ export function describeNonStringName(manifest: { metadata?: { name?: unknown } }): string | undefined {
90
+ const name = manifest.metadata?.name;
91
+ if (name === undefined || name === null || typeof name === "string") return undefined;
92
+ if (Array.isArray(name)) return "a list";
93
+ if (typeof name === "object") {
94
+ const keys = Object.keys(name);
95
+ if (keys.length === 1 && keys[0] === "[object Object]") {
96
+ return "a map, which is what YAML makes of a {{placeholder}}";
97
+ }
98
+ const shown = keys.slice(0, 3).map((k) => JSON.stringify(k)).join(", ");
99
+ return keys.length === 0 ? "an empty map" : `a map with the key${keys.length > 1 ? "s" : ""} ${shown}${keys.length > 3 ? ", ..." : ""}`;
100
+ }
101
+ return `${typeof name} ${String(name)}`;
102
+ }
103
+
104
+ /**
105
+ * The name a diagnostic prints and uses as its `entity`: `metadata.name` when
106
+ * it is a string, otherwise `fallback`. A name that is a map or a list would
107
+ * print as `[object Object]` and break the report's string `entity`, so it
108
+ * never gets through; {@link describeNonStringName} says what it was.
109
+ */
110
+ export function nameOf<F extends string | undefined>(manifest: { metadata?: { name?: unknown } }, fallback: F): string | F {
111
+ const name = manifest.metadata?.name;
112
+ if (typeof name === "string") return name;
113
+ if (typeof name === "number" || typeof name === "boolean") return String(name);
114
+ return fallback;
115
+ }
116
+
80
117
  /**
81
118
  * Extract the pod spec from any workload manifest.
82
119
  *
@@ -124,6 +161,9 @@ export function extractPodSpec(
124
161
  }
125
162
  }
126
163
 
164
+ /** Where each container extracted by {@link extractContainers} sits in its pod spec, e.g. `containers[1]`. */
165
+ const containerPaths = new WeakMap<object, string>();
166
+
127
167
  /**
128
168
  * Extract all containers (including init containers) from a workload manifest.
129
169
  */
@@ -133,25 +173,30 @@ export function extractContainers(manifest: K8sManifest): K8sContainer[] {
133
173
 
134
174
  const containers: K8sContainer[] = [];
135
175
 
136
- if (Array.isArray(podSpec.containers)) {
137
- for (const c of podSpec.containers) {
176
+ for (const field of ["containers", "initContainers"] as const) {
177
+ const list = podSpec[field];
178
+ if (!Array.isArray(list)) continue;
179
+ list.forEach((c, i) => {
138
180
  if (typeof c === "object" && c !== null) {
181
+ containerPaths.set(c, `${field}[${i}]`);
139
182
  containers.push(c as K8sContainer);
140
183
  }
141
- }
142
- }
143
-
144
- if (Array.isArray(podSpec.initContainers)) {
145
- for (const c of podSpec.initContainers) {
146
- if (typeof c === "object" && c !== null) {
147
- containers.push(c as K8sContainer);
148
- }
149
- }
184
+ });
150
185
  }
151
186
 
152
187
  return containers;
153
188
  }
154
189
 
190
+ /**
191
+ * The place of a container in its workload, `<kind>/<field>[<index>]`, for a
192
+ * diagnostic's `locator`. It names the position, not the container, so a
193
+ * finding keeps its audit identity when the container is renamed. Pass a
194
+ * container that {@link extractContainers} returned.
195
+ */
196
+ export function containerLocator(manifest: K8sManifest, container: K8sContainer): string {
197
+ return `${manifest.kind ?? ""}/${containerPaths.get(container) ?? "containers"}`;
198
+ }
199
+
155
200
  /**
156
201
  * Workload kinds that contain pod templates.
157
202
  */
@@ -4,12 +4,62 @@
4
4
  * Detects container environment variables with names suggesting sensitive
5
5
  * values (password, token, key, secret) that use hardcoded string values
6
6
  * instead of secretKeyRef or configMapKeyRef.
7
+ *
8
+ * Two shapes are not secrets and are skipped. A name that ends in _FILE, _PATH
9
+ * or _DIR whose value is a path (AWS_WEB_IDENTITY_TOKEN_FILE pointing at a
10
+ * projected token) names where a secret lives, not the secret. A name whose
11
+ * only credential word is KEY, where KEY follows a structural qualifier
12
+ * (LOG_MESSAGE_KEY, PARTITION_KEY, SORT_KEY), names a field, not a credential.
13
+ * Everything else keeps matching: a name that also carries password, token or
14
+ * secret, a KEY with any other prefix (API_KEY, STRIPE_KEY, KEY), and any
15
+ * *_FILE name whose value is not path-shaped.
7
16
  */
8
17
 
9
18
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
19
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers";
11
20
 
12
21
  const SENSITIVE_NAME_PATTERN = /password|token|key|secret/i;
22
+ const STRONG_NAME_PATTERN = /password|token|secret/i;
23
+
24
+ /** Words that make a following KEY a data field name rather than a credential. */
25
+ const STRUCTURAL_KEY_QUALIFIERS = new Set([
26
+ "message", "msg", "partition", "sort", "range", "hash", "primary", "foreign",
27
+ "shard", "routing", "index", "cache", "group", "order", "label", "field",
28
+ "timestamp", "level",
29
+ ]);
30
+
31
+ const FILE_SUFFIX_PATTERN = /(?:^|[_-])(?:file|path|dir|directory|filepath)$/i;
32
+
33
+ function nameTokens(name: string): string[] {
34
+ return name
35
+ .replace(/([a-z0-9])([A-Z])/g, "$1_$2")
36
+ .split(/[^A-Za-z0-9]+/)
37
+ .filter(Boolean)
38
+ .map((t) => t.toLowerCase());
39
+ }
40
+
41
+ /** True when KEY is the only credential word and each KEY follows a structural qualifier. */
42
+ function isStructuralKeyName(name: string): boolean {
43
+ if (STRONG_NAME_PATTERN.test(name)) return false;
44
+ const tokens = nameTokens(name);
45
+ let sawKey = false;
46
+ for (let i = 0; i < tokens.length; i++) {
47
+ if (!tokens[i].includes("key")) continue;
48
+ sawKey = true;
49
+ if (tokens[i] !== "key" || i === 0 || !STRUCTURAL_KEY_QUALIFIERS.has(tokens[i - 1])) return false;
50
+ }
51
+ return sawKey;
52
+ }
53
+
54
+ /** Absolute, home or explicitly relative path made only of path characters. */
55
+ function isPathValue(value: string): boolean {
56
+ return /^(?:\/|~\/|\.{1,2}\/)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*\/?$/.test(value) ||
57
+ /^[A-Za-z]:[\\/][^\s]+$/.test(value);
58
+ }
59
+
60
+ function isFilePointer(name: string, value: string): boolean {
61
+ return FILE_SUFFIX_PATTERN.test(name) && isPathValue(value);
62
+ }
13
63
 
14
64
  export const wk8005: PostSynthCheck = {
15
65
  id: "WK8005",
@@ -22,7 +72,7 @@ export const wk8005: PostSynthCheck = {
22
72
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
23
73
 
24
74
  const containers = extractContainers(manifest);
25
- const resourceName = manifest.metadata?.name ?? manifest.kind;
75
+ const resourceName = nameOf(manifest, manifest.kind);
26
76
 
27
77
  for (const container of containers) {
28
78
  if (!Array.isArray(container.env)) continue;
@@ -31,17 +81,20 @@ export const wk8005: PostSynthCheck = {
31
81
  if (
32
82
  typeof envVar.name === "string" &&
33
83
  SENSITIVE_NAME_PATTERN.test(envVar.name) &&
84
+ !isStructuralKeyName(envVar.name) &&
34
85
  envVar.value !== undefined &&
35
86
  envVar.value !== null &&
36
87
  typeof envVar.value === "string" &&
37
88
  envVar.value !== "" &&
38
- !envVar.valueFrom
89
+ !envVar.valueFrom &&
90
+ !isFilePointer(envVar.name, envVar.value)
39
91
  ) {
40
92
  diagnostics.push({
41
93
  checkId: "WK8005",
42
94
  severity: "error",
43
95
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has hardcoded value for sensitive env var "${envVar.name}" — use secretKeyRef instead`,
44
96
  entity: resourceName,
97
+ locator: containerLocator(manifest, container),
45
98
  lexicon: "k8s",
46
99
  });
47
100
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
9
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers";
10
10
 
11
11
  export const wk8006: PostSynthCheck = {
12
12
  id: "WK8006",
@@ -19,7 +19,7 @@ export const wk8006: PostSynthCheck = {
19
19
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
20
20
 
21
21
  const containers = extractContainers(manifest);
22
- const resourceName = manifest.metadata?.name ?? manifest.kind;
22
+ const resourceName = nameOf(manifest, manifest.kind);
23
23
 
24
24
  for (const container of containers) {
25
25
  const image = container.image;
@@ -41,6 +41,7 @@ export const wk8006: PostSynthCheck = {
41
41
  severity: "warning",
42
42
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" uses untagged image "${image}" — specify an explicit version tag`,
43
43
  entity: resourceName,
44
+ locator: containerLocator(manifest, container),
44
45
  lexicon: "k8s",
45
46
  });
46
47
  } else {
@@ -51,6 +52,7 @@ export const wk8006: PostSynthCheck = {
51
52
  severity: "warning",
52
53
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" uses :latest tag on image "${image}" — use a specific version tag`,
53
54
  entity: resourceName,
55
+ locator: containerLocator(manifest, container),
54
56
  lexicon: "k8s",
55
57
  });
56
58
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
10
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers";
11
11
 
12
12
  /**
13
13
  * Known API key patterns and their descriptions.
@@ -39,7 +39,7 @@ export const wk8041: PostSynthCheck = {
39
39
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
40
40
 
41
41
  const containers = extractContainers(manifest);
42
- const resourceName = manifest.metadata?.name ?? manifest.kind;
42
+ const resourceName = nameOf(manifest, manifest.kind);
43
43
 
44
44
  for (const container of containers) {
45
45
  if (!Array.isArray(container.env)) continue;
@@ -54,6 +54,7 @@ export const wk8041: PostSynthCheck = {
54
54
  severity: "error",
55
55
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has a ${label} hardcoded in env var "${envVar.name ?? "(unnamed)"}" — use a Secret reference instead`,
56
56
  entity: resourceName,
57
+ locator: containerLocator(manifest, container),
57
58
  lexicon: "k8s",
58
59
  });
59
60
  break; // One match per env var is sufficient
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { docsToManifests } from "./k8s-helpers";
10
+ import { docsToManifests, nameOf } from "./k8s-helpers";
11
11
 
12
12
  const PRIVATE_KEY_PATTERN = /-----BEGIN\s+[\w\s]*PRIVATE KEY-----/;
13
13
 
@@ -21,7 +21,7 @@ export const wk8042: PostSynthCheck = {
21
21
  for (const manifest of docsToManifests(ctx)) {
22
22
  if (manifest.kind !== "ConfigMap") continue;
23
23
 
24
- const resourceName = manifest.metadata?.name ?? "ConfigMap";
24
+ const resourceName = nameOf(manifest, "ConfigMap");
25
25
  const data = manifest.data;
26
26
  if (typeof data !== "object" || data === null) continue;
27
27
 
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { docsToManifests } from "./k8s-helpers";
10
+ import { docsToManifests, nameOf } from "./k8s-helpers";
11
11
 
12
12
  export const wk8101: PostSynthCheck = {
13
13
  id: "WK8101",
@@ -19,7 +19,7 @@ export const wk8101: PostSynthCheck = {
19
19
  for (const manifest of docsToManifests(ctx)) {
20
20
  if (manifest.kind !== "Deployment") continue;
21
21
 
22
- const resourceName = manifest.metadata?.name ?? "Deployment";
22
+ const resourceName = nameOf(manifest, "Deployment");
23
23
  const spec = manifest.spec;
24
24
  if (!spec) continue;
25
25
 
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
- import { docsToManifests } from "./k8s-helpers";
9
+ import { describeNonStringName, docsToManifests, nameOf } from "./k8s-helpers";
10
10
 
11
11
  export const wk8102: PostSynthCheck = {
12
12
  id: "WK8102",
@@ -18,14 +18,18 @@ export const wk8102: PostSynthCheck = {
18
18
  for (const manifest of docsToManifests(ctx)) {
19
19
  if (!manifest.kind || !manifest.metadata) continue;
20
20
 
21
- const resourceName = manifest.metadata.name ?? manifest.kind;
21
+ const resourceName = nameOf(manifest, manifest.kind);
22
22
  const labels = manifest.metadata.labels;
23
23
 
24
24
  if (!labels || typeof labels !== "object" || Object.keys(labels).length === 0) {
25
+ const notString = describeNonStringName(manifest);
26
+ const message = notString
27
+ ? `${manifest.kind} has no metadata.labels, and its metadata.name is ${notString}, not a string. This is most likely a template that is filled in before it is applied; audit the rendered manifest instead`
28
+ : `${manifest.kind} "${resourceName}" has no metadata.labels — add labels for organizational purposes`;
25
29
  diagnostics.push({
26
30
  checkId: "WK8102",
27
31
  severity: "warning",
28
- message: `${manifest.kind} "${resourceName}" has no metadata.labels — add labels for organizational purposes`,
32
+ message,
29
33
  entity: resourceName,
30
34
  lexicon: "k8s",
31
35
  });
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
9
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers";
10
10
 
11
11
  export const wk8103: PostSynthCheck = {
12
12
  id: "WK8103",
@@ -19,7 +19,7 @@ export const wk8103: PostSynthCheck = {
19
19
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
20
20
 
21
21
  const containers = extractContainers(manifest);
22
- const resourceName = manifest.metadata?.name ?? manifest.kind;
22
+ const resourceName = nameOf(manifest, manifest.kind);
23
23
 
24
24
  for (let i = 0; i < containers.length; i++) {
25
25
  const container = containers[i];
@@ -29,6 +29,7 @@ export const wk8103: PostSynthCheck = {
29
29
  severity: "error",
30
30
  message: `${manifest.kind} "${resourceName}" has a container at index ${i} without a name — the name field is required`,
31
31
  entity: resourceName,
32
+ locator: containerLocator(manifest, container),
32
33
  lexicon: "k8s",
33
34
  });
34
35
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
10
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers";
11
11
 
12
12
  export const wk8104: PostSynthCheck = {
13
13
  id: "WK8104",
@@ -17,7 +17,7 @@ export const wk8104: PostSynthCheck = {
17
17
  const diagnostics: PostSynthDiagnostic[] = [];
18
18
 
19
19
  for (const manifest of docsToManifests(ctx)) {
20
- const resourceName = manifest.metadata?.name ?? manifest.kind ?? "(unknown)";
20
+ const resourceName = nameOf(manifest, manifest.kind ?? "(unknown)");
21
21
 
22
22
  // Check container ports in workloads
23
23
  if (manifest.kind && WORKLOAD_KINDS.has(manifest.kind)) {
@@ -31,6 +31,7 @@ export const wk8104: PostSynthCheck = {
31
31
  severity: "warning",
32
32
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has an unnamed port (containerPort: ${port.containerPort ?? "?"}) — add a name for clarity`,
33
33
  entity: resourceName,
34
+ locator: containerLocator(manifest, container),
34
35
  lexicon: "k8s",
35
36
  });
36
37
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
10
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers";
11
11
 
12
12
  export const wk8105: PostSynthCheck = {
13
13
  id: "WK8105",
@@ -20,7 +20,7 @@ export const wk8105: PostSynthCheck = {
20
20
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
21
21
 
22
22
  const containers = extractContainers(manifest);
23
- const resourceName = manifest.metadata?.name ?? manifest.kind;
23
+ const resourceName = nameOf(manifest, manifest.kind);
24
24
 
25
25
  for (const container of containers) {
26
26
  if (!container.imagePullPolicy) {
@@ -29,6 +29,7 @@ export const wk8105: PostSynthCheck = {
29
29
  severity: "warning",
30
30
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has no explicit imagePullPolicy — set it to "Always", "IfNotPresent", or "Never"`,
31
31
  entity: resourceName,
32
+ locator: containerLocator(manifest, container),
32
33
  lexicon: "k8s",
33
34
  });
34
35
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
10
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers";
11
11
 
12
12
  export const wk8201: PostSynthCheck = {
13
13
  id: "WK8201",
@@ -20,7 +20,7 @@ export const wk8201: PostSynthCheck = {
20
20
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
21
21
 
22
22
  const containers = extractContainers(manifest);
23
- const resourceName = manifest.metadata?.name ?? manifest.kind;
23
+ const resourceName = nameOf(manifest, manifest.kind);
24
24
 
25
25
  for (const container of containers) {
26
26
  const limits = container.resources?.limits;
@@ -39,6 +39,7 @@ export const wk8201: PostSynthCheck = {
39
39
  severity: "warning",
40
40
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" is missing resource limits for ${missing.join(", ")}`,
41
41
  entity: resourceName,
42
+ locator: containerLocator(manifest, container),
42
43
  lexicon: "k8s",
43
44
  });
44
45
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
10
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers";
11
11
 
12
12
  export const wk8202: PostSynthCheck = {
13
13
  id: "WK8202",
@@ -20,7 +20,7 @@ export const wk8202: PostSynthCheck = {
20
20
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
21
21
 
22
22
  const containers = extractContainers(manifest);
23
- const resourceName = manifest.metadata?.name ?? manifest.kind;
23
+ const resourceName = nameOf(manifest, manifest.kind);
24
24
 
25
25
  for (const container of containers) {
26
26
  const secCtx = container.securityContext;
@@ -30,6 +30,7 @@ export const wk8202: PostSynthCheck = {
30
30
  severity: "error",
31
31
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" runs in privileged mode — this grants full host access and should be avoided`,
32
32
  entity: resourceName,
33
+ locator: containerLocator(manifest, container),
33
34
  lexicon: "k8s",
34
35
  });
35
36
  }