From c9558de57447ffc5a6781a2952ee115469ccf1aa Mon Sep 17 00:00:00 2001 From: Marc Lopez Rubio Date: Thu, 23 Sep 2021 12:13:02 +0200 Subject: [PATCH 1/2] Stop recording `http.request.socket.encrypted` Deprecates the `http.request.socket.encrypted` field in the apm agent, and stops recording it in the modules that populated that field: - `module/apmhttp` - `module/apmgrpc` - `module/apmfiber` Signed-off-by: Marc Lopez Rubio --- context.go | 1 - gofuzz.go | 3 --- model/marshal_fastjson.go | 10 ---------- model/marshal_test.go | 2 -- model/model.go | 2 +- module/apmfiber/middleware_test.go | 1 - module/apmgrpc/server_test.go | 1 - module/apmhttp/handler_http2_test.go | 1 - 8 files changed, 1 insertion(+), 20 deletions(-) diff --git a/context.go b/context.go index 7e5177cda..828fabe3c 100644 --- a/context.go +++ b/context.go @@ -197,7 +197,6 @@ func (c *Context) SetHTTPRequest(req *http.Request) { } c.requestSocket = model.RequestSocket{ - Encrypted: req.TLS != nil, RemoteAddress: apmhttputil.RemoteAddr(req), } if c.requestSocket != (model.RequestSocket{}) { diff --git a/gofuzz.go b/gofuzz.go index da3e00149..281b81a87 100644 --- a/gofuzz.go +++ b/gofuzz.go @@ -81,9 +81,6 @@ func Fuzz(data []byte) int { capturedBody := tracer.CaptureHTTPRequestBody(req) if in.Request.Socket != nil { req.RemoteAddr = in.Request.Socket.RemoteAddress - if in.Request.Socket.Encrypted { - req.TLS = new(tls.ConnectionState) - } } req.PostForm = postForm if in.User != nil && in.User.Username != "" { diff --git a/model/marshal_fastjson.go b/model/marshal_fastjson.go index 4cdbb44c9..90f88a20b 100644 --- a/model/marshal_fastjson.go +++ b/model/marshal_fastjson.go @@ -1299,16 +1299,6 @@ func (v *Request) MarshalFastJSON(w *fastjson.Writer) error { func (v *RequestSocket) MarshalFastJSON(w *fastjson.Writer) error { w.RawByte('{') first := true - if v.Encrypted != false { - const prefix = ",\"encrypted\":" - if first { - first = false - w.RawString(prefix[1:]) - } else { - w.RawString(prefix) - } - w.Bool(v.Encrypted) - } if v.RemoteAddress != "" { const prefix = ",\"remote_address\":" if first { diff --git a/model/marshal_test.go b/model/marshal_test.go index ec9cc2342..13156c933 100644 --- a/model/marshal_test.go +++ b/model/marshal_test.go @@ -83,7 +83,6 @@ func TestMarshalTransaction(t *testing.T) { "random": "junk", }, "socket": map[string]interface{}{ - "encrypted": true, "remote_address": "[::1]", }, }, @@ -594,7 +593,6 @@ func fakeTransaction() model.Transaction { {Name: "random", Value: "junk"}, }, Socket: &model.RequestSocket{ - Encrypted: true, RemoteAddress: "[::1]", }, }, diff --git a/model/model.go b/model/model.go index 05a7c8f37..64927579d 100644 --- a/model/model.go +++ b/model/model.go @@ -666,7 +666,7 @@ type Header struct { // RequestSocket holds transport-level information relating to an HTTP request. type RequestSocket struct { // Encrypted indicates whether or not the request was sent - // as an SSL/HTTPS request. + // as an SSL/HTTPS request. Deprecated. Encrypted bool `json:"encrypted,omitempty"` // RemoteAddress holds the remote address for the request. diff --git a/module/apmfiber/middleware_test.go b/module/apmfiber/middleware_test.go index 82eb835c8..901e0dcb7 100644 --- a/module/apmfiber/middleware_test.go +++ b/module/apmfiber/middleware_test.go @@ -129,7 +129,6 @@ func TestMiddleware(t *testing.T) { }, Request: &model.Request{ Socket: &model.RequestSocket{ - Encrypted: false, RemoteAddress: "remote-addr", }, URL: model.URL{ diff --git a/module/apmgrpc/server_test.go b/module/apmgrpc/server_test.go index d83753fa6..117bb897e 100644 --- a/module/apmgrpc/server_test.go +++ b/module/apmgrpc/server_test.go @@ -335,7 +335,6 @@ func TestServerTLS(t *testing.T) { Values: []string{"grpc-go/" + grpc.Version}, }}, Socket: &model.RequestSocket{ - Encrypted: true, // Server is listening on loopback, so the client // should have the same IP address. RemoteAddress // does not record the port. diff --git a/module/apmhttp/handler_http2_test.go b/module/apmhttp/handler_http2_test.go index 2b0141eaa..5bf6c34e5 100644 --- a/module/apmhttp/handler_http2_test.go +++ b/module/apmhttp/handler_http2_test.go @@ -73,7 +73,6 @@ func TestHandlerHTTP2(t *testing.T) { assert.Equal(t, &model.Context{ Request: &model.Request{ Socket: &model.RequestSocket{ - Encrypted: true, // 127.0.0.1 or ::1. RemoteAddress: srvAddr.IP.String(), }, From 94712af1342a937ac6e6319a0a829aaa00716fef Mon Sep 17 00:00:00 2001 From: Marc Lopez Rubio Date: Thu, 23 Sep 2021 12:30:04 +0200 Subject: [PATCH 2/2] Add changelog, fix imports Signed-off-by: Marc Lopez Rubio --- CHANGELOG.asciidoc | 2 ++ gofuzz.go | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 43f602605..1cae868b4 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -23,6 +23,8 @@ endif::[] https://github.com/elastic/apm-agent-go/compare/v1.14.0...master[View commits] +- Deprecate `http.request.socket.encrypted` and stop recording it in `module/apmhttp`, `module/apmgrpc` and `module/apmfiber`. {pull}1129[#(1129)] + [[release-notes-1.x]] === Go Agent version 1.x diff --git a/gofuzz.go b/gofuzz.go index 281b81a87..a857eb4bd 100644 --- a/gofuzz.go +++ b/gofuzz.go @@ -23,7 +23,6 @@ package apm // import "go.elastic.co/apm" import ( "bytes" "context" - "crypto/tls" "encoding/json" "fmt" "io"