lenjador 2.2.0 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6196d724a25318d7d37585d8240aeadf4539730a3d2456852e99f00a703ad60
4
- data.tar.gz: aefd0d89ad20ed8f1decdd5e084adee315fdc6dbc14702fc26747f83b81274ec
3
+ metadata.gz: 26f40334235faaeecd2b8f1e960641c98d7926be963cb485d57b5db7476abd9d
4
+ data.tar.gz: 9417049506b81464afd16c050a72c0c9af8e4078c5b361aededb74c2fca2c117
5
5
  SHA512:
6
- metadata.gz: 74e4d77b7bbe1867605dac6cd7edfa7e5b7ff5fdf7d2699422c49a0bd6168d531174d7f4c2f594b104afb4e90eaf5d0926c595d5543f3c56bea16d156465a283
7
- data.tar.gz: 1bb069818e94912e408cd7cd95fa09db743336dd3242ebccd1b0029cb887b3dcf223cc4aa207ee2f543dac9044b38e6549ace8efe24453a4aae8f1380c898ccc
6
+ metadata.gz: 1005262582ae1ec5bc03445af4346f6011a5e32c553cdd86469dbcf9d380d8114a995f53649bd398d09674e145e023821e6717b70914f04bf5f96b5ec5429b00
7
+ data.tar.gz: ed3a7f3f6afc47cc7e431217c1c103bd290d3a9bd51f2e8bc0a94e5fd8fa6cf8d6de538a89a4eb1834d5c938987aa0fbe2be23530b7e48761936a6e6e60c5a85
@@ -0,0 +1,25 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['2.6', '2.7']
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ with:
18
+ submodules: true
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true
24
+ - name: Run lint & tests
25
+ run: bundle exec rake
@@ -0,0 +1,20 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ with:
14
+ fetch-depth: 2
15
+ - name: Release Gem
16
+ uses: discourse/publish-rubygems-action@ec5415e2cc3509a5cc8c4eef9499cf3fb05f8391
17
+ env:
18
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
20
+ RELEASE_COMMAND: rake release
data/.gitignore CHANGED
@@ -1,4 +1,2 @@
1
1
  node_modules/
2
2
  npm-debug.log
3
- Gemfile.lock
4
-
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ inherit_gem:
2
2
  rubocop-salemove: config/default.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.4
5
+ TargetRubyVersion: 2.6
6
6
 
7
7
  Style/FrozenStringLiteralComment:
8
8
  Enabled: yes
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,9 @@
1
+ # Contributing to lenjador
2
+
3
+ We currently do not accept any contributions from external sources.
4
+
5
+ The code is still open source and if you wish to add any changes, feel free to fork it and add changes to your fork.
6
+
7
+ Issues for any security-related bugs found are still welcome, but we offer no guarantees on whether or when they will be acted upon.
8
+
9
+ For any exceptional cases, please contact us at open-source@glia.com.
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lenjador (2.2.2)
5
+ lru_redux
6
+ oj (~> 3.6)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ benchmark-ips (2.8.4)
13
+ coderay (1.1.3)
14
+ diff-lcs (1.4.4)
15
+ lru_redux (1.1.0)
16
+ method_source (1.0.0)
17
+ oj (3.11.5)
18
+ opentelemetry-api (0.17.0)
19
+ parallel (1.20.1)
20
+ parser (3.0.1.1)
21
+ ast (~> 2.4.1)
22
+ pry (0.14.1)
23
+ coderay (~> 1.1)
24
+ method_source (~> 1.0)
25
+ rainbow (3.0.0)
26
+ rake (13.0.3)
27
+ regexp_parser (2.1.1)
28
+ rexml (3.2.5)
29
+ rspec (3.10.0)
30
+ rspec-core (~> 3.10.0)
31
+ rspec-expectations (~> 3.10.0)
32
+ rspec-mocks (~> 3.10.0)
33
+ rspec-core (3.10.1)
34
+ rspec-support (~> 3.10.0)
35
+ rspec-expectations (3.10.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.10.0)
38
+ rspec-mocks (3.10.2)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.10.0)
41
+ rspec-support (3.10.2)
42
+ rubocop (0.93.1)
43
+ parallel (~> 1.10)
44
+ parser (>= 2.7.1.5)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8)
47
+ rexml
48
+ rubocop-ast (>= 0.6.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 1.4.0, < 2.0)
51
+ rubocop-ast (1.5.0)
52
+ parser (>= 3.0.1.1)
53
+ rubocop-rspec (1.44.1)
54
+ rubocop (~> 0.87)
55
+ rubocop-ast (>= 0.7.1)
56
+ rubocop-salemove (0.0.5)
57
+ rubocop (~> 0.82)
58
+ rubocop-rspec (~> 1.15)
59
+ ruby-prof (1.4.3)
60
+ ruby-progressbar (1.11.0)
61
+ unicode-display_width (1.7.0)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ benchmark-ips
68
+ bundler
69
+ lenjador!
70
+ opentelemetry-api
71
+ pry
72
+ rake
73
+ rspec
74
+ rubocop-salemove
75
+ ruby-prof
76
+
77
+ BUNDLED WITH
78
+ 2.1.4
data/README.md CHANGED
@@ -119,3 +119,7 @@ Logger output:
119
119
  ```
120
120
  Received request {password: "********", "info": {"phone": "+12055555555"}, "addresses": [{"host": "example.com","path": "****"}]}
121
121
  ```
122
+
123
+ ## Releasing a new version
124
+
125
+ A new version is created when a change is merged into the master branch that changes the version number in `lenjador.gemspec`. A Github Action will create a tag for the version and push the `.gem` file to [rubygems.org](https://rubygems.org)
data/lenjador.gemspec CHANGED
@@ -5,13 +5,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = 'lenjador'
8
- gem.version = '2.2.0'
8
+ gem.version = '2.2.2'
9
9
  gem.authors = ['Salemove']
10
10
  gem.email = ['support@salemove.com']
11
11
  gem.description = "It's lenjadoric"
12
12
  gem.summary = 'What description said'
13
13
  gem.license = 'MIT'
14
- gem.required_ruby_version = '>= 2.4'
14
+ gem.required_ruby_version = '>= 2.6'
15
15
 
16
16
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -21,8 +21,11 @@ class Lenjador
21
21
  when Array
22
22
  process_array(data, pointer)
23
23
 
24
- else
24
+ when String, Numeric, Symbol, Date, Time, TrueClass, FalseClass, NilClass
25
25
  data
26
+
27
+ else
28
+ MASKED_VALUE
26
29
  end
27
30
  end
28
31
 
@@ -18,8 +18,11 @@ class Lenjador
18
18
  when Array
19
19
  process_array(data, pointer)
20
20
 
21
- else
21
+ when String, Numeric, Symbol, Date, Time, TrueClass, FalseClass, NilClass
22
22
  data
23
+
24
+ else
25
+ nil
23
26
  end
24
27
  end
25
28
 
@@ -7,7 +7,7 @@ require 'lenjador/preprocessors/strategies/prune'
7
7
  class Lenjador
8
8
  module Preprocessors
9
9
  class Whitelist
10
- DEFAULT_WHITELIST = %w[/id /message /correlation_id /queue].freeze
10
+ DEFAULT_WHITELIST = %w[/id /message /correlation_id /queue /trace_id /span_id].freeze
11
11
  MASK_SYMBOL = '*'
12
12
  MASKED_VALUE = MASK_SYMBOL * 5
13
13
 
@@ -147,10 +147,105 @@ RSpec.describe Lenjador::Preprocessors::Whitelist do
147
147
  end
148
148
 
149
149
  context 'when boolean present' do
150
- let(:data) { {bool: true} }
150
+ let(:pointers) { ['/bool'] }
151
+ let(:data) do
152
+ {
153
+ bool: true,
154
+ bool2: true
155
+ }
156
+ end
157
+
158
+ it 'masks only if not in whitelist' do
159
+ expect(processed_data).to eq({
160
+ bool: true,
161
+ bool2: '*****'
162
+ })
163
+ end
164
+ end
165
+
166
+ context 'when nil present' do
167
+ let(:pointers) { ['/nil'] }
168
+ let(:data) do
169
+ {
170
+ nil: nil,
171
+ nil2: nil
172
+ }
173
+ end
151
174
 
152
- it 'masks it with asteriks' do
153
- expect(processed_data).to eq(bool: '*****')
175
+ it 'masks only if not in whitelist' do
176
+ expect(processed_data).to eq({
177
+ nil: nil,
178
+ nil2: '*****'
179
+ })
180
+ end
181
+ end
182
+
183
+ context 'when numbers present' do
184
+ let(:data) do
185
+ {
186
+ integer: 1,
187
+ float: 2.03,
188
+ integer2: 3,
189
+ float2: 3.34324
190
+ }
191
+ end
192
+ let(:pointers) { ['/integer', '/float'] }
193
+
194
+ it 'masks only if not in whitelist' do
195
+ expect(processed_data).to eq({
196
+ integer: 1,
197
+ float: 2.03,
198
+ integer2: '*****',
199
+ float2: '*****'
200
+ })
201
+ end
202
+ end
203
+
204
+ context 'when symbol present' do
205
+ let(:data) do
206
+ {
207
+ symbol1: :symbol1,
208
+ symbol2: :symbol2
209
+ }
210
+ end
211
+ let(:pointers) { ['/symbol1'] }
212
+
213
+ it 'masks only if not in whitelist' do
214
+ expect(processed_data).to eq({
215
+ symbol1: :symbol1,
216
+ symbol2: '*****'
217
+ })
218
+ end
219
+ end
220
+
221
+ context 'when date time present' do
222
+ let(:data) do
223
+ {
224
+ date: Date.new(2023, 12, 12),
225
+ time: Time.new(2023, 12, 13),
226
+ datetime: DateTime.new(2023, 12, 14)
227
+ }
228
+ end
229
+ let(:pointers) { ['/date', '/time', '/datetime'] }
230
+
231
+ it 'shows dates' do
232
+ expect(processed_data).to eq({
233
+ date: Date.new(2023, 12, 12),
234
+ time: Time.new(2023, 12, 13),
235
+ datetime: DateTime.new(2023, 12, 14)
236
+ })
237
+ end
238
+ end
239
+
240
+ context 'when unsupported object present' do
241
+ let(:pointers) { ['/field'] }
242
+ let(:some_class) { OpenStruct.new(name: 'Rowdy', pin_code: '1234') }
243
+ let(:data) { {field: some_class} }
244
+
245
+ it 'masks the object' do
246
+ expect(processed_data).to eq(
247
+ field: '*****'
248
+ )
154
249
  end
155
250
  end
156
251
 
@@ -312,6 +407,103 @@ RSpec.describe Lenjador::Preprocessors::Whitelist do
312
407
  end
313
408
  end
314
409
 
410
+ context 'when boolean present' do
411
+ let(:pointers) { ['/bool'] }
412
+ let(:data) do
413
+ {
414
+ bool: true,
415
+ bool2: true
416
+ }
417
+ end
418
+
419
+ it 'prunes only if not in whitelist' do
420
+ expect(processed_data).to eq({
421
+ bool: true
422
+ })
423
+ end
424
+ end
425
+
426
+ context 'when nil present' do
427
+ let(:pointers) { ['/nil'] }
428
+ let(:data) do
429
+ {
430
+ nil: nil,
431
+ nil2: nil
432
+ }
433
+ end
434
+
435
+ it 'prunes only if not in whitelist' do
436
+ expect(processed_data).to eq({
437
+ nil: nil
438
+ })
439
+ end
440
+ end
441
+
442
+ context 'when numbers present' do
443
+ let(:data) do
444
+ {
445
+ integer: 1,
446
+ float: 2.03,
447
+ integer2: 3,
448
+ float2: 3.34324
449
+ }
450
+ end
451
+ let(:pointers) { ['/integer', '/float'] }
452
+
453
+ it 'prunes only if not in whitelist' do
454
+ expect(processed_data).to eq({
455
+ integer: 1,
456
+ float: 2.03
457
+ })
458
+ end
459
+ end
460
+
461
+ context 'when symbol present' do
462
+ let(:data) do
463
+ {
464
+ symbol1: :symbol1,
465
+ symbol2: :symbol2
466
+ }
467
+ end
468
+ let(:pointers) { ['/symbol1'] }
469
+
470
+ it 'prunes only if not in whitelist' do
471
+ expect(processed_data).to eq({
472
+ symbol1: :symbol1
473
+ })
474
+ end
475
+ end
476
+
477
+ context 'when date time present' do
478
+ let(:data) do
479
+ {
480
+ date: Date.new(2023, 12, 12),
481
+ time: Time.new(2023, 12, 13),
482
+ datetime: DateTime.new(2023, 12, 14)
483
+ }
484
+ end
485
+ let(:pointers) { ['/date', '/time', '/datetime'] }
486
+
487
+ it 'shows dates' do
488
+ expect(processed_data).to eq({
489
+ date: Date.new(2023, 12, 12),
490
+ time: Time.new(2023, 12, 13),
491
+ datetime: DateTime.new(2023, 12, 14)
492
+ })
493
+ end
494
+ end
495
+
496
+ context 'when unsupported object present' do
497
+ let(:pointers) { ['/class'] }
498
+ let(:some_class) { OpenStruct.new(name: 'Rowdy', pin_code: '1234') }
499
+
500
+ let(:data) { {class: some_class} }
501
+
502
+ it 'does not return the object' do
503
+ expect(processed_data).to eq({class: nil})
504
+ end
505
+ end
506
+
315
507
  def process(pointers, data)
316
508
  described_class.new(pointers: pointers, action: :prune).process(data)
317
509
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lenjador
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salemove
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-17 00:00:00.000000000 Z
11
+ date: 2023-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lru_redux
@@ -157,13 +157,16 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
+ - ".github/workflows/ci.yml"
161
+ - ".github/workflows/publish.yml"
160
162
  - ".gitignore"
161
163
  - ".rspec"
162
164
  - ".rubocop.yml"
163
165
  - ".ruby-gemset"
164
166
  - ".ruby-version"
165
- - ".travis.yml"
167
+ - CONTRIBUTING.md
166
168
  - Gemfile
169
+ - Gemfile.lock
167
170
  - README.md
168
171
  - Rakefile
169
172
  - benchmark/whitelisting.rb
@@ -202,14 +205,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
205
  requirements:
203
206
  - - ">="
204
207
  - !ruby/object:Gem::Version
205
- version: '2.4'
208
+ version: '2.6'
206
209
  required_rubygems_version: !ruby/object:Gem::Requirement
207
210
  requirements:
208
211
  - - ">="
209
212
  - !ruby/object:Gem::Version
210
213
  version: '0'
211
214
  requirements: []
212
- rubygems_version: 3.1.2
215
+ rubygems_version: 3.1.6
213
216
  signing_key:
214
217
  specification_version: 4
215
218
  summary: What description said
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4
4
- - 2.5
5
- - 2.7