From 22568cfda6d0432d15d7aae592e4a7e484328054 Mon Sep 17 00:00:00 2001 From: RakeshMohan-MSFT <49954584+RakeshMohanMSFT@users.noreply.github.com> Date: Sat, 24 Sep 2022 11:52:23 +0530 Subject: [PATCH 1/3] {containerapp} Fix #23934: Add validation for revision suffix parameter --- src/containerapp/azext_containerapp/custom.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index 78344fbeb1d..f1d5a629807 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -69,7 +69,7 @@ validate_hostname, patch_new_custom_domain, get_custom_domains, _validate_revision_name, set_managed_identity, create_acrpull_role_assignment, is_registry_msi_system, clean_null_values, _populate_secret_values, validate_environment_location, safe_set, parse_metadata_flags, parse_auth_flags) -from ._validators import validate_create +from ._validators import validate_create, validate_revision_suffix from ._ssh_utils import (SSH_DEFAULT_ENCODING, WebSocketConnection, read_ssh, get_stdin_writer, SSH_CTRL_C_MSG, SSH_BACKUP_ENCODING) from ._constants import (MAXIMUM_SECRET_LENGTH, MICROSOFT_SECRET_SETTING_NAME, FACEBOOK_SECRET_SETTING_NAME, GITHUB_SECRET_SETTING_NAME, @@ -346,6 +346,7 @@ def create_containerapp(cmd, register_provider_if_needed(cmd, CONTAINER_APPS_RP) validate_container_app_name(name) validate_create(registry_identity, registry_pass, registry_user, registry_server, no_wait) + validate_revision_suffix(revision_suffix) if registry_identity and not is_registry_msi_system(registry_identity): logger.info("Creating an acrpull role assignment for the registry identity") From 322e2c9c19b676ef6fcc67a69de3910b70d85059 Mon Sep 17 00:00:00 2001 From: RakeshMohan-MSFT <49954584+RakeshMohanMSFT@users.noreply.github.com> Date: Sat, 24 Sep 2022 11:55:50 +0530 Subject: [PATCH 2/3] {containerapp} Fix #23934: Add validation for revision suffix parameter --- src/containerapp/azext_containerapp/_validators.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/containerapp/azext_containerapp/_validators.py b/src/containerapp/azext_containerapp/_validators.py index c06fd2347b7..ad03fc0c409 100644 --- a/src/containerapp/azext_containerapp/_validators.py +++ b/src/containerapp/azext_containerapp/_validators.py @@ -13,6 +13,7 @@ from ._ssh_utils import ping_container_app from ._utils import safe_get, is_registry_msi_system from ._constants import ACR_IMAGE_SUFFIX +import re logger = get_logger(__name__) @@ -38,6 +39,15 @@ def _is_number(s): return False +def validate_revision_suffix(value): + if value is not None: + matched = re.match(r"^[a-z](?!.*-{2})([-a-z0-9]*[a-z0-9])?$", value) + if not matched: + raise ValidationError("Revision suffix value must consist of lower case alphanumeric characters or '-', " + "start with an alphabetic character, " + " and end with an alphanumeric character and cannot have '--'.") + + def validate_memory(namespace): if namespace.memory is not None: valid = False From a06f5558f3e269a09be82e115a0f42a096a03e81 Mon Sep 17 00:00:00 2001 From: Silas Strawn Date: Tue, 4 Oct 2022 15:43:58 -0700 Subject: [PATCH 3/3] Update src/containerapp/azext_containerapp/_validators.py Co-authored-by: Haroon Feisal <38823870+haroonf@users.noreply.github.com> --- src/containerapp/azext_containerapp/_validators.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/containerapp/azext_containerapp/_validators.py b/src/containerapp/azext_containerapp/_validators.py index ad03fc0c409..fe439411435 100644 --- a/src/containerapp/azext_containerapp/_validators.py +++ b/src/containerapp/azext_containerapp/_validators.py @@ -43,9 +43,8 @@ def validate_revision_suffix(value): if value is not None: matched = re.match(r"^[a-z](?!.*-{2})([-a-z0-9]*[a-z0-9])?$", value) if not matched: - raise ValidationError("Revision suffix value must consist of lower case alphanumeric characters or '-', " - "start with an alphabetic character, " - " and end with an alphanumeric character and cannot have '--'.") + raise ValidationError(f"Invalid Container App revision name {value}. A revision name must consist of lower case alphanumeric characters or '-', start with a letter, end with an alphanumeric character and cannot have '--'.") + def validate_memory(namespace):