File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
artifacts/opt/jboss/container/java/run Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,27 @@ get_classpath() {
202
202
echo " ${cp_path} "
203
203
}
204
204
205
+ # Mask secrets before printing
206
+ mask_passwords () {
207
+ local content=" $1 "
208
+ local result=" "
209
+
210
+ IFS=' ' read -r -a key_value_pairs <<< " $content"
211
+
212
+ for pair in " ${key_value_pairs[@]} " ; do
213
+ key=$( echo " $pair " | cut -d ' =' -f 1)
214
+ value=$( echo " $pair " | cut -d ' =' -f 2-)
215
+
216
+ if [[ $key =~ [Pp][Aa][Ss][Ss][Ww][Oo][Rr][Dd] ]]; then
217
+ result+=" $key =***** "
218
+ else
219
+ result+=" $pair "
220
+ fi
221
+ done
222
+
223
+ echo " ${result% } "
224
+ }
225
+
205
226
# Start JVM
206
227
startup () {
207
228
# Initialize environment
@@ -215,9 +236,11 @@ startup() {
215
236
args=" -jar ${JAVA_APP_JAR} "
216
237
fi
217
238
218
- procname=" ${JAVA_APP_NAME-java} "
239
+ local procname=" ${JAVA_APP_NAME-java} "
240
+
241
+ local masked_opts=$( mask_passwords " $( get_java_options) " )
219
242
220
- log_info " exec -a \" ${procname} \" java $( get_java_options ) -cp \" $( get_classpath) \" ${args} $* "
243
+ log_info " exec -a \" ${procname} \" java ${masked_opts} -cp \" $( get_classpath) \" ${args} $* "
221
244
log_info " running in $PWD "
222
245
exec -a " ${procname} " java $( get_java_options) -cp " $( get_classpath) " ${args} $*
223
246
}
Original file line number Diff line number Diff line change
1
+ @ubi9
2
+ Feature : OpenJDK run script tests
3
+ Scenario : 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