1 |
commit: 4a7e8d870f80b9d2f8a33a8c65d8c8c7db480637 |
2 |
Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Apr 3 21:46:38 2022 +0000 |
4 |
Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Apr 3 21:46:38 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=4a7e8d87 |
7 |
|
8 |
Add secret string remote shell command patch |
9 |
|
10 |
Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org> |
11 |
|
12 |
patches/secretstring.patch | 74 ++++++++++++++++++++++++++++++++++++++++++++++ |
13 |
1 file changed, 74 insertions(+) |
14 |
|
15 |
diff --git a/patches/secretstring.patch b/patches/secretstring.patch |
16 |
new file mode 100644 |
17 |
index 0000000..4e0833d |
18 |
--- /dev/null |
19 |
+++ b/patches/secretstring.patch |
20 |
@@ -0,0 +1,74 @@ |
21 |
+diff --git a/master/buildbot/process/buildstep.py b/master/buildbot/process/buildstep.py |
22 |
+index 7ac18b086..82ff7ce07 100644 |
23 |
+--- a/master/buildbot/process/buildstep.py |
24 |
++++ b/master/buildbot/process/buildstep.py |
25 |
+@@ -850,6 +850,7 @@ class ShellMixin: |
26 |
+ 'sigtermTime', |
27 |
+ 'initialStdin', |
28 |
+ 'decodeRC', |
29 |
++ 'SecretString', |
30 |
+ ] |
31 |
+ renderables = _shellMixinArgs |
32 |
+ |
33 |
+diff --git a/master/buildbot/process/remotecommand.py b/master/buildbot/process/remotecommand.py |
34 |
+index 90ec4c44d..fb3099b28 100644 |
35 |
+--- a/master/buildbot/process/remotecommand.py |
36 |
++++ b/master/buildbot/process/remotecommand.py |
37 |
+@@ -44,7 +44,7 @@ class RemoteCommand(base.RemoteCommandImpl): |
38 |
+ |
39 |
+ def __init__(self, remote_command, args, ignore_updates=False, |
40 |
+ collectStdout=False, collectStderr=False, decodeRC=None, |
41 |
+- stdioLogName='stdio'): |
42 |
++ stdioLogName='stdio', SecretString=False): |
43 |
+ if decodeRC is None: |
44 |
+ decodeRC = {0: SUCCESS} |
45 |
+ self.logs = {} |
46 |
+@@ -70,6 +70,7 @@ class RemoteCommand(base.RemoteCommandImpl): |
47 |
+ self.commandID = None |
48 |
+ self.deferred = None |
49 |
+ self.interrupted = False |
50 |
++ self.SecretString = SecretString |
51 |
+ # a lock to make sure that only one log-handling method runs at a time. |
52 |
+ # This is really only a problem with old-style steps, which do not |
53 |
+ # wait for the Deferred from one method before invoking the next. |
54 |
+@@ -275,6 +276,8 @@ class RemoteCommand(base.RemoteCommandImpl): |
55 |
+ def cleanup(data): |
56 |
+ if self.step is None: |
57 |
+ return data |
58 |
++ if self.SecretString and isinstance(self.SecretString, list) and len(self.SecretString) == 2: |
59 |
++ data = data.replace(self.SecretString[0], '<' + self.SecretString[1] + '>') |
60 |
+ return self.step.build.properties.cleanupTextFromSecrets(data) |
61 |
+ |
62 |
+ if self.debug: |
63 |
+@@ -358,7 +361,8 @@ class RemoteShellCommand(RemoteCommand): |
64 |
+ collectStdout=False, collectStderr=False, |
65 |
+ interruptSignal=None, |
66 |
+ initialStdin=None, decodeRC=None, |
67 |
+- stdioLogName='stdio'): |
68 |
++ stdioLogName='stdio', |
69 |
++ SecretString=False): |
70 |
+ if logfiles is None: |
71 |
+ logfiles = {} |
72 |
+ if decodeRC is None: |
73 |
+@@ -398,7 +402,8 @@ class RemoteShellCommand(RemoteCommand): |
74 |
+ super().__init__("shell", args, collectStdout=collectStdout, |
75 |
+ collectStderr=collectStderr, |
76 |
+ decodeRC=decodeRC, |
77 |
+- stdioLogName=stdioLogName) |
78 |
++ stdioLogName=stdioLogName, |
79 |
++ SecretString=SecretString) |
80 |
+ |
81 |
+ def _start(self): |
82 |
+ if self.args['usePTY'] is None: |
83 |
+diff --git a/master/buildbot/steps/shell.py b/master/buildbot/steps/shell.py |
84 |
+index d21ca7b9b..cf56a2802 100644 |
85 |
+--- a/master/buildbot/steps/shell.py |
86 |
++++ b/master/buildbot/steps/shell.py |
87 |
+@@ -183,6 +183,7 @@ class ShellCommand(buildstep.ShellMixin, buildstep.BuildStep): |
88 |
+ 'decodeRC', |
89 |
+ 'stdioLogName', |
90 |
+ 'workdir', |
91 |
++ 'SecretString', |
92 |
+ ] + buildstep.BuildStep.parms |
93 |
+ |
94 |
+ invalid_args = [] |