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

feat: remove request URI query params from emitted url.path #269

Merged
merged 5 commits into from
Oct 6, 2023

Conversation

robbkidd
Copy link
Member

@robbkidd robbkidd commented Oct 4, 2023

Which problem is this PR solving?

Short description of the changes

  • add tests for path-only url.path
  • use url package for URL parsing and emit only the path portion of the URI for url.path

How to verify that this has the expected result

No more content after a # or a ? in a URL sent for url.path!

Add urlshaper to the project, use it to parse path of the request URI.
@robbkidd
Copy link
Member Author

robbkidd commented Oct 4, 2023

urlshaper does the job for removing parameters from request URIs. I stopped changing code at the point where it did what #214 described: no query params in the url.path. So at this point, both cardinality of url.path and the likelihood of sensitive information getting passed along have been reduced. Also, now we're following the convention for url.path which should only be—like—the path.

We could put them in url.query per semconv, but without more data munging, the values could still be sensitive.

urlshaper's Shape field is tempting, too, with its "query param values transformed into '?'" as output. There's no semconv-named field for that kind of value, though.

@robbkidd robbkidd added the type: enhancement New feature or request label Oct 4, 2023
@robbkidd robbkidd self-assigned this Oct 4, 2023
@robbkidd robbkidd marked this pull request as ready for review October 4, 2023 22:06
@robbkidd robbkidd requested a review from a team October 4, 2023 22:06
@@ -155,7 +158,10 @@ func (handler *libhoneyEventHandler) handleEvent(event assemblers.HttpEvent) {
ev.AddField(string(semconv.HTTPRequestBodySizeKey), event.Request.ContentLength)
if handler.config.IncludeRequestURL {
requestURI = event.Request.RequestURI
ev.AddField(string(semconv.URLPathKey), requestURI)
urlShape, err := handler.urlParser.Parse(requestURI)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you feel about always adding the templated path and then using the new IncludeRequesURL config option to add in the original url?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Templated path is not something we've got yet without accepting regexes from the user to know how to parse out the variable bits of a path. 😞

No need (yet) for an external dependency to parse URI for the path.
@robbkidd
Copy link
Member Author

robbkidd commented Oct 5, 2023

Here's a go at emitting strictly the url.path (e.g. without query params) by using only stdlib's url package. No urlshaper needed yet.

Copy link
Contributor

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep your secrets

@robbkidd robbkidd merged commit 4058e88 into main Oct 6, 2023
@robbkidd robbkidd deleted the robb.fewer-cardinals-in-url branch October 6, 2023 20:52
MikeGoldsmith added a commit that referenced this pull request Oct 13, 2023
## Which problem is this PR solving?
Now we strip query string parameters from the Url in #269, we can more
safely default to recording HTTP URL. The option is still be available
to opt-out if desired.

- Closes #280

## Short description of the changes
- Change default value of IncludeRequestURL config option to `true`
- Update unit tests 

## How to verify that this has the expected result
The agent's default behaviour to to record HTTP request URLs. The can be
disabled via setting the config option to false.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce cardinality of http.url, break up non-sensitive components into more attributes
3 participants