29
29
import java .net .URISyntaxException ;
30
30
import java .net .URL ;
31
31
import java .util .ArrayList ;
32
+ import java .util .Arrays ;
32
33
import java .util .List ;
33
34
import java .util .Properties ;
34
35
import java .util .concurrent .Callable ;
@@ -157,13 +158,7 @@ protected String buildCommandLine(String[] command) {
157
158
boolean obscureParam = false ;
158
159
for (int i = 0 ; i < command .length ; i ++) {
159
160
String cmd = command [i ];
160
- if (StringUtils .isNotEmpty (cmd ) && cmd .startsWith ("vi://" )) {
161
- String [] tokens = cmd .split ("@" );
162
- if (tokens .length >= 2 ) {
163
- builder .append ("vi://" ).append ("******@" ).append (tokens [1 ]).append (" " );
164
- } else {
165
- builder .append ("vi://" ).append ("******" ).append (" " );
166
- }
161
+ if (sanitizeViCmdParameter (cmd , builder ) || sanitizeRbdFileFormatCmdParameter (cmd , builder )) {
167
162
continue ;
168
163
}
169
164
if (obscureParam ) {
@@ -181,6 +176,41 @@ protected String buildCommandLine(String[] command) {
181
176
return builder .toString ();
182
177
}
183
178
179
+ private boolean sanitizeViCmdParameter (String cmd , StringBuilder builder ) {
180
+ if (StringUtils .isEmpty (cmd ) || !cmd .startsWith ("vi://" )) {
181
+ return false ;
182
+ }
183
+
184
+ String [] tokens = cmd .split ("@" );
185
+ if (tokens .length >= 2 ) {
186
+ builder .append ("vi://" ).append ("******@" ).append (tokens [1 ]).append (" " );
187
+ } else {
188
+ builder .append ("vi://" ).append ("******" ).append (" " );
189
+ }
190
+ return true ;
191
+ }
192
+
193
+ private boolean sanitizeRbdFileFormatCmdParameter (String cmd , StringBuilder builder ) {
194
+ if (StringUtils .isEmpty (cmd ) || !cmd .startsWith ("rbd:" ) || !cmd .contains ("key=" )) {
195
+ return false ;
196
+ }
197
+
198
+ String [] tokens = cmd .split ("key=" );
199
+ if (tokens .length != 2 ) {
200
+ return false ;
201
+ }
202
+
203
+ String tokenWithKey = tokens [1 ];
204
+ String [] options = tokenWithKey .split (":" );
205
+ if (options .length > 1 ) {
206
+ String optionsAfterKey = String .join (":" , Arrays .copyOfRange (options , 1 , options .length ));
207
+ builder .append (tokens [0 ]).append ("key=" ).append ("******" ).append (":" ).append (optionsAfterKey ).append (" " );
208
+ } else {
209
+ builder .append (tokens [0 ]).append ("key=" ).append ("******" ).append (" " );
210
+ }
211
+ return true ;
212
+ }
213
+
184
214
public long getTimeout () {
185
215
return _timeout ;
186
216
}
0 commit comments