-
-
Notifications
You must be signed in to change notification settings - Fork 540
feat(data-collection): Request data collection #3030
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 |
|---|---|---|
|
|
@@ -28,7 +28,11 @@ | |
| # data_collection.stack_frame_variables = true | ||
| # data_collection.frame_context_lines = 5 | ||
| # end | ||
|
|
||
| MODES = %i[off deny_list allow_list].freeze | ||
|
|
||
| PII_HEADER_SNIPPETS = %w[forwarded -ip _ip remote via _user -user].freeze | ||
|
|
||
| BODY_TYPES = %i[ | ||
| incoming_request | ||
| outgoing_request | ||
|
|
@@ -102,6 +106,11 @@ | |
| # @default `3` | ||
| attr_accessor :frame_context_lines | ||
|
|
||
| # Filters key-value data using the default sensitive denylist. | ||
| def self.filter(values) | ||
| KeyValueCollection.new(mode: :deny_list, terms: nil).filter(values) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd memoize this, no need to keep creating the same instance all over again. def self.filter(values)
default_filter.filter(values)
end
def self.default_filter
@default_filter ||= KeyValueColletion.new(mode: :deny_list, terms: nil)
end |
||
| end | ||
|
Check warning on line 112 in sentry-ruby/lib/sentry/data_collection.rb
|
||
|
sl0thentr0py marked this conversation as resolved.
|
||
|
|
||
| # Builds data collection settings compatible with the legacy send_default_pii | ||
| # configuration. | ||
| def self.backfill(configuration) | ||
|
|
@@ -112,8 +121,10 @@ | |
| # TODO-neel-data map to exact ruby behaviour for backwards compat behavior | ||
| data_collection.user_info = false | ||
| data_collection.cookies.mode = :off | ||
| data_collection.http_headers.request.mode = :off | ||
| data_collection.http_headers.response.mode = :off | ||
| data_collection.http_headers.request.mode = :deny_list | ||
| data_collection.http_headers.request.terms = PII_HEADER_SNIPPETS | ||
| data_collection.http_headers.response.mode = :deny_list | ||
| data_collection.http_headers.response.terms = PII_HEADER_SNIPPETS | ||
| data_collection.http_bodies = [] | ||
| data_collection.url_query_params.mode = :off | ||
| data_collection.graphql.document = false | ||
|
|
@@ -132,13 +143,19 @@ | |
| request: KeyValueCollection.new(mode: :deny_list, terms: nil), | ||
| response: KeyValueCollection.new(mode: :deny_list, terms: nil) | ||
| ) | ||
| @http_bodies = nil | ||
| @http_bodies = BODY_TYPES | ||
| @url_query_params = KeyValueCollection.new(mode: :deny_list, terms: nil) | ||
| @database_query_data = true | ||
| @graphql = GraphQL.new(document: true, variables: true) | ||
| @queues = true | ||
| @stack_frame_variables = false | ||
| @frame_context_lines = 3 | ||
| end | ||
|
|
||
| # Returns whether incoming HTTP request bodies should be collected. | ||
| # nil imples all BODY_TYPES according to spec | ||
| def collect_incoming_http_body? | ||
| http_bodies.nil? || http_bodies.include?(:incoming_request) | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,7 @@ | |
| it "normalizes terms assigned after initialization" do | ||
| collection.terms = ["USER"] | ||
|
|
||
| expect(collection.filter("user_id" => "1")).to eq("user_id" => "[Filtered]") | ||
| expect(collection.filter({ "user_id" => "1" })).to eq("user_id" => "[Filtered]") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was wrong with the implicit form? 🤔
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jruby bug with kwargs |
||
| end | ||
|
|
||
| it "covers every built-in sensitive term" do | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.