mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudformation): apply SES string schema constraints (#8879)
The CloudFormation property types generator now keeps minLength, maxLength and pattern on every string the published schemas constrain, and HandlerReader checks them for AWS::SES::ConfigurationSetEventDestination with CloudFormation's wording: "expected minLength: 36, actual: 0", "expected maxLength: 1024, actual: 1100" and "failed validation constraint for keyword [pattern]". A blank required string counts as missing only where the schema sets no constraint. Follow-up to #8733.
This commit is contained in:
1 parent
c0325c5488
commit
8619ad65cc
6 files changed
+349
-62
No files matched your search
@@ -23,9 +23,14 @@ public record RequestShapeModel(Map<String, String> operations, Map<String, Shap
|
||||
|
||||
/**
|
||||
* One shape: its type, the shape of each structure member and the members it requires, or the
|
||||
* list element or map value shape.
|
||||
* list element or map value shape, and any string constraints the vendor retains.
|
||||
*/
|
||||
public record Shape(String type, Map<String, String> members, String element, List<String> required) {
|
||||
public record Shape(String type, Map<String, String> members, String element, List<String> required,
|
||||
Integer minLength, Integer maxLength, String pattern) {
|
||||
|
||||
public Shape(String type, Map<String, String> members, String element, List<String> required) {
|
||||
this(type, members, element, required, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/** The vendored resource {@code name}; {@code description} names it in a failure. */
|
||||
@@ -45,7 +50,10 @@ public record RequestShapeModel(Map<String, String> operations, Map<String, Shap
|
||||
List<String> required = new ArrayList<>();
|
||||
node.path("required").forEach(name -> required.add(name.asText()));
|
||||
shapes.put(entry.getKey(), new Shape(node.path("type").asText(), Collections.unmodifiableMap(members),
|
||||
element, List.copyOf(required)));
|
||||
element, List.copyOf(required),
|
||||
node.hasNonNull("minLength") ? node.get("minLength").asInt() : null,
|
||||
node.hasNonNull("maxLength") ? node.get("maxLength").asInt() : null,
|
||||
node.hasNonNull("pattern") ? node.get("pattern").asText() : null));
|
||||
}
|
||||
return new RequestShapeModel(Map.copyOf(operations), Map.copyOf(shapes));
|
||||
}
|
||||
|
||||
+33
-6
@@ -161,6 +161,9 @@ final class CfnPropertyTypes {
|
||||
|
||||
abstract JsonNode readBoolean(String path, String property, JsonNode value);
|
||||
|
||||
void checkString(String path, Shape shape, String value) {
|
||||
}
|
||||
|
||||
/** Checks the members {@code shape} requires of the object {@code value} at {@code path}; none by default. */
|
||||
void checkRequired(String path, JsonNode value, Shape shape) {
|
||||
}
|
||||
@@ -191,7 +194,7 @@ final class CfnPropertyTypes {
|
||||
case "structure" -> readObject(path, property, value, shape);
|
||||
case "map" -> readMap(path, property, value, shape.element());
|
||||
case "list" -> readList(path, property, value, shape.element());
|
||||
case "string" -> readString(path, property, value);
|
||||
case "string" -> readString(path, property, value, shape);
|
||||
case "integer" -> readInteger(path, property, value);
|
||||
case "boolean" -> readBoolean(path, property, value);
|
||||
default -> value == raw ? engine.resolveNode(raw) : value;
|
||||
@@ -283,12 +286,14 @@ final class CfnPropertyTypes {
|
||||
return out;
|
||||
}
|
||||
|
||||
private JsonNode readString(String path, String property, JsonNode value) {
|
||||
private JsonNode readString(String path, String property, JsonNode value, Shape shape) {
|
||||
if (value.isContainerNode()) {
|
||||
mismatch(path, property, "String", containerName(value));
|
||||
return null;
|
||||
}
|
||||
return value.isTextual() ? value : TextNode.valueOf(value.asText());
|
||||
JsonNode text = value.isTextual() ? value : TextNode.valueOf(value.asText());
|
||||
checkString(path, shape, text.textValue());
|
||||
return text;
|
||||
}
|
||||
|
||||
static String child(String path, String name) {
|
||||
@@ -471,6 +476,24 @@ final class CfnPropertyTypes {
|
||||
return flag == null ? value : BooleanNode.valueOf(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
void checkString(String path, Shape shape, String value) {
|
||||
if (shape.minLength() == null && shape.maxLength() == null && shape.pattern() == null) {
|
||||
return;
|
||||
}
|
||||
int length = value.codePointCount(0, value.length());
|
||||
if (shape.minLength() != null && length < shape.minLength()) {
|
||||
record(new Violation(path, "expected minLength: " + shape.minLength() + ", actual: " + length,
|
||||
false), false);
|
||||
} else if (shape.maxLength() != null && length > shape.maxLength()) {
|
||||
record(new Violation(path, "expected maxLength: " + shape.maxLength() + ", actual: " + length,
|
||||
false), false);
|
||||
} else if (shape.pattern() != null && !Pattern.compile(shape.pattern()).matcher(value).matches()) {
|
||||
record(new Violation(path, "failed validation constraint for keyword [pattern]", false),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void checkRequired(String path, JsonNode value, Shape shape) {
|
||||
for (String member : shape.required()) {
|
||||
@@ -478,10 +501,14 @@ final class CfnPropertyTypes {
|
||||
boolean absent = raw == null;
|
||||
if (!absent && !preserveEcsHandlerSemantics) {
|
||||
absent = raw.isNull() || raw.isMissingNode();
|
||||
if (!absent && "string".equals(model.shapes().get(shape.members().get(member)).type())) {
|
||||
Shape memberShape = model.shapes().get(shape.members().get(member));
|
||||
if (!absent && "string".equals(memberShape.type())) {
|
||||
JsonNode resolved = engine.resolveNode(raw);
|
||||
absent = resolved == null || resolved.isNull() || resolved.isMissingNode()
|
||||
|| resolved.isTextual() && resolved.textValue().isBlank();
|
||||
absent = resolved == null || resolved.isNull() || resolved.isMissingNode();
|
||||
if (!absent && memberShape.minLength() == null && memberShape.maxLength() == null
|
||||
&& memberShape.pattern() == null) {
|
||||
absent = resolved.isTextual() && resolved.textValue().isBlank();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (absent) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"_source": {
|
||||
"generator": "tools/aws/regen_cfn_property_types.py",
|
||||
"schemas": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip",
|
||||
"retrieved": "2026-11-17",
|
||||
"retrieved": "2026-11-18",
|
||||
"note": "make cfn-property-types-verify checks the file against AWS."
|
||||
},
|
||||
"operations": {
|
||||
@@ -23,10 +23,10 @@
|
||||
"members": {
|
||||
"PlacementTenancy": "String",
|
||||
"SecurityGroups": "AWS::AutoScaling::LaunchConfiguration.SecurityGroups",
|
||||
"LaunchConfigurationName": "String",
|
||||
"LaunchConfigurationName": "AWS::AutoScaling::LaunchConfiguration.LaunchConfigurationName",
|
||||
"MetadataOptions": "AWS::AutoScaling::LaunchConfiguration/MetadataOptions",
|
||||
"InstanceId": "String",
|
||||
"UserData": "String",
|
||||
"UserData": "AWS::AutoScaling::LaunchConfiguration.UserData",
|
||||
"ClassicLinkVPCSecurityGroups": "AWS::AutoScaling::LaunchConfiguration.ClassicLinkVPCSecurityGroups",
|
||||
"BlockDeviceMappings": "AWS::AutoScaling::LaunchConfiguration.BlockDeviceMappings",
|
||||
"IamInstanceProfile": "String",
|
||||
@@ -54,10 +54,19 @@
|
||||
"type": "list",
|
||||
"member": "String"
|
||||
},
|
||||
"AWS::AutoScaling::LaunchConfiguration.LaunchConfigurationName": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 255
|
||||
},
|
||||
"AWS::AutoScaling::LaunchConfiguration.SecurityGroups": {
|
||||
"type": "list",
|
||||
"member": "String"
|
||||
},
|
||||
"AWS::AutoScaling::LaunchConfiguration.UserData": {
|
||||
"type": "string",
|
||||
"maxLength": 21847
|
||||
},
|
||||
"AWS::AutoScaling::LaunchConfiguration/BlockDevice": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
@@ -149,14 +158,24 @@
|
||||
"AWS::DSQL::Cluster/Tag": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"Key": "String",
|
||||
"Value": "String"
|
||||
"Key": "AWS::DSQL::Cluster/Tag.Key",
|
||||
"Value": "AWS::DSQL::Cluster/Tag.Value"
|
||||
},
|
||||
"required": [
|
||||
"Key",
|
||||
"Value"
|
||||
]
|
||||
},
|
||||
"AWS::DSQL::Cluster/Tag.Key": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 128
|
||||
},
|
||||
"AWS::DSQL::Cluster/Tag.Value": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 256
|
||||
},
|
||||
"AWS::EC2::Instance": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
@@ -1553,7 +1572,7 @@
|
||||
"EncryptionConfig": "AWS::EKS::Cluster.EncryptionConfig",
|
||||
"KubernetesNetworkConfig": "AWS::EKS::Cluster/KubernetesNetworkConfig",
|
||||
"Logging": "AWS::EKS::Cluster/Logging",
|
||||
"Name": "String",
|
||||
"Name": "AWS::EKS::Cluster.Name",
|
||||
"Id": "String",
|
||||
"ResourcesVpcConfig": "AWS::EKS::Cluster/ResourcesVpcConfig",
|
||||
"OutpostConfig": "AWS::EKS::Cluster/OutpostConfig",
|
||||
@@ -1563,7 +1582,7 @@
|
||||
"ComputeConfig": "AWS::EKS::Cluster/ComputeConfig",
|
||||
"StorageConfig": "AWS::EKS::Cluster/StorageConfig",
|
||||
"RoleArn": "String",
|
||||
"Version": "String",
|
||||
"Version": "AWS::EKS::Cluster.Version",
|
||||
"Force": "Boolean",
|
||||
"RollbackConfig": "AWS::EKS::Cluster/RollbackConfig",
|
||||
"Tags": "AWS::EKS::Cluster.Tags",
|
||||
@@ -1592,10 +1611,20 @@
|
||||
"type": "list",
|
||||
"member": "AWS::EKS::Cluster/EncryptionConfig"
|
||||
},
|
||||
"AWS::EKS::Cluster.Name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100,
|
||||
"pattern": "^[0-9A-Za-z][A-Za-z0-9\\-_]*"
|
||||
},
|
||||
"AWS::EKS::Cluster.Tags": {
|
||||
"type": "list",
|
||||
"member": "AWS::EKS::Cluster/Tag"
|
||||
},
|
||||
"AWS::EKS::Cluster.Version": {
|
||||
"type": "string",
|
||||
"pattern": "1\\.\\d\\d"
|
||||
},
|
||||
"AWS::EKS::Cluster/AccessConfig": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
@@ -1890,14 +1919,24 @@
|
||||
"AWS::EKS::Cluster/Tag": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"Key": "String",
|
||||
"Value": "String"
|
||||
"Key": "AWS::EKS::Cluster/Tag.Key",
|
||||
"Value": "AWS::EKS::Cluster/Tag.Value"
|
||||
},
|
||||
"required": [
|
||||
"Key",
|
||||
"Value"
|
||||
]
|
||||
},
|
||||
"AWS::EKS::Cluster/Tag.Key": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 128
|
||||
},
|
||||
"AWS::EKS::Cluster/Tag.Value": {
|
||||
"type": "string",
|
||||
"minLength": 0,
|
||||
"maxLength": 256
|
||||
},
|
||||
"AWS::EKS::Cluster/UpgradePolicy": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
@@ -2226,7 +2265,7 @@
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"FunctionScalingConfig": "AWS::Lambda::Function/FunctionScalingConfig",
|
||||
"Description": "String",
|
||||
"Description": "AWS::Lambda::Function.Description",
|
||||
"TracingConfig": "AWS::Lambda::Function/TracingConfig",
|
||||
"VpcConfig": "AWS::Lambda::Function/VpcConfig",
|
||||
"RuntimeManagementConfig": "AWS::Lambda::Function/RuntimeManagementConfig",
|
||||
@@ -2234,13 +2273,13 @@
|
||||
"ReservedConcurrentExecutions": "Integer",
|
||||
"SnapStart": "AWS::Lambda::Function/SnapStart",
|
||||
"FileSystemConfigs": "AWS::Lambda::Function.FileSystemConfigs",
|
||||
"FunctionName": "String",
|
||||
"FunctionName": "AWS::Lambda::Function.FunctionName",
|
||||
"AcceleratorConfig": "AWS::Lambda::Function/AcceleratorConfig",
|
||||
"Runtime": "String",
|
||||
"KmsKeyArn": "String",
|
||||
"KmsKeyArn": "AWS::Lambda::Function.KmsKeyArn",
|
||||
"PublishToLatestPublished": "Boolean",
|
||||
"PackageType": "String",
|
||||
"CodeSigningConfigArn": "String",
|
||||
"CodeSigningConfigArn": "AWS::Lambda::Function.CodeSigningConfigArn",
|
||||
"Layers": "AWS::Lambda::Function.Layers",
|
||||
"TenancyConfig": "AWS::Lambda::Function/TenancyConfig",
|
||||
"Tags": "AWS::Lambda::Function.Tags",
|
||||
@@ -2249,10 +2288,10 @@
|
||||
"DeadLetterConfig": "AWS::Lambda::Function/DeadLetterConfig",
|
||||
"Timeout": "Integer",
|
||||
"CapacityProviderConfig": "AWS::Lambda::Function/CapacityProviderConfig",
|
||||
"Handler": "String",
|
||||
"Handler": "AWS::Lambda::Function.Handler",
|
||||
"SnapStartResponse": "AWS::Lambda::Function/SnapStartResponse",
|
||||
"Code": "AWS::Lambda::Function/Code",
|
||||
"Role": "String",
|
||||
"Role": "AWS::Lambda::Function.Role",
|
||||
"LoggingConfig": "AWS::Lambda::Function/LoggingConfig",
|
||||
"RecursiveLoop": "AWS::Lambda::Function/RecursiveLoop",
|
||||
"Environment": "AWS::Lambda::Function/Environment",
|
||||
@@ -2270,14 +2309,39 @@
|
||||
"type": "list",
|
||||
"member": "String"
|
||||
},
|
||||
"AWS::Lambda::Function.CodeSigningConfigArn": {
|
||||
"type": "string",
|
||||
"pattern": "arn:(aws[a-zA-Z-]*)?:lambda:(eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:\\d{12}:code-signing-config:csc-[a-z0-9]{17}"
|
||||
},
|
||||
"AWS::Lambda::Function.Description": {
|
||||
"type": "string",
|
||||
"maxLength": 256
|
||||
},
|
||||
"AWS::Lambda::Function.FileSystemConfigs": {
|
||||
"type": "list",
|
||||
"member": "AWS::Lambda::Function/FileSystemConfig"
|
||||
},
|
||||
"AWS::Lambda::Function.FunctionName": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"AWS::Lambda::Function.Handler": {
|
||||
"type": "string",
|
||||
"maxLength": 128,
|
||||
"pattern": "^[^\\s]+$"
|
||||
},
|
||||
"AWS::Lambda::Function.KmsKeyArn": {
|
||||
"type": "string",
|
||||
"pattern": "^(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()$"
|
||||
},
|
||||
"AWS::Lambda::Function.Layers": {
|
||||
"type": "list",
|
||||
"member": "String"
|
||||
},
|
||||
"AWS::Lambda::Function.Role": {
|
||||
"type": "string",
|
||||
"pattern": "^arn:(aws[a-zA-Z-]*)?:iam::\\d{12}:role/?[a-zA-Z_0-9+=,.@\\-_/]+$"
|
||||
},
|
||||
"AWS::Lambda::Function.Tags": {
|
||||
"type": "list",
|
||||
"member": "AWS::Lambda::Function/Tag"
|
||||
@@ -2303,25 +2367,49 @@
|
||||
"AWS::Lambda::Function/Code": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"SourceKMSKeyArn": "String",
|
||||
"S3ObjectVersion": "String",
|
||||
"S3Bucket": "String",
|
||||
"SourceKMSKeyArn": "AWS::Lambda::Function/Code.SourceKMSKeyArn",
|
||||
"S3ObjectVersion": "AWS::Lambda::Function/Code.S3ObjectVersion",
|
||||
"S3Bucket": "AWS::Lambda::Function/Code.S3Bucket",
|
||||
"ZipFile": "String",
|
||||
"S3Key": "String",
|
||||
"S3Key": "AWS::Lambda::Function/Code.S3Key",
|
||||
"S3ObjectStorageMode": "String",
|
||||
"ImageUri": "String"
|
||||
}
|
||||
},
|
||||
"AWS::Lambda::Function/Code.S3Bucket": {
|
||||
"type": "string",
|
||||
"minLength": 3,
|
||||
"maxLength": 63,
|
||||
"pattern": "^[0-9A-Za-z\\.\\-_]*(?<!\\.)$"
|
||||
},
|
||||
"AWS::Lambda::Function/Code.S3Key": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 1024
|
||||
},
|
||||
"AWS::Lambda::Function/Code.S3ObjectVersion": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 1024
|
||||
},
|
||||
"AWS::Lambda::Function/Code.SourceKMSKeyArn": {
|
||||
"type": "string",
|
||||
"pattern": "^(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()$"
|
||||
},
|
||||
"AWS::Lambda::Function/DeadLetterConfig": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"TargetArn": "String"
|
||||
"TargetArn": "AWS::Lambda::Function/DeadLetterConfig.TargetArn"
|
||||
}
|
||||
},
|
||||
"AWS::Lambda::Function/DeadLetterConfig.TargetArn": {
|
||||
"type": "string",
|
||||
"pattern": "^(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()$"
|
||||
},
|
||||
"AWS::Lambda::Function/DurableConfig": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"KMSKeyArn": "String",
|
||||
"KMSKeyArn": "AWS::Lambda::Function/DurableConfig.KMSKeyArn",
|
||||
"ExecutionTimeout": "Integer",
|
||||
"RetentionPeriodInDays": "Integer"
|
||||
},
|
||||
@@ -2329,6 +2417,10 @@
|
||||
"ExecutionTimeout"
|
||||
]
|
||||
},
|
||||
"AWS::Lambda::Function/DurableConfig.KMSKeyArn": {
|
||||
"type": "string",
|
||||
"pattern": "^(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()$"
|
||||
},
|
||||
"AWS::Lambda::Function/Environment": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
@@ -2352,14 +2444,24 @@
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"S3FilesConfig": "AWS::Lambda::Function/S3FilesConfig",
|
||||
"Arn": "String",
|
||||
"LocalMountPath": "String"
|
||||
"Arn": "AWS::Lambda::Function/FileSystemConfig.Arn",
|
||||
"LocalMountPath": "AWS::Lambda::Function/FileSystemConfig.LocalMountPath"
|
||||
},
|
||||
"required": [
|
||||
"Arn",
|
||||
"LocalMountPath"
|
||||
]
|
||||
},
|
||||
"AWS::Lambda::Function/FileSystemConfig.Arn": {
|
||||
"type": "string",
|
||||
"maxLength": 200,
|
||||
"pattern": "^arn:aws[a-zA-Z-]*:elasticfilesystem:(eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:\\d{12}:access-point/fsap-[a-f0-9]{17}$|^arn:aws[-a-z]*:s3files:[0-9a-z-:]+:file-system/fs-[0-9a-f]{17,40}/access-point/fsap-[0-9a-f]{17,40}$"
|
||||
},
|
||||
"AWS::Lambda::Function/FileSystemConfig.LocalMountPath": {
|
||||
"type": "string",
|
||||
"maxLength": 160,
|
||||
"pattern": "^/mnt/[a-zA-Z0-9-_.]+$"
|
||||
},
|
||||
"AWS::Lambda::Function/FunctionScalingConfig": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
@@ -2387,36 +2489,58 @@
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"ExecutionEnvironmentMemoryGiBPerVCpu": "Double",
|
||||
"CapacityProviderArn": "String",
|
||||
"CapacityProviderArn": "AWS::Lambda::Function/LambdaManagedInstancesCapacityProviderConfig.CapacityProviderArn",
|
||||
"PerExecutionEnvironmentMaxConcurrency": "Integer"
|
||||
},
|
||||
"required": [
|
||||
"CapacityProviderArn"
|
||||
]
|
||||
},
|
||||
"AWS::Lambda::Function/LambdaManagedInstancesCapacityProviderConfig.CapacityProviderArn": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 140,
|
||||
"pattern": "^arn:aws[a-zA-Z-]*:lambda:(eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:\\d{12}:capacity-provider:[a-zA-Z0-9-_]+$"
|
||||
},
|
||||
"AWS::Lambda::Function/LoggingConfig": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"LogFormat": "String",
|
||||
"ApplicationLogLevel": "String",
|
||||
"LogGroup": "String",
|
||||
"LogGroup": "AWS::Lambda::Function/LoggingConfig.LogGroup",
|
||||
"SystemLogLevel": "String"
|
||||
}
|
||||
},
|
||||
"AWS::Lambda::Function/LoggingConfig.LogGroup": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 512,
|
||||
"pattern": "[\\.\\-_/#A-Za-z0-9]+"
|
||||
},
|
||||
"AWS::Lambda::Function/RecursiveLoop": {
|
||||
"type": "string"
|
||||
},
|
||||
"AWS::Lambda::Function/RuntimeConfig": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"RuntimeAlias": "String",
|
||||
"RuntimeArn": "String"
|
||||
"RuntimeAlias": "AWS::Lambda::Function/RuntimeConfig.RuntimeAlias",
|
||||
"RuntimeArn": "AWS::Lambda::Function/RuntimeConfig.RuntimeArn"
|
||||
},
|
||||
"required": [
|
||||
"RuntimeArn",
|
||||
"RuntimeAlias"
|
||||
]
|
||||
},
|
||||
"AWS::Lambda::Function/RuntimeConfig.RuntimeAlias": {
|
||||
"type": "string",
|
||||
"maxLength": 128,
|
||||
"pattern": "^[A-Za-z0-9_]([A-Za-z0-9_.-]{0,126}[A-Za-z0-9_])?$"
|
||||
},
|
||||
"AWS::Lambda::Function/RuntimeConfig.RuntimeArn": {
|
||||
"type": "string",
|
||||
"maxLength": 2048,
|
||||
"pattern": "^arn:[a-z-]+:lambda:[a-z0-9-]+:\\d{12}:runtime/.+$"
|
||||
},
|
||||
"AWS::Lambda::Function/RuntimeManagementConfig": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
@@ -2452,13 +2576,23 @@
|
||||
"AWS::Lambda::Function/Tag": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"Value": "String",
|
||||
"Key": "String"
|
||||
"Value": "AWS::Lambda::Function/Tag.Value",
|
||||
"Key": "AWS::Lambda::Function/Tag.Key"
|
||||
},
|
||||
"required": [
|
||||
"Key"
|
||||
]
|
||||
},
|
||||
"AWS::Lambda::Function/Tag.Key": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 128
|
||||
},
|
||||
"AWS::Lambda::Function/Tag.Value": {
|
||||
"type": "string",
|
||||
"minLength": 0,
|
||||
"maxLength": 256
|
||||
},
|
||||
"AWS::Lambda::Function/TenancyConfig": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
@@ -2552,8 +2686,8 @@
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"DimensionValueSource": "String",
|
||||
"DefaultDimensionValue": "String",
|
||||
"DimensionName": "String"
|
||||
"DefaultDimensionValue": "AWS::SES::ConfigurationSetEventDestination/DimensionConfiguration.DefaultDimensionValue",
|
||||
"DimensionName": "AWS::SES::ConfigurationSetEventDestination/DimensionConfiguration.DimensionName"
|
||||
},
|
||||
"required": [
|
||||
"DimensionValueSource",
|
||||
@@ -2561,19 +2695,37 @@
|
||||
"DimensionName"
|
||||
]
|
||||
},
|
||||
"AWS::SES::ConfigurationSetEventDestination/DimensionConfiguration.DefaultDimensionValue": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 256,
|
||||
"pattern": "^[a-zA-Z0-9_-]{1,256}$"
|
||||
},
|
||||
"AWS::SES::ConfigurationSetEventDestination/DimensionConfiguration.DimensionName": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 256,
|
||||
"pattern": "^[a-zA-Z0-9_:-]{1,256}$"
|
||||
},
|
||||
"AWS::SES::ConfigurationSetEventDestination/EventBridgeDestination": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"EventBusArn": "String"
|
||||
"EventBusArn": "AWS::SES::ConfigurationSetEventDestination/EventBridgeDestination.EventBusArn"
|
||||
},
|
||||
"required": [
|
||||
"EventBusArn"
|
||||
]
|
||||
},
|
||||
"AWS::SES::ConfigurationSetEventDestination/EventBridgeDestination.EventBusArn": {
|
||||
"type": "string",
|
||||
"minLength": 36,
|
||||
"maxLength": 1024,
|
||||
"pattern": "^arn:aws[a-z0-9-]*:events:[a-z0-9-]+:\\d{12}:event-bus/[^:]+$"
|
||||
},
|
||||
"AWS::SES::ConfigurationSetEventDestination/EventDestination": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"Name": "String",
|
||||
"Name": "AWS::SES::ConfigurationSetEventDestination/EventDestination.Name",
|
||||
"Enabled": "Boolean",
|
||||
"MatchingEventTypes": "AWS::SES::ConfigurationSetEventDestination/EventDestination.MatchingEventTypes",
|
||||
"CloudWatchDestination": "AWS::SES::ConfigurationSetEventDestination/CloudWatchDestination",
|
||||
@@ -2589,6 +2741,10 @@
|
||||
"type": "list",
|
||||
"member": "String"
|
||||
},
|
||||
"AWS::SES::ConfigurationSetEventDestination/EventDestination.Name": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]{0,64}$"
|
||||
},
|
||||
"AWS::SES::ConfigurationSetEventDestination/KinesisFirehoseDestination": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
@@ -2603,12 +2759,18 @@
|
||||
"AWS::SES::ConfigurationSetEventDestination/SnsDestination": {
|
||||
"type": "structure",
|
||||
"members": {
|
||||
"TopicARN": "String"
|
||||
"TopicARN": "AWS::SES::ConfigurationSetEventDestination/SnsDestination.TopicARN"
|
||||
},
|
||||
"required": [
|
||||
"TopicARN"
|
||||
]
|
||||
},
|
||||
"AWS::SES::ConfigurationSetEventDestination/SnsDestination.TopicARN": {
|
||||
"type": "string",
|
||||
"minLength": 36,
|
||||
"maxLength": 1024,
|
||||
"pattern": "^arn:aws[a-z0-9-]*:sns:[a-z0-9-]+:\\d{12}:[^:]+$"
|
||||
},
|
||||
"Boolean": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
||||
+92
-13
@@ -270,12 +270,95 @@ class CfnPropertyTypesTest {
|
||||
"#/EventDestination: required key [MatchingEventTypes] not found"),
|
||||
Arguments.of("null nested ARN",
|
||||
"{\"ConfigurationSetName\":\"set\",\"EventDestination\":{\"MatchingEventTypes\":[\"SEND\"],\"SnsDestination\":{\"TopicARN\":null}}}",
|
||||
"#/EventDestination/SnsDestination: required key [TopicARN] not found"),
|
||||
Arguments.of("blank nested ARN",
|
||||
"{\"ConfigurationSetName\":\"set\",\"EventDestination\":{\"MatchingEventTypes\":[\"SEND\"],\"SnsDestination\":{\"TopicARN\":\" \"}}}",
|
||||
"#/EventDestination/SnsDestination: required key [TopicARN] not found"));
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0}")
|
||||
@MethodSource("invalidSesArnValues")
|
||||
void handlerReaderRejectsArnValuesOutsideSchemaConstraints(String caseName, String destination,
|
||||
String member, String arn, String violation) {
|
||||
String properties = """
|
||||
{"ConfigurationSetName":"set","EventDestination":{
|
||||
"MatchingEventTypes":["SEND"],"%s":{"%s":"%s"}}}
|
||||
""".formatted(destination, member, arn);
|
||||
|
||||
assertHandlerReaderFailure("AWS::SES::ConfigurationSetEventDestination", properties,
|
||||
"Model validation failed (#/EventDestination/" + destination + "/" + member + ": "
|
||||
+ violation + ")");
|
||||
}
|
||||
|
||||
static Stream<Arguments> invalidSesArnValues() {
|
||||
String snsPrefix = "arn:aws:sns:us-east-1:000000000000:";
|
||||
return Stream.of(
|
||||
Arguments.of("SNS ARN has wrong service", "SnsDestination", "TopicARN",
|
||||
"arn:aws:sqs:us-east-1:000000000000:topic-name",
|
||||
"failed validation constraint for keyword [pattern]"),
|
||||
Arguments.of("SNS ARN is below schema minimum", "SnsDestination", "TopicARN",
|
||||
"arn:aws:sns:a:000000000000:x", "expected minLength: 36, actual: 28"),
|
||||
Arguments.of("SNS ARN is blank", "SnsDestination", "TopicARN", "",
|
||||
"expected minLength: 36, actual: 0"),
|
||||
Arguments.of("SNS ARN exceeds schema maximum", "SnsDestination", "TopicARN",
|
||||
snsPrefix + "x".repeat(1100 - snsPrefix.length()),
|
||||
"expected maxLength: 1024, actual: 1100"),
|
||||
Arguments.of("EventBridge ARN has wrong service", "EventBridgeDestination", "EventBusArn",
|
||||
"arn:aws:sns:us-east-1:000000000000:event-bus/topic-name",
|
||||
"failed validation constraint for keyword [pattern]"));
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0}")
|
||||
@MethodSource("invalidSesDestinationStrings")
|
||||
void handlerReaderChecksEveryConstrainedSesString(String caseName, String properties,
|
||||
String expectedMessage) {
|
||||
assertHandlerReaderFailure("AWS::SES::ConfigurationSetEventDestination", properties,
|
||||
"Model validation failed (" + expectedMessage + ")");
|
||||
}
|
||||
|
||||
static Stream<Arguments> invalidSesDestinationStrings() {
|
||||
String dimensions = """
|
||||
{"ConfigurationSetName":"set","EventDestination":{"MatchingEventTypes":["SEND"],
|
||||
"CloudWatchDestination":{"DimensionConfigurations":[{"DimensionValueSource":"emailHeader",
|
||||
"DimensionName":"%s","DefaultDimensionValue":"%s"}]}}}
|
||||
""";
|
||||
return Stream.of(
|
||||
Arguments.of("event destination name pattern", """
|
||||
{"ConfigurationSetName":"set","EventDestination":{
|
||||
"MatchingEventTypes":["SEND"],"Name":"bad name"}}
|
||||
""", "#/EventDestination/Name: failed validation constraint for keyword [pattern]"),
|
||||
Arguments.of("dimension name minimum", dimensions.formatted("", "value"),
|
||||
"#/EventDestination/CloudWatchDestination/DimensionConfigurations/0/DimensionName: "
|
||||
+ "expected minLength: 1, actual: 0"),
|
||||
Arguments.of("default dimension value maximum", dimensions.formatted("name", "x".repeat(257)),
|
||||
"#/EventDestination/CloudWatchDestination/DimensionConfigurations/0/DefaultDimensionValue: "
|
||||
+ "expected maxLength: 256, actual: 257"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void handlerReaderAcceptsValidSesArnsAndUnconstrainedRequiredStrings() {
|
||||
JsonNode properties = json("""
|
||||
{"ConfigurationSetName":"x","EventDestination":{
|
||||
"Name":"","MatchingEventTypes":["SEND"],
|
||||
"SnsDestination":{"TopicARN":"arn:aws:sns:us-east-1:000000000000:topic-name"},
|
||||
"EventBridgeDestination":{"EventBusArn":"arn:aws:events:us-east-1:000000000000:event-bus/topic-name"},
|
||||
"KinesisFirehoseDestination":{"IAMRoleARN":"role","DeliveryStreamARN":"stream"}}}
|
||||
""");
|
||||
|
||||
assertEquals(properties, new CfnPropertyTypes.HandlerReader(engine())
|
||||
.read("AWS::SES::ConfigurationSetEventDestination", properties));
|
||||
}
|
||||
|
||||
@Test
|
||||
void handlerReaderAcceptsSesArnAtSchemaMaximumLength() {
|
||||
String prefix = "arn:aws:sns:us-east-1:000000000000:";
|
||||
String arn = prefix + "x".repeat(1024 - prefix.length());
|
||||
JsonNode properties = json("""
|
||||
{"ConfigurationSetName":"set","EventDestination":{
|
||||
"MatchingEventTypes":["SEND"],"SnsDestination":{"TopicARN":"%s"}}}
|
||||
""".formatted(arn));
|
||||
|
||||
assertEquals(properties, new CfnPropertyTypes.HandlerReader(engine())
|
||||
.read("AWS::SES::ConfigurationSetEventDestination", properties));
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0}")
|
||||
@MethodSource("unknownSesMembers")
|
||||
void handlerReaderRejectsExtraneousMembers(String caseName, String properties, String violation) {
|
||||
@@ -289,7 +372,7 @@ class CfnPropertyTypesTest {
|
||||
"{\"ConfigurationSetName\":\"set\",\"EventDestination\":{\"MatchingEventTypes\":[\"SEND\"]},\"Extra\":true}",
|
||||
"#: extraneous key [Extra] is not permitted"),
|
||||
Arguments.of("nested member",
|
||||
"{\"ConfigurationSetName\":\"set\",\"EventDestination\":{\"MatchingEventTypes\":[\"SEND\"],\"SnsDestination\":{\"TopicARN\":\"arn\",\"Extra\":true}}}",
|
||||
"{\"ConfigurationSetName\":\"set\",\"EventDestination\":{\"MatchingEventTypes\":[\"SEND\"],\"SnsDestination\":{\"TopicARN\":\"arn:aws:sns:us-east-1:000000000000:topic-name\",\"Extra\":true}}}",
|
||||
"#/EventDestination/SnsDestination: extraneous key [Extra] is not permitted"));
|
||||
}
|
||||
|
||||
@@ -357,15 +440,11 @@ class CfnPropertyTypesTest {
|
||||
|
||||
@Test
|
||||
void handlerReaderReportsKnownMembersBeforeExtraneousMembers() {
|
||||
AwsException failure = assertThrows(AwsException.class,
|
||||
() -> new CfnPropertyTypes.HandlerReader(engine())
|
||||
.read("AWS::SES::ConfigurationSetEventDestination", json("""
|
||||
{"ConfigurationSetName":"set","EventDestination":{
|
||||
"Extra":true,"MatchingEventTypes":["SEND"],"Enabled":"bogus"}}
|
||||
""")));
|
||||
|
||||
assertEquals("Model validation failed (#/EventDestination/Enabled: expected type: Boolean, found: String\n"
|
||||
+ "#/EventDestination: extraneous key [Extra] is not permitted)", failure.getMessage());
|
||||
assertHandlerReaderFailure("AWS::SES::ConfigurationSetEventDestination", """
|
||||
{"ConfigurationSetName":"set","EventDestination":{
|
||||
"Extra":true,"MatchingEventTypes":["SEND"],"Enabled":"bogus"}}
|
||||
""", "Model validation failed (#/EventDestination/Enabled: expected type: Boolean, found: String\n"
|
||||
+ "#/EventDestination: extraneous key [Extra] is not permitted)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -55,7 +55,7 @@ RESOURCE_TYPES = ["AWS::AutoScaling::LaunchConfiguration", "AWS::DSQL::Cluster",
|
||||
"AWS::Lambda::Function", "AWS::Lambda::LayerVersion",
|
||||
"AWS::SES::ConfigurationSetEventDestination"]
|
||||
|
||||
# The shared shape each scalar body is written as, inline; a definition keeps its own name.
|
||||
# The shared shape each unconstrained scalar body is written as, inline; a definition keeps its own name.
|
||||
SCALAR_SHAPES = {"string": "String", "integer": "Integer", "boolean": "Boolean", "double": "Double", "json": "Json"}
|
||||
SCHEMA_SCALARS = {"string": "string", "integer": "integer", "boolean": "boolean", "number": "double"}
|
||||
SHAPE_TYPES = {"structure", "list", "map", *SCALAR_SHAPES}
|
||||
@@ -146,7 +146,7 @@ def shape_for(schema: dict, resource_type: str, name: str, node: dict, shapes: d
|
||||
shapes[target] = body_of(schema, resource_type, target, schema["definitions"][definition], shapes)
|
||||
return target
|
||||
body = body_of(schema, resource_type, name, node, shapes)
|
||||
if body["type"] in SCALAR_SHAPES:
|
||||
if body["type"] in SCALAR_SHAPES and len(body) == 1:
|
||||
return SCALAR_SHAPES[body["type"]]
|
||||
shapes[name] = body
|
||||
return name
|
||||
@@ -178,7 +178,12 @@ def body_of(schema: dict, resource_type: str, name: str, node: dict, shapes: dic
|
||||
items = node.get("items")
|
||||
member = shape_for(schema, resource_type, f"{name}[]", items, shapes) if isinstance(items, dict) else "Json"
|
||||
return {"type": "list", "member": member}
|
||||
return {"type": SCHEMA_SCALARS.get(kind, "json")}
|
||||
body = {"type": SCHEMA_SCALARS.get(kind, "json")}
|
||||
if kind == "string":
|
||||
for constraint in ("minLength", "maxLength", "pattern"):
|
||||
if constraint in node:
|
||||
body[constraint] = node[constraint]
|
||||
return body
|
||||
|
||||
|
||||
def render(document: dict) -> str:
|
||||
|
||||
@@ -23,7 +23,7 @@ SCHEMA = {
|
||||
"Attempts": {"type": "integer"}, "Enabled": {"type": "boolean"}, "Ratio": {"type": "number"}}},
|
||||
},
|
||||
"properties": {
|
||||
"Name": {"type": "string"},
|
||||
"Name": {"type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[a-z]+$"},
|
||||
"Targets": {"type": "array", "items": {"$ref": "#/definitions/Target"}},
|
||||
"Pattern": {"type": "object"},
|
||||
"Tags": {"type": "array", "items": {"type": "object", "properties": {"Key": {"type": "string"}}}},
|
||||
@@ -46,8 +46,10 @@ def test_each_schema_type_becomes_a_shape(monkeypatch):
|
||||
assert doc["operations"] == {"AWS::Test::Thing": "AWS::Test::Thing"}
|
||||
shapes = doc["shapes"]
|
||||
assert shapes["AWS::Test::Thing"] == {"type": "structure", "members": {
|
||||
"Name": "String", "Targets": "AWS::Test::Thing.Targets", "Pattern": "Json", "Tags": "AWS::Test::Thing.Tags"},
|
||||
"Name": "AWS::Test::Thing.Name", "Targets": "AWS::Test::Thing.Targets", "Pattern": "Json", "Tags": "AWS::Test::Thing.Tags"},
|
||||
"required": ["Name"]}
|
||||
assert shapes["AWS::Test::Thing.Name"] == {
|
||||
"type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[a-z]+$"}
|
||||
assert shapes["AWS::Test::Thing.Targets"] == {"type": "list", "member": "AWS::Test::Thing/Target"}
|
||||
assert shapes["AWS::Test::Thing/Target"] == {"type": "structure", "members": {
|
||||
"Id": "String", "Retry": "AWS::Test::Thing/Retry", "Labels": "AWS::Test::Thing/Target.Labels",
|
||||
@@ -77,7 +79,11 @@ def test_ses_event_destination_shape_preserves_nested_schema_constraints():
|
||||
assert shapes[type_name]["required"] == ["ConfigurationSetName", "EventDestination"]
|
||||
destination = shapes[f"{type_name}/EventDestination"]
|
||||
assert destination["required"] == ["MatchingEventTypes"]
|
||||
assert destination["members"]["Name"] == "String"
|
||||
assert destination["members"]["Name"] == f"{type_name}/EventDestination.Name"
|
||||
assert shapes[f"{type_name}/EventDestination.Name"]["pattern"] == "^[a-zA-Z0-9_-]{0,64}$"
|
||||
dimension = shapes[f"{type_name}/DimensionConfiguration"]
|
||||
assert shapes[dimension["members"]["DimensionName"]]["minLength"] == 1
|
||||
assert shapes[dimension["members"]["DefaultDimensionValue"]]["maxLength"] == 256
|
||||
assert destination["members"]["MatchingEventTypes"] == f"{type_name}/EventDestination.MatchingEventTypes"
|
||||
assert shapes[f"{type_name}/SnsDestination"]["required"] == ["TopicARN"]
|
||||
assert shapes[f"{type_name}/KinesisFirehoseDestination"]["required"] == ["IAMRoleARN", "DeliveryStreamARN"]
|
||||
|
||||
Reference in new issue
Block a user