Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
e19c6245
Commit
e19c6245
authored
Nov 24, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consider endpoints.sensitive when endpoints.health.sensitive is not set
Closes gh-7476
parent
1f828193
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
3 deletions
+54
-3
HealthMvcEndpoint.java
...ramework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java
+12
-3
HealthMvcEndpointTests.java
...ork/boot/actuate/endpoint/mvc/HealthMvcEndpointTests.java
+42
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java
View file @
e19c6245
...
@@ -59,7 +59,9 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
...
@@ -59,7 +59,9 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
private
Map
<
String
,
HttpStatus
>
statusMapping
=
new
HashMap
<
String
,
HttpStatus
>();
private
Map
<
String
,
HttpStatus
>
statusMapping
=
new
HashMap
<
String
,
HttpStatus
>();
private
RelaxedPropertyResolver
propertyResolver
;
private
RelaxedPropertyResolver
healthPropertyResolver
;
private
RelaxedPropertyResolver
endpointPropertyResolver
;
private
RelaxedPropertyResolver
roleResolver
;
private
RelaxedPropertyResolver
roleResolver
;
...
@@ -84,8 +86,10 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
...
@@ -84,8 +86,10 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
@Override
@Override
public
void
setEnvironment
(
Environment
environment
)
{
public
void
setEnvironment
(
Environment
environment
)
{
this
.
p
ropertyResolver
=
new
RelaxedPropertyResolver
(
environment
,
this
.
healthP
ropertyResolver
=
new
RelaxedPropertyResolver
(
environment
,
"endpoints.health."
);
"endpoints.health."
);
this
.
endpointPropertyResolver
=
new
RelaxedPropertyResolver
(
environment
,
"endpoints."
);
this
.
roleResolver
=
new
RelaxedPropertyResolver
(
environment
,
this
.
roleResolver
=
new
RelaxedPropertyResolver
(
environment
,
"management.security."
);
"management.security."
);
}
}
...
@@ -209,7 +213,12 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
...
@@ -209,7 +213,12 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
}
}
private
boolean
isUnrestricted
()
{
private
boolean
isUnrestricted
()
{
Boolean
sensitive
=
this
.
propertyResolver
.
getProperty
(
"sensitive"
,
Boolean
.
class
);
Boolean
sensitive
=
this
.
healthPropertyResolver
.
getProperty
(
"sensitive"
,
Boolean
.
class
);
if
(
sensitive
==
null
)
{
sensitive
=
this
.
endpointPropertyResolver
.
getProperty
(
"sensitive"
,
Boolean
.
class
);
}
return
!
this
.
secure
&&
!
Boolean
.
TRUE
.
equals
(
sensitive
);
return
!
this
.
secure
&&
!
Boolean
.
TRUE
.
equals
(
sensitive
);
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpointTests.java
View file @
e19c6245
...
@@ -24,6 +24,7 @@ import org.junit.Test;
...
@@ -24,6 +24,7 @@ import org.junit.Test;
import
org.springframework.boot.actuate.endpoint.HealthEndpoint
;
import
org.springframework.boot.actuate.endpoint.HealthEndpoint
;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.boot.actuate.health.Status
;
import
org.springframework.boot.actuate.health.Status
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
...
@@ -264,4 +265,45 @@ public class HealthMvcEndpointTests {
...
@@ -264,4 +265,45 @@ public class HealthMvcEndpointTests {
assertThat
(
health
.
getStatus
()
==
Status
.
DOWN
).
isTrue
();
assertThat
(
health
.
getStatus
()
==
Status
.
DOWN
).
isTrue
();
}
}
@Test
public
void
detailIsHiddenWhenAllEndpointsAreSensitive
()
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
environment
,
"endpoints.sensitive:true"
);
this
.
mvc
=
new
HealthMvcEndpoint
(
this
.
endpoint
,
false
);
this
.
mvc
.
setEnvironment
(
this
.
environment
);
given
(
this
.
endpoint
.
invoke
())
.
willReturn
(
new
Health
.
Builder
().
up
().
withDetail
(
"foo"
,
"bar"
).
build
());
Object
result
=
this
.
mvc
.
invoke
(
null
);
assertThat
(
result
instanceof
Health
).
isTrue
();
assertThat
(((
Health
)
result
).
getStatus
()
==
Status
.
UP
).
isTrue
();
assertThat
(((
Health
)
result
).
getDetails
().
get
(
"foo"
)).
isNull
();
}
@Test
public
void
detailIsHiddenWhenHealthEndpointIsSensitive
()
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
environment
,
"endpoints.health.sensitive:true"
);
this
.
mvc
=
new
HealthMvcEndpoint
(
this
.
endpoint
,
false
);
this
.
mvc
.
setEnvironment
(
this
.
environment
);
given
(
this
.
endpoint
.
invoke
())
.
willReturn
(
new
Health
.
Builder
().
up
().
withDetail
(
"foo"
,
"bar"
).
build
());
Object
result
=
this
.
mvc
.
invoke
(
null
);
assertThat
(
result
instanceof
Health
).
isTrue
();
assertThat
(((
Health
)
result
).
getStatus
()
==
Status
.
UP
).
isTrue
();
assertThat
(((
Health
)
result
).
getDetails
().
get
(
"foo"
)).
isNull
();
}
@Test
public
void
detailIsHiddenWhenOnlyHealthEndpointIsSensitive
()
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
environment
,
"endpoints.health.sensitive:true"
,
"endpoints.sensitive:false"
);
this
.
mvc
=
new
HealthMvcEndpoint
(
this
.
endpoint
,
false
);
this
.
mvc
.
setEnvironment
(
this
.
environment
);
given
(
this
.
endpoint
.
invoke
())
.
willReturn
(
new
Health
.
Builder
().
up
().
withDetail
(
"foo"
,
"bar"
).
build
());
Object
result
=
this
.
mvc
.
invoke
(
null
);
assertThat
(
result
instanceof
Health
).
isTrue
();
assertThat
(((
Health
)
result
).
getStatus
()
==
Status
.
UP
).
isTrue
();
assertThat
(((
Health
)
result
).
getDetails
().
get
(
"foo"
)).
isNull
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment