Skip to content

Commit 7cc1153

Browse files
authored
chore: use coveralls (#10)
1 parent 4c43d79 commit 7cc1153

21 files changed

+465
-339
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
name: CI
1+
name: CI linux
22
on:
33
push:
4-
branches:
5-
- master
64
pull_request:
75

86
jobs:
@@ -16,6 +14,7 @@ jobs:
1614
- { ruby_version: 2.7 }
1715
- { ruby_version: 3.0 }
1816
- { ruby_version: 3.1 }
17+
- { ruby_version: 3.2 }
1918
- { ruby_version: jruby }
2019
steps:
2120
- uses: actions/checkout@v1
@@ -31,22 +30,9 @@ jobs:
3130
bundle install --jobs 4 --retry 3 --no-cache
3231
bundle exec rspec
3332
34-
- uses: coverallsapp/github-action@master
33+
- uses: coverallsapp/github-action@v2
34+
env:
35+
COVERALLS_SERVICE_NUMBER: ${{ github.sha }}
3536
with:
36-
github-token: ${{ secrets.GITHUB_TOKEN }}
37-
flag-name: ruby-${{ matrix.ruby_version }}
38-
path-to-lcov: ./coverage/lcov/sentry-sanitizer.lcov
37+
flag-name: ruby-${{ join(matrix.*, '-') }}
3938
parallel: true
40-
41-
coverage:
42-
needs: rspec
43-
name: Unit tests
44-
if: ${{ always() }}
45-
runs-on: ubuntu-latest
46-
steps:
47-
- uses: coverallsapp/github-action@master
48-
with:
49-
github-token: ${{ secrets.GITHUB_TOKEN }}
50-
carryforward: "ruby-2.5,ruby-2.7,ruby-3.0,ruby-3.1,ruby-jruby"
51-
parallel-finished: true
52-

.github/workflows/ci-macos.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI macos
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
rspec:
8+
name: Unit tests
9+
runs-on: macos-latest
10+
strategy:
11+
matrix:
12+
include:
13+
- { ruby_version: 2.5 }
14+
- { ruby_version: 2.7 }
15+
- { ruby_version: 3.0 }
16+
- { ruby_version: 3.1 }
17+
- { ruby_version: 3.2 }
18+
- { ruby_version: jruby }
19+
steps:
20+
- uses: actions/checkout@v1
21+
22+
- name: Set up Ruby ${{ matrix.ruby_version }}
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
bundler: 2
26+
ruby-version: ${{ matrix.ruby_version }}
27+
28+
- name: Run specs
29+
run: |
30+
bundle install --jobs 4 --retry 3 --no-cache
31+
bundle exec rspec
32+
33+
- uses: coverallsapp/github-action@v2
34+
env:
35+
COVERALLS_SERVICE_NUMBER: ${{ github.sha }}
36+
with:
37+
flag-name: ruby-${{ join(matrix.*, '-') }}
38+
parallel: true
39+
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Coveralls
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
coveralls:
8+
name: Coveralls Report
9+
runs-on: ubuntu-latest
10+
if: ${{ always() }}
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Wait on tests (PR)
15+
uses: lewagon/wait-on-check-action@v1.3.1
16+
if: github.event_name == 'pull_request'
17+
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
repo-token: ${{ secrets.GITHUB_TOKEN }}
20+
wait-interval: 10 # seconds
21+
running-workflow-name: Coveralls Report
22+
allowed-conclusions: success,skipped,cancelled,failure
23+
24+
- name: Wait on tests
25+
uses: lewagon/wait-on-check-action@v1.3.1
26+
with:
27+
ref: ${{ github.sha }}
28+
repo-token: ${{ secrets.GITHUB_TOKEN }}
29+
wait-interval: 10 # seconds
30+
running-workflow-name: Coveralls Report
31+
allowed-conclusions: success,skipped,cancelled,failure
32+
33+
- uses: coverallsapp/github-action@v2
34+
env:
35+
COVERALLS_SERVICE_NUMBER: ${{ github.sha }}
36+
with:
37+
carryforward: "ruby-2.5,ruby-2.6,ruby-2.7,ruby-3.0,ruby-3.1,ruby-jruby"
38+
parallel-finished: true

.rubocop.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
AllCops:
2+
NewCops: enable
3+
SuggestExtensions: false
4+
5+
Style/StringLiterals:
6+
EnforcedStyle: double_quotes
7+
8+
Metrics/BlockLength:
9+
Enabled: false
10+
11+
Style/Documentation:
12+
Enabled: false
13+
14+
Layout/LineLength:
15+
Enabled: false
16+
17+
Naming/FileName:
18+
Enabled: false
19+
20+
Metrics/MethodLength:
21+
Enabled: false
22+
23+
Metrics/ClassLength:
24+
Enabled: false
25+
26+
Metrics/AbcSize:
27+
Enabled: false
28+
29+
Gemspec/RequiredRubyVersion:
30+
Enabled: false
31+
32+
Style/SelectByRegexp:
33+
Enabled: false
34+
35+
Style/CaseLikeIf:
36+
Enabled: false

Gemfile

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
# frozen_string_literal: true
2+
13
source "https://rubygems.org"
24

3-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
46

57
# Specify your gem's dependencies in sentry-sanitizer.gemspec
68
gemspec
79

8-
gem 'simplecov', require: false, group: :test
9-
gem 'simplecov-lcov', require: false, group: :test
10+
gem "rubocop", "~> 1.28.2"
11+
gem "simplecov", require: false, group: :test
12+
13+
gem "bundler", ">= 1.17"
14+
gem "rack"
15+
gem "rake", "~> 10.0"
16+
gem "rspec", "~> 3.0"

Gemfile.lock

+21-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ PATH
77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
codecov (0.6.0)
11-
simplecov (>= 0.15, < 0.22)
10+
ast (2.4.2)
1211
concurrent-ruby (1.1.10)
1312
diff-lcs (1.5.0)
1413
docile (1.4.0)
14+
parallel (1.23.0)
15+
parser (3.2.2.1)
16+
ast (~> 2.4.1)
1517
rack (2.2.3.1)
18+
rainbow (3.1.1)
1619
rake (10.5.0)
20+
regexp_parser (2.8.0)
21+
rexml (3.2.5)
1722
rspec (3.11.0)
1823
rspec-core (~> 3.11.0)
1924
rspec-expectations (~> 3.11.0)
@@ -27,26 +32,37 @@ GEM
2732
diff-lcs (>= 1.2.0, < 2.0)
2833
rspec-support (~> 3.11.0)
2934
rspec-support (3.11.0)
35+
rubocop (1.28.2)
36+
parallel (~> 1.10)
37+
parser (>= 3.1.0.0)
38+
rainbow (>= 2.2.2, < 4.0)
39+
regexp_parser (>= 1.8, < 3.0)
40+
rexml
41+
rubocop-ast (>= 1.17.0, < 2.0)
42+
ruby-progressbar (~> 1.7)
43+
unicode-display_width (>= 1.4.0, < 3.0)
44+
rubocop-ast (1.29.0)
45+
parser (>= 3.2.1.0)
46+
ruby-progressbar (1.13.0)
3047
sentry-ruby (5.4.1)
3148
concurrent-ruby (~> 1.0, >= 1.0.2)
3249
simplecov (0.18.5)
3350
docile (~> 1.1)
3451
simplecov-html (~> 0.11)
3552
simplecov-html (0.12.3)
36-
simplecov-lcov (0.8.0)
53+
unicode-display_width (2.4.2)
3754

3855
PLATFORMS
3956
ruby
4057

4158
DEPENDENCIES
4259
bundler (>= 1.17)
43-
codecov
4460
rack
4561
rake (~> 10.0)
4662
rspec (~> 3.0)
63+
rubocop (~> 1.28.2)
4764
sentry-sanitizer!
4865
simplecov
49-
simplecov-lcov
5066

5167
BUNDLED WITH
5268
2.3.16

Rakefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# frozen_string_literal: true
2+
13
require "bundler/gem_tasks"
24
require "rspec/core/rake_task"
35

46
RSpec::Core::RakeTask.new(:spec)
57

6-
task :default => :spec
8+
task default: :spec

bin/console

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

34
require "bundler/setup"
45
require "sentry/sanitizer"

lefthook.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pre-commit:
2+
commands:
3+
lint:
4+
run: bundle exec rubocop -A {staged_files}
5+
glob: "*.rb"
6+
stage_fixed: true

lib/sentry-sanitizer.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
require 'sentry/sanitizer/version'
2-
require 'sentry/sanitizer'
1+
# frozen_string_literal: true
2+
3+
require "sentry/sanitizer/version"
4+
require "sentry/sanitizer"

lib/sentry/sanitizer.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
require 'sentry-ruby'
2-
require 'sentry/integrable'
3-
require 'sentry/sanitizer/configuration'
1+
# frozen_string_literal: true
2+
3+
require "sentry-ruby"
4+
require "sentry/integrable"
5+
require "sentry/sanitizer/configuration"
46

57
module Sentry
68
module Sanitizer
79
extend Integrable
810

9-
register_integration name: 'sanitizer', version: Sentry::Sanitizer::VERSION
11+
register_integration name: "sanitizer", version: Sentry::Sanitizer::VERSION
1012
end
1113
end

lib/sentry/sanitizer/cleaner.rb

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# frozen_string_literal: true
2+
13
module Sentry
24
module Sanitizer
35
class Cleaner
4-
DEFAULT_MASK = '[FILTERED]'.freeze
6+
DEFAULT_MASK = "[FILTERED]"
57
DEFAULT_SENSITIVE_HEADERS = %w[
68
Authorization
79
X-Xsrf-Token
@@ -21,7 +23,7 @@ def call(event)
2123
if event.is_a?(Sentry::Event)
2224
sanitize(event, :object) if event.request
2325
elsif event.is_a?(Hash)
24-
sanitize(event, :stringified_hash) if event['request']
26+
sanitize(event, :stringified_hash) if event["request"]
2527
sanitize(event, :symbolized_hash) if event[:request]
2628
end
2729
end
@@ -35,11 +37,11 @@ def sanitize(event, type)
3537
event.request.query_string = sanitize_query_string(event.request.query_string)
3638
event.extra = sanitize_data(event.extra)
3739
when :stringified_hash
38-
event['request']['data'] = sanitize_data(event['request']['data'])
39-
event['request']['headers'] = sanitize_headers(event['request']['headers'])
40-
event['request']['cookies'] = sanitize_cookies(event['request']['cookies'])
41-
event['request']['query_string'] = sanitize_query_string(event['request']['query_string'])
42-
event['extra'] = sanitize_data(event['extra'])
40+
event["request"]["data"] = sanitize_data(event["request"]["data"])
41+
event["request"]["headers"] = sanitize_headers(event["request"]["headers"])
42+
event["request"]["cookies"] = sanitize_cookies(event["request"]["cookies"])
43+
event["request"]["query_string"] = sanitize_query_string(event["request"]["query_string"])
44+
event["extra"] = sanitize_data(event["extra"])
4345
when :symbolized_hash
4446
event[:request][:data] = sanitize_data(event[:request][:data])
4547
event[:request][:headers] = sanitize_headers(event[:request][:headers])
@@ -71,6 +73,7 @@ def sanitize_headers(headers)
7173
headers.transform_values { mask }
7274
when Array
7375
return headers unless http_headers.size.positive?
76+
7477
http_headers_regex = sensitive_regexp(http_headers)
7578

7679
headers.keys.select { |key| key.match?(http_headers_regex) }.each do |key|
@@ -95,14 +98,14 @@ def sanitize_query_string(query_string)
9598
return query_string unless do_query_string
9699
return query_string unless query_string.is_a? String
97100

98-
sanitized_array = query_string.split('&').map do |kv_pair|
99-
k, v = kv_pair.split('=')
101+
sanitized_array = query_string.split("&").map do |kv_pair|
102+
k, v = kv_pair.split("=")
100103
new_v = sanitize_string(k, v)
101104

102105
"#{k}=#{new_v}"
103106
end
104107

105-
sanitized_array.join('&')
108+
sanitized_array.join("&")
106109
end
107110

108111
def sanitize_value(value, key)
@@ -145,7 +148,7 @@ def sensitive_fields
145148
end
146149

147150
def sensitive_regexp(fields)
148-
Regexp.new(fields.map { |field| "\\b#{field}\\b" }.join('|'), 'i')
151+
Regexp.new(fields.map { |field| "\\b#{field}\\b" }.join("|"), "i")
149152
end
150153
end
151154
end

0 commit comments

Comments
 (0)