commit:     4a7e8d870f80b9d2f8a33a8c65d8c8c7db480637
Author:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
AuthorDate: Sun Apr  3 21:46:38 2022 +0000
Commit:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
CommitDate: Sun Apr  3 21:46:38 2022 +0000
URL:        
https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=4a7e8d87

Add secret string remote shell command patch

Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org>

 patches/secretstring.patch | 74 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/patches/secretstring.patch b/patches/secretstring.patch
new file mode 100644
index 0000000..4e0833d
--- /dev/null
+++ b/patches/secretstring.patch
@@ -0,0 +1,74 @@
+diff --git a/master/buildbot/process/buildstep.py 
b/master/buildbot/process/buildstep.py
+index 7ac18b086..82ff7ce07 100644
+--- a/master/buildbot/process/buildstep.py
++++ b/master/buildbot/process/buildstep.py
+@@ -850,6 +850,7 @@ class ShellMixin:
+         'sigtermTime',
+         'initialStdin',
+         'decodeRC',
++        'SecretString',
+     ]
+     renderables = _shellMixinArgs
+ 
+diff --git a/master/buildbot/process/remotecommand.py 
b/master/buildbot/process/remotecommand.py
+index 90ec4c44d..fb3099b28 100644
+--- a/master/buildbot/process/remotecommand.py
++++ b/master/buildbot/process/remotecommand.py
+@@ -44,7 +44,7 @@ class RemoteCommand(base.RemoteCommandImpl):
+ 
+     def __init__(self, remote_command, args, ignore_updates=False,
+                  collectStdout=False, collectStderr=False, decodeRC=None,
+-                 stdioLogName='stdio'):
++                 stdioLogName='stdio', SecretString=False):
+         if decodeRC is None:
+             decodeRC = {0: SUCCESS}
+         self.logs = {}
+@@ -70,6 +70,7 @@ class RemoteCommand(base.RemoteCommandImpl):
+         self.commandID = None
+         self.deferred = None
+         self.interrupted = False
++        self.SecretString = SecretString
+         # a lock to make sure that only one log-handling method runs at a 
time.
+         # This is really only a problem with old-style steps, which do not
+         # wait for the Deferred from one method before invoking the next.
+@@ -275,6 +276,8 @@ class RemoteCommand(base.RemoteCommandImpl):
+         def cleanup(data):
+             if self.step is None:
+                 return data
++            if self.SecretString and isinstance(self.SecretString, list) and 
len(self.SecretString) == 2:
++                data = data.replace(self.SecretString[0], '<' + 
self.SecretString[1] + '>')
+             return self.step.build.properties.cleanupTextFromSecrets(data)
+ 
+         if self.debug:
+@@ -358,7 +361,8 @@ class RemoteShellCommand(RemoteCommand):
+                  collectStdout=False, collectStderr=False,
+                  interruptSignal=None,
+                  initialStdin=None, decodeRC=None,
+-                 stdioLogName='stdio'):
++                 stdioLogName='stdio',
++                 SecretString=False):
+         if logfiles is None:
+             logfiles = {}
+         if decodeRC is None:
+@@ -398,7 +402,8 @@ class RemoteShellCommand(RemoteCommand):
+         super().__init__("shell", args, collectStdout=collectStdout,
+                          collectStderr=collectStderr,
+                          decodeRC=decodeRC,
+-                         stdioLogName=stdioLogName)
++                         stdioLogName=stdioLogName,
++                         SecretString=SecretString)
+ 
+     def _start(self):
+         if self.args['usePTY'] is None:
+diff --git a/master/buildbot/steps/shell.py b/master/buildbot/steps/shell.py
+index d21ca7b9b..cf56a2802 100644
+--- a/master/buildbot/steps/shell.py
++++ b/master/buildbot/steps/shell.py
+@@ -183,6 +183,7 @@ class ShellCommand(buildstep.ShellMixin, 
buildstep.BuildStep):
+                 'decodeRC',
+                 'stdioLogName',
+                 'workdir',
++                'SecretString',
+             ] + buildstep.BuildStep.parms
+ 
+             invalid_args = []

Reply via email to