From 4802a9c68192e0cbeb51cf95673ff52c9ab2fed5 Mon Sep 17 00:00:00 2001 From: sawadashota Date: Tue, 29 Mar 2022 12:01:08 +0900 Subject: [PATCH 1/3] fix: Do not expose debug in a response when schema is not found Signed-off-by: sawadashota --- schema/handler.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/schema/handler.go b/schema/handler.go index c046563a3e52..e4a1dd47b1a5 100644 --- a/schema/handler.go +++ b/schema/handler.go @@ -10,9 +10,10 @@ import ( "os" "strings" - "github.com/ory/kratos/driver/config" "github.com/ory/x/urlx" + "github.com/ory/kratos/driver/config" + "github.com/julienschmidt/httprouter" "github.com/pkg/errors" @@ -105,7 +106,7 @@ func (h *Handler) getByID(w http.ResponseWriter, r *http.Request, ps httprouter. s, err = ss.GetByID(id) if err != nil { - h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrNotFound.WithDebugf("%+v", err))) + h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrNotFound.WithReason("The schema is not found"))) return } } From df61e8d8c262a56bffc6c3ee10906dcb69a80828 Mon Sep 17 00:00:00 2001 From: sawadashota Date: Tue, 29 Mar 2022 17:25:41 +0900 Subject: [PATCH 2/3] Update schema/handler.go Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> --- schema/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/handler.go b/schema/handler.go index e4a1dd47b1a5..498ca85e2bdf 100644 --- a/schema/handler.go +++ b/schema/handler.go @@ -106,7 +106,7 @@ func (h *Handler) getByID(w http.ResponseWriter, r *http.Request, ps httprouter. s, err = ss.GetByID(id) if err != nil { - h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrNotFound.WithReason("The schema is not found"))) + h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrNotFound.WithReasonf("Identity schema `%s` could not be found.", id)))) return } } From 6a76e95d9484e5f901ce7279fc7fa1a6547476e3 Mon Sep 17 00:00:00 2001 From: sawadashota Date: Tue, 29 Mar 2022 19:45:22 +0900 Subject: [PATCH 3/3] fix: Syntac error --- schema/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/handler.go b/schema/handler.go index 498ca85e2bdf..da53eb0d0fa1 100644 --- a/schema/handler.go +++ b/schema/handler.go @@ -106,7 +106,7 @@ func (h *Handler) getByID(w http.ResponseWriter, r *http.Request, ps httprouter. s, err = ss.GetByID(id) if err != nil { - h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrNotFound.WithReasonf("Identity schema `%s` could not be found.", id)))) + h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrNotFound.WithReasonf("Identity schema `%s` could not be found.", id))) return } }