cdk-real-drift 0.12.95 → 0.12.97
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/README.md +11 -4
- package/dist/cli.js +93 -13
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -291,7 +291,10 @@ needs `--remove-unrecorded`).
|
|
|
291
291
|
- **EC2**: VPC subnets, VPC endpoints, VPC route tables, VPC network ACLs, route
|
|
292
292
|
table routes
|
|
293
293
|
- **ECS**: cluster services
|
|
294
|
-
- **KMS**: key aliases
|
|
294
|
+
- **KMS**: key aliases, key grants (an out-of-band `kms create-grant` on a key —
|
|
295
|
+
grants are not a CloudFormation type, so cdkrd surfaces them as a synthetic
|
|
296
|
+
`AWS::KMS::Grant`; AWS-service-created grants, e.g. a Lambda env-encryption key's
|
|
297
|
+
grant, are folded so only a human/IAM-principal grant surfaces)
|
|
295
298
|
- **AppConfig**: application environments, configuration profiles
|
|
296
299
|
- **EFS**: file system mount targets
|
|
297
300
|
- **RDS**: database cluster instances
|
|
@@ -1024,7 +1027,10 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
1024
1027
|
`ecs:DescribeServices` override reader listed above)
|
|
1025
1028
|
- `AWS::KMS::Key`: `kms:ListAliases` (the same action listed as optional
|
|
1026
1029
|
above — here it enumerates a key's aliases as child resources, so it is
|
|
1027
|
-
required, not optional, for the `added` tier)
|
|
1030
|
+
required, not optional, for the `added` tier), `kms:ListGrants` (enumerates a
|
|
1031
|
+
key's out-of-band grants as synthetic `AWS::KMS::Grant` children; AWS-service
|
|
1032
|
+
grants are folded, so only a human/IAM-principal grant surfaces). Reverting a
|
|
1033
|
+
detected one also needs `kms:RevokeGrant` (the SDK deleter revokes the grant).
|
|
1028
1034
|
- `AWS::AppConfig::Application`: `appconfig:ListEnvironments`,
|
|
1029
1035
|
`appconfig:ListConfigurationProfiles`
|
|
1030
1036
|
- `AWS::EFS::FileSystem`: `elasticfilesystem:DescribeMountTargets`
|
|
@@ -1057,9 +1063,10 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
1057
1063
|
`cloudcontrol:UpdateResource` (which resolves to each type's own update
|
|
1058
1064
|
permissions), `cloudcontrol:DeleteResource` (to delete an out-of-band `added`
|
|
1059
1065
|
resource; a type Cloud Control cannot delete goes through its own SDK action
|
|
1060
|
-
instead — `appsync:DeleteApiKey` for an out-of-band `AWS::AppSync::ApiKey`,
|
|
1066
|
+
instead — `appsync:DeleteApiKey` for an out-of-band `AWS::AppSync::ApiKey`,
|
|
1061
1067
|
`route53:ChangeResourceRecordSets` (a DELETE change) for an out-of-band
|
|
1062
|
-
`AWS::Route53::RecordSet`
|
|
1068
|
+
`AWS::Route53::RecordSet`, or `kms:RevokeGrant` for an out-of-band
|
|
1069
|
+
`AWS::KMS::Grant`), and
|
|
1063
1070
|
`cloudcontrol:GetResourceRequestStatus` (to poll the async Cloud
|
|
1064
1071
|
Control request to completion). Plus, for the SDK-written types:
|
|
1065
1072
|
`s3:PutBucketPolicy` /
|
package/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ import { DescribeServicesCommand, ECSClient, ListAccountSettingsCommand, ListSer
|
|
|
15
15
|
import { DescribeCertificatesCommand, DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeOptionGroupOptionsCommand, RDSClient } from "@aws-sdk/client-rds";
|
|
16
16
|
import { DescribeParametersCommand, GetParametersCommand, GetServiceSettingCommand, SSMClient } from "@aws-sdk/client-ssm";
|
|
17
17
|
import jsonata from "jsonata";
|
|
18
|
-
import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
|
|
18
|
+
import { KMSClient, ListAliasesCommand, ListGrantsCommand, RevokeGrantCommand } from "@aws-sdk/client-kms";
|
|
19
19
|
import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, GetStagesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
|
|
20
20
|
import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
|
|
21
21
|
import { AppSyncClient, DeleteApiKeyCommand, ListApiKeysCommand, ListDataSourcesCommand, ListFunctionsCommand, ListResolversCommand, ListTypesCommand } from "@aws-sdk/client-appsync";
|
|
@@ -2829,7 +2829,10 @@ const KNOWN_DEFAULTS = {
|
|
|
2829
2829
|
},
|
|
2830
2830
|
"AWS::CodeStarConnections::Connection": { HostArn: "arn:aws:codestar-connections:us-west-2:000000000000:host/00000000-0000-0000-0000-000000000000" }
|
|
2831
2831
|
};
|
|
2832
|
-
const KNOWN_DEFAULT_ONE_OF = {
|
|
2832
|
+
const KNOWN_DEFAULT_ONE_OF = {
|
|
2833
|
+
"AWS::ApiGatewayV2::Integration": { TimeoutInMillis: [29e3, 3e4] },
|
|
2834
|
+
"AWS::SecurityHub::Hub": { ControlFindingGenerator: ["SECURITY_CONTROL", "STANDARD_CONTROL"] }
|
|
2835
|
+
};
|
|
2833
2836
|
const KNOWN_DEFAULT_ONE_OF_PATHS = {
|
|
2834
2837
|
"AWS::EKS::Cluster": { "KubernetesNetworkConfig.ServiceIpv4Cidr": ["10.100.0.0/16", "172.20.0.0/16"] },
|
|
2835
2838
|
"AWS::S3::Bucket": { "LifecycleConfiguration.TransitionDefaultMinimumObjectSize": ["all_storage_classes_128K", "varies_by_storage_class"] }
|
|
@@ -5551,16 +5554,22 @@ const MEANINGFUL_WHEN_OFF = {
|
|
|
5551
5554
|
"AWS::ElasticLoadBalancingV2::TargetGroup": { HealthCheckEnabled: ({ declared }) => declared["TargetType"] !== "lambda" }
|
|
5552
5555
|
};
|
|
5553
5556
|
const MEANINGFUL_WHEN_OFF_NESTED = { "AWS::CloudFront::Distribution": { "DistributionConfig.IPV6Enabled": () => true } };
|
|
5554
|
-
const
|
|
5557
|
+
const GUARDDUTY_FEATURE_CREATION_STATUS = {
|
|
5558
|
+
AI_ANALYST: ["DISABLED"],
|
|
5559
|
+
RUNTIME_MONITORING: ["DISABLED", "ENABLED"],
|
|
5560
|
+
EKS_RUNTIME_MONITORING: ["DISABLED", "ENABLED"],
|
|
5561
|
+
EKS_ADDON_MANAGEMENT: ["DISABLED"],
|
|
5562
|
+
ECS_FARGATE_AGENT_MANAGEMENT: ["DISABLED"],
|
|
5563
|
+
EC2_AGENT_MANAGEMENT: ["DISABLED"]
|
|
5564
|
+
};
|
|
5555
5565
|
function guardDutyFeaturesAllAtDefault(features) {
|
|
5556
5566
|
const atDefault = (node) => {
|
|
5557
5567
|
if (Array.isArray(node)) return node.every(atDefault);
|
|
5558
5568
|
if (node !== null && typeof node === "object") {
|
|
5559
5569
|
const rec = node;
|
|
5560
5570
|
if ("Status" in rec) {
|
|
5561
|
-
const
|
|
5562
|
-
|
|
5563
|
-
if (rec["Status"] !== defaultStatus) return false;
|
|
5571
|
+
const defaults = GUARDDUTY_FEATURE_CREATION_STATUS[typeof rec["Name"] === "string" ? rec["Name"] : ""] ?? ["ENABLED"];
|
|
5572
|
+
if (typeof rec["Status"] !== "string" || !defaults.includes(rec["Status"])) return false;
|
|
5564
5573
|
}
|
|
5565
5574
|
return Object.values(rec).every(atDefault);
|
|
5566
5575
|
}
|
|
@@ -7292,6 +7301,18 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
7292
7301
|
});
|
|
7293
7302
|
continue;
|
|
7294
7303
|
}
|
|
7304
|
+
if (resourceType === "AWS::Kinesis::Stream" && k === "ShardCount") {
|
|
7305
|
+
if ((declared.StreamModeDetails?.StreamMode ?? live.StreamModeDetails?.StreamMode) === "ON_DEMAND") {
|
|
7306
|
+
findings.push({
|
|
7307
|
+
tier: "atDefault",
|
|
7308
|
+
logicalId,
|
|
7309
|
+
resourceType,
|
|
7310
|
+
path: k,
|
|
7311
|
+
actual: v
|
|
7312
|
+
});
|
|
7313
|
+
continue;
|
|
7314
|
+
}
|
|
7315
|
+
}
|
|
7295
7316
|
const namePattern = DEFAULT_MANAGED_NAME_PATHS[resourceType]?.[k];
|
|
7296
7317
|
if (namePattern !== void 0 && typeof v === "string" && namePattern.test(v)) {
|
|
7297
7318
|
findings.push({
|
|
@@ -9908,13 +9929,59 @@ async function enumerateKmsKeyChildren(ctx) {
|
|
|
9908
9929
|
const name = typeof r.declared.AliasName === "string" ? r.declared.AliasName : r.physicalId;
|
|
9909
9930
|
if (name) declaredAliasNames.push(name);
|
|
9910
9931
|
}
|
|
9932
|
+
const client = new KMSClient({
|
|
9933
|
+
region,
|
|
9934
|
+
...READ_RETRY
|
|
9935
|
+
});
|
|
9936
|
+
const liveAliases = (await pageAliases(client, keyId)).filter((a) => typeof a.AliasName === "string").map((a) => ({ name: a.AliasName }));
|
|
9937
|
+
const liveGrants = (await pageGrants(client, keyId)).filter((g) => typeof g.GrantId === "string").map((g) => ({
|
|
9938
|
+
grantId: g.GrantId,
|
|
9939
|
+
name: g.Name,
|
|
9940
|
+
granteePrincipal: g.GranteePrincipal,
|
|
9941
|
+
retiringPrincipal: g.RetiringPrincipal,
|
|
9942
|
+
operations: g.Operations
|
|
9943
|
+
}));
|
|
9911
9944
|
return diffKmsKeyChildren({
|
|
9912
9945
|
declaredAliasNames,
|
|
9913
|
-
liveAliases
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9946
|
+
liveAliases
|
|
9947
|
+
}).concat(diffKmsKeyGrants({ liveGrants }));
|
|
9948
|
+
}
|
|
9949
|
+
function isAwsServicePrincipal(principal) {
|
|
9950
|
+
if (typeof principal !== "string" || principal.startsWith("arn:")) return false;
|
|
9951
|
+
return /^[a-z0-9-]+(\.[a-z0-9-]+)*\.amazonaws\.com$/.test(principal);
|
|
9952
|
+
}
|
|
9953
|
+
function diffKmsKeyGrants(input) {
|
|
9954
|
+
const added = [];
|
|
9955
|
+
for (const g of input.liveGrants) {
|
|
9956
|
+
if (isAwsServicePrincipal(g.granteePrincipal) || isAwsServicePrincipal(g.retiringPrincipal)) continue;
|
|
9957
|
+
added.push({
|
|
9958
|
+
resourceType: "AWS::KMS::Grant",
|
|
9959
|
+
identifier: g.grantId,
|
|
9960
|
+
siblingLookupId: g.grantId,
|
|
9961
|
+
label: g.name ? `grant ${g.name} (${g.grantId.slice(0, 12)}…)` : `grant ${g.grantId}`,
|
|
9962
|
+
live: {
|
|
9963
|
+
GrantId: g.grantId,
|
|
9964
|
+
...g.name !== void 0 ? { GrantName: g.name } : {},
|
|
9965
|
+
...g.granteePrincipal !== void 0 ? { GranteePrincipal: g.granteePrincipal } : {},
|
|
9966
|
+
...g.retiringPrincipal !== void 0 ? { RetiringPrincipal: g.retiringPrincipal } : {},
|
|
9967
|
+
...g.operations !== void 0 ? { Operations: g.operations } : {}
|
|
9968
|
+
}
|
|
9969
|
+
});
|
|
9970
|
+
}
|
|
9971
|
+
return added;
|
|
9972
|
+
}
|
|
9973
|
+
async function pageGrants(client, keyId) {
|
|
9974
|
+
const out = [];
|
|
9975
|
+
let marker;
|
|
9976
|
+
do {
|
|
9977
|
+
const res = await client.send(new ListGrantsCommand({
|
|
9978
|
+
KeyId: keyId,
|
|
9979
|
+
Marker: marker
|
|
9980
|
+
}));
|
|
9981
|
+
out.push(...res.Grants ?? []);
|
|
9982
|
+
marker = res.NextMarker;
|
|
9983
|
+
} while (marker);
|
|
9984
|
+
return out;
|
|
9918
9985
|
}
|
|
9919
9986
|
function diffAppConfigApplicationChildren(input) {
|
|
9920
9987
|
const { applicationId, declaredEnvironmentIds, liveEnvironments } = input;
|
|
@@ -13115,7 +13182,8 @@ const CC_GET_UNSUPPORTED_ADDED_TYPES = new Set([
|
|
|
13115
13182
|
"AWS::Route53::RecordSet",
|
|
13116
13183
|
"AWS::SQS::QueuePolicy",
|
|
13117
13184
|
"AWS::SecretsManager::ResourcePolicy",
|
|
13118
|
-
"AWS::SNS::TopicPolicy"
|
|
13185
|
+
"AWS::SNS::TopicPolicy",
|
|
13186
|
+
"AWS::KMS::Grant"
|
|
13119
13187
|
]);
|
|
13120
13188
|
async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
|
|
13121
13189
|
const normalizeWith = async (raw) => {
|
|
@@ -17354,12 +17422,24 @@ const deleteSnsTopicPolicy = async (ctx) => {
|
|
|
17354
17422
|
AttributeValue: defaultPolicy
|
|
17355
17423
|
}));
|
|
17356
17424
|
};
|
|
17425
|
+
const deleteKmsGrant = async (ctx) => {
|
|
17426
|
+
const keyId = ctx.parentPhysicalId;
|
|
17427
|
+
if (!keyId) throw new Error("cannot resolve the parent KMS Key id for the grant revoke");
|
|
17428
|
+
await new KMSClient({
|
|
17429
|
+
region: ctx.region,
|
|
17430
|
+
...CLIENT_TIMEOUTS
|
|
17431
|
+
}).send(new RevokeGrantCommand({
|
|
17432
|
+
KeyId: keyId,
|
|
17433
|
+
GrantId: ctx.physicalId
|
|
17434
|
+
}));
|
|
17435
|
+
};
|
|
17357
17436
|
const SDK_DELETERS = {
|
|
17358
17437
|
"AWS::AppSync::ApiKey": deleteAppSyncApiKey,
|
|
17359
17438
|
"AWS::Route53::RecordSet": deleteRoute53RecordSet,
|
|
17360
17439
|
"AWS::SQS::QueuePolicy": deleteSqsQueuePolicy,
|
|
17361
17440
|
"AWS::SecretsManager::ResourcePolicy": deleteSecretsManagerResourcePolicy,
|
|
17362
|
-
"AWS::SNS::TopicPolicy": deleteSnsTopicPolicy
|
|
17441
|
+
"AWS::SNS::TopicPolicy": deleteSnsTopicPolicy,
|
|
17442
|
+
"AWS::KMS::Grant": deleteKmsGrant
|
|
17363
17443
|
};
|
|
17364
17444
|
|
|
17365
17445
|
//#endregion
|