From b25afbb4e99404ce5c6f30ac3be69aa525f07042 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 12 Aug 2024 17:28:27 -0700 Subject: [PATCH] Suppress cryptography warnings for paramiko (#83772) --- changelogs/fragments/suppress-paramiko-warnings.yml | 2 ++ lib/ansible/module_utils/compat/paramiko.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/suppress-paramiko-warnings.yml diff --git a/changelogs/fragments/suppress-paramiko-warnings.yml b/changelogs/fragments/suppress-paramiko-warnings.yml new file mode 100644 index 00000000000..15c726cb366 --- /dev/null +++ b/changelogs/fragments/suppress-paramiko-warnings.yml @@ -0,0 +1,2 @@ +minor_changes: + - Suppress cryptography deprecation warnings for Blowfish and TripleDES when the ``paramiko`` Python module is installed. diff --git a/lib/ansible/module_utils/compat/paramiko.py b/lib/ansible/module_utils/compat/paramiko.py index 8c84261cef8..302309cdaa8 100644 --- a/lib/ansible/module_utils/compat/paramiko.py +++ b/lib/ansible/module_utils/compat/paramiko.py @@ -11,7 +11,12 @@ PARAMIKO_IMPORT_ERR = None try: with warnings.catch_warnings(): - warnings.filterwarnings('ignore', message='Blowfish has been deprecated', category=UserWarning) + # Blowfish has been moved, but the deprecated import is used by paramiko versions older than 2.9.5. + # See: https://github.com/paramiko/paramiko/pull/2039 + warnings.filterwarnings('ignore', message='Blowfish has been ', category=UserWarning) + # TripleDES has been moved, but the deprecated import is used by paramiko versions older than 3.3.2 and 3.4.1. + # See: https://github.com/paramiko/paramiko/pull/2421 + warnings.filterwarnings('ignore', message='TripleDES has been ', category=UserWarning) import paramiko # pylint: disable=unused-import # paramiko and gssapi are incompatible and raise AttributeError not ImportError # When running in FIPS mode, cryptography raises InternalError