From d05eae7feddf536bdf5986f73febf5dcb30dfe8e Mon Sep 17 00:00:00 2001 From: Brian Pandola Date: Sat, 22 Jul 2023 03:55:57 -0700 Subject: [PATCH] Fix code scanning alerts (#6551) * Escape period in URL regex * Fix capital letter range * Fix unintentional range and duplicate period in regex * Formatting --- moto/backend_index.py | 7 +++++-- moto/glue/glue_schema_registry_constants.py | 2 +- moto/ssm/models.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/moto/backend_index.py b/moto/backend_index.py index 9f99ed313..477175fb2 100644 --- a/moto/backend_index.py +++ b/moto/backend_index.py @@ -110,9 +110,12 @@ backend_url_patterns = [ ), ( "meteringmarketplace", - re.compile("https?://metering.marketplace.(.+).amazonaws.com"), + re.compile("https?://metering.marketplace\\.(.+)\\.amazonaws.com"), + ), + ( + "meteringmarketplace", + re.compile("https?://aws-marketplace\\.(.+)\\.amazonaws.com"), ), - ("meteringmarketplace", re.compile("https?://aws-marketplace.(.+).amazonaws.com")), ("mq", re.compile("https?://mq\\.(.+)\\.amazonaws\\.com")), ("opsworks", re.compile("https?://opsworks\\.us-east-1\\.amazonaws.com")), ("organizations", re.compile("https?://organizations\\.(.+)\\.amazonaws\\.com")), diff --git a/moto/glue/glue_schema_registry_constants.py b/moto/glue/glue_schema_registry_constants.py index 2dc709a97..7aef1186f 100644 --- a/moto/glue/glue_schema_registry_constants.py +++ b/moto/glue/glue_schema_registry_constants.py @@ -39,7 +39,7 @@ SCHEMA_VERSION_ID_PATTERN = re.compile( r"^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$" ) MIN_SCHEMA_VERSION_ID_LENGTH = 36 -SCHEMA_VERSION_METADATA_PATTERN = re.compile(r"^[a-zA-Z0-9+-=._./@]+$") +SCHEMA_VERSION_METADATA_PATTERN = re.compile(r"^[a-zA-Z0-9+=._/@-]+$") MAX_SCHEMA_VERSION_METADATA_ALLOWED = 10 MAX_SCHEMA_VERSION_METADATA_LENGTH = 128 METADATA_KEY = "MetadataKey" diff --git a/moto/ssm/models.py b/moto/ssm/models.py index 1ffc1a9d5..f570edf32 100644 --- a/moto/ssm/models.py +++ b/moto/ssm/models.py @@ -1981,7 +1981,7 @@ class SimpleSystemManagerBackend(BaseBackend): label.startswith("aws") or label.startswith("ssm") or label[:1].isdigit() - or not re.match(r"^[a-zA-z0-9_\.\-]*$", label) + or not re.match(r"^[a-zA-Z0-9_\.\-]*$", label) ): invalid_labels.append(label) continue