From 0074fcc1af58b0fba9790ddb59ac10557d74b32b Mon Sep 17 00:00:00 2001 From: Joe Testa Date: Wed, 26 Apr 2023 21:55:40 -0400 Subject: [PATCH] Rolled back Windows multithreading crash fix, as upgrading from Python v3.9 to v3.11 may have fixed the root cause. (#152) --- README.md | 1 - build_windows_executable.sh | 4 ++-- src/ssh_audit/ssh_audit.py | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a62a88f..4595b23 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,6 @@ For convenience, a web front-end on top of the command-line tool is available at - JSON output now includes recommendations and CVE data. - Mixed host key/CA key types (i.e.: RSA host keys signed with ED25519 CAs, etc.) are now properly handled. - Warnings are now printed for 2048-bit moduli. - - Fixed Windows-specific crash when multiple threads were used. - SHA-1 algorithms now cause failures. - CBC mode ciphers are now warnings instead of failures. - Generic failure/warning messages replaced with more specific reasons (i.e.: 'using weak cipher' => 'using broken RC4 cipher'). diff --git a/build_windows_executable.sh b/build_windows_executable.sh index 009e7fe..62ffc54 100755 --- a/build_windows_executable.sh +++ b/build_windows_executable.sh @@ -49,8 +49,8 @@ if [[ "$(python -V)" != "Python 3."* ]]; then fi # Install/update package dependencies. -echo "Installing/updating pyinstaller, colorama, and idna packages..." -pip install -U pyinstaller colorama idna +echo "Installing/updating pyinstaller and colorama packages..." +pip install -U pyinstaller colorama echo # Prompt for the version to release. diff --git a/src/ssh_audit/ssh_audit.py b/src/ssh_audit/ssh_audit.py index bc6099b..815e6a8 100755 --- a/src/ssh_audit/ssh_audit.py +++ b/src/ssh_audit/ssh_audit.py @@ -62,7 +62,7 @@ from ssh_audit.utils import Utils from ssh_audit.versionvulnerabilitydb import VersionVulnerabilityDB -no_idna_workaround = False +# no_idna_workaround = False # Only import colorama under Windows. Other OSes can natively handle terminal colors. if sys.platform == 'win32': @@ -73,12 +73,12 @@ if sys.platform == 'win32': pass # This is a workaround for a Python bug that causes a crash on Windows when multiple threads are used (see https://github.com/python/cpython/issues/73474). Importing the idna module and using it in a no-op seems to fix the issue. Otherwise, if idna isn't available at run-time, force single threaded scans. - try: - import idna # noqa: F401 - - ''.encode('idna') - except ImportError: - no_idna_workaround = True + # try: + # import idna # noqa: F401 + # + # ''.encode('idna') + # except ImportError: + # no_idna_workaround = True def usage(uout: OutputBuffer, err: Optional[str] = None) -> None: @@ -766,13 +766,13 @@ def process_commandline(out: OutputBuffer, args: List[str], usage_cb: Callable[. aconf.target_file = a # If we're on Windows, and we can't use the idna workaround, force only one thread to be used (otherwise a crash would occur). - if no_idna_workaround: - print("\nWARNING: the idna module was not found on this system, thus only single-threaded scanning will be done (this is a workaround for this Windows-specific crash: https://github.com/python/cpython/issues/73474). Multi-threaded scanning can be enabled by installing the idna module (pip install idna).\n") - aconf.threads = 1 + # if no_idna_workaround: + # print("\nWARNING: the idna module was not found on this system, thus only single-threaded scanning will be done (this is a workaround for this Windows-specific crash: https://github.com/python/cpython/issues/73474). Multi-threaded scanning can be enabled by installing the idna module (pip install idna).\n") + # aconf.threads = 1 elif o == '--threads': aconf.threads = int(a) - if no_idna_workaround: - aconf.threads = 1 + # if no_idna_workaround: + # aconf.threads = 1 elif o in ('-L', '--list-policies'): aconf.list_policies = True elif o == '--lookup':