Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milktea02/25f2f1f38376b6ff87848ce1126d3025 to your computer and use it in GitHub Desktop.
Save milktea02/25f2f1f38376b6ff87848ce1126d3025 to your computer and use it in GitHub Desktop.
A patch that does a regex search and replace
From 173187af791ef1db3b431d9c4500050905b3da6d Mon Sep 17 00:00:00 2001
From: jw <jwong91@gmail.com>
Date: Tue, 24 Aug 2021 17:11:58 -0700
Subject: [PATCH] censor clickhouse config password in diffs
---
lib/ansible/plugins/callback/__init__.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py
index 38a1daa76d..f4bc087e88 100644
--- a/lib/ansible/plugins/callback/__init__.py
+++ b/lib/ansible/plugins/callback/__init__.py
@@ -22,6 +22,7 @@ __metaclass__ = type
import difflib
import json
import sys
+import re
from copy import deepcopy
@@ -232,6 +233,8 @@ class CallbackBase(AnsiblePlugin):
has_diff = False
for line in difflines:
has_diff = True
+ # milktea02 patch for config censoring
+ line = re.sub(r'(.*<password>).*(</password>.*)', r'\1redacted\2', line)
if line.startswith(u'+'):
line = stringc(line, C.COLOR_DIFF_ADD)
elif line.startswith(u'-'):
--
2.30.1 (Apple Git-130)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment