-
Notifications
You must be signed in to change notification settings - Fork 440
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
internal/appsec: add support for http.request.path_params address #1106
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5a606b8
contrib/labstack/echo.v4: add support for http.request.path_params ad…
Hellzy fd5a49e
contrib/gorilla/mux: add support for http.request.path_params address
Hellzy bc9b9b2
contrib/gorilla/mux: simplify AppSecParams struct to PathParams strin…
Hellzy f0376f2
Merge remote-tracking branch 'origin/v1' into francois.mazeau/appsec-…
Julio-Guerra fcd965b
pr review
Julio-Guerra f73dff9
self pr review
Julio-Guerra 70f1125
self pr review
Julio-Guerra 986f33c
Merge remote-tracking branch 'origin/v1' into francois.mazeau/appsec-…
Julio-Guerra ae47a85
self pr review
Julio-Guerra a993cca
Merge branch 'v1' into francois.mazeau/appsec-http-path-params
Julio-Guerra 7ff222d
contrib/net/http/trace.go: update the RouteParams documentation
Julio-Guerra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016 Datadog, Inc. | ||
|
||
package echo | ||
|
||
import ( | ||
"net" | ||
|
||
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" | ||
"gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/dyngo/instrumentation/httpsec" | ||
|
||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
func withAppSec(next echo.HandlerFunc) echo.HandlerFunc { | ||
return func(c echo.Context) error { | ||
req := c.Request() | ||
span, ok := tracer.SpanFromContext(req.Context()) | ||
if !ok { | ||
return next(c) | ||
} | ||
httpsec.SetAppSecTags(span) | ||
params := make(map[string]string) | ||
for _, n := range c.ParamNames() { | ||
params[n] = c.Param(n) | ||
} | ||
args := httpsec.MakeHandlerOperationArgs(req, params) | ||
op := httpsec.StartOperation(args, nil) | ||
defer func() { | ||
events := op.Finish(httpsec.HandlerOperationRes{Status: c.Response().Status}) | ||
if len(events) > 0 { | ||
remoteIP, _, err := net.SplitHostPort(req.RemoteAddr) | ||
if err != nil { | ||
remoteIP = req.RemoteAddr | ||
} | ||
httpsec.SetSecurityEventTags(span, events, remoteIP, args.Headers, c.Response().Writer.Header()) | ||
} | ||
}() | ||
return next(c) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also worth mentioning that it's used specifically for that. In the current form we are saying that it's "monitored by appsec" but it's not clear if it has other uses to.
Is there any point in mentioning more details, as in how AppSec monitors these? I'm thinking that maybe some people who may be using
TraceAndServe
independently for their own handlers, might be able to benefit from AppSec by using these fields with some other framework which is not supported by us. Is it also worth mentioning that AppSec must be enabled for these to be taken into consideration? For example: if someone passesRouteParams
but has AppSec disabled, will it be taken into account?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a simple addition here: 7ff222d
No need to further explain how AppSec monitors them, as it depends on the security rules, that are exposed and detailed in our UI.