forked from sosreport/sos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforemanctl.py
More file actions
64 lines (50 loc) · 2.18 KB
/
Copy pathforemanctl.py
File metadata and controls
64 lines (50 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright (C) 2026 Red Hat, Inc., Pavel Moravec <pmoravec@redhat.com>
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin)
class Foremanctl(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
short_desc = 'Foremanctl as foreman in pods'
plugin_name = 'foremanctl'
profiles = ('sysmgmt',)
packages = ('foremanctl', )
containers = ('foreman', 'foreman-proxy',)
def setup(self):
self.add_copy_spec([
"/etc/foremanctl/inventory",
"/var/lib/foremanctl/parameters.yaml",
"/var/log/foremanctl/foremanctl.*log",
])
self.add_cmd_output([
"foremanctl features",
"foremanctl health",
])
self.add_dir_listing(["/var/lib/foremanctl/"], recursive=True)
def postproc(self):
# Scrub passwords, credentials, tokens, secrets, and keys
self.do_path_regex_sub(
"/var/lib/foremanctl/parameters.yaml",
r"((.*)?(passw|cred|token|secret|key).*(\:\s|=))(.*)",
r"\1********")
# Scrub passwords from foremanctl logs - Pattern 1: key=value format
self.do_path_regex_sub(
"/var/log/foremanctl/foremanctl.*log*",
r"((passw|cred|token|secret|key)\w*\s*=\s*)(.*?)(\s|,|\"|'|$)",
r"\1********\4")
# Scrub passwords from foremanctl logs -
# Pattern 2: "password something" format
self.do_path_regex_sub(
"/var/log/foremanctl/foremanctl.*log*",
r"(password\s+)(.*?)(\s|,|\"|$)",
r"\1********\3")
# Scrub admin credentials in username:password format
self.do_path_regex_sub(
"/var/log/foremanctl/foremanctl.*log*",
r"(Admin credentials:\s+\w+:)(.*?)(\"|,|$)",
r"\1********\3")
# vim: set et ts=4 sw=4 :