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
This commit is contained in:
David Danielsson 2025-05-30 15:25:10 -05:00 committed by GitHub
parent 9520c83da9
commit a655a3f127
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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