File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
artifacts/opt/jboss/container/java/run Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,26 @@ function configure_passwd() {
225
225
if [ -w " $HOME /passwd" ]; then
226
226
sed " /^jboss/s/[^:]*/$( id -u) /3" /etc/passwd > " $HOME /passwd"
227
227
fi
228
+
229
+ # Mask secrets before printing
230
+ mask_passwords () {
231
+ local content=" $1 "
232
+ local result=" "
233
+
234
+ IFS=' ' read -r -a key_value_pairs <<< " $content"
235
+
236
+ for pair in " ${key_value_pairs[@]} " ; do
237
+ key=$( echo " $pair " | cut -d ' =' -f 1)
238
+ value=$( echo " $pair " | cut -d ' =' -f 2-)
239
+
240
+ if [[ $key =~ [Pp][Aa][Ss][Ss][Ww][Oo][Rr][Dd] ]]; then
241
+ result+=" $key =***** "
242
+ else
243
+ result+=" $pair "
244
+ fi
245
+ done
246
+
247
+ echo " ${result% } "
228
248
}
229
249
230
250
# Start JVM
@@ -242,9 +262,11 @@ startup() {
242
262
args=" -jar ${JAVA_APP_JAR} "
243
263
fi
244
264
245
- procname=" ${JAVA_APP_NAME-java} "
265
+ local procname=" ${JAVA_APP_NAME-java} "
266
+
267
+ local masked_opts=$( mask_passwords " $( get_java_options) " )
246
268
247
- log_info " exec -a \" ${procname} \" java $( get_java_options ) -cp \" $( get_classpath) \" ${args} $* "
269
+ log_info " exec -a \" ${procname} \" java ${masked_opts} -cp \" $( get_classpath) \" ${args} $* "
248
270
log_info " running in $PWD "
249
271
exec -a " ${procname} " java $( get_java_options) -cp " $( get_classpath) " ${args} $*
250
272
}
Original file line number Diff line number Diff line change
1
+ @ubi8
2
+ Feature : OpenJDK run script tests
3
+ Scenario : OPENJDK-3009: Ensure command-line options containing 'password' are masked in logs
4
+ Given container is started with env
5
+ | variable | value |
6
+ | JAVA_OPTS_APPEND | -Djavax .net .ssl .trustStorePassword =sensitiveString |
7
+ Then container log should not contain sensitiveString
8
+
You can’t perform that action at this time.
0 commit comments