From a68e081de452e0b9b1d4b89a74eebb1eae19a081 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Thu, 6 Aug 2015 16:26:31 -0700 Subject: [PATCH] Do not expose health check data in health handler Because health check errors may expose sensitive data, we shouldn't expose the details of the failure to clients. Instead, an error is returned to the client with a hint about where they could find further information on why the service is down. Signed-off-by: Stephen J Day --- health/health.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/health/health.go b/health/health.go index b1b8c2c68..ba9549192 100644 --- a/health/health.go +++ b/health/health.go @@ -8,6 +8,7 @@ import ( "time" "github.com/docker/distribution/context" + "github.com/docker/distribution/registry/api/errcode" ) var ( @@ -214,7 +215,8 @@ func Handler(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { checks := CheckStatus() if len(checks) != 0 { - statusResponse(w, r, http.StatusServiceUnavailable, checks) + errcode.ServeJSON(w, errcode.ErrorCodeUnavailable. + WithDetail("health check failed: please see /debug/health")) return }