Skip to content

Commit cd0e4fe

Browse files
committed
Sanitize sun.java.command by default
Closes gh-12796
1 parent a06de4d commit cd0e4fe

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/Sanitizer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,8 @@ class Sanitizer {
3636
private Pattern[] keysToSanitize;
3737

3838
Sanitizer() {
39-
this("password", "secret", "key", "token", ".*credentials.*", "vcap_services");
39+
this("password", "secret", "key", "token", ".*credentials.*", "vcap_services",
40+
"sun.java.command");
4041
}
4142

4243
Sanitizer(String... keysToSanitize) {

spring-boot-actuator/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"key",
2121
"token",
2222
".*credentials.*",
23-
"vcap_services"
23+
"vcap_services",
24+
"sun.java.command"
2425
]
2526
},
2627
{
@@ -44,7 +45,8 @@
4445
"key",
4546
"token",
4647
".*credentials.*",
47-
"vcap_services"
48+
"vcap_services",
49+
"sun.java.command"
4850
]
4951
},
5052
{

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpointTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -92,6 +92,10 @@ public void testKeySanitization() throws Exception {
9292
assertThat(systemProperties.get("mySecret")).isEqualTo("******");
9393
assertThat(systemProperties.get("myCredentials")).isEqualTo("******");
9494
assertThat(systemProperties.get("VCAP_SERVICES")).isEqualTo("******");
95+
Object command = systemProperties.get("sun.java.command");
96+
if (command != null) {
97+
assertThat(command).isEqualTo("******");
98+
}
9599
clearSystemProperties("dbPassword", "apiKey", "mySecret", "myCredentials");
96100
}
97101

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/SanitizerTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,6 +39,8 @@ public void defaults() throws Exception {
3939
assertThat(sanitizer.sanitize("token", "secret")).isEqualTo("******");
4040
assertThat(sanitizer.sanitize("sometoken", "secret")).isEqualTo("******");
4141
assertThat(sanitizer.sanitize("find", "secret")).isEqualTo("secret");
42+
assertThat(sanitizer.sanitize("sun.java.command",
43+
"--spring.redis.password=pa55w0rd")).isEqualTo("******");
4244
}
4345

4446
@Test

0 commit comments

Comments
 (0)