Skip to content

Commit c071f56

Browse files
committed
Protect against empty OS string in Docker Image
Update `Image` to protect against `os` being `null` or and empty String. Fixes gh-45152
1 parent 5926766 commit c071f56

File tree

2 files changed

+4
-1
lines changed
  • spring-boot-project

2 files changed

+4
-1
lines changed

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ private HttpStatus getResponseStatus(AssertableWebApplicationContext context, St
178178
static class CustomSecurityConfiguration {
179179

180180
@Bean
181+
@SuppressWarnings("removal")
181182
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
182183
http.authorizeHttpRequests((requests) -> {
183184
requests.requestMatchers(new AntPathRequestMatcher("/foo")).permitAll();
@@ -207,6 +208,7 @@ static class TestRemoteDevToolsSecurityFilterChainConfig extends TestSecurityFil
207208

208209
@Bean
209210
@Order(SecurityProperties.BASIC_AUTH_ORDER - 1)
211+
@SuppressWarnings("removal")
210212
SecurityFilterChain testRemoteDevToolsSecurityFilterChain(HttpSecurity http) throws Exception {
211213
http.securityMatcher(new AntPathRequestMatcher("/**"));
212214
http.authorizeHttpRequests((requests) -> requests.anyRequest().anonymous());

Diff for: spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/Image.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.fasterxml.jackson.databind.JsonNode;
2727

2828
import org.springframework.boot.buildpack.platform.json.MappedObject;
29+
import org.springframework.util.StringUtils;
2930

3031
/**
3132
* Image details as returned from {@code Docker inspect}.
@@ -90,7 +91,7 @@ public List<LayerId> getLayers() {
9091
* @return the image OS
9192
*/
9293
public String getOs() {
93-
return (this.os != null) ? this.os : "linux";
94+
return (!StringUtils.hasText(this.os)) ? this.os : "linux";
9495
}
9596

9697
/**

0 commit comments

Comments
 (0)