Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion sos/report/plugins/saltmaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class SaltMaster(Plugin, IndependentPlugin):

packages = ('salt-master', 'salt-api',)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.collected_pillar_roots = []
Comment thread
TrevorBenson marked this conversation as resolved.

def setup(self):
if self.get_option("all_logs"):
self.add_copy_spec("/var/log/salt")
Expand Down Expand Up @@ -61,11 +65,22 @@ def add_pillar_roots(self):
cfg_pillar_roots = []
all_pillar_roots.extend(cfg_pillar_roots)

self.collected_pillar_roots = all_pillar_roots
self.add_copy_spec(all_pillar_roots)

def postproc(self):
regexp = r'(^\s+.*(pass|secret|(?<![A-z])key(?![A-z])).*:\ ).+$'
regexp = (
r'(^\s*.*(pass|secret|(?<![A-z])key(?![A-z])|'
r'api_?key|encryption_?key).*:\ ).+'
)
subst = r'\1******'

self.do_path_regex_sub("/etc/salt/*", regexp, subst)

for pillar_root in self.collected_pillar_roots:
normalized_root = pillar_root if pillar_root.endswith('/') else (
f"{pillar_root}/"
)
self.do_path_regex_sub(f"{normalized_root}*", regexp, subst)

# vim: set et ts=4 sw=4 :