Skip to content

Commit f053ef8

Browse files
committed
Trim "\x00" from a decoded Docker Registry password
Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
1 parent c6045c3 commit f053ef8

File tree

2 files changed

+8
-3
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src

2 files changed

+8
-3
lines changed

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/DockerConfigurationMetadata.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ static final class Auth extends MappedObject {
219219
Auth(JsonNode node) {
220220
super(node, MethodHandles.lookup());
221221
String auth = valueAt("/auth", String.class);
222-
if (StringUtils.hasText(auth)) {
222+
if (StringUtils.hasLength(auth)) {
223223
String[] parts = new String(Base64.getDecoder().decode(auth)).split(":", 2);
224224
Assert.state(parts.length == 2, "Malformed auth in docker configuration metadata");
225225
this.username = parts[0];
226-
this.password = parts[1];
226+
this.password = trim(parts[1], Character.MIN_VALUE);
227227
}
228228
else {
229229
this.username = valueAt("/username", String.class);
@@ -244,6 +244,11 @@ String getEmail() {
244244
return this.email;
245245
}
246246

247+
private static String trim(String source, char character) {
248+
source = StringUtils.trimLeadingCharacter(source, character);
249+
return StringUtils.trimTrailingCharacter(source, character);
250+
}
251+
247252
}
248253

249254
static final class DockerContext extends MappedObject {

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/docker/configuration/with-auth/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"auths": {
33
"https://index.docker.io/v1/": {
4-
"auth": "dXNlcm5hbWU6cGFzc3dvcmQ=",
4+
"auth": "dXNlcm5hbWU6AHBhc3N3b3JkAA==",
55
"email": "test@gmail.com"
66
},
77
"custom-registry.example.com": {

0 commit comments

Comments
 (0)