-
Notifications
You must be signed in to change notification settings - Fork 1
feat: propagate traceparent from bandit callback URLs #196
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -641,6 +641,11 @@ func urlTestGET(ctx context.Context, link string, detour N.Dialer) (uint16, erro | |
| if err != nil { | ||
| return 0, err | ||
| } | ||
| // Propagate embedded trace context so the bandit callback | ||
| // appears in the same distributed trace as the config assignment. | ||
| if tp := linkURL.Query().Get("tp"); tp != "" { | ||
| req.Header.Set("traceparent", tp) | ||
| } | ||
|
Comment on lines
+644
to
+648
|
||
| client := http.Client{ | ||
| Transport: &http.Transport{ | ||
| DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { | ||
|
|
||
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.
tpcomes from a URL query parameter and is copied verbatim into an HTTP header. If it contains control characters (or is just not a valid W3Ctraceparent), Go's HTTP client can fail the request at send time (invalid header value) and an untrusted URL could also attempt header injection. Consider validating/sanitizing the value (e.g., trim spaces, reject any CTLs, and only accept the expectedversion-traceid-spanid-flagsformat) before settingtraceparent.