From a655a3f127e730c924f3fb5c129180a72d3842d0 Mon Sep 17 00:00:00 2001 From: David Danielsson Date: Fri, 30 May 2025 15:25:10 -0500 Subject: [PATCH] standardizing how host gets validated (#16003) * removing the requirement for re and changing to startswith which the other AAP collections use * telling sonarqube to ignore this line * fixing lint error --- awx_collection/plugins/module_utils/controller_api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/awx_collection/plugins/module_utils/controller_api.py b/awx_collection/plugins/module_utils/controller_api.py index 8ecb3d2ab7..77b4d126e3 100644 --- a/awx_collection/plugins/module_utils/controller_api.py +++ b/awx_collection/plugins/module_utils/controller_api.py @@ -15,7 +15,6 @@ from ansible.module_utils.six.moves.configparser import ConfigParser, NoOptionEr from base64 import b64encode from socket import getaddrinfo, IPPROTO_TCP import time -import re from json import loads, dumps from os.path import isfile, expanduser, split, join, exists, isdir from os import access, R_OK, getcwd, environ, getenv @@ -106,7 +105,7 @@ class ControllerModule(AnsibleModule): setattr(self, short_param, direct_value) # Perform some basic validation - if not re.match('^https{0,1}://', self.host): + if not self.host.startswith(("https://", "http://")): # NOSONAR self.host = "https://{0}".format(self.host) # Try to parse the hostname as a url