diff --git a/humble.py b/humble.py index 9e02d7c..e5611b9 100644 --- a/humble.py +++ b/humble.py @@ -40,6 +40,7 @@ from fpdf import FPDF from time import time from datetime import datetime +from urllib.parse import urlparse from os import linesep, path, remove from colorama import Fore, Style, init from collections import Counter, defaultdict @@ -292,10 +293,21 @@ def testssl_params(directory, uri): testssl_file = path.join(directory, 'testssl.sh') if not path.isfile(testssl_file): sys.exit(f"\n{get_detail('[notestssl_path]')}") + elif not testsst_check_uri(uri): + print("") + sys.exit(get_detail('[kotestssl_uri]')) else: testssl_analysis(testssl_file, uri) +def testsst_check_uri(uri): + try: + parsed_uri = urlparse(uri) + return all([parsed_uri.scheme, parsed_uri.netloc]) + except ValueError: + return False + + def testssl_analysis(testssl_file, uri): # Check './testssl.sh --help' to choose your preferred options: # -p: checks TLS/SSL protocols (including SPDY/HTTP2) @@ -309,9 +321,9 @@ def testssl_analysis(testssl_file, uri): stderr=subprocess.PIPE, text=True) for line in iter(process.stdout.readline, ''): print(line, end='') - if line.strip().startswith("(Done )"): - break - process.communicate() + if 'Done' in line: + process.terminate() + sys.exit() except subprocess.CalledProcessError as e: print(f"Command stderr: {e.stderr}") except Exception as e: diff --git a/i10n/details.txt b/i10n/details.txt index cae210d..b1dcdb6 100644 --- a/i10n/details.txt +++ b/i10n/details.txt @@ -1160,4 +1160,7 @@ Windows is excluded in this analysis (it should work with Cygwin//MSYS2/WSL but '-o json' currently requires '-b'. [notestssl_path] -Error: 'testssl.sh' is not found in that PATH. \ No newline at end of file +Error: 'testssl.sh' is not found in that PATH. + +[kotestssl_uri] +Error: The URL may be incorrect; please check it. \ No newline at end of file diff --git a/i10n/details_es.txt b/i10n/details_es.txt index 78e9e1e..057af36 100644 --- a/i10n/details_es.txt +++ b/i10n/details_es.txt @@ -1160,4 +1160,7 @@ Windows está excluido en este análisis (debería funcionar con Cygwin//MSYS2/W '-o json' requiere, por ahora, '-b'. [notestssl_path] -Error: no ha encontrado 'testssl.sh' en esa ruta. \ No newline at end of file +Error: no ha encontrado 'testssl.sh' en esa ruta. + +[kotestssl_uri] +Error: La URL puede ser incorrecta; por favor, revísala. \ No newline at end of file