Skip to content

Commit

Permalink
[foreman] Obfuscate http_proxy passwords. PR-3878 improvement
Browse files Browse the repository at this point in the history
Regular expression improvement for
#3878

Related: SAT-30137
Closes: #3878

Signed-off-by: Pablo Fernández Rodríguez <[email protected]>
  • Loading branch information
pafernanr committed Dec 13, 2024
1 parent 5f06a1b commit e52bc8a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions sos/report/plugins/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,14 @@ def postproc(self):
r"((\:|\s*)(passw|cred|token|secret|key).*(\:\s|=))(.*)",
r'\1"********"')
# hide proxy credentials..
self.do_paths_http_sub([
'/var/log/foreman/production.log*',
])
# .. even those appearing TWICE in the logfile, in format (one-line):
# Setting (7) update event on value --- https://USER:PASS@foobar:443,\
# --- https://USER:PASS@foobar:3128
self.do_path_regex_sub(
'/var/log/foreman/production.log*',
r", --- (http(s)?://)\S+:\S+(@.*)",
r"\1******:******\3"
r"((http(s)?://)\S+:\S+(@[^ \n]*))"
r"(, -- (http(s)?://)\S+:\S+(@.*))*",
r"\2******:******\4"
)
# hide proxy credentials from http_proxy setting
self.do_cmd_output_sub(
Expand Down

0 comments on commit e52bc8a

Please sign in to comment.