sentry-sanitizer 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed85a8f652fb2b3b54796967d622c65699a630543a2911ccfdd1c30cf74704c7
4
- data.tar.gz: 2cc6ea9f662817521cc22663734ae392a48ca6fbab77a785897e97d64766c70b
3
+ metadata.gz: fda0761b926ec58a8247355163c29c8b3b48fe3f0b343e3fb492b6e6402b6e6c
4
+ data.tar.gz: 4e53e4ab1fe8194c6757ff958ddda229dcf6603b8724798c94fd24ccbe8681a2
5
5
  SHA512:
6
- metadata.gz: 727f6686da725234549fda38f2125e530ace8f641a9ea95469a692edf28f8a07863aeded84c4226ad7871c836ccbb6d6c504b671b97ed818fc02808b45e89e5c
7
- data.tar.gz: 47da7c136e56db35e7435ae5d579ebc19f00bb2e0fb575c9e1b5e41e984a710d6804a815aa662428341b2a3d8b46254a392a529d015b93b06447c581ce8ade3e
6
+ metadata.gz: fb63ecf8b95c47080a0a376072600aac28839da51d3f3b3892c4cae7584bf7ec7367d81cee3f0db1afd687c45324d999135604b852f6c38dc99ec4b9ac03368c
7
+ data.tar.gz: 214ba8ef2ae130dcd99e5dce43d75c77b4fd6c2c1903479aa6e7f96915c4fccdaf0986860c96ed8192abcb9ff2a3c6f97735cbcaac7f907a1d5c0fad6184afef
@@ -1,4 +1,4 @@
1
- name: CI linux
1
+ name: CI
2
2
  on:
3
3
  push:
4
4
  pull_request:
@@ -11,6 +11,7 @@ jobs:
11
11
  matrix:
12
12
  include:
13
13
  - { ruby_version: 3.3, sentry_version: "~> 6.0" }
14
+ - { ruby_version: 3.3, sentry_version: "~> 7.0" }
14
15
  - { ruby_version: 3.4, sentry_version: "~> 6.0" }
15
16
  - { ruby_version: 3.4, sentry_version: "~> 7.0" }
16
17
  - { ruby_version: 4.0, sentry_version: "~> 6.0" }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.1
4
+
5
+ - Sanitize `Sentry::TransactionEvent#spans` [#27](https://github.com/mrexox/sentry-sanitizer/pull/27)
6
+
7
+ ## 0.10.0
8
+
9
+ - Sanitize transaction events (`before_send_transaction`) and check-in events (`before_send_check_in`). Only `request` and `extra` are sanitized; span data is not
10
+ - Allow multiple `before_send_transaction` and `before_send_check_in` hooks
11
+ - Stop the `before_send` hook chain when a hook returns `nil`, so next hooks do not get `nil`
12
+
3
13
  ## 0.9.0
4
14
 
5
15
  - Add `filter` option to pass a custom filter, e.g. `ActiveSupport::ParameterFilter` [#25](https://github.com/mrexox/sentry-sanitizer/pull/25)
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sentry-sanitizer (0.9.0)
5
- sentry-ruby (>= 5.3, < 8.0.0)
4
+ sentry-sanitizer (0.10.1)
5
+ sentry-ruby (>= 6.0, < 8.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![CI](https://github.com/mrexox/sentry-sanitizer/actions/workflows/ci-linux.yml/badge.svg)](https://github.com/mrexox/sentry-sanitizer/actions/workflows/ci-linux.yml)
1
+ [![CI](https://github.com/mrexox/sentry-sanitizer/actions/workflows/ci.yml/badge.svg)](https://github.com/mrexox/sentry-sanitizer/actions/workflows/ci.yml)
2
2
  [![Gem Version](https://badge.fury.io/rb/sentry-sanitizer.svg)](https://badge.fury.io/rb/sentry-sanitizer)
3
3
  [![Coverage Status](https://coveralls.io/repos/github/mrexox/sentry-sanitizer/badge.svg?branch=master)](https://coveralls.io/github/mrexox/sentry-sanitizer?branch=master)
4
4
 
@@ -21,16 +21,20 @@ Currently this gem provides following features
21
21
  Add this line to your application's Gemfile:
22
22
 
23
23
  ```ruby
24
- gem 'sentry-sanitizer', '>= 0.2.0'
24
+ gem 'sentry-sanitizer', '~> 0.10.0'
25
25
  ```
26
26
 
27
- And then execute:
27
+ And then in the terminal:
28
28
 
29
- $ bundle
29
+ ```sh
30
+ bundle install
31
+ ```
30
32
 
31
- Or install it yourself as:
33
+ Or alternatively:
32
34
 
33
- $ gem install sentry-sanitizer
35
+ ```sh
36
+ gem install sentry-sanitizer
37
+ ```
34
38
 
35
39
  ## Usage
36
40
 
@@ -74,15 +78,15 @@ end
74
78
 
75
79
  Install dependencies
76
80
 
77
- $ bin/setup
81
+ bin/setup
78
82
 
79
83
  Experiment with the code in IRB
80
84
 
81
- $ bin/console
85
+ bin/console
82
86
 
83
87
  Run tests
84
88
 
85
- $ bin/rake test
89
+ bin/rake test
86
90
 
87
91
  ## Contributing
88
92
 
@@ -46,6 +46,7 @@ module Sentry
46
46
  event.request.query_string = sanitize_query_string(event.request.query_string)
47
47
  end
48
48
  event.extra = sanitize_data(event.extra)
49
+ event.spans = sanitize_data(event.spans) if event.is_a?(Sentry::TransactionEvent)
49
50
  end
50
51
 
51
52
  def sanitize_hash!(event)
@@ -66,6 +67,12 @@ module Sentry
66
67
  elsif event[:extra]
67
68
  event[:extra] = sanitize_data(event[:extra])
68
69
  end
70
+
71
+ if event["spans"]
72
+ event["spans"] = sanitize_data(event["spans"])
73
+ elsif event[:spans]
74
+ event[:spans] = sanitize_data(event[:spans])
75
+ end
69
76
  end
70
77
 
71
78
  def sanitize_breadcrumb!(breadcrumb)
@@ -23,6 +23,18 @@ module Sentry
23
23
  event
24
24
  }
25
25
 
26
+ self.before_send_transaction = lambda { |event, _hint|
27
+ Sentry::Sanitizer::Cleaner.new(Sentry.configuration.sanitize).call(event)
28
+
29
+ event
30
+ }
31
+
32
+ self.before_send_check_in = lambda { |event, _hint|
33
+ Sentry::Sanitizer::Cleaner.new(Sentry.configuration.sanitize).call(event)
34
+
35
+ event
36
+ }
37
+
26
38
  self.before_breadcrumb = lambda { |breadcrumb, _hint|
27
39
  Sentry::Sanitizer::Cleaner.new(Sentry.configuration.sanitize).call(breadcrumb)
28
40
 
@@ -4,11 +4,12 @@ module Sentry
4
4
  module Sanitizer
5
5
  module ConfigurationMixin
6
6
  # Allow adding multiple hooks to `before_send`, so user hooks are not ignored.
7
+ # Available since sentry-ruby 4.5.0
7
8
  #
8
9
  # @param [nil, #call] value
9
10
  #
10
11
  def before_send=(value)
11
- raise ArgumentError, "before_send must be callable (or nil to disable)" unless value.nil? || value == false || value.respond_to?(:call)
12
+ _check_callable!("before_send", value)
12
13
 
13
14
  return unless value
14
15
 
@@ -18,6 +19,53 @@ module Sentry
18
19
  @before_send = lambda { |event, hint|
19
20
  @before_send_hook_list.each do |hook|
20
21
  event = hook.call(event, hint)
22
+ break unless event
23
+ end
24
+
25
+ event
26
+ }
27
+ end
28
+
29
+ # Allow adding multiple hooks to `before_send_transaction`, so user hooks are not ignored.
30
+ # Available since sentry-ruby 5.8.0
31
+ #
32
+ # @param [nil, #call] value
33
+ #
34
+ def before_send_transaction=(value)
35
+ _check_callable!("before_send_transaction", value)
36
+
37
+ return unless value
38
+
39
+ @before_send_transaction_hook_list ||= []
40
+ @before_send_transaction_hook_list << value
41
+
42
+ @before_send_transaction = lambda { |event, hint|
43
+ @before_send_transaction_hook_list.each do |hook|
44
+ event = hook.call(event, hint)
45
+ break unless event
46
+ end
47
+
48
+ event
49
+ }
50
+ end
51
+
52
+ # Allow adding multiple hooks to `before_send_check_in`, so user hooks are not ignored.
53
+ # Available since sentry-ruby 6.0.0
54
+ #
55
+ # @param [nil, #call] value
56
+ #
57
+ def before_send_check_in=(value)
58
+ _check_callable!("before_send_check_in", value)
59
+
60
+ return unless value
61
+
62
+ @before_send_check_in_hook_list ||= []
63
+ @before_send_check_in_hook_list << value
64
+
65
+ @before_send_check_in = lambda { |event, hint|
66
+ @before_send_check_in_hook_list.each do |hook|
67
+ event = hook.call(event, hint)
68
+ break unless event
21
69
  end
22
70
 
23
71
  event
@@ -25,11 +73,12 @@ module Sentry
25
73
  end
26
74
 
27
75
  # Allow adding multiple hooks to `before_breadcrumb`, so user hooks are not ignored.
76
+ # Available since sentry-ruby 4.5.0
28
77
  #
29
78
  # @param [nil, #call] value
30
79
  #
31
80
  def before_breadcrumb=(value)
32
- raise ArgumentError, "before_breadcrumb must be callable (or nil to disable)" unless value.nil? || value == false || value.respond_to?(:call)
81
+ _check_callable!("before_breadcrumb", value)
33
82
 
34
83
  return unless value
35
84
 
@@ -45,6 +94,12 @@ module Sentry
45
94
  breadcrumb
46
95
  }
47
96
  end
97
+
98
+ private
99
+
100
+ def _check_callable!(hook, value)
101
+ raise ArgumentError, "#{hook} must be callable (or nil to disable)" unless value.nil? || value == false || value.respond_to?(:call)
102
+ end
48
103
  end
49
104
  end
50
105
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sentry
4
4
  module Sanitizer
5
- VERSION = "0.9.0"
5
+ VERSION = "0.10.1"
6
6
  end
7
7
  end
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_runtime_dependency "sentry-ruby", ">= 5.3", "< 8.0.0"
30
+ spec.add_runtime_dependency "sentry-ruby", ">= 6.0", "< 8.0.0"
31
31
  spec.metadata["rubygems_mfa_required"] = "true"
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-sanitizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentine Kiselev
@@ -15,7 +15,7 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '5.3'
18
+ version: '6.0'
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 8.0.0
@@ -25,7 +25,7 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '5.3'
28
+ version: '6.0'
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
31
  version: 8.0.0
@@ -36,8 +36,7 @@ executables: []
36
36
  extensions: []
37
37
  extra_rdoc_files: []
38
38
  files:
39
- - ".github/workflows/ci-linux.yml"
40
- - ".github/workflows/ci-macos.yml"
39
+ - ".github/workflows/ci.yml"
41
40
  - ".github/workflows/coveralls-report.yml"
42
41
  - ".gitignore"
43
42
  - ".rspec"
@@ -1,40 +0,0 @@
1
- name: CI macos
2
- on:
3
- push:
4
- pull_request:
5
-
6
- jobs:
7
- rspec:
8
- name: Unit tests
9
- runs-on: macos-13
10
- strategy:
11
- matrix:
12
- include:
13
- - { ruby_version: 3.3, sentry_version: "~> 6.0" }
14
- - { ruby_version: 3.4, sentry_version: "~> 6.0" }
15
- - { ruby_version: 3.4, sentry_version: "~> 7.0" }
16
- - { ruby_version: 4.0, sentry_version: "~> 6.0" }
17
- - { ruby_version: 4.0, sentry_version: "~> 7.0" }
18
- - { ruby_version: jruby, sentry_version: "~> 6.0" }
19
- env:
20
- SENTRY_VERSION: ${{ matrix.sentry_version }}
21
- steps:
22
- - uses: actions/checkout@v1
23
-
24
- - name: Set up Ruby ${{ matrix.ruby_version }}
25
- uses: ruby/setup-ruby@v1
26
- with:
27
- bundler: 2
28
- ruby-version: ${{ matrix.ruby_version }}
29
-
30
- - name: Run specs
31
- run: |
32
- bundle install --jobs 4 --retry 3 --no-cache
33
- bundle exec rspec
34
-
35
- - uses: coverallsapp/github-action@v2
36
- env:
37
- COVERALLS_SERVICE_NUMBER: ${{ github.sha }}
38
- with:
39
- flag-name: ruby-${{ join(matrix.*, '-') }}
40
- parallel: true