From 12c214b9bf74c23a11420bece23fdc51a17daed2 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Tue, 26 Nov 2024 13:04:10 -0800 Subject: [PATCH 1/3] Add SES to case insensitive enums --- scripts/boto/_automated_patches.py | 9 ++++++--- scripts/boto/update_schemas_from_boto.py | 9 +++++++++ .../boto.json | 16 ++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/scripts/boto/_automated_patches.py b/scripts/boto/_automated_patches.py index 0910340ed8..e41435d7e0 100644 --- a/scripts/boto/_automated_patches.py +++ b/scripts/boto/_automated_patches.py @@ -9,7 +9,7 @@ from _types import AllPatches, Patch, ResourcePatches -from cfnlint.schema.resolver import RefResolver +from cfnlint.schema.resolver import RefResolutionError, RefResolver skip = [ "account", @@ -144,7 +144,7 @@ def _nested_objects( start_path: str, source: list[str], ): - results = {} + results: dict[str, Patch] = {} for member, member_data in shape_data.get("members", {}).items(): for p_name, p_data in schema_data.get("properties", {}).items(): if p_name in skip_property_names: @@ -162,7 +162,10 @@ def _nested_objects( if "$ref" not in p_data: break path = p_data["$ref"][1:] - p_data = resolver.resolve_from_url(p_data["$ref"]) + try: + p_data = resolver.resolve_from_url(p_data["$ref"]) + except RefResolutionError: + return results # skip if we already have an enum or pattern if any([p_data.get(field) for field in _fields]): diff --git a/scripts/boto/update_schemas_from_boto.py b/scripts/boto/update_schemas_from_boto.py index 4cde551bc4..d18ebe625a 100755 --- a/scripts/boto/update_schemas_from_boto.py +++ b/scripts/boto/update_schemas_from_boto.py @@ -88,6 +88,15 @@ def build_resource_type_patches( ) continue if value: + if ( + path + == ( + "/definitions/EventDestination/" + "properties/MatchingEventTypes/items" + ) + and patch.source[0] == "ses" + ): + value = [v.upper() for v in value] if patch.source[0] in case_insensitive_services and field == "enum": field = "enumCaseInsensitive" value = [v.lower() for v in value] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_ses_configurationseteventdestination/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_ses_configurationseteventdestination/boto.json index 9abbe34034..de9d95a474 100644 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_ses_configurationseteventdestination/boto.json +++ b/src/cfnlint/data/schemas/patches/extensions/all/aws_ses_configurationseteventdestination/boto.json @@ -3,14 +3,14 @@ "op": "add", "path": "/definitions/EventDestination/properties/MatchingEventTypes/items/enum", "value": [ - "bounce", - "click", - "complaint", - "delivery", - "open", - "reject", - "renderingFailure", - "send" + "BOUNCE", + "CLICK", + "COMPLAINT", + "DELIVERY", + "OPEN", + "REJECT", + "RENDERINGFAILURE", + "SEND" ] }, { From f71248498d234d7c9faea9f9a1f06665bb1df023 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Tue, 26 Nov 2024 13:22:08 -0800 Subject: [PATCH 2/3] update boto scripts to have upper exc --- scripts/boto/update_schemas_from_boto.py | 15 ++++++--------- ...aws-ses-configurationseteventdestination.json | 16 ++++++++-------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/scripts/boto/update_schemas_from_boto.py b/scripts/boto/update_schemas_from_boto.py index d18ebe625a..067d3bf503 100755 --- a/scripts/boto/update_schemas_from_boto.py +++ b/scripts/boto/update_schemas_from_boto.py @@ -27,6 +27,9 @@ case_insensitive_services = [ "batch", ] +upper_case_paths = { + "ses": ["/definitions/EventDestination/properties/MatchingEventTypes/items"] +} def configure_logging(): @@ -88,15 +91,9 @@ def build_resource_type_patches( ) continue if value: - if ( - path - == ( - "/definitions/EventDestination/" - "properties/MatchingEventTypes/items" - ) - and patch.source[0] == "ses" - ): - value = [v.upper() for v in value] + if patch.source[0] in upper_case_paths: + if path in upper_case_paths[patch.source[0]]: + value = [v.upper() for v in value] if patch.source[0] in case_insensitive_services and field == "enum": field = "enumCaseInsensitive" value = [v.lower() for v in value] diff --git a/src/cfnlint/data/schemas/providers/us_east_1/aws-ses-configurationseteventdestination.json b/src/cfnlint/data/schemas/providers/us_east_1/aws-ses-configurationseteventdestination.json index 19445a5447..3a4493c14f 100644 --- a/src/cfnlint/data/schemas/providers/us_east_1/aws-ses-configurationseteventdestination.json +++ b/src/cfnlint/data/schemas/providers/us_east_1/aws-ses-configurationseteventdestination.json @@ -83,14 +83,14 @@ "insertionOrder": false, "items": { "enum": [ - "bounce", - "click", - "complaint", - "delivery", - "open", - "reject", - "renderingFailure", - "send" + "BOUNCE", + "CLICK", + "COMPLAINT", + "DELIVERY", + "OPEN", + "REJECT", + "RENDERINGFAILURE", + "SEND" ], "type": "string" }, From adf02d09a9b0743ec4cb0ff6c38e0b00fc1ce9da Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Wed, 27 Nov 2024 16:48:23 -0800 Subject: [PATCH 3/3] Turn MatchingEventTypes into an exception --- scripts/boto/update_schemas_from_boto.py | 9 +++++---- .../boto.json | 14 -------------- .../aws-ses-configurationseteventdestination.json | 10 ---------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/scripts/boto/update_schemas_from_boto.py b/scripts/boto/update_schemas_from_boto.py index 067d3bf503..829cd3f629 100755 --- a/scripts/boto/update_schemas_from_boto.py +++ b/scripts/boto/update_schemas_from_boto.py @@ -27,7 +27,8 @@ case_insensitive_services = [ "batch", ] -upper_case_paths = { + +exceptions = { "ses": ["/definitions/EventDestination/properties/MatchingEventTypes/items"] } @@ -91,9 +92,9 @@ def build_resource_type_patches( ) continue if value: - if patch.source[0] in upper_case_paths: - if path in upper_case_paths[patch.source[0]]: - value = [v.upper() for v in value] + if patch.source[0] in exceptions: + if path in exceptions[patch.source[0]]: + continue if patch.source[0] in case_insensitive_services and field == "enum": field = "enumCaseInsensitive" value = [v.lower() for v in value] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_ses_configurationseteventdestination/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_ses_configurationseteventdestination/boto.json index de9d95a474..abdb8fdcbc 100644 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_ses_configurationseteventdestination/boto.json +++ b/src/cfnlint/data/schemas/patches/extensions/all/aws_ses_configurationseteventdestination/boto.json @@ -1,18 +1,4 @@ [ - { - "op": "add", - "path": "/definitions/EventDestination/properties/MatchingEventTypes/items/enum", - "value": [ - "BOUNCE", - "CLICK", - "COMPLAINT", - "DELIVERY", - "OPEN", - "REJECT", - "RENDERINGFAILURE", - "SEND" - ] - }, { "op": "add", "path": "/definitions/DimensionConfiguration/properties/DimensionValueSource/enum", diff --git a/src/cfnlint/data/schemas/providers/us_east_1/aws-ses-configurationseteventdestination.json b/src/cfnlint/data/schemas/providers/us_east_1/aws-ses-configurationseteventdestination.json index 3a4493c14f..f2b68e7434 100644 --- a/src/cfnlint/data/schemas/providers/us_east_1/aws-ses-configurationseteventdestination.json +++ b/src/cfnlint/data/schemas/providers/us_east_1/aws-ses-configurationseteventdestination.json @@ -82,16 +82,6 @@ "MatchingEventTypes": { "insertionOrder": false, "items": { - "enum": [ - "BOUNCE", - "CLICK", - "COMPLAINT", - "DELIVERY", - "OPEN", - "REJECT", - "RENDERINGFAILURE", - "SEND" - ], "type": "string" }, "type": "array",