Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Security Features #956

Merged
merged 11 commits into from
Sep 10, 2024
3 changes: 3 additions & 0 deletions v3/integrations/nrecho-v3/nrecho.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func Middleware(app *newrelic.Application) func(echo.HandlerFunc) echo.HandlerFu
} else {
txn.SetWebResponse(nil).WriteHeader(http.StatusInternalServerError)
}
if newrelic.IsSecurityAgentPresent() {
newrelic.GetSecurityAgentInterface().SendEvent("RESPONSE_HEADER", c.Response().Header())
}
}

return
Expand Down
3 changes: 3 additions & 0 deletions v3/integrations/nrecho-v4/nrecho.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func Middleware(app *newrelic.Application, opts ...ConfigOption) func(echo.Handl
} else {
txn.SetWebResponse(nil).WriteHeader(http.StatusInternalServerError)
}
if newrelic.IsSecurityAgentPresent() {
newrelic.GetSecurityAgentInterface().SendEvent("RESPONSE_HEADER", c.Response().Header())
}
}

return
Expand Down
6 changes: 5 additions & 1 deletion v3/integrations/nrfasthttp/instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ func WrapHandle(app *newrelic.Application, pattern string, handler fasthttp.Requ

handler(ctx)
if newrelic.IsSecurityAgentPresent() {
newrelic.GetSecurityAgentInterface().SendEvent("INBOUND_WRITE", resp.Body(), resp.Header())
header := resp.Header()
ctx.Response.Header.VisitAllCookie(func(key, value []byte) {
header.Add("Set-Cookie", string(value))
})
newrelic.GetSecurityAgentInterface().SendEvent("INBOUND_WRITE", resp.Body(), header)
newrelic.GetSecurityAgentInterface().SendEvent("INBOUND_RESPONSE_CODE", ctx.Response.StatusCode())
}
}
Expand Down
3 changes: 3 additions & 0 deletions v3/integrations/nrgin/nrgin.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,8 @@ func middleware(app *newrelic.Application, useNewNames bool) gin.HandlerFunc {
c.Set(internal.GinTransactionContextKey, txn)
}
c.Next()
if newrelic.IsSecurityAgentPresent() {
newrelic.GetSecurityAgentInterface().SendEvent("RESPONSE_HEADER", c.Writer.Header())
}
}
}
3 changes: 3 additions & 0 deletions v3/integrations/nrgorilla/nrgorilla.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func Middleware(app *newrelic.Application) mux.MiddlewareFunc {
w = txn.SetWebResponse(w)
r = newrelic.RequestWithTransactionContext(r, txn)
next.ServeHTTP(w, r)
if newrelic.IsSecurityAgentPresent() {
newrelic.GetSecurityAgentInterface().SendEvent("RESPONSE_HEADER", w.Header())
}
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions v3/integrations/nrhttprouter/nrhttprouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,7 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}

r.Router.ServeHTTP(w, req)
if newrelic.IsSecurityAgentPresent() {
newrelic.GetSecurityAgentInterface().SendEvent("RESPONSE_HEADER", w.Header())
}
}
2 changes: 1 addition & 1 deletion v3/integrations/nrsecurityagent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/newrelic/go-agent/v3/integrations/nrsecurityagent
go 1.20

require (
github.com/newrelic/csec-go-agent v1.3.0
github.com/newrelic/csec-go-agent v1.4.0
github.com/newrelic/go-agent/v3 v3.33.1
github.com/newrelic/go-agent/v3/integrations/nrsqlite3 v1.2.0
gopkg.in/yaml.v2 v2.4.0
Expand Down
3 changes: 3 additions & 0 deletions v3/newrelic/instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func WrapHandle(app *Application, pattern string, handler http.Handler, options
r = RequestWithTransactionContext(r, txn)

handler.ServeHTTP(w, r)
if IsSecurityAgentPresent() {
secureAgent.SendEvent("RESPONSE_HEADER", w.Header())
}
})
}

Expand Down
Loading