Skip to content

Commit a9f5a41

Browse files
lhotariphilwebb
authored andcommitted
Make heapdump endpoint restricted by default
See gh-45624 Signed-off-by: Lari Hotari <[email protected]>
1 parent 31c864b commit a9f5a41

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/management/HeapDumpWebEndpointAutoConfigurationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 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,13 +36,13 @@ class HeapDumpWebEndpointAutoConfigurationTests {
3636

3737
@Test
3838
void runShouldCreateIndicator() {
39-
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(HeapDumpWebEndpoint.class));
39+
this.contextRunner.withPropertyValues("management.endpoint.heapdump.access:UNRESTRICTED")
40+
.run((context) -> assertThat(context).hasSingleBean(HeapDumpWebEndpoint.class));
4041
}
4142

4243
@Test
4344
void runWhenDisabledShouldNotCreateIndicator() {
44-
this.contextRunner.withPropertyValues("management.endpoint.heapdump.enabled:false")
45-
.run((context) -> assertThat(context).doesNotHaveBean(HeapDumpWebEndpoint.class));
45+
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(HeapDumpWebEndpoint.class));
4646
}
4747

4848
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/management/HeapDumpWebEndpointDocumentationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.springframework.restdocs.cli.CliDocumentation;
3131
import org.springframework.restdocs.cli.CurlRequestSnippet;
3232
import org.springframework.restdocs.operation.Operation;
33+
import org.springframework.test.context.TestPropertySource;
3334
import org.springframework.util.FileCopyUtils;
3435

3536
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,6 +41,7 @@
4041
*
4142
* @author Andy Wilkinson
4243
*/
44+
@TestPropertySource(properties = "management.endpoint.heapdump.access=unrestricted")
4345
class HeapDumpWebEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
4446

4547
@Test

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.apache.commons.logging.Log;
3737
import org.apache.commons.logging.LogFactory;
3838

39+
import org.springframework.boot.actuate.endpoint.Access;
3940
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
4041
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
4142
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
@@ -56,7 +57,7 @@
5657
* @author Andy Wilkinson
5758
* @since 2.0.0
5859
*/
59-
@WebEndpoint(id = "heapdump")
60+
@WebEndpoint(id = "heapdump", defaultAccess = Access.NONE)
6061
public class HeapDumpWebEndpoint {
6162

6263
private final long timeout;

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/endpoints.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ If your application is a web application (Spring MVC, Spring WebFlux, or Jersey)
120120
[[actuator.endpoints.controlling-access]]
121121
== Controlling Access to Endpoints
122122

123-
By default, access to all endpoints except for `shutdown` is unrestricted.
123+
By default, access to all endpoints except for `shutdown` and `heapdump` is unrestricted.
124124
To configure the permitted access to an endpoint, use its `management.endpoint.<id>.access` property.
125125
The following example allows unrestricted access to the `shutdown` endpoint:
126126

0 commit comments

Comments
 (0)