Class: Sentry::DataCollection::KeyValueCollection
- Inherits:
-
Object
- Object
- Sentry::DataCollection::KeyValueCollection
- Defined in:
- lib/sentry/data_collection/key_value_collection.rb
Overview
Configuration for key-value data collection.
Constant Summary collapse
- FILTERED_VALUE =
"[Filtered]"- SENSITIVE_DENY_LIST =
Keys from this list are ALWAYS filtered, regardless of :mode
%w[ auth token secret session password passwd pwd key jwt bearer sso saml csrf xsrf credentials sid identity cookie set-cookie ].freeze
- SENSITIVE_COOKIE_NAME_DENY_LIST =
Additional terms applied to cookie names only. These cover common opaque session, identity-provider, and load-balancer cookies without making the general header denylist overly broad.
%w[ .sid sessid remember oidc pkce nonce __secure- __host- awsalb awselb akamai __stripe cognito firebase supabase sb- mfa 2fa ].freeze
Instance Attribute Summary collapse
-
#mode ⇒ :off, ...
modecontrols whether values are collected: -:offdisables collection. -
#terms ⇒ Array<String, Regexp>?
termscontains the keys or patterns used by the selected mode.
Class Method Summary collapse
-
.from(value) ⇒ Object
Converts the boolean shorthand into a collection configuration.
Instance Method Summary collapse
-
#filter(values, cookie: false) ⇒ Hash
Applies this collection configuration without changing the input hash.
-
#initialize(mode:, terms:) ⇒ KeyValueCollection
constructor
A new instance of KeyValueCollection.
Constructor Details
#initialize(mode:, terms:) ⇒ KeyValueCollection
Returns a new instance of KeyValueCollection.
68 69 70 71 |
# File 'lib/sentry/data_collection/key_value_collection.rb', line 68 def initialize(mode:, terms:) self.mode = mode self.terms = terms end |
Instance Attribute Details
#mode ⇒ :off, ...
mode controls whether values are collected:
:offdisables collection.:deny_listcollects values except those matchingterms.:allow_listcollects only values matchingterms. Boolean values are accepted as shorthand for:deny_listand:off.
62 63 64 |
# File 'lib/sentry/data_collection/key_value_collection.rb', line 62 def mode @mode end |
#terms ⇒ Array<String, Regexp>?
terms contains the keys or patterns used by the selected mode.
66 67 68 |
# File 'lib/sentry/data_collection/key_value_collection.rb', line 66 def terms @terms end |
Class Method Details
.from(value) ⇒ Object
Converts the boolean shorthand into a collection configuration.
82 83 84 85 86 |
# File 'lib/sentry/data_collection/key_value_collection.rb', line 82 def self.from(value) return new(mode: value, terms: nil) if value.equal?(true) || value.equal?(false) || value.nil? value end |
Instance Method Details
#filter(values, cookie: false) ⇒ Hash
Applies this collection configuration without changing the input hash. Keys are retained whenever the category is collected; values that are not safe to send are replaced with FILTERED_VALUE.
99 100 101 102 103 104 105 |
# File 'lib/sentry/data_collection/key_value_collection.rb', line 99 def filter(values, cookie: false) return {} if mode == :off values.each_with_object({}) do |(key, value), filtered| filtered[key] = safe_value?(key, cookie: ) ? value : FILTERED_VALUE end end |