@intentius/chant-lexicon-k8s 0.124.97 → 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
@@ -4,6 +4,15 @@
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
  import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
9
18
  export declare const wk8005: PostSynthCheck;
@@ -1 +1 @@
1
- {"version":3,"file":"wk8005.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8005.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAK9G,eAAO,MAAM,MAAM,EAAE,cAwCpB,CAAC"}
1
+ {"version":3,"file":"wk8005.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8005.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AA8C9G,eAAO,MAAM,MAAM,EAAE,cA2CpB,CAAC"}
@@ -4,9 +4,56 @@
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
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
17
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
18
  const SENSITIVE_NAME_PATTERN = /password|token|key|secret/i;
19
+ const STRONG_NAME_PATTERN = /password|token|secret/i;
20
+ /** Words that make a following KEY a data field name rather than a credential. */
21
+ const STRUCTURAL_KEY_QUALIFIERS = new Set([
22
+ "message", "msg", "partition", "sort", "range", "hash", "primary", "foreign",
23
+ "shard", "routing", "index", "cache", "group", "order", "label", "field",
24
+ "timestamp", "level",
25
+ ]);
26
+ const FILE_SUFFIX_PATTERN = /(?:^|[_-])(?:file|path|dir|directory|filepath)$/i;
27
+ function nameTokens(name) {
28
+ return name
29
+ .replace(/([a-z0-9])([A-Z])/g, "$1_$2")
30
+ .split(/[^A-Za-z0-9]+/)
31
+ .filter(Boolean)
32
+ .map((t) => t.toLowerCase());
33
+ }
34
+ /** True when KEY is the only credential word and each KEY follows a structural qualifier. */
35
+ function isStructuralKeyName(name) {
36
+ if (STRONG_NAME_PATTERN.test(name))
37
+ return false;
38
+ const tokens = nameTokens(name);
39
+ let sawKey = false;
40
+ for (let i = 0; i < tokens.length; i++) {
41
+ if (!tokens[i].includes("key"))
42
+ continue;
43
+ sawKey = true;
44
+ if (tokens[i] !== "key" || i === 0 || !STRUCTURAL_KEY_QUALIFIERS.has(tokens[i - 1]))
45
+ return false;
46
+ }
47
+ return sawKey;
48
+ }
49
+ /** Absolute, home or explicitly relative path made only of path characters. */
50
+ function isPathValue(value) {
51
+ return /^(?:\/|~\/|\.{1,2}\/)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*\/?$/.test(value) ||
52
+ /^[A-Za-z]:[\\/][^\s]+$/.test(value);
53
+ }
54
+ function isFilePointer(name, value) {
55
+ return FILE_SUFFIX_PATTERN.test(name) && isPathValue(value);
56
+ }
10
57
  export const wk8005 = {
11
58
  id: "WK8005",
12
59
  description: "Hardcoded secrets in env vars — sensitive environment variables should use secretKeyRef",
@@ -16,23 +63,26 @@ export const wk8005 = {
16
63
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
17
64
  continue;
18
65
  const containers = extractContainers(manifest);
19
- const resourceName = manifest.metadata?.name ?? manifest.kind;
66
+ const resourceName = nameOf(manifest, manifest.kind);
20
67
  for (const container of containers) {
21
68
  if (!Array.isArray(container.env))
22
69
  continue;
23
70
  for (const envVar of container.env) {
24
71
  if (typeof envVar.name === "string" &&
25
72
  SENSITIVE_NAME_PATTERN.test(envVar.name) &&
73
+ !isStructuralKeyName(envVar.name) &&
26
74
  envVar.value !== undefined &&
27
75
  envVar.value !== null &&
28
76
  typeof envVar.value === "string" &&
29
77
  envVar.value !== "" &&
30
- !envVar.valueFrom) {
78
+ !envVar.valueFrom &&
79
+ !isFilePointer(envVar.name, envVar.value)) {
31
80
  diagnostics.push({
32
81
  checkId: "WK8005",
33
82
  severity: "error",
34
83
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has hardcoded value for sensitive env var "${envVar.name}" — use secretKeyRef instead`,
35
84
  entity: resourceName,
85
+ locator: containerLocator(manifest, container),
36
86
  lexicon: "k8s",
37
87
  });
38
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wk8006.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8006.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAoDpB,CAAC"}
1
+ {"version":3,"file":"wk8006.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8006.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAsDpB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * Container images should use explicit version tags for reproducibility.
5
5
  * Flags images using the `:latest` tag or no tag at all.
6
6
  */
7
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
7
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
8
8
  export const wk8006 = {
9
9
  id: "WK8006",
10
10
  description: "No :latest or untagged images — container images should use explicit version tags",
@@ -14,7 +14,7 @@ export const wk8006 = {
14
14
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
15
15
  continue;
16
16
  const containers = extractContainers(manifest);
17
- const resourceName = manifest.metadata?.name ?? manifest.kind;
17
+ const resourceName = nameOf(manifest, manifest.kind);
18
18
  for (const container of containers) {
19
19
  const image = container.image;
20
20
  if (typeof image !== "string" || image === "")
@@ -34,6 +34,7 @@ export const wk8006 = {
34
34
  severity: "warning",
35
35
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" uses untagged image "${image}" — specify an explicit version tag`,
36
36
  entity: resourceName,
37
+ locator: containerLocator(manifest, container),
37
38
  lexicon: "k8s",
38
39
  });
39
40
  }
@@ -45,6 +46,7 @@ export const wk8006 = {
45
46
  severity: "warning",
46
47
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" uses :latest tag on image "${image}" — use a specific version tag`,
47
48
  entity: resourceName,
49
+ locator: containerLocator(manifest, container),
48
50
  lexicon: "k8s",
49
51
  });
50
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wk8041.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8041.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAsB9G,eAAO,MAAM,MAAM,EAAE,cAqCpB,CAAC"}
1
+ {"version":3,"file":"wk8041.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8041.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAsB9G,eAAO,MAAM,MAAM,EAAE,cAsCpB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Catches Stripe keys, GitHub PATs, AWS access keys, Google API keys, and
6
6
  * other common credential formats.
7
7
  */
8
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  /**
10
10
  * Known API key patterns and their descriptions.
11
11
  */
@@ -33,7 +33,7 @@ export const wk8041 = {
33
33
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
34
34
  continue;
35
35
  const containers = extractContainers(manifest);
36
- const resourceName = manifest.metadata?.name ?? manifest.kind;
36
+ const resourceName = nameOf(manifest, manifest.kind);
37
37
  for (const container of containers) {
38
38
  if (!Array.isArray(container.env))
39
39
  continue;
@@ -47,6 +47,7 @@ export const wk8041 = {
47
47
  severity: "error",
48
48
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has a ${label} hardcoded in env var "${envVar.name ?? "(unnamed)"}" — use a Secret reference instead`,
49
49
  entity: resourceName,
50
+ locator: containerLocator(manifest, container),
50
51
  lexicon: "k8s",
51
52
  });
52
53
  break; // One match per env var is sufficient
@@ -5,7 +5,7 @@
5
5
  * Private keys should be stored in Secrets, not ConfigMaps, since
6
6
  * ConfigMaps are not encrypted at rest by default.
7
7
  */
8
- import { docsToManifests } from "./k8s-helpers.js";
8
+ import { docsToManifests, nameOf } from "./k8s-helpers.js";
9
9
  const PRIVATE_KEY_PATTERN = /-----BEGIN\s+[\w\s]*PRIVATE KEY-----/;
10
10
  export const wk8042 = {
11
11
  id: "WK8042",
@@ -15,7 +15,7 @@ export const wk8042 = {
15
15
  for (const manifest of docsToManifests(ctx)) {
16
16
  if (manifest.kind !== "ConfigMap")
17
17
  continue;
18
- const resourceName = manifest.metadata?.name ?? "ConfigMap";
18
+ const resourceName = nameOf(manifest, "ConfigMap");
19
19
  const data = manifest.data;
20
20
  if (typeof data !== "object" || data === null)
21
21
  continue;
@@ -5,7 +5,7 @@
5
5
  * spec.template.metadata.labels. If they don't match, the Deployment
6
6
  * controller cannot find the Pods it creates, causing a runtime failure.
7
7
  */
8
- import { docsToManifests } from "./k8s-helpers.js";
8
+ import { docsToManifests, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8101 = {
10
10
  id: "WK8101",
11
11
  description: "Deployment selector must match template labels — mismatched selectors cause runtime failures",
@@ -14,7 +14,7 @@ export const wk8101 = {
14
14
  for (const manifest of docsToManifests(ctx)) {
15
15
  if (manifest.kind !== "Deployment")
16
16
  continue;
17
- const resourceName = manifest.metadata?.name ?? "Deployment";
17
+ const resourceName = nameOf(manifest, "Deployment");
18
18
  const spec = manifest.spec;
19
19
  if (!spec)
20
20
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"wk8102.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8102.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA0BpB,CAAC"}
1
+ {"version":3,"file":"wk8102.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8102.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA8BpB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * All Kubernetes resources should have metadata.labels for organizational
5
5
  * purposes. Labels enable filtering, selection, and operational tooling.
6
6
  */
7
- import { docsToManifests } from "./k8s-helpers.js";
7
+ import { describeNonStringName, docsToManifests, nameOf } from "./k8s-helpers.js";
8
8
  export const wk8102 = {
9
9
  id: "WK8102",
10
10
  description: "Resources should have metadata labels — labels enable filtering and operational tooling",
@@ -13,13 +13,17 @@ export const wk8102 = {
13
13
  for (const manifest of docsToManifests(ctx)) {
14
14
  if (!manifest.kind || !manifest.metadata)
15
15
  continue;
16
- const resourceName = manifest.metadata.name ?? manifest.kind;
16
+ const resourceName = nameOf(manifest, manifest.kind);
17
17
  const labels = manifest.metadata.labels;
18
18
  if (!labels || typeof labels !== "object" || Object.keys(labels).length === 0) {
19
+ const notString = describeNonStringName(manifest);
20
+ const message = notString
21
+ ? `${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`
22
+ : `${manifest.kind} "${resourceName}" has no metadata.labels — add labels for organizational purposes`;
19
23
  diagnostics.push({
20
24
  checkId: "WK8102",
21
25
  severity: "warning",
22
- message: `${manifest.kind} "${resourceName}" has no metadata.labels — add labels for organizational purposes`,
26
+ message,
23
27
  entity: resourceName,
24
28
  lexicon: "k8s",
25
29
  });
@@ -1 +1 @@
1
- {"version":3,"file":"wk8103.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8103.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA6BpB,CAAC"}
1
+ {"version":3,"file":"wk8103.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8103.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA8BpB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * Every container in a pod spec must have a `name` field. This is required
5
5
  * by the Kubernetes API and will be rejected at apply time if missing.
6
6
  */
7
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
7
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
8
8
  export const wk8103 = {
9
9
  id: "WK8103",
10
10
  description: "Containers must have name — the name field is required by the Kubernetes API",
@@ -14,7 +14,7 @@ export const wk8103 = {
14
14
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
15
15
  continue;
16
16
  const containers = extractContainers(manifest);
17
- const resourceName = manifest.metadata?.name ?? manifest.kind;
17
+ const resourceName = nameOf(manifest, manifest.kind);
18
18
  for (let i = 0; i < containers.length; i++) {
19
19
  const container = containers[i];
20
20
  if (!container.name || typeof container.name !== "string" || container.name.trim() === "") {
@@ -23,6 +23,7 @@ export const wk8103 = {
23
23
  severity: "error",
24
24
  message: `${manifest.kind} "${resourceName}" has a container at index ${i} without a name — the name field is required`,
25
25
  entity: resourceName,
26
+ locator: containerLocator(manifest, container),
26
27
  lexicon: "k8s",
27
28
  });
28
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wk8104.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8104.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAoDpB,CAAC"}
1
+ {"version":3,"file":"wk8104.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8104.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAqDpB,CAAC"}
@@ -5,14 +5,14 @@
5
5
  * referencing by name in Service targetPort and NetworkPolicy rules,
6
6
  * improving maintainability.
7
7
  */
8
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8104 = {
10
10
  id: "WK8104",
11
11
  description: "Ports should be named — named ports improve Service and NetworkPolicy configuration",
12
12
  check(ctx) {
13
13
  const diagnostics = [];
14
14
  for (const manifest of docsToManifests(ctx)) {
15
- const resourceName = manifest.metadata?.name ?? manifest.kind ?? "(unknown)";
15
+ const resourceName = nameOf(manifest, manifest.kind ?? "(unknown)");
16
16
  // Check container ports in workloads
17
17
  if (manifest.kind && WORKLOAD_KINDS.has(manifest.kind)) {
18
18
  const containers = extractContainers(manifest);
@@ -26,6 +26,7 @@ export const wk8104 = {
26
26
  severity: "warning",
27
27
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has an unnamed port (containerPort: ${port.containerPort ?? "?"}) — add a name for clarity`,
28
28
  entity: resourceName,
29
+ locator: containerLocator(manifest, container),
29
30
  lexicon: "k8s",
30
31
  });
31
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wk8105.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8105.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA4BpB,CAAC"}
1
+ {"version":3,"file":"wk8105.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8105.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA6BpB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Kubernetes defaults to "Always" for :latest and "IfNotPresent" for
6
6
  * other tags, which can lead to unexpected behavior.
7
7
  */
8
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8105 = {
10
10
  id: "WK8105",
11
11
  description: "ImagePullPolicy should be explicit — avoids surprising default behavior",
@@ -15,7 +15,7 @@ export const wk8105 = {
15
15
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
16
16
  continue;
17
17
  const containers = extractContainers(manifest);
18
- const resourceName = manifest.metadata?.name ?? manifest.kind;
18
+ const resourceName = nameOf(manifest, manifest.kind);
19
19
  for (const container of containers) {
20
20
  if (!container.imagePullPolicy) {
21
21
  diagnostics.push({
@@ -23,6 +23,7 @@ export const wk8105 = {
23
23
  severity: "warning",
24
24
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has no explicit imagePullPolicy — set it to "Always", "IfNotPresent", or "Never"`,
25
25
  entity: resourceName,
26
+ locator: containerLocator(manifest, container),
26
27
  lexicon: "k8s",
27
28
  });
28
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wk8201.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8201.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAsCpB,CAAC"}
1
+ {"version":3,"file":"wk8201.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8201.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAuCpB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Without limits, a container can consume unbounded resources, potentially
6
6
  * affecting other workloads on the node.
7
7
  */
8
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8201 = {
10
10
  id: "WK8201",
11
11
  description: "Resource limits required — containers should have CPU and memory limits",
@@ -15,7 +15,7 @@ export const wk8201 = {
15
15
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
16
16
  continue;
17
17
  const containers = extractContainers(manifest);
18
- const resourceName = manifest.metadata?.name ?? manifest.kind;
18
+ const resourceName = nameOf(manifest, manifest.kind);
19
19
  for (const container of containers) {
20
20
  const limits = container.resources?.limits;
21
21
  const missing = [];
@@ -34,6 +34,7 @@ export const wk8201 = {
34
34
  severity: "warning",
35
35
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" is missing resource limits for ${missing.join(", ")}`,
36
36
  entity: resourceName,
37
+ locator: containerLocator(manifest, container),
37
38
  lexicon: "k8s",
38
39
  });
39
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wk8202.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8202.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA6BpB,CAAC"}
1
+ {"version":3,"file":"wk8202.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8202.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA8BpB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * have full access to the host's devices and kernel capabilities,
6
6
  * which is a significant security risk.
7
7
  */
8
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8202 = {
10
10
  id: "WK8202",
11
11
  description: "No privileged containers — privileged mode grants full host access",
@@ -15,7 +15,7 @@ export const wk8202 = {
15
15
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
16
16
  continue;
17
17
  const containers = extractContainers(manifest);
18
- const resourceName = manifest.metadata?.name ?? manifest.kind;
18
+ const resourceName = nameOf(manifest, manifest.kind);
19
19
  for (const container of containers) {
20
20
  const secCtx = container.securityContext;
21
21
  if (secCtx && secCtx.privileged === true) {
@@ -24,6 +24,7 @@ export const wk8202 = {
24
24
  severity: "error",
25
25
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" runs in privileged mode — this grants full host access and should be avoided`,
26
26
  entity: resourceName,
27
+ locator: containerLocator(manifest, container),
27
28
  lexicon: "k8s",
28
29
  });
29
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wk8203.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8203.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA6BpB,CAAC"}
1
+ {"version":3,"file":"wk8203.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8203.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA8BpB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * A read-only root filesystem prevents runtime modification of the container
6
6
  * image, reducing the attack surface.
7
7
  */
8
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8203 = {
10
10
  id: "WK8203",
11
11
  description: "ReadOnlyRootFilesystem recommended — prevents runtime modification of the container image",
@@ -15,7 +15,7 @@ export const wk8203 = {
15
15
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
16
16
  continue;
17
17
  const containers = extractContainers(manifest);
18
- const resourceName = manifest.metadata?.name ?? manifest.kind;
18
+ const resourceName = nameOf(manifest, manifest.kind);
19
19
  for (const container of containers) {
20
20
  const secCtx = container.securityContext;
21
21
  if (!secCtx || secCtx.readOnlyRootFilesystem !== true) {
@@ -24,6 +24,7 @@ export const wk8203 = {
24
24
  severity: "warning",
25
25
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" does not set readOnlyRootFilesystem: true — set it to reduce the attack surface`,
26
26
  entity: resourceName,
27
+ locator: containerLocator(manifest, container),
27
28
  lexicon: "k8s",
28
29
  });
29
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wk8204.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8204.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAiEpB,CAAC"}
1
+ {"version":3,"file":"wk8204.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8204.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAoEpB,CAAC"}
@@ -9,7 +9,7 @@
9
9
  * runAsUser is provided — without a numeric UID, K8s relies on the
10
10
  * image's USER directive, which may be root (UID 0).
11
11
  */
12
- import { docsToManifests, extractContainers, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers.js";
12
+ import { docsToManifests, extractContainers, containerLocator, extractPodSpec, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
13
13
  export const wk8204 = {
14
14
  id: "WK8204",
15
15
  description: "RunAsNonRoot recommended — running as root increases container breakout risk",
@@ -18,7 +18,7 @@ export const wk8204 = {
18
18
  for (const manifest of docsToManifests(ctx)) {
19
19
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
20
20
  continue;
21
- const resourceName = manifest.metadata?.name ?? manifest.kind;
21
+ const resourceName = nameOf(manifest, manifest.kind);
22
22
  const podSpec = extractPodSpec(manifest);
23
23
  if (!podSpec)
24
24
  continue;
@@ -38,6 +38,7 @@ export const wk8204 = {
38
38
  severity: "warning",
39
39
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" does not set runAsNonRoot: true — set it at container or pod level`,
40
40
  entity: resourceName,
41
+ locator: containerLocator(manifest, container),
41
42
  lexicon: "k8s",
42
43
  });
43
44
  continue;
@@ -51,6 +52,7 @@ export const wk8204 = {
51
52
  severity: "warning",
52
53
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has runAsNonRoot: true but runAsUser: 0 — these settings are contradictory and the container will fail to start`,
53
54
  entity: resourceName,
55
+ locator: containerLocator(manifest, container),
54
56
  lexicon: "k8s",
55
57
  });
56
58
  }
@@ -61,6 +63,7 @@ export const wk8204 = {
61
63
  severity: "warning",
62
64
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has runAsNonRoot: true but no explicit runAsUser — set a numeric UID to ensure the container doesn't run as root`,
63
65
  entity: resourceName,
66
+ locator: containerLocator(manifest, container),
64
67
  lexicon: "k8s",
65
68
  });
66
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wk8205.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8205.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAuCpB,CAAC"}
1
+ {"version":3,"file":"wk8205.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8205.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAwCpB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * explicitly needed. This follows the principle of least privilege and
6
6
  * reduces the attack surface.
7
7
  */
8
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8205 = {
10
10
  id: "WK8205",
11
11
  description: "Drop ALL capabilities — containers should drop all capabilities and add only what is needed",
@@ -15,7 +15,7 @@ export const wk8205 = {
15
15
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
16
16
  continue;
17
17
  const containers = extractContainers(manifest);
18
- const resourceName = manifest.metadata?.name ?? manifest.kind;
18
+ const resourceName = nameOf(manifest, manifest.kind);
19
19
  for (const container of containers) {
20
20
  const secCtx = container.securityContext;
21
21
  const capabilities = secCtx?.capabilities;
@@ -28,6 +28,7 @@ export const wk8205 = {
28
28
  severity: "warning",
29
29
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" does not drop ALL capabilities — add securityContext.capabilities.drop: ["ALL"]`,
30
30
  entity: resourceName,
31
+ locator: containerLocator(manifest, container),
31
32
  lexicon: "k8s",
32
33
  });
33
34
  }
@@ -5,7 +5,7 @@
5
5
  * bypasses network isolation and allows the pod to access all network
6
6
  * interfaces on the host.
7
7
  */
8
- import { docsToManifests, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractPodSpec, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8207 = {
10
10
  id: "WK8207",
11
11
  description: "No hostNetwork — using host network bypasses network isolation",
@@ -17,7 +17,7 @@ export const wk8207 = {
17
17
  const podSpec = extractPodSpec(manifest);
18
18
  if (!podSpec)
19
19
  continue;
20
- const resourceName = manifest.metadata?.name ?? manifest.kind;
20
+ const resourceName = nameOf(manifest, manifest.kind);
21
21
  if (podSpec.hostNetwork === true) {
22
22
  diagnostics.push({
23
23
  checkId: "WK8207",
@@ -5,7 +5,7 @@
5
5
  * allows the pod to see and interact with all processes on the host,
6
6
  * which is a significant security risk.
7
7
  */
8
- import { docsToManifests, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractPodSpec, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8208 = {
10
10
  id: "WK8208",
11
11
  description: "No hostPID — sharing host PID namespace allows visibility into all host processes",
@@ -17,7 +17,7 @@ export const wk8208 = {
17
17
  const podSpec = extractPodSpec(manifest);
18
18
  if (!podSpec)
19
19
  continue;
20
- const resourceName = manifest.metadata?.name ?? manifest.kind;
20
+ const resourceName = nameOf(manifest, manifest.kind);
21
21
  if (podSpec.hostPID === true) {
22
22
  diagnostics.push({
23
23
  checkId: "WK8208",
@@ -5,7 +5,7 @@
5
5
  * allows the pod to access shared memory segments on the host, which
6
6
  * can be used to escalate privileges or exfiltrate data.
7
7
  */
8
- import { docsToManifests, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractPodSpec, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8209 = {
10
10
  id: "WK8209",
11
11
  description: "No hostIPC — sharing host IPC namespace can expose shared memory segments",
@@ -17,7 +17,7 @@ export const wk8209 = {
17
17
  const podSpec = extractPodSpec(manifest);
18
18
  if (!podSpec)
19
19
  continue;
20
- const resourceName = manifest.metadata?.name ?? manifest.kind;
20
+ const resourceName = nameOf(manifest, manifest.kind);
21
21
  if (podSpec.hostIPC === true) {
22
22
  diagnostics.push({
23
23
  checkId: "WK8209",
@@ -1 +1 @@
1
- {"version":3,"file":"wk8301.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8301.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAqCpB,CAAC"}
1
+ {"version":3,"file":"wk8301.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8301.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAsCpB,CAAC"}
@@ -10,7 +10,7 @@
10
10
  * HTTP-probe and no readiness signal for a Service to gate on. Flagging them
11
11
  * would force a placeholder exec probe on a correct, port-less pattern.
12
12
  */
13
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
13
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
14
14
  export const wk8301 = {
15
15
  id: "WK8301",
16
16
  description: "Probes required — containers should have livenessProbe and readinessProbe",
@@ -23,7 +23,7 @@ export const wk8301 = {
23
23
  if (manifest.kind === "Job" || manifest.kind === "CronJob")
24
24
  continue;
25
25
  const containers = extractContainers(manifest);
26
- const resourceName = manifest.metadata?.name ?? manifest.kind;
26
+ const resourceName = nameOf(manifest, manifest.kind);
27
27
  for (const container of containers) {
28
28
  // No declared port → no inbound traffic → nothing to HTTP-probe.
29
29
  if (!container.ports || container.ports.length === 0)
@@ -39,6 +39,7 @@ export const wk8301 = {
39
39
  severity: "warning",
40
40
  message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" is missing ${missing.join(" and ")}`,
41
41
  entity: resourceName,
42
+ locator: containerLocator(manifest, container),
42
43
  lexicon: "k8s",
43
44
  });
44
45
  }
@@ -4,7 +4,7 @@
4
4
  * Deployments should have at least 2 replicas for high availability.
5
5
  * A single replica means any pod disruption causes downtime.
6
6
  */
7
- import { docsToManifests } from "./k8s-helpers.js";
7
+ import { docsToManifests, nameOf } from "./k8s-helpers.js";
8
8
  export const wk8302 = {
9
9
  id: "WK8302",
10
10
  description: "Replicas >= 2 recommended — single-replica Deployments have no high availability",
@@ -13,7 +13,7 @@ export const wk8302 = {
13
13
  for (const manifest of docsToManifests(ctx)) {
14
14
  if (manifest.kind !== "Deployment")
15
15
  continue;
16
- const resourceName = manifest.metadata?.name ?? "Deployment";
16
+ const resourceName = nameOf(manifest, "Deployment");
17
17
  const spec = manifest.spec;
18
18
  if (!spec)
19
19
  continue;