From e309a9cb2253484136933094fe4cab1e57f54bbc Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 10 Aug 2023 23:42:27 +0200 Subject: [PATCH] feat: strict http headers null validation with tests --- input/elasticapm/internal/modeldecoder/nullable/nullable.go | 1 - .../elasticapm/internal/modeldecoder/nullable/nullable_test.go | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/input/elasticapm/internal/modeldecoder/nullable/nullable.go b/input/elasticapm/internal/modeldecoder/nullable/nullable.go index 97295567..ccdd1eec 100644 --- a/input/elasticapm/internal/modeldecoder/nullable/nullable.go +++ b/input/elasticapm/internal/modeldecoder/nullable/nullable.go @@ -128,7 +128,6 @@ func init() { h := http.Header{} for key, val := range m { switch v := val.(type) { - case nil: case string: h.Add(key, v) case []interface{}: diff --git a/input/elasticapm/internal/modeldecoder/nullable/nullable_test.go b/input/elasticapm/internal/modeldecoder/nullable/nullable_test.go index 71bed051..30948ccb 100644 --- a/input/elasticapm/internal/modeldecoder/nullable/nullable_test.go +++ b/input/elasticapm/internal/modeldecoder/nullable/nullable_test.go @@ -326,6 +326,8 @@ func TestHTTPHeader(t *testing.T) { }}, {name: "valid2", input: `{"h":{"k":["a","b"]}}`, isSet: true, val: http.Header{"K": []string{"a", "b"}}}, {name: "null", input: `{"h":null}`}, + {name: "null-value", input: `{"h":{"k": null}`, fail: true}, + {name: "null-array", input: `{"h":{"k": [null]}`, fail: true}, {name: "invalid-type", input: `{"h":""}`, fail: true, isSet: true}, {name: "invalid-array", input: `{"h":{"k":["a",23]}}`, isSet: true, fail: true}, {name: "missing", input: `{}`},