Commit Graph

1000 Commits

Author SHA1 Message Date
Spring Buildmaster
8db59059a5 Next Development Version 2015-12-18 05:43:02 -08:00
Johnny Lim
c09a14a128 Fix typos
Closes gh-4806
2015-12-18 12:58:35 +01:00
Phillip Webb
5d311d6203 Polish 2015-12-17 09:51:33 +00:00
Kirill Vlasov
ec2f33f986 Make loggers private static final
Apply consistency across all static loggers.

Closes gh-4784
2015-12-16 21:02:53 +00:00
Kirill Vlasov
786aacf2e9 Use Collections.isEmpty() instead of .size() == 0
Ensure that Collections.isEmpty() is used to check if there are no
elements in a collections. This is more explicit and can be faster than
calling .size().

Closes gh-4783
2015-12-16 20:59:33 +00:00
Dave Syer
471947b400 Be more defensive when instantiating custom ServerProperties
If the user provides their own ServerProperties bean we want to peek
at it to see if they set the port (and only that) when we are deciding
if the actuator context needs to be created. This happens very early
(in a @Condition) so we need to be very defensive. There are already
quite a few checks in place to prevent a ServerProperties bean from
being instantiated unless we really need it, and yet, when it is
we can do more.

This change creates the bean (and the ManagementProperties) in a
throwaway BeanFactory using the same BeanDefinition as the main
context. This ensures that when the main context bean is created
it will be in the "natural" order and binding to the Environment
can take place as normal.

Fixes gh-4631
2015-12-16 17:48:28 +00:00
Dave Syer
c7c685f65f Disable hypermedia in actuator endpoints by default
This change permanently removes links from the endpoints that return
arrays or collections, and also disables them in the rest of the
endpoints (except /actuator) by default.

Fixes gh-4616
2015-12-16 11:00:22 +00:00
Andy Wilkinson
097e588109 Use more sensible defaults for OpenTsdbGaugeWriter's timeouts
Previously, the default RestTemplate that is used OpenTsdbGaugeWriter
was not used with its default configuration. Notably this meant that
it would have infinite connect and read timeouts. This is problematic
as it can cause metric writing to hang and block the scheduler for
performing any other tasks.

This commit updates OpenTsdbGaugeWriter to use a default connect
timeout of 10 seconds and a default read timeout of 30 seconds. A
constructor has been added to ease the configuration of these
timeouts. The existing option of providing your own RestTemplate
(via setRestTemplate) remains.

Closes gh-4698
2015-12-15 14:44:50 +00:00
Eddú Meléndez
1b81d9f0b5 Add support for server.server-header property
Add a `server.server-header` property which can be used to override the
`server` header usually sent back automatically by Tomcat/Jetty or
Undertow.

See https://www.owasp.org/index.php/Securing_tomcat for background.

Fixes gh-4461
Closes gh-4504
2015-12-12 21:24:29 +00:00
Vedran Pavic
c05432d221 Move publisher injection to abstract listeners
Push up publisher injection from AuthenticationAuditListener and
AuthorizationAuditListener to the abstract superclasses.

Closes gh-4625
2015-12-12 11:21:48 +00:00
Vedran Pavic
f8090d94b2 Add AbstractHealthAggregator.aggregateDetails
Extract aggregate details logic to a protected method that can be
overridden if required.

Closes gh-4674
2015-12-11 14:42:02 +00:00
mnhock
fcf6e5d6eb Prefer valueOf() to create Number values
Update Long/Integer constructor calls with `valueOf` which can make use
of global caches.

Closes gh-4688
2015-12-11 14:04:25 +00:00
Phillip Webb
0489a3b4de Polish 2015-12-10 19:43:29 +00:00
Phillip Webb
2d2e4eea82 Merge branch '1.2.x' 2015-12-10 15:01:29 +00:00
Stephane Nicoll
66fe95369c Polish doc
See gh-4743
2015-12-10 15:49:34 +01:00
Phillip Webb
2694605a4d Polish 2015-12-10 14:43:00 +00:00
Stephane Nicoll
59cb5cf8d9 Merge branch '1.2.x'
# Conflicts:
#	spring-boot-actuator/src/main/resources/META-INF/additional-spring-configuration-metadata.json
#	spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
2015-12-10 15:40:44 +01:00
Stephane Nicoll
ce2346b087 Reintroduce endpoints.metrics.filter.enabled
Commit 8c14009 removed the endpoints.metrics.filter.enabled property so
that endpoints.metrics.enabled is used for both disabling the endpoint
and the servlet filter that records interactions.

This was an unfortunate decision as it was no longer possible to only
disable the servlet filter. The endpoints.metrics.filter.enabled property
has therefore been restored.

Closes gh-4365
2015-12-10 15:37:10 +01:00
Dave Syer
21d6c73539 Fix checkstyle 2015-12-09 10:35:57 +00:00
Dave Syer
8b97c3b342 Add nonheap metrics to /metrics endpoint
Fixes gh-4712
2015-12-09 10:17:32 +00:00
Stephane Nicoll
7b2afbdf13 Polish 2015-12-08 10:26:44 +01:00
Johnny Lim
ec7fed1ecc Polish
Closes gh-4677
2015-12-07 20:46:36 +01:00
Andy Wilkinson
ee47ae4d20 Ensure that 5xx responses to unmapped requests produce a single metric
Previously, each 5xx response to a request that used a path variable
would result in a metric being recorded that contained the path
variable. Therefore, if a different path variable was included in each
request, a new metric would be recorded for each request. This is
problematic as it can lead to the metrics being flooded with unwanted
entries.

This commit updates MetricsFilter to treat 5xx responses sent before
mapping has occurred in the same way as 4xx and redirect responses.
A single metric, counter.status.500.unmapped, is now used.

Closes gh-4377
2015-12-07 10:38:31 +00:00
Vedran Pavic
d9f15636d0 Fix use of == in EndpointWebMvcHypermediaManagementContextConfiguration
Closes gh-4502
Closes gh-4536
2015-12-04 14:43:02 +00:00
Johnny Lim
a4baacc549 Remove a redundant setUseSuffixPatternMatch(false)
Closes gh-4656
2015-12-02 09:56:38 +00:00
Andy Wilkinson
8e0d3ed0eb Don’t return 404 when metric or env regex matches entry with null value
Previously, if a regular expression was used when calling the metrics or
environment endpoints, a metric or property with a null value would
result in a 404 response.

This commit updates the two affected endpoints so that any metric or
property whose name matches the regular expression but has a null value
is ignored. This allows all of the matching metrics or properties with
non-null values to be returned in a 200 OK response.

Closes gh-4552
2015-12-01 17:12:07 +00:00
Dave Syer
6ec767437a Fix server.error.path reference in error controller 2015-11-30 14:20:37 +00:00
Stephane Nicoll
7d6f63ae34 Add redirection to actuator endpoint
If a request to the actuator endpoint ends with a slash with Spring
HATEOAS on the classpath, an empty array of links is returned whereas
a request without the slash returns a response with all the expected
links to the actuator's other endpoints.

This commit adds an automatic redirection so that both URIs return the
expected result.

Closes gh-4575
2015-11-30 10:32:50 +01:00
Dave Syer
2de48a35ab Make /error the error page in child context as well as parent
If user set the management.port *and* the management.context-path
then the /error path was in the wrong place because formerly it
was implemented (in this case) by an MvcEndpoint. If we
switch it to a regular @Controller (which are now supported in the
child context if there is one) then it won't disappear under the
management.context-path.

Also use lazy request matching in ignores as well as secure paths.
The problem was that the ignores were constructed eagerly from the
actuator paths before they were available (the EndpointHandlerMapping
needs to be lazily accessed to avoid a security-induced bean creation
cascade).

Fixes gh-4624
2015-11-27 16:53:37 +00:00
Dave Syer
4488bac4c3 Remove server.context-path from actuator endpoints if port set
If the user sets the management.port, he wants some of the
server.* properties, but not the context-path. This change
restores the behaviour in 1.2.x.

Fixes gh-4401
2015-11-27 12:49:43 +00:00
Dave Syer
dd7d587ea8 Add tests to assert behaviour of actuator endpoints with context path
See gh-4401
2015-11-27 12:49:43 +00:00
Dave Syer
7d04ca1e1b Add tests to assert behaviour of actuator endpoints with context path
See gh-4401
2015-11-27 10:56:04 +00:00
Stephane Nicoll
091478e0fd Disable ehcache statistics if necessary
`EhCacheStatisticsProvider` uses the `StatisticsGateway` API introduced
in ehcache 2.7 (march 2013). If an older ehcache version is present, we
should back-off as this class is not available.

Closes gh-4621
2015-11-26 16:15:29 +01:00
Johnny Lim
da16d6d306 Polishing
Closes gh-4503
2015-11-18 11:40:19 +00:00
Spring Buildmaster
3f6f57a80e Next Development Version 2015-11-16 03:18:54 -08:00
Johnny Lim
4369493f8d Polish 2015-11-14 18:54:50 -08:00
Phillip Webb
e9440ad5b5 Formatting 2015-11-13 10:35:55 -08:00
Stephane Nicoll
ba2aea4ef1 Polish contribution
Closes gh-4456
2015-11-13 10:13:44 +01:00
Eddú Meléndez
41300c35ab Add timeout configuration for CRaSH
Closes gh-4325
2015-11-13 09:55:54 +01:00
Dave Syer
8749fc745b Disallow all extensions in actuator endpoints (except .json)
Along with the recent change in Spring to use content-disposition
"inline" (which prevents the download), it also makes sense to limit
the extensions allowed by the actuator endpoints. Really there *is*
no extension for these endpoints, but since all of them explicitly
produce JSON we can add .json for browsers as a convenience in case
the app would otherwise choose to send XML.

Fixes gh-4402
2015-11-12 10:25:06 +00:00
Phillip Webb
09b5222f52 Disable suffix pattern matching for Endpoints
Update EndpointHandlerMapping so that setUseSuffixPatternMatch is set
to false. This prevents URLs of the form /beans.json from returning
results and provides another line of defense against RDF attacks.

Fixes gh-4402
2015-11-11 20:15:28 -08:00
Johnny Lim
4c1398148b Polish docs
Closes gh-4433
2015-11-11 15:04:45 +01:00
Phillip Webb
a3fac37904 Fix checkstyle error 2015-11-10 15:32:25 -08:00
Phillip Webb
287a62c8f3 Update Johannes Edmeier author attribution
Congratulations to Johannes Edmeier on getting married!
2015-11-10 15:29:44 -08:00
Johannes Edmeier
a1b1cdb18f Improve resource handling in LogFileMvcEndpoint
Update `LogFileMvcEndpoint` to use a `ResourceHttpRequestHandler` when
serving the log file resource. This gives support for requesting parts
of the logfile via the HTTP Range header. Requests with the
`If-Modified-Since` header are now also handled correctly.

Closes gh-4333
2015-11-10 15:17:06 -08:00
Tommy Ludwig
d8247657a0 Auto-configure CassandraHealthIndicator
Add auto-configuration for the CassandraHealthIndicator. Also update
the implementation to use CassandraOperations rather than
CassandraAdminOperations.

Closes gh-4409
2015-11-10 13:49:39 -08:00
Phillip Webb
0bac6ebda7 Fix typo
See gh-4419
2015-11-10 09:52:39 -08:00
Stephane Nicoll
3311419a08 Fix typo
See gh-4419
2015-11-10 14:52:07 +01:00
Rob Winch
c6e08eb883 Secure actuator when all endpoints are sensitive
Previously if every actuator endpoint was marked as sensitive, then all
endpoints were marked as permitted.

This commit ensures that if all endpoints are marked as sensitive, then
all the endpoints are secured.

Fixes gh-4368
Closes gh-4383
2015-11-09 22:30:35 -08:00
Phillip Webb
8c642bec74 Support global endpoint.sensitive override
Add support for an `endpoint.sensitive` property that can be used to
override the endpoint `sensitive` default.

Fixes gh-4419
2015-11-09 22:25:12 -08:00
Phillip Webb
332c6911cf Polish 2015-11-09 22:19:03 -08:00
Phillip Webb
aa8d0dd072 Add HAL test for endpoints.enabled=false 2015-11-09 22:18:20 -08:00
Phillip Webb
b1b3fc6639 Use consistent MvcEndpoint class names
Rename HAL and docs MVC endpoints so that classnames consistently end
with MvcEndpoint. Also rename integration tests so that they are grouped
together in the IDE.
2015-11-09 22:15:06 -08:00
Vedran Pavic
a0c696b17b Allow security AuditListener overrides
Introduce `AbstractAuthenticationAuditListener` and
`AbstractAuthorizationAuditListener` classes so that users can
extended them to replace the auto-configured defaults.

Closes gh-4406
2015-11-09 13:51:30 -08:00
Phillip Webb
564cbfe96c Add missing @param tag
See gh-4415
2015-11-09 12:18:55 -08:00
Phillip Webb
bd20b5419e Consider prefixes when sanitizing /configprops
Update ConfigurationPropertiesReportEndpoint so that property prefixes
are also considered when sanitizing values.

Fixes gh-4415
2015-11-09 11:19:10 -08:00
Stephane Nicoll
bd8521c1ab Polish contribution
Closes gh-4356
2015-11-06 09:24:08 +01:00
邱占波
35417622e6 Add thread total started count to SystemPublicMetrics
See gh-4356
2015-11-06 09:17:37 +01:00
Phillip Webb
6c2ea4648f Polish 2015-11-03 20:36:20 -08:00
Stephane Nicoll
7a665c5f58 Merge branch '1.2.x' 2015-11-03 10:15:39 +01:00
Stephane Nicoll
8c140092b6 Fix key to disable the metrics filter
Commit d0cf6b5 introduced a `endpoints.metrics.filter.enabled` property
key meant to disable the filter. Unfortunately, the `endpoints.metrics`
namespace is already managed so setting this property will fail.

We now use the same key than the one used to disable the metrics
endpoint.

Closes gh-4365
2015-11-03 10:14:39 +01:00
Stephane Nicoll
8188060edf Fix broken build 2015-11-02 13:38:08 +01:00
Dave Syer
cc3f673874 Narrow range of events listened for in security audit
The InteractiveAuthenticationSuccessEvent is always shadowed by a
regulat AuthenticationSuccessEvent, so there's no need to listen for
all AbstractAuthenticationSuccessEvents.

Fixes gh-4355
2015-11-02 10:01:45 +00:00
Dave Syer
96fcd49e2e OpenTsdbMetricWriter -> OpenTsdbGaugeWriter 2015-10-31 16:10:49 +00:00
Dave Syer
db03e8ea50 Fix sample and tidy up MetricWriter/GaugeWriter
The metric export configuration was still using the MetricWriter
interface where it should be using GaugeWriter
2015-10-31 16:00:48 +00:00
Dave Syer
03c56b4cf1 Split MetricWriter into 2 interfaces covering counters and gauges
This way the MetricCopyExporter can make a sensible choice about
what to do with counter metrics, and cache the latest values, so that
they can be properly incremented.

Fixes gh-4305
2015-10-31 15:26:02 +00:00
Andy Wilkinson
02d7e2826c Don’t call ignoring.antMatchers([]) as empty array now maps to /**
Previously, if security.ignored was set to none and the error controller
was disabled, there would be no paths to ignore and we would call
IgnoredRequestConfigurer.antMatchers with an empty array. While a bit
pointless, this had no effect on Spring Security’s configuration.

This behaviour has changed in the latest 4.0.3 snapshots [1]. An empty
array passed to IgnoredRequestConfigurer.antMatchers now maps to /**. As
Spring Boot configures its ignored paths with highest precedence this
means that security is now disabled for every path.

This commit updates both the management security and application
security configuration to avoid calling antMatchers with an empty
array, thereby ensuring that we don’t inadvertently ignore every path.
Even if the change to Spring Security is reverted we can keep this
change. The behaviour will remain the same and, arguably, it makes the
intent of our configuration clearer.

Closes gh-4345

[1] 8663ac4173
2015-10-30 11:26:00 +00:00
Stephane Nicoll
86c753a149 Temporary fix the build
(I mean it this thime)

See gh-4345
2015-10-30 10:41:01 +01:00
Andy Wilkinson
79d99e1847 Update ShellPropertiesTests to expect whitespace to be trimmed
The latest Spring Framework 4.2.3 snapshots appear to be trimming
whitespace as part of the binding process. This commit updates the
test's expectations accordingly.
2015-10-29 15:05:09 +00:00
Andy Wilkinson
aa3313cfc5 Update NamePatternFilter to detect regular expression character class
Previously, NamePatternFilter looked for “*”, “$”, “^”, or “+” when
trying to identify a string as being a regular expression. This meant
that it missed the use of a character class ([a-z], for example). This
commit adds “[“} to the list of characters that are considered to be
part of a regular expression.

Closes gh-4233
2015-10-26 10:56:16 +00:00
Stephane Nicoll
601225027f Merge branch '1.2.x' 2015-10-21 13:59:04 +02:00
Stephane Nicoll
2e2ebeb9fa Allow PORTFILE to always override the file to use
Previously, the `PORTFILE` system property was not checked if the
`EmbeddedServerPortFileWriter` was created using the default constructor.

This had the effect to prevent overriding of the port file when this
listener is created without any file or via `META-INF/spring.factories`.

Closes gh-4254
2015-10-21 13:58:48 +02:00
Johnny Lim
71c8a114f1 Make response headers optional in /trace endpoint
Update `WebRequestTraceFilter` so that the response respects the
TraceProperties.Include.RESPONSE enum.

See gh-3948
Closes gh-4242
2015-10-20 16:04:51 -07:00
Andy Wilkinson
0862ad7f52 Polishing: remove dead code 2015-10-20 15:28:52 +01:00
Andy Wilkinson
2109559f37 Ensure that, where appropriate, actuator endpoints always produce JSON
Previously, the Actuator’s endpoints did not specify a produces
attribute on their request mappings. With Jackson’s XML binding on the
classpath, this would lead to requests made by a browser receiving
application/xml responses (due to the Accept header indicating that
application/xml is preferred). This was problematic as some of the
response payloads were not legal xml. Problems included XML tags
beginning with ‘\’ or containing ‘#’.

This commit updates the endpoints to specify that they produce
application/json. The environment and metrics endpoints have also been
updated so that always return a JSON object, even when they are
returning a single entry. This consistency avoids problems where
clients may not consider a single scalar value to be legal JSON.

Closes gh-2449
2015-10-20 15:28:52 +01:00
Stephane Nicoll
4ae6d7c97e Remove outdated key
See gh-3696
2015-10-20 15:35:03 +02:00
Johnny Lim
f67b6a233a Remove unused property in TraceProperties
Closes gh-4241
2015-10-20 09:11:51 +02:00
Phillip Webb
634bb770b2 Organize imports with new settings
See gh-4234
2015-10-19 12:58:34 -07:00
Phillip Webb
1e4d974ec0 Merge remote-tracking branch 'local12x/1.2.x' 2015-10-19 12:56:55 -07:00
Phillip Webb
a79131f8d2 Organize imports with new settings
See gh-4234
2015-10-19 12:55:44 -07:00
Spring Buildmaster
2b38a861e3 Next Development Version 2015-10-16 05:57:24 -07:00
Phillip Webb
7e99d08473 Fail startup if management server can't start
Update EndpointWebMvcAutoConfiguration to no longer catch and ignore
EmbeddedServletContainerExceptions. Since commit 764e34b9, starting a
management on a different port is not even attempted when running in a
classic servlet container. This means that the catch/log logic (which
was originally added in 45315a97) is no longer necessary, and only
serves to hide genuine problems.

Fixes gh-4064
2015-10-15 17:52:51 -07:00
Wallace Wadge
e3315d2252 Allow TraceWebFilter to trace more attributes
Update TraceWebFilter to optionally trace more details from the
HttpServletRequest/HttpServletResponse. The `management.trace.include`
property can be used to change what aspects are logged.

Closes gh-3948
2015-10-14 13:25:11 -07:00
Andy Wilkinson
17fde264e2 Merge branch '1.2.x' 2015-10-14 12:20:09 +01:00
Andy Wilkinson
e4895f8fde Disable child context's /error endpoint if disabled in parent
Previously, EndpointWebMvcChildContextConfiguration would attempt to
create a /error endpoint, irrespective of whether or not the parent
had such an endpoint. If the endpoint was disabled in the parent this
would cause a failure due to the absence of an ErrorAttributes bean.

This commit updates EndpointWebMvcChildContextConfiguration to make
the creation of its /error endpoint conditional on the existence of
an ErrorAttributes bean.

Closes gh-4164
2015-10-14 12:06:10 +01:00
Phillip Webb
6333426cbf Reformat package-info.java files with Eclipse Mars 2015-10-09 13:54:25 -07:00
Phillip Webb
04074fece1 Merge branch '1.2.x' 2015-10-09 13:39:09 -07:00
Phillip Webb
94736719f1 Reformat package-info.java files with Eclipse Mars 2015-10-09 13:32:57 -07:00
Stephane Nicoll
b9c885f5d2 Polish
Closes gh-4118
2015-10-09 17:16:46 +02:00
Marten Deinum
bad8c1bee8 Added support for the DB2 AS400 Driver
Closes gh-4115
2015-10-09 17:16:21 +02:00
Phillip Webb
c9fb9916b8 Reformat code using Eclipse Mars 2015-10-07 23:37:10 -07:00
Phillip Webb
e473364e4e Merge branch '1.2.x' 2015-10-07 23:34:08 -07:00
Phillip Webb
6ab376e2e8 Reformat code use Eclipse Mars 2015-10-07 23:32:31 -07:00
Andy Wilkinson
08aa6f788d Merge branch '1.2.x' 2015-10-07 11:34:29 +01:00
Andy Wilkinson
9a703ab4d1 Correct quotation marks in spring-boot-actuator’s README
Closes gh-4095
2015-10-07 11:33:43 +01:00
Andy Wilkinson
d793d5abcb Work around intermittent failure caused by SPR-13079
See gh-4098
2015-10-06 11:43:53 +01:00
Andy Wilkinson
6387f36efa Work around MockMvc bug (SPR-13079) that has only been fixed in 4.2
See gh-4098
2015-10-06 11:25:18 +01:00
Andy Wilkinson
b7719a131b Merge branch '1.2.x' 2015-10-06 11:01:07 +01:00
Andy Wilkinson
b8b4ea489e Improve MetricsFilter’s handling of async requests
Previously, MetricsFilter would treat async requests the same as
sync requests and would record their response status as soon as the
request had been processed by the filter chain. This would result in a
200 response being recorded and the actual response status produced by
the async processing being ignored. Furthermore, the time that was
recorded for the request would not include the time take for any async processing.

This commit updates MetricsFilter to check whether or not an async
request has been started before it records the metrics for the request.
In the event of an async request having been started no metrics are
recorded. Instead, the StopWatch is stored in a request attribute that
is then retrieved during the filtering of the request’s async
dispatch(es). Once the async processing has completed (isAsyncStarted()
returns false), the StopWatch is stopped, removed from the request’s
attributes and the metrics for the request are recorded.

Closes gh-4098
2015-10-06 11:00:59 +01:00
Stephane Nicoll
7d182028af Remove unecessary modifier 2015-10-03 09:11:32 +02:00