From 77dc35fbd65db3001db7260e3b57fdb55739197a Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Thu, 12 Mar 2015 19:09:26 -0700 Subject: [PATCH] Validate prefix lookups for WithRequest/WithResponse contexts Signed-off-by: Stephen J Day --- context/http.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/context/http.go b/context/http.go index ab3a3744d..357f0dc32 100644 --- a/context/http.go +++ b/context/http.go @@ -133,6 +133,10 @@ func (ctx *httpRequestContext) Value(key interface{}) interface{} { return ctx.r } + if !strings.HasPrefix(keyStr, "http.request.") { + goto fallback + } + parts := strings.Split(keyStr, ".") if len(parts) != 3 { @@ -241,6 +245,10 @@ func (irw *instrumentedResponseWriter) Value(key interface{}) interface{} { return irw.ResponseWriter } + if !strings.HasPrefix(keyStr, "http.response.") { + goto fallback + } + parts := strings.Split(keyStr, ".") if len(parts) != 3 {