@intentius/chant-lexicon-k8s 0.124.103 → 0.124.104

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "b99accdbf26e50527cad56bf9d5fafbe5f9621d2649c3c9b0ddad03c3f46a756",
4
+ "manifest.json": "d5a9bb6c2fd59c10e931d4094c1c3435b22eddc7b94b6d39d2974fd356c59285",
5
5
  "meta.json": "c8a4cb1d36eba59a277083c8b888b150b025384e429b26db4203ec748d5e7f08",
6
6
  "types/index.d.ts": "35f6ca4fa77c28ecad363920b444f27ab72f0fe49e82eb20e42824c312ac689b",
7
7
  "rules/argo-appset-single-project.ts": "afa9f310753aa2d475f35012b13135b2dfaebed2a35d44edbe185ebc07673674",
@@ -80,5 +80,5 @@
80
80
  "skills/chant-k8s-argo.md": "24c9a85b78a2fc5c6657424baac9cc6d6caff6f47605b8146b2c0082133181cf",
81
81
  "skills/chant-k8s-flux.md": "9670efc2e9854bd14686b5adeb707396b9030a4dcaee6529b30abf56efe2c50c"
82
82
  },
83
- "composite": "c81d25d37b71408ceaaa47f66ad55d5cbae309d62834df3515af1b436cbdb0b5"
83
+ "composite": "05f59716dd3139938482d4f6d40b73bc9bab8363ff32c0068520d2c128379d1e"
84
84
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k8s",
3
- "version": "0.124.103",
3
+ "version": "0.124.104",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "K8s",
6
6
  "intrinsics": [],
@@ -151,6 +151,30 @@ const POD_SPECS = [
151
151
  ["K8s::Batch::Job", "spec.template.spec"],
152
152
  ["K8s::Batch::CronJob", "spec.jobTemplate.spec.template.spec"],
153
153
  ];
154
+ /**
155
+ * Namespaced built-in kinds a cluster lists that no rule here reads by name:
156
+ * they get the `in namespace` containment edge and nothing else (#5284). Their
157
+ * namespace is a short word as often as not (`shop`), which the identity pass
158
+ * skips, so without a rule here an Endpoints or an EndpointSlice sits in no
159
+ * namespace.
160
+ */
161
+ const CONTAINED_KINDS = [
162
+ "K8s::Core::Endpoints",
163
+ "K8s::Discovery::EndpointSlice",
164
+ "K8s::Apps::ControllerRevision",
165
+ "K8s::Core::ReplicationController",
166
+ "K8s::Core::PodTemplate",
167
+ "K8s::Core::ResourceQuota",
168
+ "K8s::Core::LimitRange",
169
+ "K8s::Core::Event",
170
+ "K8s::Events::Event",
171
+ "K8s::Coordination::Lease",
172
+ "K8s::Coordination::LeaseCandidate",
173
+ "K8s::Resource::ResourceClaim",
174
+ "K8s::Resource::ResourceClaimTemplate",
175
+ "K8s::Storage::CSIStorageCapacity",
176
+ "K8s::Certificates::PodCertificateRequest",
177
+ ];
154
178
  /** Kinds that sit in a namespace, so `metadata.namespace` places them. */
155
179
  const NAMESPACED_KINDS = [
156
180
  ...POD_SPECS.map(([kind]) => kind),
@@ -229,6 +253,43 @@ function roleRefRules(from, roleKinds) {
229
253
  },
230
254
  }));
231
255
  }
256
+ /**
257
+ * A binding's `subjects` name a ServiceAccount by `name` and `namespace`
258
+ * (#5284). The subject's own namespace says where the account is: a RoleBinding
259
+ * in `shop2` can name `shop/web-sa`, and a ClusterRoleBinding, which sits in no
260
+ * namespace, reaches its account only through that field. A subject with no
261
+ * namespace is the binding's own namespace for a RoleBinding, and names nothing
262
+ * on a ClusterRoleBinding. Only `kind: ServiceAccount` subjects are read: a
263
+ * User or a Group of the same name is not an account.
264
+ */
265
+ function subjectRules(from, inOwnNamespace) {
266
+ return [
267
+ {
268
+ from,
269
+ path: "subjects[].name",
270
+ targetKind: "K8s::Core::ServiceAccount",
271
+ relation: "reference",
272
+ label: "grants",
273
+ optional: true,
274
+ join(holder, find) {
275
+ const subjects = holder.attrs.subjects;
276
+ if (!Array.isArray(subjects))
277
+ return [];
278
+ const out = [];
279
+ for (const s of subjects) {
280
+ if (!s || s.kind !== "ServiceAccount" || typeof s.name !== "string" || s.name === "")
281
+ continue;
282
+ const ns = typeof s.namespace === "string" && s.namespace !== "" ? s.namespace : undefined;
283
+ if (ns === undefined && !inOwnNamespace)
284
+ continue;
285
+ const found = ns === undefined ? find(s.name) : find(s.name, ns);
286
+ out.push({ value: ns === undefined ? s.name : `${ns}/${s.name}`, targets: found.filter((n) => n.kind === "K8s::Core::ServiceAccount"), via: "subjects" });
287
+ }
288
+ return out;
289
+ },
290
+ },
291
+ ];
292
+ }
232
293
  /** What a pod spec names: its service account, mounted config and secrets, claims, pull secrets. */
233
294
  function podSpecRules(kind, p) {
234
295
  const containers = [`${p}.containers[]`, `${p}.initContainers[]`];
@@ -430,7 +491,7 @@ const identityRules = [
430
491
  ];
431
492
  const refs = [
432
493
  // ── containment: the namespace an object is in ──
433
- ...NAMESPACED_KINDS.map((kind) => ref(kind, "metadata.namespace", "K8s::Core::Namespace", "in namespace", "containment")),
494
+ ...[...NAMESPACED_KINDS, ...CONTAINED_KINDS].map((kind) => ref(kind, "metadata.namespace", "K8s::Core::Namespace", "in namespace", "containment")),
434
495
  // ── owner references, by name inside the namespace ──
435
496
  ...anyOf("K8s::Core::Pod", "metadata.ownerReferences[].name", ["K8s::Apps::ReplicaSet", "K8s::Apps::StatefulSet", "K8s::Apps::DaemonSet", "K8s::Batch::Job"], "owned by"),
436
497
  ...anyOf("K8s::Apps::ReplicaSet", "metadata.ownerReferences[].name", ["K8s::Apps::Deployment"], "owned by"),
@@ -453,9 +514,9 @@ const refs = [
453
514
  ref("K8s::Core::PersistentVolumeClaim", "spec.storageClassName", "K8s::Storage::StorageClass", "class"),
454
515
  ref("K8s::Core::PersistentVolume", "spec.storageClassName", "K8s::Storage::StorageClass", "class"),
455
516
  ...roleRefRules("K8s::Rbac::RoleBinding", ["K8s::Rbac::Role", "K8s::Rbac::ClusterRole"]),
456
- ...anyOf("K8s::Rbac::RoleBinding", "subjects[].name", ["K8s::Core::ServiceAccount"], "grants"),
517
+ ...subjectRules("K8s::Rbac::RoleBinding", true),
457
518
  ...roleRefRules("K8s::Rbac::ClusterRoleBinding", ["K8s::Rbac::ClusterRole"]),
458
- ...anyOf("K8s::Rbac::ClusterRoleBinding", "subjects[].name", ["K8s::Core::ServiceAccount"], "grants"),
519
+ ...subjectRules("K8s::Rbac::ClusterRoleBinding", false),
459
520
  ref("K8s::Core::ServiceAccount", "secrets[].name", "K8s::Core::Secret", "token"),
460
521
  ref("K8s::Core::ServiceAccount", "imagePullSecrets[].name", "K8s::Core::Secret", "pulls with"),
461
522
  // ── External Secrets: the store, and the cloud secret through it ──
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-k8s",
3
- "version": "0.124.103",
3
+ "version": "0.124.104",
4
4
  "description": "Kubernetes lexicon for chant — declarative IaC in TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "peerDependencies": {
87
87
  "zod": "^4.3.6",
88
- "@intentius/chant": "^0.124.104",
88
+ "@intentius/chant": "^0.124.105",
89
89
  "@intentius/chant-k8s-client": "^0.124.101"
90
90
  },
91
91
  "peerDependenciesMeta": {