INNER CODE UNIT · Python
validate_testssl_uri
rfc-st/humble · humble.py:451
def validate_testssl_uri(uri):
"""Check that the URI is well-formed before analyzing it.
Exit with a specific message if the URI has no scheme, an unsupported
one, no host, or embedded whitespace that could smuggle extra arguments
into the `testssl.sh` command; related to `-e` option.
"""
if any(char.isspace() for char in uri):
print_error_detail("[e_url]")
parsed_uri = urlparse(uri)
if not parsed_uri.scheme:
print_error_detail("[e_mschema]")
if parsed_uri.scheme not in HTTP_SCHEMES_S:
print_error_detail("[e_ischema]")
if not parsed_uri.netloc:
print_error_detail("[e_url]")