Skip to content

Commit

Permalink
Minor: Improve TLS/SSL checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc-st committed Nov 17, 2023
1 parent 7822185 commit 4e97012
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
18 changes: 15 additions & 3 deletions humble.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion i10n/details.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Error: 'testssl.sh' is not found in that PATH.

[kotestssl_uri]
Error: The URL may be incorrect; please check it.
5 changes: 4 additions & 1 deletion i10n/details_es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Error: no ha encontrado 'testssl.sh' en esa ruta.

[kotestssl_uri]
Error: La URL puede ser incorrecta; por favor, revísala.

0 comments on commit 4e97012

Please sign in to comment.