startback 1.0.0 → 1.0.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: 85db266a4c72694e948fc85a4bd7e4923f0ecce7afeb9976a1d6033d120a8191
4
- data.tar.gz: fb68dc41bc6acc1bd6dda521146d5f0f444f81c6824137d64dd1393d78db0199
3
+ metadata.gz: 7c8384cd6e24cd8fd0c1c6ac4b2361e6d96e36267fda450ba0628f3c58674106
4
+ data.tar.gz: e70ab5bd8c0fcb84edb6e4abd510cd88493df60b6c3faf595e015e047c2f5864
5
5
  SHA512:
6
- metadata.gz: a56a2fc06d115226421684fc78441ee22b111fd3fd8a2d1ab18cf5a44ab5f699df7b43e5eebb6be2ac5e968c157f4c6c20e1e74f5b44faabc7130965099c9c59
7
- data.tar.gz: 0c75bea563030c189613f45d29f61fed3869777f4987f8e6bc6af1b169fbf3184e4f561d2c655d3efdadfd250cfe44d397cff03d40e8048c6f80a0d597a31d5a
6
+ metadata.gz: e2f8f4bd5413b19f1cc7abc8930f917ee32cdfc6cb491003b6cbbaa2623fa88ac333bffad08e618f7bcf8ff67948d8fd84cc0232dd6632b0b68a41525d85bea4
7
+ data.tar.gz: abe4b7dc61b8c21d8ad45aa7d493ff9c6c867534af7bba41786c374728465272a91fc99628659df79712f3441e8e729e8aa50f7bd2c31acd6f584685f2772937
@@ -58,7 +58,7 @@ module Startback
58
58
  end
59
59
 
60
60
  def connect
61
- log(:info, self, "Connecting to the bus now!")
61
+ log(:debug, "Connecting to the bus now!", self)
62
62
  bus.connect
63
63
  end
64
64
 
@@ -6,9 +6,10 @@ module Startback
6
6
  pretty_print: nil
7
7
  }
8
8
 
9
- def initialize(options = {})
9
+ def initialize(options = {}, redactor = default_redactor)
10
10
  @options = DEFAULT_OPTIONS.merge(options)
11
11
  @options[:pretty_print] = auto_pretty_print unless @options.has_key?(:pretty_print)
12
+ @redactor = redactor
12
13
  end
13
14
 
14
15
  def pretty_print?
@@ -24,6 +25,7 @@ module Startback
24
25
  }.merge(msg)
25
26
  .merge(error: error_to_json(msg[:error], severity))
26
27
  .compact
28
+ data = @redactor.redact(data)
27
29
  if pretty_print?
28
30
  JSON.pretty_generate(data) << "\n"
29
31
  else
@@ -48,6 +50,10 @@ module Startback
48
50
 
49
51
  private
50
52
 
53
+ def default_redactor
54
+ Support::Redactor.new
55
+ end
56
+
51
57
  def auto_pretty_print
52
58
  development?
53
59
  end
@@ -21,6 +21,8 @@ module Startback
21
21
  }]
22
22
  when Enumerable
23
23
  data.map{|elm| redact(elm) }.compact
24
+ when /:\/\//
25
+ data.gsub(/:\/\/([^@]+[@])/){|m| "://--redacted--@" }
24
26
  else
25
27
  data
26
28
  end
@@ -2,7 +2,7 @@ module Startback
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 0
5
+ TINY = 1
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -79,6 +79,17 @@ module Startback
79
79
  })
80
80
  end
81
81
 
82
+ it 'redacts urls as expected' do
83
+ r = Redactor.new
84
+ expect(r.redact('hello')).to eql('hello')
85
+ expect(r.redact('http://google.com')).to eql('http://google.com')
86
+ expect(r.redact('http://google.com/a/path')).to eql('http://google.com/a/path')
87
+ expect(r.redact('http://user@google.com')).to eql('http://--redacted--@google.com')
88
+ expect(r.redact('http://user@google.com/a/path')).to eql('http://--redacted--@google.com/a/path')
89
+ expect(r.redact('http://user:password@google.com')).to eql('http://--redacted--@google.com')
90
+ expect(r.redact('http://user:password@google.com/a/path')).to eql('http://--redacted--@google.com/a/path')
91
+ end
92
+
82
93
  end # class Redactor
83
94
  end # module Support
84
95
  end # module Startback
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startback
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-23 00:00:00.000000000 Z
11
+ date: 2023-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec