Skip to content

Commit ad2a092

Browse files
arif-alipmoravec
authored andcommitted
[haproxy] Obfuscate the stats auth
Example of the line that needed to be obfuscated ``` listen stats bind 127.0.0.1:8888 mode http stats enable stats hide-version stats realm Haproxy\ Statistics stats uri / stats auth admin:AQoZ0cvVsXdVfMOYuOfWS7BEr4aVe42e ``` Also use f-strings on the rest of the plugin. Signed-off-by: Arif Ali <arif-ali@ubuntu.com>
1 parent 46cc231 commit ad2a092

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

sos/report/plugins/haproxy.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class HAProxy(Plugin, RedHatPlugin, DebianPlugin):
3131
def setup(self):
3232
self.add_copy_spec([
3333
"/etc/haproxy/haproxy.cfg",
34-
self.var_puppet_gen + "/etc/haproxy/haproxy.cfg"
34+
f"{self.var_puppet_gen}/etc/haproxy/haproxy.cfg"
3535
])
3636
self.add_copy_spec("/etc/haproxy/conf.d/*")
3737
self.add_cmd_output("haproxy -f /etc/haproxy/haproxy.cfg -c")
@@ -63,10 +63,20 @@ def setup(self):
6363
return
6464

6565
# check if provision_ip contains port - if not, add default ":1993"
66-
if urlparse("http://"+provision_ip).port is None:
66+
if urlparse(f"http://{provision_ip}").port is None:
6767
provision_ip = provision_ip + ":1993"
6868

69-
self.add_cmd_output("curl http://"+provision_ip+r"/\;csv",
69+
self.add_cmd_output(fr"curl http://{provision_ip}/\;csv",
7070
suggest_filename="haproxy_overview.txt")
7171

72+
def postproc(self):
73+
self.do_path_regex_sub(
74+
"/etc/haproxy/",
75+
r"(stats auth \w+:)(.*)",
76+
r"\1*********")
77+
self.do_path_regex_sub(
78+
f"{self.var_puppet_gen}/etc/haproxy/",
79+
r"(stats auth \w+:)(.*)",
80+
r"\1*********")
81+
7282
# vim: set et ts=4 sw=4 :

0 commit comments

Comments
 (0)