fluent-plugin-masking 1.1.0 → 1.3.0
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 +4 -4
- data/.circleci/config.yml +29 -0
- data/.gitignore +3 -1
- data/README.md +22 -9
- data/fluent-plugin-masking.gemspec +1 -3
- data/lib/fluent/plugin/filter_masking.rb +40 -10
- data/lib/fluent/plugin/helpers.rb +17 -0
- data/lib/fluent/plugin/version.rb +2 -2
- data/test/fields-to-mask +2 -1
- data/test/fields-to-mask-insensitive +5 -0
- data/test/test_filter_masking.rb +95 -4
- data/test/test_helpers.rb +42 -0
- metadata +12 -37
- data/.travis.yml +0 -14
- data/Gemfile.lock +0 -55
- data/Rakefile +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8c2ddb483a737dd913e64111218e9484bffb2d94db68c8aefb49ec4efdcfd58
|
4
|
+
data.tar.gz: 3080f077ae6d4437fc3921d34b642d77ffb57e1d4498d6b3028882d3a97a94a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53514f891096b90ce5c8b1957b248ebaf27f6ad25bf6176ac10fcc873e9bd471995c8157deeae57fb9af78487a0018562a973627129d14c6d9a3eabaab2c0d9b
|
7
|
+
data.tar.gz: ca252648f6799d83a5ca72796452ac2a165527275d8387c6cc051a3341381e177d94bb7ab07bef3254016cd4bd7124ec3691b593608d7802acce23eee9cb4eac
|
@@ -0,0 +1,29 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.1.2
|
4
|
+
|
5
|
+
executors:
|
6
|
+
v2-5-0:
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:2.5.0
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
tests:
|
12
|
+
parameters:
|
13
|
+
ruby-version:
|
14
|
+
type: executor
|
15
|
+
executor: << parameters.ruby-version >>
|
16
|
+
steps:
|
17
|
+
- checkout
|
18
|
+
- run: gem install bundler
|
19
|
+
- run: bundle install
|
20
|
+
- run: ruby -r ./test/*.rb
|
21
|
+
|
22
|
+
workflows:
|
23
|
+
tests:
|
24
|
+
jobs:
|
25
|
+
- tests:
|
26
|
+
matrix:
|
27
|
+
parameters:
|
28
|
+
ruby-version: [v2-5-0]
|
29
|
+
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -8,26 +8,30 @@ Fluentd filter plugin to mask sensitive or privacy records with `*******` in pla
|
|
8
8
|
## Requirements
|
9
9
|
| fluent-plugin-masking | fluentd | ruby |
|
10
10
|
| --------------------- | ---------- | ------ |
|
11
|
-
| 1.
|
11
|
+
| 1.2.x | >= v0.14.0 | >= 2.5 |
|
12
12
|
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
Install with gem:
|
16
16
|
|
17
|
-
`gem install fluent-plugin-masking`
|
17
|
+
`fluent-gem install fluent-plugin-masking`
|
18
18
|
|
19
19
|
## Setup
|
20
|
-
In order to setup this plugin, the parameter `fieldsToMaskFilePath` needs to be a valid path to a file containing a list of all the fields to mask. The file should have a unique field on each line. These fields **are** case-sensitive (`Name` != `name`).
|
20
|
+
In order to setup this plugin, the parameter `fieldsToMaskFilePath` needs to be a valid path to a file containing a list of all the fields to mask. The file should have a unique field on each line. These fields **are** case-sensitive (`Name` != `name`). if you one or more of the fields will be case insensitive, use the `/i` suffix in your field. see example below.
|
21
21
|
|
22
|
-
|
23
|
-
The JSON fields that are excluded are comma separated.
|
24
|
-
This can be used for logs of registration services or audit log entries which do not need to be masked.
|
25
|
-
|
22
|
+
### Optional configuration
|
23
|
+
- `fieldsToExcludeJSONPaths` - this field receives as input a comma separated string of JSON fields that should be excluded in the masking procedure. Nested JSON fields are supported by `dot notation` (i.e: `path.to.excluded.field.in.record.nestedExcludedField`) The JSON fields that are excluded are comma separated.
|
24
|
+
This can be used for logs of registration services or audit log entries which do not need to be masked.
|
25
|
+
|
26
|
+
- `handleSpecialEscapedJsonCases` - a boolean value that try to fix special escaped json cases. this feature is currently on alpha stage (default: false). for more details about thoose special cases see [Special Json Cases](#Special-escaped-json-cases-handling)
|
27
|
+
|
28
|
+
An example with optional configuration parameters:
|
26
29
|
```
|
27
30
|
<filter "**">
|
28
31
|
@type masking
|
29
32
|
fieldsToMaskFilePath "/path/to/fields-to-mask-file"
|
30
33
|
fieldsToExcludeJSONPaths "excludedField,exclude.path.nestedExcludedField"
|
34
|
+
handleSpecialEscapedJsonCases true
|
31
35
|
</filter>
|
32
36
|
```
|
33
37
|
|
@@ -35,10 +39,9 @@ Example fields-to-mask-file:
|
|
35
39
|
```
|
36
40
|
name
|
37
41
|
email
|
38
|
-
phone
|
42
|
+
phone/i # the '/i' suffix will make sure phone field will be case insensitive
|
39
43
|
```
|
40
44
|
|
41
|
-
|
42
45
|
## Quick Guide
|
43
46
|
|
44
47
|
### Configuration:
|
@@ -98,3 +101,13 @@ echo '{ :body => "{\"first_name\":\"mickey\", \"type\":\"puggle\", \"last_name\"
|
|
98
101
|
```
|
99
102
|
2019-12-01 14:25:53.385681000 +0300 maskme: {"message":"{ :body => \"{\\\"first_name\\\":\\\"mickey\\\", \\\"type\\\":\\\"puggle\\\", \\\"last_name\\\":\\\"the-dog\\\", \\\"password\\\":\\\"*******\\\"}\"}"}
|
100
103
|
```
|
104
|
+
|
105
|
+
## Run Unit Tests
|
106
|
+
```
|
107
|
+
gem install bundler
|
108
|
+
bundle install
|
109
|
+
ruby -r ./test/*.rb
|
110
|
+
```
|
111
|
+
|
112
|
+
## Special escaped json cases handling
|
113
|
+
|
@@ -18,11 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
spec.license = "Apache-2.0"
|
20
20
|
|
21
|
-
spec.required_ruby_version = '>= 2.
|
21
|
+
spec.required_ruby_version = '>= 2.5.0'
|
22
22
|
|
23
23
|
spec.add_runtime_dependency "fluentd", ">= 0.14.0"
|
24
|
-
spec.add_development_dependency "bundler"
|
25
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
26
24
|
spec.add_development_dependency "test-unit", ">= 3.1.0"
|
27
25
|
spec.add_development_dependency "test-unit-rr"
|
28
26
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'fluent/filter'
|
2
|
+
require_relative './helpers.rb'
|
2
3
|
|
3
4
|
module Fluent
|
4
5
|
module Plugin
|
5
6
|
class MaskingFilter < Filter
|
7
|
+
include Helpers
|
6
8
|
Fluent::Plugin.register_filter("masking", self) # for "@type masking" in configuration
|
7
9
|
|
8
10
|
MASK_STRING = "*******"
|
@@ -16,22 +18,32 @@ module Fluent
|
|
16
18
|
def maskRecord(record)
|
17
19
|
maskedRecord = record
|
18
20
|
excludedFields = []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
begin
|
22
|
+
@fieldsToExcludeJSONPathsArray.each do | field |
|
23
|
+
field_value = myDig(record, field)
|
24
|
+
if field_value != nil
|
25
|
+
excludedFields = excludedFields + field_value.split(',')
|
26
|
+
end
|
23
27
|
end
|
28
|
+
rescue Exception => e
|
29
|
+
$log.error "Failed to find mask exclude record: #{e}"
|
24
30
|
end
|
25
|
-
begin
|
31
|
+
begin
|
26
32
|
recordStr = record.to_s
|
33
|
+
|
34
|
+
if @handleSpecialEscapedJsonCases == true
|
35
|
+
@specialEscapedJsonRegexs.each do | regex, replace |
|
36
|
+
recordStr = recordStr.gsub(regex, replace)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
27
40
|
@fields_to_mask_regex.each do | fieldToMaskRegex, fieldToMaskRegexStringReplacement |
|
28
41
|
if !(excludedFields.include? @fields_to_mask_keys[fieldToMaskRegex])
|
29
42
|
recordStr = recordStr.gsub(fieldToMaskRegex, fieldToMaskRegexStringReplacement)
|
30
43
|
end
|
31
44
|
end
|
32
|
-
|
45
|
+
|
33
46
|
maskedRecord = strToHash(recordStr)
|
34
|
-
|
35
47
|
rescue Exception => e
|
36
48
|
$log.error "Failed to mask record: #{e}"
|
37
49
|
end
|
@@ -45,6 +57,11 @@ module Fluent
|
|
45
57
|
@fields_to_mask_regex = {}
|
46
58
|
@fields_to_mask_keys = {}
|
47
59
|
@fieldsToExcludeJSONPathsArray = []
|
60
|
+
|
61
|
+
@handleSpecialEscapedJsonCases = false
|
62
|
+
@specialEscapedJsonRegexs = {
|
63
|
+
Regexp.new(/,(( *)(\\*)("*)( *)),/m) => "\1,"
|
64
|
+
}
|
48
65
|
end
|
49
66
|
|
50
67
|
# this method only called ones (on startup time)
|
@@ -52,6 +69,7 @@ module Fluent
|
|
52
69
|
super
|
53
70
|
fieldsToMaskFilePath = conf['fieldsToMaskFilePath']
|
54
71
|
fieldsToExcludeJSONPaths = conf['fieldsToExcludeJSONPaths']
|
72
|
+
handleSpecialCases = conf['handleSpecialEscapedJsonCases']
|
55
73
|
|
56
74
|
if fieldsToExcludeJSONPaths != nil && fieldsToExcludeJSONPaths.size() > 0
|
57
75
|
fieldsToExcludeJSONPaths.split(",").each do | field |
|
@@ -67,25 +85,37 @@ module Fluent
|
|
67
85
|
|
68
86
|
File.open(fieldsToMaskFilePath, "r") do |f|
|
69
87
|
f.each_line do |line|
|
70
|
-
|
71
88
|
value = line.to_s # make sure it's string
|
72
89
|
value = value.gsub(/\s+/, "") # remove spaces
|
73
90
|
value = value.gsub('\n', '') # remove line breakers
|
74
91
|
|
92
|
+
if value.end_with? "/i"
|
93
|
+
# case insensitive
|
94
|
+
value = value.delete_suffix('/i')
|
95
|
+
hashObjectRegex = Regexp.new(/(?::#{value}=>")(.*?)(?:")/mi) # mask element in hash object
|
96
|
+
innerJSONStringRegex = Regexp.new(/(\\+)"#{value}\\+":\\+.+?((?=(})|,( *|)(\s|\\+)\")|(?=}"$))/mi) # mask element in json string using capture groups that count the level of escaping inside the json string
|
97
|
+
else
|
98
|
+
# case sensitive
|
99
|
+
hashObjectRegex = Regexp.new(/(?::#{value}=>")(.*?)(?:")/m) # mask element in hash object
|
100
|
+
innerJSONStringRegex = Regexp.new(/(\\+)"#{value}\\+":\\+.+?((?=(})|,( *|)(\s|\\+)\")|(?=}"$))/m) # mask element in json string using capture groups that count the level of escaping inside the json string
|
101
|
+
end
|
102
|
+
|
75
103
|
@fields_to_mask.push(value)
|
76
104
|
|
77
|
-
hashObjectRegex = Regexp.new(/(?::#{value}=>")(.*?)(?:")/m) # mask element in hash object
|
78
105
|
hashObjectRegexStringReplacement = ":#{value}=>\"#{MASK_STRING}\""
|
79
106
|
@fields_to_mask_regex[hashObjectRegex] = hashObjectRegexStringReplacement
|
80
107
|
@fields_to_mask_keys[hashObjectRegex] = value
|
81
108
|
|
82
|
-
innerJSONStringRegex = Regexp.new(/(\\+)"#{value}\\+":\\+.+?((?=(})|,( *|)(\s|\\+)\")|(?=}"$))/m) # mask element in json string using capture groups that count the level of escaping inside the json string
|
83
109
|
innerJSONStringRegexStringReplacement = "\\1\"#{value}\\1\":\\1\"#{MASK_STRING}\\1\""
|
84
110
|
@fields_to_mask_regex[innerJSONStringRegex] = innerJSONStringRegexStringReplacement
|
85
111
|
@fields_to_mask_keys[innerJSONStringRegex] = value
|
86
112
|
end
|
87
113
|
end
|
88
114
|
|
115
|
+
# if true, each record (a json record), will be checked for a special escaped json cases
|
116
|
+
# any found case will be 'gsub' with the right solution
|
117
|
+
@handleSpecialEscapedJsonCases = handleSpecialCases != nil && handleSpecialCases.casecmp("true") == 0
|
118
|
+
|
89
119
|
puts "black list fields:"
|
90
120
|
puts @fields_to_mask
|
91
121
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Helpers
|
2
|
+
def myDig(input, path)
|
3
|
+
curr = input
|
4
|
+
for segment in path do
|
5
|
+
if curr != nil && curr.is_a?(Hash)
|
6
|
+
if curr[segment] == nil # segment is not a symbol
|
7
|
+
curr = curr[segment.to_s] # segment as string
|
8
|
+
else
|
9
|
+
curr = curr[segment] # segment as symbol
|
10
|
+
end
|
11
|
+
else
|
12
|
+
return nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
curr
|
16
|
+
end
|
17
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module FilterMasking
|
2
|
-
VERSION = "1.
|
3
|
-
end
|
2
|
+
VERSION = "1.3.0"
|
3
|
+
end
|
data/test/fields-to-mask
CHANGED
data/test/test_filter_masking.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
|
-
# test/plugin/test_filter_your_own.rb
|
2
|
-
|
3
1
|
require "test-unit"
|
4
2
|
require "fluent/test"
|
5
3
|
require "fluent/test/driver/filter"
|
6
4
|
require "fluent/test/helpers"
|
7
5
|
require "./lib/fluent/plugin/filter_masking.rb"
|
8
6
|
|
9
|
-
|
10
7
|
MASK_STRING = "*******"
|
11
8
|
|
12
9
|
class YourOwnFilterTest < Test::Unit::TestCase
|
@@ -25,6 +22,18 @@ class YourOwnFilterTest < Test::Unit::TestCase
|
|
25
22
|
fieldsToMaskFilePath test/fields-to-mask
|
26
23
|
]
|
27
24
|
|
25
|
+
# configuration for tests with case insensitive fields
|
26
|
+
CONFIG_CASE_INSENSITIVE = %[
|
27
|
+
fieldsToMaskFilePath test/fields-to-mask-insensitive
|
28
|
+
]
|
29
|
+
|
30
|
+
# configuration for special json escaped cases
|
31
|
+
CONFIG_SPECIAL_CASES = %[
|
32
|
+
fieldsToMaskFilePath test/fields-to-mask
|
33
|
+
fieldsToExcludeJSONPaths excludedField,exclude.path.nestedExcludedField
|
34
|
+
handleSpecialEscapedJsonCases true
|
35
|
+
]
|
36
|
+
|
28
37
|
def create_driver(conf = CONFIG)
|
29
38
|
Fluent::Test::Driver::Filter.new(Fluent::Plugin::MaskingFilter).configure(conf)
|
30
39
|
end
|
@@ -39,7 +48,7 @@ class YourOwnFilterTest < Test::Unit::TestCase
|
|
39
48
|
d.filtered_records
|
40
49
|
end
|
41
50
|
|
42
|
-
sub_test_case 'plugin will mask all fields that need masking' do
|
51
|
+
sub_test_case 'plugin will mask all fields that need masking - case sensitive fields' do
|
43
52
|
test 'mask field in hash object' do
|
44
53
|
conf = CONFIG_NO_EXCLUDE
|
45
54
|
messages = [
|
@@ -99,6 +108,7 @@ class YourOwnFilterTest < Test::Unit::TestCase
|
|
99
108
|
filtered_records = filter(conf, messages)
|
100
109
|
assert_equal(expected, filtered_records)
|
101
110
|
end
|
111
|
+
|
102
112
|
test 'mask field in hash object with exclude' do
|
103
113
|
conf = CONFIG
|
104
114
|
messages = [
|
@@ -110,6 +120,7 @@ class YourOwnFilterTest < Test::Unit::TestCase
|
|
110
120
|
filtered_records = filter(conf, messages)
|
111
121
|
assert_equal(expected, filtered_records)
|
112
122
|
end
|
123
|
+
|
113
124
|
test 'mask field in hash object with nested exclude' do
|
114
125
|
conf = CONFIG
|
115
126
|
messages = [
|
@@ -121,6 +132,7 @@ class YourOwnFilterTest < Test::Unit::TestCase
|
|
121
132
|
filtered_records = filter(conf, messages)
|
122
133
|
assert_equal(expected, filtered_records)
|
123
134
|
end
|
135
|
+
|
124
136
|
test 'mask field in hash object with base and nested exclude' do
|
125
137
|
conf = CONFIG
|
126
138
|
messages = [
|
@@ -132,5 +144,84 @@ class YourOwnFilterTest < Test::Unit::TestCase
|
|
132
144
|
filtered_records = filter(conf, messages)
|
133
145
|
assert_equal(expected, filtered_records)
|
134
146
|
end
|
147
|
+
|
148
|
+
test 'mask field in json string with exclude' do
|
149
|
+
conf = CONFIG
|
150
|
+
messages = [
|
151
|
+
{ :body => "{\"first_name\":\"mickey\",\"last_name\":\"the-dog\", \"type\":\"puggle\"}", :excludedField=>"first_name" }
|
152
|
+
]
|
153
|
+
expected = [
|
154
|
+
{ :body => "{\"first_name\":\"mickey\",\"last_name\":\"*******\", \"type\":\"puggle\"}", :excludedField=>"first_name" }
|
155
|
+
]
|
156
|
+
filtered_records = filter(conf, messages)
|
157
|
+
assert_equal(expected, filtered_records)
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
sub_test_case 'plugin will mask all fields that need masking - case INSENSITIVE fields' do
|
163
|
+
|
164
|
+
test 'mask field in hash object with camel case' do
|
165
|
+
conf = CONFIG_CASE_INSENSITIVE
|
166
|
+
messages = [
|
167
|
+
{:not_masked_field=>"mickey-the-dog", :Email=>"mickey-the-dog@zooz.com"}
|
168
|
+
]
|
169
|
+
expected = [
|
170
|
+
{:not_masked_field=>"mickey-the-dog", :email=>MASK_STRING}
|
171
|
+
]
|
172
|
+
filtered_records = filter(conf, messages)
|
173
|
+
assert_equal(expected, filtered_records)
|
174
|
+
end
|
175
|
+
|
176
|
+
test 'not mask field in hash object since case not match' do
|
177
|
+
conf = CONFIG_CASE_INSENSITIVE
|
178
|
+
messages = [
|
179
|
+
{:not_masked_field=>"mickey-the-dog", :FIRST_NAME=>"mickey-the-dog@zooz.com"}
|
180
|
+
]
|
181
|
+
expected = [
|
182
|
+
{:not_masked_field=>"mickey-the-dog", :FIRST_NAME=>"mickey-the-dog@zooz.com"}
|
183
|
+
]
|
184
|
+
filtered_records = filter(conf, messages)
|
185
|
+
assert_equal(expected, filtered_records)
|
186
|
+
end
|
187
|
+
|
188
|
+
test 'mask field in hash object with snakecase' do
|
189
|
+
conf = CONFIG_CASE_INSENSITIVE
|
190
|
+
messages = [
|
191
|
+
{:not_masked_field=>"mickey-the-dog", :LaSt_NaMe=>"mickey-the-dog@zooz.com"}
|
192
|
+
]
|
193
|
+
expected = [
|
194
|
+
{:not_masked_field=>"mickey-the-dog", :last_name=>MASK_STRING}
|
195
|
+
]
|
196
|
+
filtered_records = filter(conf, messages)
|
197
|
+
assert_equal(expected, filtered_records)
|
198
|
+
end
|
199
|
+
|
200
|
+
test 'mask case insensitive and case sensitive field in nested json escaped string' do
|
201
|
+
conf = CONFIG_CASE_INSENSITIVE
|
202
|
+
messages = [
|
203
|
+
{ :body => "{\"firsT_naMe\":\"mickey\",\"last_NAME\":\"the-dog\",\"address\":\"{\\\"Street\":\\\"Austin\\\",\\\"number\":\\\"89\\\"}\", \"type\":\"puggle\"}" }
|
204
|
+
]
|
205
|
+
expected = [
|
206
|
+
{ :body => "{\"firsT_naMe\":\"mickey\",\"last_name\":\"*******\",\"address\":\"{\\\"street\\\":\\\"*******\\\",\\\"number\\\":\\\"*******\\\"}\", \"type\":\"puggle\"}" }
|
207
|
+
]
|
208
|
+
filtered_records = filter(conf, messages)
|
209
|
+
assert_equal(expected, filtered_records)
|
210
|
+
end
|
211
|
+
|
135
212
|
end
|
213
|
+
|
214
|
+
sub_test_case 'plugin will mask all fields that need masking - special json escaped cases' do
|
215
|
+
test 'mask field in nested json escaped string when one of the values ends with "," (the value for "some_custom" field)' do
|
216
|
+
conf = CONFIG_SPECIAL_CASES
|
217
|
+
messages = [
|
218
|
+
{ :body => "{\"first_name\":\"mickey\",\"last_name\":\"the-dog\",\"address\":\"{\\\"street\":\\\"Austin\\\",\\\"number\":\\\"89\\\"}\", \"type\":\"puggle\", \"cookie\":\"some_custom=,,live,default,,2097403972,2.22.242.38,\", \"city\":\"new york\"}" }
|
219
|
+
]
|
220
|
+
expected = [
|
221
|
+
{ :body => "{\"first_name\":\"*******\",\"last_name\":\"*******\",\"address\":\"{\\\"street\\\":\\\"*******\\\",\\\"number\\\":\\\"*******\\\"}\", \"type\":\"puggle\", \"cookie\":\"*******\", \"city\":\"new york\"}" }
|
222
|
+
]
|
223
|
+
filtered_records = filter(conf, messages)
|
224
|
+
assert_equal(expected, filtered_records)
|
225
|
+
end
|
226
|
+
end
|
136
227
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "./lib/fluent/plugin/helpers.rb"
|
3
|
+
|
4
|
+
class HelpersTest < Test::Unit::TestCase
|
5
|
+
m = Class.new do
|
6
|
+
include Helpers
|
7
|
+
end.new
|
8
|
+
sub_test_case "myDig function" do
|
9
|
+
test "Call function with nil" do
|
10
|
+
t = m.myDig(nil ,[:a])
|
11
|
+
assert_equal(t, nil)
|
12
|
+
end
|
13
|
+
test "Not found" do
|
14
|
+
t = m.myDig({:b => "t"},[:a])
|
15
|
+
assert_equal(t, nil)
|
16
|
+
end
|
17
|
+
test "Found symbol" do
|
18
|
+
t = m.myDig({:a => "t"},[:a])
|
19
|
+
assert_equal(t, "t")
|
20
|
+
end
|
21
|
+
test "Found string when given symbol" do
|
22
|
+
t = m.myDig({"a" => "t"},[:a])
|
23
|
+
assert_equal(t, "t")
|
24
|
+
end
|
25
|
+
test "Found symbol nested" do
|
26
|
+
t = m.myDig({:a => {:b => "t"}},[:a, :b])
|
27
|
+
assert_equal(t, "t")
|
28
|
+
end
|
29
|
+
test "Found string when given symbol nested" do
|
30
|
+
t = m.myDig({"a" => {"b" => "t"}},[:a, :b])
|
31
|
+
assert_equal(t, "t")
|
32
|
+
end
|
33
|
+
test "Found hybrid string/symbol when given symbol nested" do
|
34
|
+
t = m.myDig({"a" => {:b => "t"}},[:a, :b])
|
35
|
+
assert_equal(t, "t")
|
36
|
+
end
|
37
|
+
test "Does not dig in string" do
|
38
|
+
t = m.myDig({"a" => {:b => "t"}},[:a, :b, :c])
|
39
|
+
assert_equal(t, nil)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-masking
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shai Moria
|
8
8
|
- Niv Lipetz
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -25,34 +25,6 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.14.0
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: bundler
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: rake
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '12.0'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "~>"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '12.0'
|
56
28
|
- !ruby/object:Gem::Dependency
|
57
29
|
name: test-unit
|
58
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,22 +61,23 @@ executables: []
|
|
89
61
|
extensions: []
|
90
62
|
extra_rdoc_files: []
|
91
63
|
files:
|
64
|
+
- ".circleci/config.yml"
|
92
65
|
- ".gitignore"
|
93
|
-
- ".travis.yml"
|
94
66
|
- Gemfile
|
95
|
-
- Gemfile.lock
|
96
67
|
- README.md
|
97
|
-
- Rakefile
|
98
68
|
- fluent-plugin-masking.gemspec
|
99
69
|
- lib/fluent/plugin/filter_masking.rb
|
70
|
+
- lib/fluent/plugin/helpers.rb
|
100
71
|
- lib/fluent/plugin/version.rb
|
101
72
|
- test/fields-to-mask
|
73
|
+
- test/fields-to-mask-insensitive
|
102
74
|
- test/test_filter_masking.rb
|
75
|
+
- test/test_helpers.rb
|
103
76
|
homepage: https://github.com/PayU/fluent-plugin-masking
|
104
77
|
licenses:
|
105
78
|
- Apache-2.0
|
106
79
|
metadata: {}
|
107
|
-
post_install_message:
|
80
|
+
post_install_message:
|
108
81
|
rdoc_options: []
|
109
82
|
require_paths:
|
110
83
|
- lib
|
@@ -112,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
85
|
requirements:
|
113
86
|
- - ">="
|
114
87
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
88
|
+
version: 2.5.0
|
116
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
90
|
requirements:
|
118
91
|
- - ">="
|
@@ -120,11 +93,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
93
|
version: '0'
|
121
94
|
requirements: []
|
122
95
|
rubygems_version: 3.0.3
|
123
|
-
signing_key:
|
96
|
+
signing_key:
|
124
97
|
specification_version: 4
|
125
98
|
summary: Fluentd filter plugin to mask sensitive or privacy records with `*******`
|
126
99
|
in place of the original value. This data masking plugin protects data such as name,
|
127
100
|
email, phonenumber, address, and any other field you would like to mask.
|
128
101
|
test_files:
|
129
102
|
- test/fields-to-mask
|
103
|
+
- test/fields-to-mask-insensitive
|
130
104
|
- test/test_filter_masking.rb
|
105
|
+
- test/test_helpers.rb
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
fluent-plugin-masking (1.1.0)
|
5
|
-
fluentd (>= 0.14.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
concurrent-ruby (1.1.5)
|
11
|
-
cool.io (1.5.4)
|
12
|
-
dig_rb (1.0.1)
|
13
|
-
fluentd (1.7.4)
|
14
|
-
cool.io (>= 1.4.5, < 2.0.0)
|
15
|
-
dig_rb (~> 1.0.0)
|
16
|
-
http_parser.rb (>= 0.5.1, < 0.7.0)
|
17
|
-
msgpack (>= 1.2.0, < 2.0.0)
|
18
|
-
serverengine (>= 2.0.4, < 3.0.0)
|
19
|
-
sigdump (~> 0.2.2)
|
20
|
-
strptime (>= 0.2.2, < 1.0.0)
|
21
|
-
tzinfo (~> 2.0)
|
22
|
-
tzinfo-data (~> 1.0)
|
23
|
-
yajl-ruby (~> 1.0)
|
24
|
-
http_parser.rb (0.6.0)
|
25
|
-
msgpack (1.3.1)
|
26
|
-
power_assert (1.1.5)
|
27
|
-
rake (12.3.3)
|
28
|
-
rr (1.2.1)
|
29
|
-
serverengine (2.2.0)
|
30
|
-
sigdump (~> 0.2.2)
|
31
|
-
sigdump (0.2.4)
|
32
|
-
strptime (0.2.3)
|
33
|
-
test-unit (3.3.3)
|
34
|
-
power_assert
|
35
|
-
test-unit-rr (1.0.5)
|
36
|
-
rr (>= 1.1.1)
|
37
|
-
test-unit (>= 2.5.2)
|
38
|
-
tzinfo (2.0.0)
|
39
|
-
concurrent-ruby (~> 1.0)
|
40
|
-
tzinfo-data (1.2019.3)
|
41
|
-
tzinfo (>= 1.0.0)
|
42
|
-
yajl-ruby (1.4.1)
|
43
|
-
|
44
|
-
PLATFORMS
|
45
|
-
ruby
|
46
|
-
|
47
|
-
DEPENDENCIES
|
48
|
-
bundler
|
49
|
-
fluent-plugin-masking!
|
50
|
-
rake (~> 12.0)
|
51
|
-
test-unit (>= 3.1.0)
|
52
|
-
test-unit-rr
|
53
|
-
|
54
|
-
BUNDLED WITH
|
55
|
-
2.0.2
|