diff options
author | Rohan Arora <roarora@redhat.com> | 2019-12-05 19:01:03 +0530 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2020-01-08 12:54:52 -0500 |
commit | dd5d421aa02eb50ad345a9218d09e1e442dbabff (patch) | |
tree | b2bb062058bb1318b1ccc2a0f10b4183c114892e | |
parent | 8958a5e378046d9f7fc30e41d939b7877e9baf15 (diff) | |
download | sos-dd5d421aa02eb50ad345a9218d09e1e442dbabff.tar.gz |
[pulp] Fix invalid syntax in collected json files
Plugin replaces sensitive data in etc/pulp/server/plugins.conf.d/*json
with ******* which is an invalid json value. Also it takes away a ","
and collected file is no longer a valid json. This change modifies the
regex used to get a valid json file.
Also Fixed Regex above it which was consuming any file having "conf"
even in middle of file path.
Closes #1878
Signed-off-by: Rohan Arora <roarora@redhat.com>
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r-- | sos/plugins/pulp.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sos/plugins/pulp.py b/sos/plugins/pulp.py index 1f227e76..bd087a0f 100644 --- a/sos/plugins/pulp.py +++ b/sos/plugins/pulp.py @@ -136,10 +136,20 @@ class Pulp(Plugin, RedHatPlugin): return _cmd % quote(_moncmd % (_mondb, query)) def postproc(self): + + # Handle all ".conf" files under /etc/pulp - note that this includes + # files nested at several distinct directory levels. For this reason we + # use a regex that matches all these path components with ".*", and + # ensure that the path ends with ".conf". etcreg = r"(([a-z].*(passw|token|cred|secret).*)\:(\s))(.*)" repl = r"\1 ********" - self.do_path_regex_sub("/etc/pulp/(.*).conf", etcreg, repl) - jreg = r"(\s*\".*(passw|cred|token|secret).*\:)(.*)" + self.do_path_regex_sub(r"/etc/pulp/(.*)\.conf$", etcreg, repl) + + # Now handle JSON-formatted data in the same /etc/pulp directory + # structure. We use a different substitution string here to preserve + # the file's JSON syntax. + jreg = r"(\s*\".*(passw|cred|token|secret).*\"\s*:\s*\")(.*)(\")" + repl = r"\1********\4" self.do_path_regex_sub("/etc/pulp(.*)(.json$)", jreg, repl) # vim: set et ts=4 sw=4 : |