Blame SOURCES/sos-bz2095267-ovirt-answer-files-passwords.patch

7701ef
From 5fd872c64c53af37015f366295e0c2418c969757 Mon Sep 17 00:00:00 2001
7701ef
From: Yedidyah Bar David <didi@redhat.com>
7701ef
Date: Thu, 26 May 2022 16:43:21 +0300
7701ef
Subject: [PATCH] [ovirt] answer files: Filter out all password keys
7701ef
7701ef
Instead of hard-coding specific keys and having to maintain them over
7701ef
time, replace the values of all keys that have 'password' in their name.
7701ef
I think this covers all our current and hopefully future keys. It might
7701ef
add "false positives" - keys that are not passwords but have 'password'
7701ef
in their name - and I think that's a risk worth taking.
7701ef
7701ef
Sadly, the engine admin password prompt's name is
7701ef
'OVESETUP_CONFIG_ADMIN_SETUP', which does not include 'password', so has
7701ef
to be listed specifically.
7701ef
7701ef
A partial list of keys added since the replaced code was written:
7701ef
- grafana-related stuff
7701ef
- keycloak-related stuff
7701ef
- otopi-style answer files
7701ef
7701ef
Signed-off-by: Yedidyah Bar David <didi@redhat.com>
7701ef
Change-Id: I416c6e4078e7c3638493eb271d08d73a0c22b5ba
7701ef
---
7701ef
 sos/report/plugins/ovirt.py | 23 +++++++++++++----------
7701ef
 1 file changed, 13 insertions(+), 10 deletions(-)
7701ef
7701ef
diff --git a/sos/report/plugins/ovirt.py b/sos/report/plugins/ovirt.py
7701ef
index 09647bf1..3b1bb29b 100644
7701ef
--- a/sos/report/plugins/ovirt.py
7701ef
+++ b/sos/report/plugins/ovirt.py
7701ef
@@ -241,19 +241,22 @@ class Ovirt(Plugin, RedHatPlugin):
7701ef
                 r'{key}=********'.format(key=key)
7701ef
             )
7701ef
 
7701ef
-        # Answer files contain passwords
7701ef
-        for key in (
7701ef
-            'OVESETUP_CONFIG/adminPassword',
7701ef
-            'OVESETUP_CONFIG/remoteEngineHostRootPassword',
7701ef
-            'OVESETUP_DWH_DB/password',
7701ef
-            'OVESETUP_DB/password',
7701ef
-            'OVESETUP_REPORTS_CONFIG/adminPassword',
7701ef
-            'OVESETUP_REPORTS_DB/password',
7701ef
+        # Answer files contain passwords.
7701ef
+        # Replace all keys that have 'password' in them, instead of hard-coding
7701ef
+        # here the list of keys, which changes between versions.
7701ef
+        # Sadly, the engine admin password prompt name does not contain
7701ef
+        # 'password'... so neither does the env key.
7701ef
+        for item in (
7701ef
+            'password',
7701ef
+            'OVESETUP_CONFIG_ADMIN_SETUP',
7701ef
         ):
7701ef
             self.do_path_regex_sub(
7701ef
                 r'/var/lib/ovirt-engine/setup/answers/.*',
7701ef
-                r'{key}=(.*)'.format(key=key),
7701ef
-                r'{key}=********'.format(key=key)
7701ef
+                re.compile(
7701ef
+                    r'(?P<key>[^=]*{item}[^=]*)=.*'.format(item=item),
7701ef
+                    flags=re.IGNORECASE
7701ef
+                ),
7701ef
+                r'\g<key>=********'
7701ef
             )
7701ef
 
7701ef
         # aaa profiles contain passwords
7701ef
-- 
7701ef
2.34.3
7701ef