2929import java .net .URISyntaxException ;
3030import java .net .URL ;
3131import java .util .ArrayList ;
32+ import java .util .Arrays ;
3233import java .util .List ;
3334import java .util .Properties ;
3435import java .util .concurrent .Callable ;
@@ -157,13 +158,7 @@ protected String buildCommandLine(String[] command) {
157158 boolean obscureParam = false ;
158159 for (int i = 0 ; i < command .length ; i ++) {
159160 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 )) {
167162 continue ;
168163 }
169164 if (obscureParam ) {
@@ -181,6 +176,49 @@ protected String buildCommandLine(String[] command) {
181176 return builder .toString ();
182177 }
183178
179+ private boolean sanitizeViCmdParameter (String cmd , StringBuilder builder ) {
180+ if (StringUtils .isEmpty (cmd ) || !cmd .startsWith ("vi://" )) {
181+ return false ;
182+ }
183+
184+ if (builder == null ) {
185+ builder = new StringBuilder ();
186+ }
187+
188+ String [] tokens = cmd .split ("@" );
189+ if (tokens .length >= 2 ) {
190+ builder .append ("vi://" ).append ("******@" ).append (tokens [1 ]).append (" " );
191+ } else {
192+ builder .append ("vi://" ).append ("******" ).append (" " );
193+ }
194+ return true ;
195+ }
196+
197+ private boolean sanitizeRbdFileFormatCmdParameter (String cmd , StringBuilder builder ) {
198+ if (StringUtils .isEmpty (cmd ) || !cmd .startsWith ("rbd:" ) || !cmd .contains ("key=" )) {
199+ return false ;
200+ }
201+
202+ String [] tokens = cmd .split ("key=" );
203+ if (tokens .length != 2 ) {
204+ return false ;
205+ }
206+
207+ if (builder == null ) {
208+ builder = new StringBuilder ();
209+ }
210+
211+ String tokenWithKey = tokens [1 ];
212+ String [] options = tokenWithKey .split (":" );
213+ if (options .length > 1 ) {
214+ String optionsAfterKey = String .join (":" , Arrays .copyOfRange (options , 1 , options .length ));
215+ builder .append (tokens [0 ]).append ("key=" ).append ("******" ).append (":" ).append (optionsAfterKey ).append (" " );
216+ } else {
217+ builder .append (tokens [0 ]).append ("key=" ).append ("******" ).append (" " );
218+ }
219+ return true ;
220+ }
221+
184222 public long getTimeout () {
185223 return _timeout ;
186224 }
0 commit comments