cdk-real-drift 0.5.4 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +48 -14
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5297,6 +5297,14 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
5297
5297
|
const schemaPath = basePath.replace(/\[[^\]]*\]/g, ".*");
|
|
5298
5298
|
return schemaPath in schema.defaultPaths && matchesKnownDefault(value, schema.defaultPaths[schemaPath]) || schemaPath in knownDefPaths && matchesKnownDefault(value, knownDefPaths[schemaPath]);
|
|
5299
5299
|
};
|
|
5300
|
+
const supplementReadGap = new Set(opts.supplementReadGapPaths ?? []);
|
|
5301
|
+
for (const p of supplementReadGap) if (!(p in declared) && !(p in live)) findings.push({
|
|
5302
|
+
tier: "readGap",
|
|
5303
|
+
logicalId,
|
|
5304
|
+
resourceType,
|
|
5305
|
+
path: p,
|
|
5306
|
+
note: "supplement read failed — property unverifiable (grant the missing read permission)"
|
|
5307
|
+
});
|
|
5300
5308
|
for (const [k, v] of Object.entries(declared)) {
|
|
5301
5309
|
if (v === UNRESOLVED || hasUnresolved(v)) {
|
|
5302
5310
|
findings.push({
|
|
@@ -5307,6 +5315,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
5307
5315
|
});
|
|
5308
5316
|
if (v === UNRESOLVED || !(k in live)) continue;
|
|
5309
5317
|
} else if (!(k in live)) {
|
|
5318
|
+
if (supplementReadGap.has(k)) {
|
|
5319
|
+
findings.push({
|
|
5320
|
+
tier: "readGap",
|
|
5321
|
+
logicalId,
|
|
5322
|
+
resourceType,
|
|
5323
|
+
path: k,
|
|
5324
|
+
note: "supplement read failed — property unverifiable (grant the missing read permission)"
|
|
5325
|
+
});
|
|
5326
|
+
continue;
|
|
5327
|
+
}
|
|
5310
5328
|
const isNonEmptyCollection = Array.isArray(v) && v.length > 0 || v !== null && typeof v === "object" && Object.keys(v).length > 0;
|
|
5311
5329
|
const isClearedAllowlistedScalar = SCALAR_RETURNED_WHEN_SET[resourceType]?.has(k) === true && (typeof v === "string" && v.length > 0 || typeof v === "number" || typeof v === "boolean");
|
|
5312
5330
|
if (isNonEmptyCollection && !READGAP_COLLECTION_PATHS[resourceType]?.has(k) || isClearedAllowlistedScalar) findings.push({
|
|
@@ -7335,8 +7353,13 @@ function diffRouteTableChildren(input) {
|
|
|
7335
7353
|
async function describeRouteTable(client, routeTableId) {
|
|
7336
7354
|
return (await client.send(new DescribeRouteTablesCommand({ RouteTableIds: [routeTableId] }))).RouteTables?.[0]?.Routes ?? [];
|
|
7337
7355
|
}
|
|
7356
|
+
function routeDestination(route) {
|
|
7357
|
+
if (typeof route.DestinationCidrBlock === "string") return route.DestinationCidrBlock;
|
|
7358
|
+
if (typeof route.DestinationIpv6CidrBlock === "string") return route.DestinationIpv6CidrBlock;
|
|
7359
|
+
if (typeof route.DestinationPrefixListId === "string") return route.DestinationPrefixListId;
|
|
7360
|
+
}
|
|
7338
7361
|
function isEnumerableRoute(route) {
|
|
7339
|
-
return
|
|
7362
|
+
return routeDestination(route) !== void 0 && route.Origin !== "CreateRouteTable" && route.Origin !== "EnableVgwRoutePropagation" && route.GatewayId !== "local";
|
|
7340
7363
|
}
|
|
7341
7364
|
async function enumerateRouteTableChildren(ctx) {
|
|
7342
7365
|
const { parent, desired, region } = ctx;
|
|
@@ -7346,7 +7369,7 @@ async function enumerateRouteTableChildren(ctx) {
|
|
|
7346
7369
|
let hasUnresolvedDeclaredRoute = false;
|
|
7347
7370
|
for (const r of desired.resources) {
|
|
7348
7371
|
if (r.resourceType !== "AWS::EC2::Route" || !parentRefMatches(r.declared.RouteTableId, routeTableId)) continue;
|
|
7349
|
-
const cidr = r.declared.DestinationCidrBlock;
|
|
7372
|
+
const cidr = r.declared.DestinationCidrBlock ?? r.declared.DestinationIpv6CidrBlock ?? r.declared.DestinationPrefixListId;
|
|
7350
7373
|
if (typeof cidr === "string") declaredCidrs.push(cidr);
|
|
7351
7374
|
else if (cidr === UNRESOLVED || hasUnresolved(cidr)) hasUnresolvedDeclaredRoute = true;
|
|
7352
7375
|
}
|
|
@@ -7356,7 +7379,7 @@ async function enumerateRouteTableChildren(ctx) {
|
|
|
7356
7379
|
liveRoutes: (await describeRouteTable(new EC2Client({
|
|
7357
7380
|
region,
|
|
7358
7381
|
...READ_RETRY
|
|
7359
|
-
}), routeTableId)).filter(isEnumerableRoute).map((route) => ({ cidr: route
|
|
7382
|
+
}), routeTableId)).filter(isEnumerableRoute).map((route) => ({ cidr: routeDestination(route) })),
|
|
7360
7383
|
hasUnresolvedDeclaredRoute
|
|
7361
7384
|
});
|
|
7362
7385
|
}
|
|
@@ -9945,17 +9968,14 @@ function compositeWith(parentKey) {
|
|
|
9945
9968
|
return typeof parent === "string" && parent.length > 0 ? `${parent}|${pid}` : void 0;
|
|
9946
9969
|
};
|
|
9947
9970
|
}
|
|
9948
|
-
function
|
|
9971
|
+
function collectSupplementReadGaps(resourceType, live, error) {
|
|
9949
9972
|
const exempt = OVERRIDE_READABLE_WRITEONLY[resourceType];
|
|
9950
|
-
const
|
|
9951
|
-
for (const path of exempt ?? []) if (
|
|
9952
|
-
const value = declared[path];
|
|
9953
|
-
if (Array.isArray(value) && value.length > 0 || value !== null && typeof value === "object" && Object.keys(value).length > 0) live[path] = value;
|
|
9954
|
-
restored.push(path);
|
|
9955
|
-
}
|
|
9973
|
+
const gaps = [];
|
|
9974
|
+
for (const path of exempt ?? []) if (!(path in live)) gaps.push(path);
|
|
9956
9975
|
const call = error?.name || "unknown error";
|
|
9957
|
-
const gap =
|
|
9976
|
+
const gap = gaps.length ? ` — treating ${gaps.join(", ")} as an unverifiable read-gap (grant the missing read permission to detect out-of-band drift on it)` : "";
|
|
9958
9977
|
process.stderr.write(`[cdkrd] warning: supplement read for ${resourceType} failed (${call})${gap}\n`);
|
|
9978
|
+
return gaps;
|
|
9959
9979
|
}
|
|
9960
9980
|
async function readLive(cc, resource, region, accountId) {
|
|
9961
9981
|
const { resourceType, physicalId, declared } = resource;
|
|
@@ -9990,7 +10010,10 @@ async function readLive(cc, resource, region, accountId) {
|
|
|
9990
10010
|
});
|
|
9991
10011
|
if (extra) Object.assign(live, extra);
|
|
9992
10012
|
} catch (e) {
|
|
9993
|
-
|
|
10013
|
+
return {
|
|
10014
|
+
live,
|
|
10015
|
+
readGapPaths: collectSupplementReadGaps(resourceType, live, e)
|
|
10016
|
+
};
|
|
9994
10017
|
}
|
|
9995
10018
|
return { live };
|
|
9996
10019
|
} catch (e) {
|
|
@@ -10207,9 +10230,15 @@ async function classifyRead(cfn, r, read, schemas, classifyOpts) {
|
|
|
10207
10230
|
note: "schema unavailable (DescribeType failed) — coverage incomplete"
|
|
10208
10231
|
}];
|
|
10209
10232
|
schemas.set(r.resourceType, res.info);
|
|
10210
|
-
return classifyResource(r, read.live, res.info,
|
|
10233
|
+
return classifyResource(r, read.live, res.info, {
|
|
10234
|
+
...classifyOpts,
|
|
10235
|
+
supplementReadGapPaths: read.readGapPaths
|
|
10236
|
+
});
|
|
10211
10237
|
}
|
|
10212
|
-
return classifyResource(r, read.live, cachedSchema,
|
|
10238
|
+
return classifyResource(r, read.live, cachedSchema, {
|
|
10239
|
+
...classifyOpts,
|
|
10240
|
+
supplementReadGapPaths: read.readGapPaths
|
|
10241
|
+
});
|
|
10213
10242
|
}
|
|
10214
10243
|
async function gatherFindings(stackName, region, templateOverride, recoveryTemplate) {
|
|
10215
10244
|
const cfn = new CloudFormationClient({
|
|
@@ -14956,6 +14985,11 @@ function formatFinding(f, stackName = "") {
|
|
|
14956
14985
|
}
|
|
14957
14986
|
else if (f.tier === "added" && f.actual !== void 0) s += `\n actual =${style.actual(j(f.actual))}`;
|
|
14958
14987
|
else if (f.tier === "undeclared" && f.arrayDelta) s += formatArrayDelta(f.arrayDelta);
|
|
14988
|
+
else if (f.tier === "undeclared" && f.desired !== void 0) if (isRecord(f.desired) && isRecord(f.actual)) s += formatMapDelta(f.desired, f.actual, true);
|
|
14989
|
+
else {
|
|
14990
|
+
const { a: base, b: act } = jPair(f.desired, f.actual);
|
|
14991
|
+
s += `\n baseline=${style.desired(base)}\n actual =${style.actual(act)}`;
|
|
14992
|
+
}
|
|
14959
14993
|
else if (f.tier === "undeclared" || f.tier === "atDefault" || f.tier === "generated") s += `\n actual =${style.actual(j(f.actual))}`;
|
|
14960
14994
|
if (f.hint) s += `\n ${style.note(`↳ ${sanitizeForTerminal(f.hint)}`)}`;
|
|
14961
14995
|
return s;
|