Skip to content

Commit 10ef991

Browse files
committed
Sanitize sensitive portion of the value of url and urls keys
Closes gh-25387
1 parent e3ad6b5 commit 10ef991

File tree

3 files changed

+14
-6
lines changed
  • spring-boot-project

3 files changed

+14
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 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.
@@ -48,7 +48,7 @@ public class Sanitizer {
4848
"key", "token", ".*credentials.*", "vcap_services", "sun.java.command"));
4949

5050
private static final Set<String> URI_USERINFO_KEYS = new LinkedHashSet<>(
51-
Arrays.asList("uri", "uris", "address", "addresses"));
51+
Arrays.asList("uri", "uris", "url", "urls", "address", "addresses"));
5252

5353
private static final Pattern URI_USERINFO_PATTERN = Pattern.compile("\\[?[A-Za-z]+://.+:(.*)@.+$");
5454

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 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.
@@ -123,8 +123,8 @@ void uriKeyWithUserProvidedListLiteralShouldBeSanitized(String key) {
123123
}
124124

125125
private static Stream<String> matchingUriUserInfoKeys() {
126-
return Stream.of("uri", "my.uri", "myuri", "uris", "my.uris", "myuris", "address", "my.address", "myaddress",
127-
"addresses", "my.addresses", "myaddresses");
126+
return Stream.of("uri", "my.uri", "myuri", "uris", "my.uris", "myuris", "url", "my.url", "myurl", "urls",
127+
"my.urls", "myurls", "address", "my.address", "myaddress", "addresses", "my.addresses", "myaddresses");
128128
}
129129

130130
@Test

spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,15 @@ The patterns to use can be customized using the `management.endpoint.env.keys-to
23402340
Spring Boot uses sensible defaults for such keys: any key ending with the word "password", "secret", "key", "token", "vcap_services", "sun.java.command" is entirely sanitized.
23412341
Additionally, any key that holds the word `credentials` as part of the key is sanitized (configured as a regular expression, i.e. `+*credentials.*+`).
23422342

2343-
Furthermore, Spring Boot only sanitizes the sensitive portion of URIs for keys which end with "uri", "uris", "address", or "addresses".
2343+
Furthermore, Spring Boot only sanitizes the sensitive portion of URI-like values for keys with one of the following endings:
2344+
2345+
- `address`
2346+
- `addresses`
2347+
- `uri`
2348+
- `uris`
2349+
- `url`
2350+
- `urls`
2351+
23442352
The sensitive portion of the URI is identified using the format `<scheme>://<username>:<password>@<host>:<port>/`.
23452353
For example, for the property `myclient.uri=http://user1:password1@localhost:8081`, the resulting sanitized value is
23462354
`++http://user1:******@localhost:8081++`.

0 commit comments

Comments
 (0)