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

Add option to set route definition as Sinatra path #972

Closed
wants to merge 1 commit into from

Conversation

tombruijn
Copy link
Member

@tombruijn tombruijn commented Jun 24, 2023

We had a report of an app that contains sensitive information in the request path and the desire to filter this out. We have no system in place to filter metadata like path and request method, as set by the Sinatra middleware.

Add a config option sinatra_sanitized_routes that can be set to true to set the route definition rather than the real request path as the path metadata.

To do

To do after merge

  • Document config option
  • Add mention of config option on Sinatra docs page

Based on #971

We had a report of an app that contains sensitive information in the
request path and the desire to filter this out. We have no system in
place to filter metadata like path and request method, as set by the
Sinatra middleware.

Add a config option `sinatra_sanitized_routes` that can be set to `true`
to set the route definition rather than the real request path as the
`path` metadata.
@tombruijn tombruijn self-assigned this Jun 24, 2023
@tombruijn tombruijn removed the bug label Jun 24, 2023
tombruijn added a commit to appsignal/test-setups that referenced this pull request Jun 26, 2023
Add test route to Sinatra app to test the sanitized routes / route
definition to be set as the `path` metadata to avoid storing PII and
other sensitive data.

Related PR appsignal/appsignal-ruby#972
tombruijn added a commit to appsignal/test-setups that referenced this pull request Jun 26, 2023
Add test route to Sinatra app to test the sanitized routes / route
definition to be set as the `path` metadata to avoid storing PII and
other sensitive data.

Related PR appsignal/appsignal-ruby#972
@tombruijn
Copy link
Member Author

Copy link
Contributor

@unflxw unflxw left a comment

Choose a reason for hiding this comment

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

As mentioned in the call, almost every instrumentation sends the full path as a tag, so, in the future, we should consider solving this for the general case, rather than by having config options for each of them. Some filter_tags configuration option, like our existing filter_parameters or filter_session_data.

Left a comment about the current implementation, but that said, happy to merge this in any form, as it fixes an issue for an user today. We can always change this and/or deprecate this later.

Comment on lines +73 to +79
path =
if Appsignal.config[:sinatra_sanitized_routes]
sanitized_route(env)
else
request.path
end
transaction.set_metadata("path", path)
Copy link
Contributor

@unflxw unflxw Jun 26, 2023

Choose a reason for hiding this comment

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

Perhaps, rather than sending the sanitised route, we shouldn't send path at all when this config option is enabled? I'm not sure if there's value in sending the route as path -- the actions are already being grouped by the route, so filtering by this tag won't do anything interesting.

And then maybe we can name it sinatra_filter_path, which I think would express its purpose more clearly. After all, routes, as in action names, are already sanitised in Sinatra by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll have a look if I can add a filter_metadata option really quickly to accomplish the same thing for all instrumentations.

@tombruijn tombruijn changed the base branch from refactor-sinatra-specs to main June 26, 2023 11:38
@tombruijn
Copy link
Member Author

Closing in favor of #973

@tombruijn tombruijn closed this Jun 26, 2023
tombruijn added a commit to appsignal/test-setups that referenced this pull request Jun 28, 2023
Add test route to Sinatra app to test the sanitized routes / route
definition to be set as the `path` metadata to avoid storing PII and
other sensitive data.

Related PR appsignal/appsignal-ruby#972
tombruijn added a commit to appsignal/test-setups that referenced this pull request Jun 28, 2023
* Add example app for Sinatra sanitized routes

Add test route to Sinatra app to test the sanitized routes / route
definition to be set as the `path` metadata to avoid storing PII and
other sensitive data.

Related PR appsignal/appsignal-ruby#972

* Update config option to filter_metadata

Added in PR appsignal/appsignal-ruby#973 in
favor of the `sinatra_sanitized_routes` option.
@tombruijn tombruijn deleted the sinatra-filtered-path branch July 10, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants