chihiro 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +150 -0
- data/chihiro.gemspec +1 -0
- data/lib/chihiro/mask_util.rb +42 -0
- data/lib/chihiro/version.rb +1 -1
- data/lib/chihiro.rb +1 -0
- data/pkg/chihiro-0.2.0.gem +0 -0
- data/spec/chihiro_spec.rb +0 -4
- data/spec/mask_util_spec.rb +40 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a171735af43b81a0c8d21746123f5bb98c41e241d3748e012a9aeab3018068e9
|
4
|
+
data.tar.gz: '09c1352e1f1642efcf7b35a8975ee82ba504618445ed60dce14f0ca17864f621'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa53981aea6d8bca984dcfaa60c4099d5a26b29353b068b5b0f51f9baa9a83a9578b366ec9e19294d24f382d3b8f5f6ce1b5581965367aa58df6b65ef1c20f69
|
7
|
+
data.tar.gz: f043162312c5821530afa96650b0a1f8c23d9970aa536173bd6b39a515300fed65000821ab3a53f2c870a019f6c00728555f20648a911d7fdf366525642f44eb
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
chihiro (0.2.0)
|
5
|
+
lograge (~> 0.10)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (5.2.0)
|
11
|
+
actionpack (= 5.2.0)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailer (5.2.0)
|
15
|
+
actionpack (= 5.2.0)
|
16
|
+
actionview (= 5.2.0)
|
17
|
+
activejob (= 5.2.0)
|
18
|
+
mail (~> 2.5, >= 2.5.4)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
actionpack (5.2.0)
|
21
|
+
actionview (= 5.2.0)
|
22
|
+
activesupport (= 5.2.0)
|
23
|
+
rack (~> 2.0)
|
24
|
+
rack-test (>= 0.6.3)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
+
actionview (5.2.0)
|
28
|
+
activesupport (= 5.2.0)
|
29
|
+
builder (~> 3.1)
|
30
|
+
erubi (~> 1.4)
|
31
|
+
rails-dom-testing (~> 2.0)
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
+
activejob (5.2.0)
|
34
|
+
activesupport (= 5.2.0)
|
35
|
+
globalid (>= 0.3.6)
|
36
|
+
activemodel (5.2.0)
|
37
|
+
activesupport (= 5.2.0)
|
38
|
+
activerecord (5.2.0)
|
39
|
+
activemodel (= 5.2.0)
|
40
|
+
activesupport (= 5.2.0)
|
41
|
+
arel (>= 9.0)
|
42
|
+
activestorage (5.2.0)
|
43
|
+
actionpack (= 5.2.0)
|
44
|
+
activerecord (= 5.2.0)
|
45
|
+
marcel (~> 0.3.1)
|
46
|
+
activesupport (5.2.0)
|
47
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
48
|
+
i18n (>= 0.7, < 2)
|
49
|
+
minitest (~> 5.1)
|
50
|
+
tzinfo (~> 1.1)
|
51
|
+
arel (9.0.0)
|
52
|
+
builder (3.2.3)
|
53
|
+
concurrent-ruby (1.0.5)
|
54
|
+
crass (1.0.4)
|
55
|
+
diff-lcs (1.3)
|
56
|
+
erubi (1.7.1)
|
57
|
+
globalid (0.4.1)
|
58
|
+
activesupport (>= 4.2.0)
|
59
|
+
i18n (1.0.1)
|
60
|
+
concurrent-ruby (~> 1.0)
|
61
|
+
lograge (0.10.0)
|
62
|
+
actionpack (>= 4)
|
63
|
+
activesupport (>= 4)
|
64
|
+
railties (>= 4)
|
65
|
+
request_store (~> 1.0)
|
66
|
+
loofah (2.2.2)
|
67
|
+
crass (~> 1.0.2)
|
68
|
+
nokogiri (>= 1.5.9)
|
69
|
+
mail (2.7.0)
|
70
|
+
mini_mime (>= 0.1.1)
|
71
|
+
marcel (0.3.2)
|
72
|
+
mimemagic (~> 0.3.2)
|
73
|
+
method_source (0.9.0)
|
74
|
+
mimemagic (0.3.2)
|
75
|
+
mini_mime (1.0.0)
|
76
|
+
mini_portile2 (2.3.0)
|
77
|
+
minitest (5.11.3)
|
78
|
+
nio4r (2.3.1)
|
79
|
+
nokogiri (1.8.4)
|
80
|
+
mini_portile2 (~> 2.3.0)
|
81
|
+
rack (2.0.5)
|
82
|
+
rack-test (1.0.0)
|
83
|
+
rack (>= 1.0, < 3)
|
84
|
+
rails (5.2.0)
|
85
|
+
actioncable (= 5.2.0)
|
86
|
+
actionmailer (= 5.2.0)
|
87
|
+
actionpack (= 5.2.0)
|
88
|
+
actionview (= 5.2.0)
|
89
|
+
activejob (= 5.2.0)
|
90
|
+
activemodel (= 5.2.0)
|
91
|
+
activerecord (= 5.2.0)
|
92
|
+
activestorage (= 5.2.0)
|
93
|
+
activesupport (= 5.2.0)
|
94
|
+
bundler (>= 1.3.0)
|
95
|
+
railties (= 5.2.0)
|
96
|
+
sprockets-rails (>= 2.0.0)
|
97
|
+
rails-dom-testing (2.0.3)
|
98
|
+
activesupport (>= 4.2.0)
|
99
|
+
nokogiri (>= 1.6)
|
100
|
+
rails-html-sanitizer (1.0.4)
|
101
|
+
loofah (~> 2.2, >= 2.2.2)
|
102
|
+
railties (5.2.0)
|
103
|
+
actionpack (= 5.2.0)
|
104
|
+
activesupport (= 5.2.0)
|
105
|
+
method_source
|
106
|
+
rake (>= 0.8.7)
|
107
|
+
thor (>= 0.18.1, < 2.0)
|
108
|
+
rake (10.5.0)
|
109
|
+
request_store (1.4.1)
|
110
|
+
rack (>= 1.4)
|
111
|
+
rspec (3.7.0)
|
112
|
+
rspec-core (~> 3.7.0)
|
113
|
+
rspec-expectations (~> 3.7.0)
|
114
|
+
rspec-mocks (~> 3.7.0)
|
115
|
+
rspec-core (3.7.1)
|
116
|
+
rspec-support (~> 3.7.0)
|
117
|
+
rspec-expectations (3.7.0)
|
118
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
119
|
+
rspec-support (~> 3.7.0)
|
120
|
+
rspec-mocks (3.7.0)
|
121
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
122
|
+
rspec-support (~> 3.7.0)
|
123
|
+
rspec-support (3.7.1)
|
124
|
+
sprockets (3.7.2)
|
125
|
+
concurrent-ruby (~> 1.0)
|
126
|
+
rack (> 1, < 3)
|
127
|
+
sprockets-rails (3.2.1)
|
128
|
+
actionpack (>= 4.0)
|
129
|
+
activesupport (>= 4.0)
|
130
|
+
sprockets (>= 3.0.0)
|
131
|
+
thor (0.20.0)
|
132
|
+
thread_safe (0.3.6)
|
133
|
+
tzinfo (1.2.5)
|
134
|
+
thread_safe (~> 0.1)
|
135
|
+
websocket-driver (0.7.0)
|
136
|
+
websocket-extensions (>= 0.1.0)
|
137
|
+
websocket-extensions (0.1.3)
|
138
|
+
|
139
|
+
PLATFORMS
|
140
|
+
ruby
|
141
|
+
|
142
|
+
DEPENDENCIES
|
143
|
+
bundler (~> 1.16)
|
144
|
+
chihiro!
|
145
|
+
rails (~> 5.1)
|
146
|
+
rake (~> 10.0)
|
147
|
+
rspec (~> 3.0)
|
148
|
+
|
149
|
+
BUNDLED WITH
|
150
|
+
1.16.2
|
data/chihiro.gemspec
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Chihiro
|
4
|
+
class MaskUtil
|
5
|
+
class << self
|
6
|
+
def mask(hash)
|
7
|
+
return hash unless hash.is_a? Hash
|
8
|
+
|
9
|
+
hash.each do |key, value|
|
10
|
+
if value.is_a? Hash
|
11
|
+
hash[key] = mask(value)
|
12
|
+
else
|
13
|
+
hash[key] = mask_item(key, value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def mask_all_characters
|
21
|
+
lambda { |value| value.to_s.gsub(/./, '*') }
|
22
|
+
end
|
23
|
+
|
24
|
+
def masks
|
25
|
+
@all_masks ||= {
|
26
|
+
'password' => mask_all_characters,
|
27
|
+
'account_number' => mask_all_characters,
|
28
|
+
'token' => mask_all_characters,
|
29
|
+
'otp' => mask_all_characters,
|
30
|
+
'current_password' => mask_all_characters,
|
31
|
+
'new_password' => mask_all_characters
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def mask_item(key, origin_str)
|
36
|
+
mask_proc = masks[key.to_s]
|
37
|
+
return origin_str unless mask_proc
|
38
|
+
mask_proc.call(origin_str)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/chihiro/version.rb
CHANGED
data/lib/chihiro.rb
CHANGED
Binary file
|
data/spec/chihiro_spec.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Chihiro::MaskUtil do
|
4
|
+
describe 'mask password' do
|
5
|
+
it 'should mask password' do
|
6
|
+
msg = {
|
7
|
+
password: 'abcde',
|
8
|
+
message: 'message1'
|
9
|
+
}
|
10
|
+
masked = Chihiro::MaskUtil.mask(msg)
|
11
|
+
expect(masked).to eq({ password: '*****', message: 'message1' })
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should mask nested password' do
|
15
|
+
msg = {
|
16
|
+
password: 'abcde',
|
17
|
+
message: 'message1',
|
18
|
+
aaa: {
|
19
|
+
password: '12345',
|
20
|
+
other: 'otherMsg'
|
21
|
+
}
|
22
|
+
}
|
23
|
+
masked = Chihiro::MaskUtil.mask(msg)
|
24
|
+
expect(masked).to eq({ password: '*****',
|
25
|
+
message: 'message1',
|
26
|
+
aaa: { password: '*****', other: 'otherMsg' } })
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'mask account number' do
|
31
|
+
it 'should mask password' do
|
32
|
+
msg = {
|
33
|
+
account_number: '12345678',
|
34
|
+
message: 'message1'
|
35
|
+
}
|
36
|
+
masked = Chihiro::MaskUtil.mask(msg)
|
37
|
+
expect(masked).to eq({ account_number: '********', message: 'message1' })
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chihiro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shu Hui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lograge
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.1'
|
69
83
|
description: Change rails log to Json format
|
70
84
|
email:
|
71
85
|
- dreamlock0630@gmail.com
|
@@ -75,6 +89,7 @@ extra_rdoc_files: []
|
|
75
89
|
files:
|
76
90
|
- CODE_OF_CONDUCT.md
|
77
91
|
- Gemfile
|
92
|
+
- Gemfile.lock
|
78
93
|
- LICENSE.txt
|
79
94
|
- README.md
|
80
95
|
- Rakefile
|
@@ -84,13 +99,16 @@ files:
|
|
84
99
|
- lib/chihiro.rb
|
85
100
|
- lib/chihiro/initializer.rb
|
86
101
|
- lib/chihiro/json_log_formatter.rb
|
102
|
+
- lib/chihiro/mask_util.rb
|
87
103
|
- lib/chihiro/version.rb
|
88
104
|
- lib/generators/chihiro/init_generator.rb
|
89
105
|
- lib/generators/chihiro/templates/initializer.rb
|
90
106
|
- pkg/chihiro-0.1.10.gem
|
91
107
|
- pkg/chihiro-0.1.8.gem
|
92
108
|
- pkg/chihiro-0.1.9.gem
|
109
|
+
- pkg/chihiro-0.2.0.gem
|
93
110
|
- spec/chihiro_spec.rb
|
111
|
+
- spec/mask_util_spec.rb
|
94
112
|
- spec/spec_helper.rb
|
95
113
|
homepage: https://github.com/blockchaintech-au/chihiro
|
96
114
|
licenses:
|