Blame SOURCES/sos-bz1967113-ds-mask-password-in-ldif.patch

47940b
From 153c0154050a111fd7e5bcf4a685f906a1dea737 Mon Sep 17 00:00:00 2001
47940b
From: Jose Castillo <jcastillo@redhat.com>
47940b
Date: Wed, 10 Mar 2021 15:33:50 +0100
47940b
Subject: [PATCH] [ds] Mask password and encription keys in ldif files
47940b
47940b
Both /etc/dirsrv/slapd*/dse.ldif{,.startOK} files contain
47940b
sensitive information :
47940b
- all the nsSymmetricKey entries : symmetric encryption key
47940b
- nsslapd-rootpw : the admin password's hash
47940b
47940b
This patch masks these entries in the files we collect.
47940b
47940b
Resolves: #2442
47940b
47940b
Signed-off-by: Jose Castillo <jcastillo@redhat.com>
47940b
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
47940b
---
47940b
 sos/report/plugins/ds.py | 18 ++++++++++++++++++
47940b
 1 file changed, 18 insertions(+)
47940b
47940b
diff --git a/sos/report/plugins/ds.py b/sos/report/plugins/ds.py
47940b
index f4d68d6e..d467dc89 100644
47940b
--- a/sos/report/plugins/ds.py
47940b
+++ b/sos/report/plugins/ds.py
47940b
@@ -74,4 +74,22 @@ class DirectoryServer(Plugin, RedHatPlugin):
47940b
 
47940b
         self.add_cmd_output("ls -l /var/lib/dirsrv/slapd-*/db/*")
47940b
 
47940b
+    def postproc(self):
47940b
+        # Example for scrubbing rootpw hash
47940b
+        #
47940b
+        # nsslapd-rootpw: AAAAB3NzaC1yc2EAAAADAQABAAABAQDeXYA3juyPqaUuyfWV2HuIM
47940b
+        # v3gebb/5cvx9ehEAFF2yIKvsQN2EJGTV+hBM1DEOB4eyy/H11NqcNwm/2QsagDB3PVwYp
47940b
+        # 9VKN3BdhQjlhuoYKhLwgtYUMiGL8AX5g1qxjirIkTRJwjbXkSNuQaXig7wVjmvXnB2o7B
47940b
+        # zLtu99DiL1AizfVeZTYA+OVowYKYaXYljVmVKS+g3t29Obaom54ZLpfuoGMmyO64AJrWs
47940b
+        #
47940b
+        # to
47940b
+        #
47940b
+        # nsslapd-rootpw:********
47940b
+
47940b
+        regexppass = r"(nsslapd-rootpw(\s)*:(\s)*)(\S+)([\r\n]\s.*)*\n"
47940b
+        regexpkey = r"(nsSymmetricKey(\s)*::(\s)*)(\S+)([\r\n]\s.*)*\n"
47940b
+        repl = r"\1********\n"
47940b
+        self.do_path_regex_sub('/etc/dirsrv/*', regexppass, repl)
47940b
+        self.do_path_regex_sub('/etc/dirsrv/*', regexpkey, repl)
47940b
+
47940b
 # vim: set et ts=4 sw=4 :
47940b
-- 
47940b
2.26.3
47940b