@intentius/chant-lexicon-k8s 0.124.102 → 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.
- package/dist/index-identity.d.ts +5 -1
- package/dist/index-identity.js +33 -3
- package/dist/integrity.json +2 -2
- package/dist/listed-types.d.ts +4 -2
- package/dist/listed-types.js +20 -3
- package/dist/manifest.json +1 -1
- package/dist/reference-catalog.js +153 -10
- package/package.json +2 -2
package/dist/index-identity.d.ts
CHANGED
|
@@ -44,7 +44,11 @@ export declare const K8S_UID_CLOUD_ID = "k8s-uid";
|
|
|
44
44
|
* none. `table` is the generated operation surface; a test passes one.
|
|
45
45
|
*/
|
|
46
46
|
export declare function k8sDeclaredIdentity(entityType: string, props: Record<string, unknown>, table?: K8sOperationTable): DeclaredIdentity;
|
|
47
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The values that name an indexed k8s object: its `<namespace>/<name>` and
|
|
49
|
+
* its uid. A cluster-scoped object's bare name names it only at the field of
|
|
50
|
+
* its kind ({@link CLUSTER_NAME_FIELDS}).
|
|
51
|
+
*/
|
|
48
52
|
export declare function k8sNodeIdentities(node: IRNode): NodeIdentityValue[];
|
|
49
53
|
export declare function createK8sIndexIdentity(table?: K8sOperationTable): IndexIdentity;
|
|
50
54
|
export declare const k8sIndexIdentity: IndexIdentity;
|
package/dist/index-identity.js
CHANGED
|
@@ -58,11 +58,41 @@ export function k8sDeclaredIdentity(entityType, props, table) {
|
|
|
58
58
|
}
|
|
59
59
|
return { kind: "identifier", listedType, identifier: `${namespace}/${name}`, global: false, location: namespace, entityKind: entityType };
|
|
60
60
|
}
|
|
61
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* The fields a cluster-scoped kind's bare name is a reference at (#5250). A
|
|
63
|
+
* name is unique only among objects of its kind, so the same string at any
|
|
64
|
+
* other field names something else: a ServiceAccount called `default` is not
|
|
65
|
+
* the Namespace `default`, and a ServiceCIDR called `kubernetes` is not the
|
|
66
|
+
* Service. A kind absent here has no bare-name identity; its references are
|
|
67
|
+
* the catalog's, which name the kind.
|
|
68
|
+
*/
|
|
69
|
+
const CLUSTER_NAME_FIELDS = {
|
|
70
|
+
"K8s::Core::Namespace": ["namespace"],
|
|
71
|
+
"K8s::Core::Node": ["nodeName"],
|
|
72
|
+
"K8s::Scheduling::PriorityClass": ["priorityClassName"],
|
|
73
|
+
"K8s::Flowcontrol::PriorityLevelConfiguration": ["priorityLevelConfiguration.name"],
|
|
74
|
+
};
|
|
75
|
+
/** Cluster-scoped kinds whose names are unambiguous values (an address) and so name the object at any field. */
|
|
76
|
+
const CLUSTER_NAME_ANYWHERE = new Set(["K8s::Networking::IPAddress"]);
|
|
77
|
+
/**
|
|
78
|
+
* The values that name an indexed k8s object: its `<namespace>/<name>` and
|
|
79
|
+
* its uid. A cluster-scoped object's bare name names it only at the field of
|
|
80
|
+
* its kind ({@link CLUSTER_NAME_FIELDS}).
|
|
81
|
+
*/
|
|
62
82
|
export function k8sNodeIdentities(node) {
|
|
63
83
|
const out = [];
|
|
64
|
-
if (node.nativeId)
|
|
65
|
-
|
|
84
|
+
if (node.nativeId) {
|
|
85
|
+
if (!node.nativeId.includes("/") && node.location === K8S_CLUSTER_LOCATION) {
|
|
86
|
+
const paths = CLUSTER_NAME_FIELDS[node.kind];
|
|
87
|
+
if (paths)
|
|
88
|
+
out.push({ kind: "native-id", value: node.nativeId, paths });
|
|
89
|
+
else if (CLUSTER_NAME_ANYWHERE.has(node.kind))
|
|
90
|
+
out.push({ kind: "native-id", value: node.nativeId });
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
out.push({ kind: "native-id", value: node.nativeId });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
66
96
|
for (const c of node.facts?.cloudIds ?? [])
|
|
67
97
|
if (c.kind === K8S_UID_CLOUD_ID)
|
|
68
98
|
out.push({ kind: c.kind, value: c.value });
|
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
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": "
|
|
83
|
+
"composite": "05f59716dd3139938482d4f6d40b73bc9bab8363ff32c0068520d2c128379d1e"
|
|
84
84
|
}
|
package/dist/listed-types.d.ts
CHANGED
|
@@ -24,8 +24,10 @@ export declare function k8sListedTypeFor(apiVersion: string, kind: string): stri
|
|
|
24
24
|
export declare function k8sKindByRule(listedType: string): string | undefined;
|
|
25
25
|
/**
|
|
26
26
|
* The k8s kind for a discovery type, or undefined. The rule's answer must be
|
|
27
|
-
* a kind the lexicon generated
|
|
28
|
-
* stands, as the lexicon's own discovery sweep
|
|
27
|
+
* a kind the lexicon generated or the reference catalog names; with nothing
|
|
28
|
+
* generated the rule's answer stands, as the lexicon's own discovery sweep
|
|
29
|
+
* does. A catalog kind is built as a generated one is: `k8sObservedTree` and
|
|
30
|
+
* the deep hooks do not depend on which list named the kind.
|
|
29
31
|
*/
|
|
30
32
|
export declare function k8sKindForListedType(listedType: string, kinds?: ReadonlySet<string> | null): string | undefined;
|
|
31
33
|
/** A listed object in the tree the deep reader compares. */
|
package/dist/listed-types.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { operationTable } from "./api/operation-surface.js";
|
|
2
2
|
import { namespaceSegmentForGroup } from "./group-namespace.js";
|
|
3
|
+
import { k8sReferenceCatalog } from "./reference-catalog.js";
|
|
3
4
|
/** `apps/v1/Deployment` or `v1/Pod` as its group, version and kind. */
|
|
4
5
|
export function parseListedGvk(listedType) {
|
|
5
6
|
const parts = listedType.split("/");
|
|
@@ -29,16 +30,32 @@ function generatedKinds() {
|
|
|
29
30
|
cachedKinds = Object.keys(table).length > 0 ? new Set(Object.keys(table)) : null;
|
|
30
31
|
return cachedKinds;
|
|
31
32
|
}
|
|
33
|
+
let cachedCatalogKinds;
|
|
34
|
+
/** The k8s kinds the reference catalog names (#5244), as its rules read them: an ExternalSecret and its stores are among them, generated or not. */
|
|
35
|
+
function catalogKinds() {
|
|
36
|
+
if (cachedCatalogKinds)
|
|
37
|
+
return cachedCatalogKinds;
|
|
38
|
+
const { identities, refs } = k8sReferenceCatalog;
|
|
39
|
+
const names = [...identities.map((r) => r.kind), ...refs.flatMap((r) => [r.from, r.targetKind])];
|
|
40
|
+
const kinds = new Set();
|
|
41
|
+
for (const k of names)
|
|
42
|
+
if (k?.startsWith("K8s::"))
|
|
43
|
+
kinds.add(k);
|
|
44
|
+
cachedCatalogKinds = kinds;
|
|
45
|
+
return kinds;
|
|
46
|
+
}
|
|
32
47
|
/**
|
|
33
48
|
* The k8s kind for a discovery type, or undefined. The rule's answer must be
|
|
34
|
-
* a kind the lexicon generated
|
|
35
|
-
* stands, as the lexicon's own discovery sweep
|
|
49
|
+
* a kind the lexicon generated or the reference catalog names; with nothing
|
|
50
|
+
* generated the rule's answer stands, as the lexicon's own discovery sweep
|
|
51
|
+
* does. A catalog kind is built as a generated one is: `k8sObservedTree` and
|
|
52
|
+
* the deep hooks do not depend on which list named the kind.
|
|
36
53
|
*/
|
|
37
54
|
export function k8sKindForListedType(listedType, kinds = generatedKinds()) {
|
|
38
55
|
const kind = k8sKindByRule(listedType);
|
|
39
56
|
if (kind === undefined)
|
|
40
57
|
return undefined;
|
|
41
|
-
if (kinds && !kinds.has(kind))
|
|
58
|
+
if (kinds && !kinds.has(kind) && !catalogKinds().has(kind))
|
|
42
59
|
return undefined;
|
|
43
60
|
return kind;
|
|
44
61
|
}
|
package/dist/manifest.json
CHANGED
|
@@ -40,9 +40,10 @@ import { readPath } from "@intentius/chant/graph-refs";
|
|
|
40
40
|
* (behold#166's case: `ASSET_BUCKET` set to the bucket's `BucketName`). The
|
|
41
41
|
* env-value rules join such a value to an `AWS::S3::Bucket` of that name, and
|
|
42
42
|
* are `optional`, since most env values name nothing. Over an index the
|
|
43
|
-
* cluster and the AWS account are two scopes, so the join
|
|
44
|
-
*
|
|
45
|
-
*
|
|
43
|
+
* cluster and the AWS account are two scopes, so the join draws in the
|
|
44
|
+
* catalog pass over a composed graph (`runCatalogPass`), where a cloud
|
|
45
|
+
* resource sits in the scope every namespace reaches: a declared one, or an
|
|
46
|
+
* indexed one handed over beside the cluster (#5245).
|
|
46
47
|
*
|
|
47
48
|
* ## External Secrets (#5098)
|
|
48
49
|
*
|
|
@@ -65,6 +66,23 @@ import { readPath } from "@intentius/chant/graph-refs";
|
|
|
65
66
|
* whose `secret_id` or `project` is a variable matches nothing. An AWS secret
|
|
66
67
|
* matches on its name alone when it sets no literal `region`.
|
|
67
68
|
*
|
|
69
|
+
* ## What a cloud index holds (#5245)
|
|
70
|
+
*
|
|
71
|
+
* The same keys and annotations join the nodes `chant index` writes, when a
|
|
72
|
+
* caller hands them to the catalog pass beside the cluster (catalog-edges.ts
|
|
73
|
+
* in core says how they share a scope). A key joins an
|
|
74
|
+
* `AWS::SecretsManager::Secret` by its `Name` (the aws catalog's identity) or
|
|
75
|
+
* its ARN, kept when the node's location, or the region its ARN names, is
|
|
76
|
+
* the store's `region`; and a `GCP::Secretmanager::Secret` whose Cloud Asset
|
|
77
|
+
* name is `//secretmanager.googleapis.com/projects/<projectID>/secrets/<key>`,
|
|
78
|
+
* so a store must name the project as the index does (Cloud Asset may name it
|
|
79
|
+
* by number). The IRSA annotation joins an `AWS::IAM::Role` whose ARN (its
|
|
80
|
+
* `Arn`, or an arn cloud id) is the annotation, or whose `RoleName` and
|
|
81
|
+
* `Path` are the ARN's and whose ARN names the same account. A role whose
|
|
82
|
+
* account cannot be read gets no edge. Each of these rules shares its id
|
|
83
|
+
* with the rule for the terraform kind, so a value one of them joins is not
|
|
84
|
+
* dangling under the other.
|
|
85
|
+
*
|
|
68
86
|
* ## Argo CD clusters (#5101)
|
|
69
87
|
*
|
|
70
88
|
* An Application's `spec.destination.name` or `.server` joins the cluster
|
|
@@ -133,6 +151,30 @@ const POD_SPECS = [
|
|
|
133
151
|
["K8s::Batch::Job", "spec.template.spec"],
|
|
134
152
|
["K8s::Batch::CronJob", "spec.jobTemplate.spec.template.spec"],
|
|
135
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
|
+
];
|
|
136
178
|
/** Kinds that sit in a namespace, so `metadata.namespace` places them. */
|
|
137
179
|
const NAMESPACED_KINDS = [
|
|
138
180
|
...POD_SPECS.map(([kind]) => kind),
|
|
@@ -188,6 +230,66 @@ const identities = [
|
|
|
188
230
|
];
|
|
189
231
|
const ref = (from, path, targetKind, label, relation = "reference") => ({ from, path, targetKind, relation, label });
|
|
190
232
|
const anyOf = (from, path, targetKinds, label) => targetKinds.map((targetKind) => ({ from, path, targetKind, relation: "reference", label, optional: true }));
|
|
233
|
+
/**
|
|
234
|
+
* A binding's `roleRef` names a role by `kind` and `name` (#5250), so a Role and
|
|
235
|
+
* a ClusterRole of one name are two objects and the binding reaches the one its
|
|
236
|
+
* `kind` says. One rule per role kind, each reading only the references of its
|
|
237
|
+
* own kind; a `roleRef` with no kind names neither.
|
|
238
|
+
*/
|
|
239
|
+
function roleRefRules(from, roleKinds) {
|
|
240
|
+
return roleKinds.map((targetKind) => ({
|
|
241
|
+
from,
|
|
242
|
+
path: "roleRef.name",
|
|
243
|
+
targetKind,
|
|
244
|
+
relation: "reference",
|
|
245
|
+
label: "binds",
|
|
246
|
+
optional: true,
|
|
247
|
+
join(holder, find) {
|
|
248
|
+
const name = first(holder, "roleRef.name");
|
|
249
|
+
const kind = first(holder, "roleRef.kind");
|
|
250
|
+
if (name === undefined || kind === undefined || `K8s::Rbac::${kind}` !== targetKind)
|
|
251
|
+
return [];
|
|
252
|
+
return [{ value: name, targets: find(name).filter((n) => n.kind === targetKind) }];
|
|
253
|
+
},
|
|
254
|
+
}));
|
|
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
|
+
}
|
|
191
293
|
/** What a pod spec names: its service account, mounted config and secrets, claims, pull secrets. */
|
|
192
294
|
function podSpecRules(kind, p) {
|
|
193
295
|
const containers = [`${p}.containers[]`, `${p}.initContainers[]`];
|
|
@@ -244,7 +346,7 @@ function storeOf(holder, find) {
|
|
|
244
346
|
* key names inside the scope its store names, `inScope` deciding what counts
|
|
245
347
|
* as inside. Reads only the ExternalSecrets whose store is of `provider`.
|
|
246
348
|
*/
|
|
247
|
-
function secretRule(path, targetKind, provider, inScope) {
|
|
349
|
+
function secretRule(path, targetKind, provider, inScope, names = (key) => [key]) {
|
|
248
350
|
return {
|
|
249
351
|
from: EXTERNAL_SECRET,
|
|
250
352
|
path,
|
|
@@ -258,18 +360,30 @@ function secretRule(path, targetKind, provider, inScope) {
|
|
|
258
360
|
return [];
|
|
259
361
|
const refs = [];
|
|
260
362
|
for (const key of new Set(readPath(holder.attrs, path))) {
|
|
261
|
-
const
|
|
363
|
+
const found = new Map(names(key, scope).flatMap((v) => find(v)).map((n) => [n.id, n]));
|
|
364
|
+
const targets = [...found.values()].filter((n) => n.kind === targetKind && inScope(n, scope));
|
|
262
365
|
refs.push({ value: key, targets, via: `remoteRef.key via ${first(store, "metadata.name") ?? store.id}`, through: store });
|
|
263
366
|
}
|
|
264
367
|
return refs;
|
|
265
368
|
},
|
|
266
369
|
};
|
|
267
370
|
}
|
|
371
|
+
const INDEXED_AWS_SECRET = "AWS::SecretsManager::Secret";
|
|
372
|
+
const INDEXED_GCP_SECRET = "GCP::Secretmanager::Secret";
|
|
373
|
+
/** The ARNs an indexed node carries: its `Arn`, its native id and its arn cloud ids. */
|
|
374
|
+
const arnsOf = (node) => [first(node, "Arn"), node.nativeId, ...(node.facts?.cloudIds ?? []).filter((c) => c.kind === "arn").map((c) => c.value)].filter((v) => v?.startsWith("arn:") === true);
|
|
375
|
+
/** An indexed node's region: its location, or the region its ARN names when the location is global. */
|
|
376
|
+
const indexedRegion = (node) => node.location !== undefined && node.location !== "" && node.location !== "global" ? node.location : arnsOf(node).map((a) => a.split(":")[3]).find((r) => r !== undefined && r !== "");
|
|
268
377
|
const gcpProject = (store) => first(store, "spec.provider.gcpsm.projectID");
|
|
269
378
|
const awsRegion = (store) => (first(store, "spec.provider.aws.service") === "SecretsManager" ? first(store, "spec.provider.aws.region") : undefined);
|
|
270
379
|
const externalSecretRules = [
|
|
271
380
|
...STORE_KINDS.map(storeRule),
|
|
272
381
|
...SECRET_KEY_PATHS.flatMap((path) => [
|
|
382
|
+
// The indexed kinds come first: of rules sharing an id, a dangling key names the last one's kind, the terraform kind as before #5245.
|
|
383
|
+
// An indexed secret (#5245): found by `Name` (the aws catalog's identity) or by its ARN, kept in the store's region.
|
|
384
|
+
secretRule(path, INDEXED_AWS_SECRET, awsRegion, (secret, region) => indexedRegion(secret) === region),
|
|
385
|
+
// Cloud Asset names a secret `//secretmanager.googleapis.com/projects/<project>/secrets/<id>`; the store's `projectID` is the project.
|
|
386
|
+
secretRule(path, INDEXED_GCP_SECRET, gcpProject, () => true, (key, project) => [`//secretmanager.googleapis.com/projects/${project}/secrets/${key}`]),
|
|
273
387
|
secretRule(path, "google_secret_manager_secret", gcpProject, (secret, project) => first(secret, "project") === project),
|
|
274
388
|
// The resource sets `region` only when it is not the provider's, so an AWS secret without one matches on its name.
|
|
275
389
|
secretRule(path, "aws_secretsmanager_secret", awsRegion, (secret, region) => (first(secret, "region") ?? region) === region),
|
|
@@ -286,6 +400,7 @@ export const GKE_ANNOTATION = 'metadata.annotations["iam.gke.io/gcp-service-acco
|
|
|
286
400
|
export const EKS_ANNOTATION = 'metadata.annotations["eks.amazonaws.com/role-arn"]';
|
|
287
401
|
const GCP_EMAIL = /^([a-z][a-z0-9-]*)@([a-z][a-z0-9-]*)\.iam\.gserviceaccount\.com$/i;
|
|
288
402
|
const AWS_ROLE_ARN = /^arn:aws[a-z-]*:iam::(\d{12}):role\/(?:(.*)\/)?([^/]+)$/;
|
|
403
|
+
const INDEXED_ROLE = "AWS::IAM::Role";
|
|
289
404
|
/**
|
|
290
405
|
* The cloud identity a ServiceAccount's annotation names (#5099). Neither
|
|
291
406
|
* value is one identifier a target carries, so both are rules with a `join`:
|
|
@@ -320,6 +435,34 @@ const identityRules = [
|
|
|
320
435
|
return [{ value: email, targets, via: "iam.gke.io/gcp-service-account" }];
|
|
321
436
|
},
|
|
322
437
|
},
|
|
438
|
+
// The indexed role (#5245) before the terraform one, so a dangling annotation names `aws_iam_role` as before.
|
|
439
|
+
{
|
|
440
|
+
from: SERVICE_ACCOUNT,
|
|
441
|
+
path: EKS_ANNOTATION,
|
|
442
|
+
targetKind: INDEXED_ROLE,
|
|
443
|
+
relation: "reference",
|
|
444
|
+
label: "acts as",
|
|
445
|
+
join(holder, find) {
|
|
446
|
+
const arn = first(holder, EKS_ANNOTATION);
|
|
447
|
+
if (arn === undefined)
|
|
448
|
+
return [];
|
|
449
|
+
const m = AWS_ROLE_ARN.exec(arn);
|
|
450
|
+
if (!m)
|
|
451
|
+
return [{ value: arn, targets: [], via: "eks.amazonaws.com/role-arn" }];
|
|
452
|
+
const found = new Map([...find(arn), ...find(m[3])].map((n) => [n.id, n]));
|
|
453
|
+
const targets = [...found.values()].filter((n) => {
|
|
454
|
+
if (n.kind !== INDEXED_ROLE)
|
|
455
|
+
return false;
|
|
456
|
+
const arns = arnsOf(n);
|
|
457
|
+
if (arns.includes(arn))
|
|
458
|
+
return true;
|
|
459
|
+
const path = (first(n, "Path") ?? "/").replace(/^\/|\/$/g, "");
|
|
460
|
+
const accounts = arns.map((a) => AWS_ROLE_ARN.exec(a)?.[1]);
|
|
461
|
+
return (first(n, "RoleName") ?? n.nativeId) === m[3] && path === (m[2] ?? "") && accounts.includes(m[1]);
|
|
462
|
+
});
|
|
463
|
+
return [{ value: arn, targets, via: "eks.amazonaws.com/role-arn" }];
|
|
464
|
+
},
|
|
465
|
+
},
|
|
323
466
|
{
|
|
324
467
|
from: SERVICE_ACCOUNT,
|
|
325
468
|
path: EKS_ANNOTATION,
|
|
@@ -348,7 +491,7 @@ const identityRules = [
|
|
|
348
491
|
];
|
|
349
492
|
const refs = [
|
|
350
493
|
// ── containment: the namespace an object is in ──
|
|
351
|
-
...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")),
|
|
352
495
|
// ── owner references, by name inside the namespace ──
|
|
353
496
|
...anyOf("K8s::Core::Pod", "metadata.ownerReferences[].name", ["K8s::Apps::ReplicaSet", "K8s::Apps::StatefulSet", "K8s::Apps::DaemonSet", "K8s::Batch::Job"], "owned by"),
|
|
354
497
|
...anyOf("K8s::Apps::ReplicaSet", "metadata.ownerReferences[].name", ["K8s::Apps::Deployment"], "owned by"),
|
|
@@ -370,10 +513,10 @@ const refs = [
|
|
|
370
513
|
ref("K8s::Core::PersistentVolumeClaim", "spec.volumeName", "K8s::Core::PersistentVolume", "bound to"),
|
|
371
514
|
ref("K8s::Core::PersistentVolumeClaim", "spec.storageClassName", "K8s::Storage::StorageClass", "class"),
|
|
372
515
|
ref("K8s::Core::PersistentVolume", "spec.storageClassName", "K8s::Storage::StorageClass", "class"),
|
|
373
|
-
...
|
|
374
|
-
...
|
|
375
|
-
...
|
|
376
|
-
...
|
|
516
|
+
...roleRefRules("K8s::Rbac::RoleBinding", ["K8s::Rbac::Role", "K8s::Rbac::ClusterRole"]),
|
|
517
|
+
...subjectRules("K8s::Rbac::RoleBinding", true),
|
|
518
|
+
...roleRefRules("K8s::Rbac::ClusterRoleBinding", ["K8s::Rbac::ClusterRole"]),
|
|
519
|
+
...subjectRules("K8s::Rbac::ClusterRoleBinding", false),
|
|
377
520
|
ref("K8s::Core::ServiceAccount", "secrets[].name", "K8s::Core::Secret", "token"),
|
|
378
521
|
ref("K8s::Core::ServiceAccount", "imagePullSecrets[].name", "K8s::Core::Secret", "pulls with"),
|
|
379
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.
|
|
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.
|
|
88
|
+
"@intentius/chant": "^0.124.105",
|
|
89
89
|
"@intentius/chant-k8s-client": "^0.124.101"
|
|
90
90
|
},
|
|
91
91
|
"peerDependenciesMeta": {
|