fluent-plugin-sanitizer 0.1.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 +7 -0
- data/Gemfile +3 -0
- data/LICENSE +201 -0
- data/README.md +155 -0
- data/Rakefile +13 -0
- data/fluent-plugin-sanitizer.gemspec +27 -0
- data/lib/fluent/plugin/filter_sanitizer.rb +311 -0
- data/test/Gemfile +3 -0
- data/test/LICENSE +202 -0
- data/test/README.md +43 -0
- data/test/Rakefile +13 -0
- data/test/fluent-plugin-sanitizer.gemspec +27 -0
- data/test/helper.rb +8 -0
- data/test/lib/fluent/plugin/filter_sanitizer.rb +27 -0
- data/test/plugin/test_filter_sanitizer.rb +18 -0
- metadata +132 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b4955af12965cbeeb185d2d62e6049804e063d679a64f6aabf392ec2413b3545
|
|
4
|
+
data.tar.gz: 961c45840adf34d58080f978e71b4dd9b562fa87e76766d439fe2f8088377c71
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9895d0a3cdaa2524affac2ccd33411964948dbc7faefa34d3295d2d8d86bfea36e744615a62de51f24da9519b20fefe3f95155320eb058ad4c4b372c20f09578
|
|
7
|
+
data.tar.gz: 553c62ebcf205ff05d405ddf054fe36b04adac50236744d1a044b50d50a9cde1f791d5a4812d68fd205b4a4da7b82f3dc0f7f1f3a913d8ede2f7c22a2fb53594
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Overview of fluent-plugin-sanitizer
|
|
2
|
+
The fluent-plugin-sanitzer is [Fluentd](https://fluentd.org/) filter plugin to sanitize sensitive information with custom rules. The fluent-plugin-sanitzer provides not only options to sanitize values with custom regular expression and keywords but also build-in options which allows users to easily sanitize IP addresses and hostnames in complex messages.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
When you are using OSS Fluentd :
|
|
6
|
+
```
|
|
7
|
+
fluent-gem install fluent-plugin-sanitizer
|
|
8
|
+
```
|
|
9
|
+
When you are using td-agent :
|
|
10
|
+
```
|
|
11
|
+
td-agent-gem install fluent-plugin-sanitizer
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Configuration
|
|
15
|
+
### Parameters
|
|
16
|
+
- hash_salt : specify hash salt used to sanitize original information (:string, default: nil)
|
|
17
|
+
- rule options
|
|
18
|
+
- keys : Name of keys whose values are to be sanitized. You can specify multiple keys. When keys are nested, you can use {parent key}.{child key} like "kubernetes.master_url". (:array, default:[])
|
|
19
|
+
- pattern_ipv4 : sanitize if values contain IPv4. (:bool, default: false)
|
|
20
|
+
- pattern_fqdn : sanitize if values contain hostname in FQDN style. (:bool, default: false)
|
|
21
|
+
- pattern_regex : Sanitize if value mactchs custom regular expression (:regexp, default: /^$/)
|
|
22
|
+
- pattern_keywords : Sanitize if values match custom keywords. You can specify multiple keywords. (:array, default:[])
|
|
23
|
+
|
|
24
|
+
You can specify multiple options in a single rule like following sample configuration.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
<filter **>
|
|
28
|
+
@type sanitizer
|
|
29
|
+
hash_salt mysalt
|
|
30
|
+
<rule>
|
|
31
|
+
keys source, kubernetes.master_url
|
|
32
|
+
pattern_ipv4 true
|
|
33
|
+
</rule>
|
|
34
|
+
<rule>
|
|
35
|
+
keys hostname, host
|
|
36
|
+
pattern_fqdn true
|
|
37
|
+
</rule>
|
|
38
|
+
<rule>
|
|
39
|
+
keys message, system.log
|
|
40
|
+
pattern_regex /^Hello World!$/
|
|
41
|
+
pattern_keywords password, passwd
|
|
42
|
+
</rule>
|
|
43
|
+
</filter>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Use cases
|
|
47
|
+
|
|
48
|
+
### Sanitize IP address and hostname
|
|
49
|
+
Sample rule #1
|
|
50
|
+
```
|
|
51
|
+
<rule>
|
|
52
|
+
keys ip
|
|
53
|
+
pattern_ipv4 true
|
|
54
|
+
</rule>
|
|
55
|
+
<rule>
|
|
56
|
+
keys host
|
|
57
|
+
pattern_fqdn true
|
|
58
|
+
</rule>
|
|
59
|
+
```
|
|
60
|
+
Sample input #1
|
|
61
|
+
```
|
|
62
|
+
{
|
|
63
|
+
"ip":"192.168.10.10",
|
|
64
|
+
"host":"test01.demo.com"
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
Sample output #1
|
|
68
|
+
```
|
|
69
|
+
{
|
|
70
|
+
"ip":"IPv4_94712b06963e277fe28469388323665d",
|
|
71
|
+
"host":"FQDN_37de34e3d799de477c742d8d7bb35550"
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Sanitize IP addresses and hostnames in between URL and messages
|
|
76
|
+
You may sanitize IP addresses and hostnames in URL and messages. The "pattern_ipv4" and "pattern_fqdn" options can help you easily to sanitize information in such cases.
|
|
77
|
+
|
|
78
|
+
Sample rule #2
|
|
79
|
+
```
|
|
80
|
+
<rule>
|
|
81
|
+
keys system.url, system.log
|
|
82
|
+
pattern_ipv4 true
|
|
83
|
+
pattern_fqdn true
|
|
84
|
+
</rule>
|
|
85
|
+
```
|
|
86
|
+
Sample input #2
|
|
87
|
+
```
|
|
88
|
+
{
|
|
89
|
+
"tag":"test",
|
|
90
|
+
"system" :
|
|
91
|
+
{
|
|
92
|
+
"url":"https://test02.demo.com:8000/event",
|
|
93
|
+
"log":"access from 192.168.10.100 was blocked"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
Sample output #3
|
|
98
|
+
```
|
|
99
|
+
{
|
|
100
|
+
"tag":"test",
|
|
101
|
+
"system":{
|
|
102
|
+
"url":"https://FQDN_e9a59624f555d02f06209c9942dded19:8000/event",
|
|
103
|
+
"log":"access from IPv4_f7374d61e6d21dc1105f70358a5f8e8f was blocked"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
### Sanitize keywords in between messages
|
|
108
|
+
When "pattern_keywords" option is selected, fluent-plugin-sanitizer splits messages and sanitizes blocks which match keywords.
|
|
109
|
+
Sample rule#3
|
|
110
|
+
```
|
|
111
|
+
<rule>
|
|
112
|
+
keys message
|
|
113
|
+
pattern_keywords user1, application1
|
|
114
|
+
</rule>
|
|
115
|
+
```
|
|
116
|
+
Sample input #3
|
|
117
|
+
```
|
|
118
|
+
{
|
|
119
|
+
"message":"user1 failed to login application1"
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
Sample output #3
|
|
123
|
+
```
|
|
124
|
+
{
|
|
125
|
+
"message":"Keyword_321865df6f0ce6bdf3ea16f74623534a failed to login Keyword_49006ff9b2ab584795e4cbb7636bd17c"
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
### Sanitize all messages
|
|
129
|
+
Sample rule #4
|
|
130
|
+
```
|
|
131
|
+
<rule>
|
|
132
|
+
keys message
|
|
133
|
+
pattern_regex /^.*$/
|
|
134
|
+
</rule>
|
|
135
|
+
```
|
|
136
|
+
Sample input#4
|
|
137
|
+
```
|
|
138
|
+
{
|
|
139
|
+
"message":"user1 failed to login application1"
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
Sample output #4
|
|
143
|
+
```
|
|
144
|
+
{
|
|
145
|
+
"message":"Regex_70e9b833f5f00a4b0ab9fcf74af81f26"
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
## Contribute
|
|
149
|
+
Contribution to fluent-plugin-sanitizer is always welcomed.
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
## Copyright
|
|
153
|
+
* Copyright(c) 2021- TK Kubota
|
|
154
|
+
* License
|
|
155
|
+
* Apache License, Version 2.0
|
data/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require "bundler"
|
|
2
|
+
Bundler::GemHelper.install_tasks
|
|
3
|
+
|
|
4
|
+
require "rake/testtask"
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs.push("lib", "test")
|
|
8
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
|
9
|
+
t.verbose = true
|
|
10
|
+
t.warning = true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
task default: [:test]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |spec|
|
|
5
|
+
spec.name = "fluent-plugin-sanitizer"
|
|
6
|
+
spec.version = "0.1.0"
|
|
7
|
+
spec.authors = ["TK Kubota"]
|
|
8
|
+
spec.email = ["tkubota@ctc-america.com"]
|
|
9
|
+
|
|
10
|
+
spec.summary = %q{Filter plugin of Fluentd which sanitize sensitive information.}
|
|
11
|
+
spec.description = %q{The fluent-plugin-sanitzer is Fluentd filter plugin to sanitize sensitive information with custom rules. The fluent-plugin-sanitzer provides not only options to sanitize values with custom regular expression and keywords but also build-in options which allows users to easily sanitize IP addresses and hostnames in complex messages.}
|
|
12
|
+
spec.homepage = "https://github.com/fluent/fluent-plugin-sanitizer"
|
|
13
|
+
spec.license = "Apache-2.0"
|
|
14
|
+
|
|
15
|
+
test_files, files = `git ls-files -z`.split("\x0").partition do |f|
|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
|
17
|
+
end
|
|
18
|
+
spec.files = files
|
|
19
|
+
spec.executables = files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
20
|
+
spec.test_files = test_files
|
|
21
|
+
spec.require_paths = ["lib"]
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
|
24
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
|
25
|
+
spec.add_development_dependency "test-unit", "~> 3.0"
|
|
26
|
+
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
|
27
|
+
end
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2021- TK Kubota
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
require "fluent/plugin/filter"
|
|
17
|
+
require "digest"
|
|
18
|
+
|
|
19
|
+
module Fluent
|
|
20
|
+
module Plugin
|
|
21
|
+
class SanitizerFilter < Fluent::Plugin::Filter
|
|
22
|
+
Fluent::Plugin.register_filter("sanitizer", self)
|
|
23
|
+
|
|
24
|
+
helpers :event_emitter, :record_accessor
|
|
25
|
+
|
|
26
|
+
desc "Hash salt to be used to generate hash values with MD5(optional)"
|
|
27
|
+
config_param :hash_salt, :string, default: nil
|
|
28
|
+
|
|
29
|
+
config_section :rule, param_name: :rules, multi: true do
|
|
30
|
+
desc "Name of keys whose valuse are to be sanitized"
|
|
31
|
+
config_param :keys, :array, default: []
|
|
32
|
+
desc "Sanitize if values contain IPv4 (optional)"
|
|
33
|
+
config_param :pattern_ipv4, :bool, default: false
|
|
34
|
+
desc "Sanitize if values contain Hostname in FQDN style (ptional)"
|
|
35
|
+
config_param :pattern_fqdn, :bool, default: false
|
|
36
|
+
desc "Sanitize if values mactch custom regular expression (optional)"
|
|
37
|
+
config_param :pattern_regex, :regexp, default: /^$/
|
|
38
|
+
desc "Sanitize if values mactch custom keywords (optional)"
|
|
39
|
+
config_param :pattern_keywords, :array, default: []
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def configure(conf)
|
|
43
|
+
super
|
|
44
|
+
|
|
45
|
+
@salt = ""
|
|
46
|
+
@salt = conf['hash_salt'] if conf['hash_salt'] != nil
|
|
47
|
+
|
|
48
|
+
@sanitizerules = []
|
|
49
|
+
@rules.each do |rule|
|
|
50
|
+
if rule.keys.empty?
|
|
51
|
+
raise Fluent::ConfigError, "You need to specify at least one key in rule statement."
|
|
52
|
+
else
|
|
53
|
+
keys = rule.keys
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if rule.pattern_ipv4 == true || rule.pattern_ipv4 == false
|
|
57
|
+
pattern_ipv4 = rule.pattern_ipv4
|
|
58
|
+
else
|
|
59
|
+
raise Fluent::ConfigError, "true or false is available for pattern_ipv4 option."
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
if rule.pattern_fqdn == true || rule.pattern_fqdn == false
|
|
63
|
+
pattern_fqdn = rule.pattern_fqdn
|
|
64
|
+
else
|
|
65
|
+
raise Fluent::ConfigError, "true or false is available for pattern_fqdn option."
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
pattern_regex = rule.pattern_regex
|
|
69
|
+
pattern_keywords = rule.pattern_keywords
|
|
70
|
+
|
|
71
|
+
case [pattern_ipv4, pattern_fqdn, pattern_regex, pattern_keywords.empty?]
|
|
72
|
+
when [false, false, /^$/, true]
|
|
73
|
+
raise Fluent::ConfigError, "You need to specify at least one pattern option in the rule statement."
|
|
74
|
+
end
|
|
75
|
+
@sanitizerules.push([keys, pattern_ipv4, pattern_fqdn, pattern_regex, pattern_keywords])
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def filter(tag, time, record)
|
|
80
|
+
@sanitizerules.each do |keys, pattern_ipv4, pattern_fqdn, pattern_regex, pattern_keywords|
|
|
81
|
+
keys.each do |key|
|
|
82
|
+
if key.include?(".")
|
|
83
|
+
nkey = key.split(".")
|
|
84
|
+
if nkey.length ==2
|
|
85
|
+
if record[nkey[0]].key?(nkey[1])
|
|
86
|
+
v = record[nkey[0]][nkey[1]]
|
|
87
|
+
record[nkey[0]][nkey[1]] = sanitize_ipv4_val(@salt, record[nkey[0]][nkey[1]]) if pattern_ipv4 == true
|
|
88
|
+
record[nkey[0]][nkey[1]] = sanitize_fqdn_val(@salt, record[nkey[0]][nkey[1]]) if pattern_fqdn == true
|
|
89
|
+
record[nkey[0]][nkey[1]] = sanitize_regex(@salt, record[nkey[0]][nkey[1]]) if is_regex?(pattern_regex) && !!(pattern_regex =~ record[nkey[0]][nkey[1]])
|
|
90
|
+
record[nkey[0]][nkey[1]] = sanitize_keyword(@salt, pattern_keywords, record[nkey[0]][nkey[1]]) if pattern_keywords.empty? == false
|
|
91
|
+
else
|
|
92
|
+
$log.error "no such nested key found : key name = #{key}"
|
|
93
|
+
end
|
|
94
|
+
elsif nkey.length ==3
|
|
95
|
+
if record[nkey[0]][nkey[1]].key?(nkey[2])
|
|
96
|
+
v = record[nkey[0]][nkey[1]][nkey[2]]
|
|
97
|
+
record[nkey[0]][nkey[1]][nkey[2]] = sanitize_ipv4_val(@salt, record[nkey[0]][nkey[1]][nkey[2]]) if pattern_ipv4 == true
|
|
98
|
+
record[nkey[0]][nkey[1]][nkey[2]] = sanitize_fqdn_val(@salt, record[nkey[0]][nkey[1]][nkey[2]]) if pattern_fqdn == true
|
|
99
|
+
record[nkey[0]][nkey[1]][nkey[2]] = sanitize_regex(@salt, record[nkey[0]][nkey[1]][nkey[2]]) if is_regex?(pattern_regex) && !!(pattern_regex =~ record[nkey[0]][nkey[1]][nkey[2]])
|
|
100
|
+
record[nkey[0]][nkey[1]][nkey[2]] = sanitize_keyword(@salt, pattern_keywords, record[nkey[0]][nkey[1]][nkey[2]]) if pattern_keywords.empty? == false
|
|
101
|
+
else
|
|
102
|
+
$log.error "no such nested key found : key name = #{key}"
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
else
|
|
106
|
+
if record.key?(key)
|
|
107
|
+
v = record[key]
|
|
108
|
+
record[key] = sanitize_ipv4_val(@salt, record[key]) if pattern_ipv4 == true
|
|
109
|
+
record[key] = sanitize_fqdn_val(@salt, record[key]) if pattern_fqdn == true
|
|
110
|
+
record[key] = sanitize_regex(@salt, v) if is_regex?(pattern_regex) && !!(pattern_regex =~ record[key])
|
|
111
|
+
record[key] = sanitize_keyword_val(@salt, pattern_keywords, v) if pattern_keywords.empty? == false
|
|
112
|
+
else
|
|
113
|
+
$log.error "no such key found : key name = #{key}"
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
record
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def include_ipv4?(str)
|
|
122
|
+
!!(str =~ /^.*\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}.*$/)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def is_ipv4?(str)
|
|
126
|
+
!!(str =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def is_ipv4_port?(str)
|
|
130
|
+
!!(str =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:[0-9]{1,5}$/)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def include_fqdn?(str)
|
|
134
|
+
!!(str =~ /^.*\b(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.){2,}([A-Za-z]|[A-Za-z][A-Za-z\-]*[A-Za-z]){2,}.*$/)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def is_fqdn?(str)
|
|
138
|
+
!!(str =~ /^\b(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.){2,}([A-Za-z]|[A-Za-z][A-Za-z\-]*[A-Za-z]){2,}$/)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def is_fqdn_port?(str)
|
|
142
|
+
!!(str =~ /^\b(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.){2,}([A-Za-z]|[A-Za-z][A-Za-z\-]*[A-Za-z]){2,}:[0-9]{1,5}$/)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def is_url?(str)
|
|
146
|
+
!!(str =~ /^[a-zA-Z0-9]{2,}:\/\/.*$/)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def is_regex?(regex)
|
|
150
|
+
return regex.class == Regexp
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def subtract_quotations(str)
|
|
154
|
+
return str.gsub(/\\\"|\'|\"|\\\'/,'')
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def sanitize_ipv4(salt, str)
|
|
158
|
+
return str, "IPv4_"+Digest::MD5.hexdigest(salt + str)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def sanitize_fqdn(salt, str)
|
|
162
|
+
return str, "FQDN_"+Digest::MD5.hexdigest(salt + str)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def sanitize_regex(salt, str)
|
|
166
|
+
return "Regex_"+Digest::MD5.hexdigest(salt + str)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def sanitize_keyword(salt, str)
|
|
170
|
+
return "Keyword_"+Digest::MD5.hexdigest(salt + str)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def sanitize_ipv4_port(salt, str)
|
|
174
|
+
ip_port = []
|
|
175
|
+
str.split(":").each do |s|
|
|
176
|
+
b, s = sanitize_ipv4(salt, s) if is_ipv4?(s)
|
|
177
|
+
ip_port.push(s)
|
|
178
|
+
end
|
|
179
|
+
return str, ip_port.join(":")
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def sanitize_fqdn_port(salt, str)
|
|
183
|
+
fqdn_port = []
|
|
184
|
+
str.split(":").each do |s|
|
|
185
|
+
b, s = sanitize_fqdn(salt, s) if is_fqdn?(s)
|
|
186
|
+
fqdn_port.push(s)
|
|
187
|
+
end
|
|
188
|
+
return str, fqdn_port.join(":")
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def sanitize_ipv4_url(salt, str)
|
|
192
|
+
ip_url = []
|
|
193
|
+
str.split("://").each do |s|
|
|
194
|
+
if s.include?("/")
|
|
195
|
+
url_slash = []
|
|
196
|
+
s.split("/").each do |ss|
|
|
197
|
+
b, ss = sanitize_ipv4(salt, ss) if is_ipv4?(ss)
|
|
198
|
+
b, ss = sanitize_ipv4_port(salt, ss) if is_ipv4_port?(ss)
|
|
199
|
+
url_slash.push(ss)
|
|
200
|
+
end
|
|
201
|
+
s = url_slash.join("/")
|
|
202
|
+
else
|
|
203
|
+
b, s = sanitize_ipv4(salt, s) if is_ipv4?(s)
|
|
204
|
+
b, s = sanitize_ipv4_port(salt, s) if is_ipv4_port?(s)
|
|
205
|
+
end
|
|
206
|
+
ip_url.push(s)
|
|
207
|
+
end
|
|
208
|
+
return str, ip_url.join("://")
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def sanitize_fqdn_url(salt, str)
|
|
212
|
+
fqdn_url = []
|
|
213
|
+
str.split("://").each do |s|
|
|
214
|
+
if s.include?("/")
|
|
215
|
+
url_slash = []
|
|
216
|
+
s.split("/").each do |ss|
|
|
217
|
+
b, ss = sanitize_fqdn(salt, ss) if is_fqdn?(ss)
|
|
218
|
+
b, ss = sanitize_fqdn_port(salt, ss) if is_fqdn_port?(ss)
|
|
219
|
+
url_slash.push(ss)
|
|
220
|
+
end
|
|
221
|
+
s = url_slash.join("/")
|
|
222
|
+
else
|
|
223
|
+
b, s = sanitize_fqdn(salt, s) if is_fqdn?(s)
|
|
224
|
+
b, s = sanitize_fqdn_port(salt, s) if is_fqdn_port?(s)
|
|
225
|
+
end
|
|
226
|
+
fqdn_url.push(s)
|
|
227
|
+
end
|
|
228
|
+
return str, fqdn_url.join("://")
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def sanitize_ipv4_val(salt, v)
|
|
232
|
+
line = []
|
|
233
|
+
if v.include?(",")
|
|
234
|
+
v.split(",").each do |s|
|
|
235
|
+
s = subtract_quotations(s)
|
|
236
|
+
if include_ipv4?(s)
|
|
237
|
+
if is_url?(s)
|
|
238
|
+
b, s = sanitize_ipv4_url(salt, s)
|
|
239
|
+
else
|
|
240
|
+
b, s = sanitize_ipv4(salt, s) if is_ipv4?(s)
|
|
241
|
+
b, s = sanitize_ipv4_port(salt, s) if is_ipv4_port?(s)
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
line.push(s)
|
|
245
|
+
end
|
|
246
|
+
return line.join(",")
|
|
247
|
+
else
|
|
248
|
+
v.split().each do |s|
|
|
249
|
+
s = subtract_quotations(s)
|
|
250
|
+
if include_ipv4?(s)
|
|
251
|
+
if is_url?(s)
|
|
252
|
+
b, s = sanitize_ipv4_url(salt, s)
|
|
253
|
+
else
|
|
254
|
+
b, s = sanitize_ipv4(salt, s) if is_ipv4?(s)
|
|
255
|
+
b, s = sanitize_ipv4_port(salt, s) if is_ipv4_port?(s)
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
line.push(s)
|
|
259
|
+
end
|
|
260
|
+
return line.join(" ")
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def sanitize_fqdn_val(salt, v)
|
|
265
|
+
line = []
|
|
266
|
+
if v.include?(",")
|
|
267
|
+
v.split(",").each do |s|
|
|
268
|
+
s = subtract_quotations(s)
|
|
269
|
+
if include_fqdn?(s)
|
|
270
|
+
if is_url?(s)
|
|
271
|
+
b, s = sanitize_fqdn_url(salt, s)
|
|
272
|
+
else
|
|
273
|
+
b, s = sanitize_fqdn(salt, s) if is_fqdn?(s)
|
|
274
|
+
b, s = sanitize_fqdn_port(salt, s) if is_fqdn_port?(s)
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
line.push(s)
|
|
278
|
+
end
|
|
279
|
+
return line.join(",")
|
|
280
|
+
else
|
|
281
|
+
v.split().each do |s|
|
|
282
|
+
s = subtract_quotations(s)
|
|
283
|
+
if include_fqdn?(s)
|
|
284
|
+
if is_url?(s)
|
|
285
|
+
b, s = sanitize_fqdn_url(salt, s)
|
|
286
|
+
else
|
|
287
|
+
b, s = sanitize_fqdn(salt, s) if is_fqdn?(s)
|
|
288
|
+
b, s = sanitize_fqdn_port(salt, s) if is_fqdn_port?(s)
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
line.push(s)
|
|
292
|
+
end
|
|
293
|
+
return line.join(" ")
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
def sanitize_keyword_val(salt, keywords, v)
|
|
298
|
+
line = []
|
|
299
|
+
v.split().each do |vv|
|
|
300
|
+
if keywords.include?(vv)
|
|
301
|
+
line.push(sanitize_keyword(salt, vv))
|
|
302
|
+
else
|
|
303
|
+
line.push(vv)
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
return line.join(" ")
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
end
|
data/test/Gemfile
ADDED
data/test/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/test/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# fluent-plugin-sanitizer
|
|
2
|
+
|
|
3
|
+
[Fluentd](https://fluentd.org/) filter plugin to do something.
|
|
4
|
+
|
|
5
|
+
TODO: write description for you plugin.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### RubyGems
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
$ gem install fluent-plugin-sanitizer
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Bundler
|
|
16
|
+
|
|
17
|
+
Add following line to your Gemfile:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
gem "fluent-plugin-sanitizer"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
And then execute:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
$ bundle
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
You can generate configuration template:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
$ fluent-plugin-config-format filter sanitizer
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
You can copy and paste generated documents here.
|
|
38
|
+
|
|
39
|
+
## Copyright
|
|
40
|
+
|
|
41
|
+
* Copyright(c) 2021- TODO: Write your name
|
|
42
|
+
* License
|
|
43
|
+
* Apache License, Version 2.0
|
data/test/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require "bundler"
|
|
2
|
+
Bundler::GemHelper.install_tasks
|
|
3
|
+
|
|
4
|
+
require "rake/testtask"
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs.push("lib", "test")
|
|
8
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
|
9
|
+
t.verbose = true
|
|
10
|
+
t.warning = true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
task default: [:test]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |spec|
|
|
5
|
+
spec.name = "fluent-plugin-sanitizer"
|
|
6
|
+
spec.version = "0.1.0"
|
|
7
|
+
spec.authors = ["TODO: Write your name"]
|
|
8
|
+
spec.email = ["TODO: Write your email"]
|
|
9
|
+
|
|
10
|
+
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
|
|
11
|
+
spec.description = %q{TODO: Write a longer description or delete this line.}
|
|
12
|
+
spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
|
13
|
+
spec.license = "Apache-2.0"
|
|
14
|
+
|
|
15
|
+
test_files, files = `git ls-files -z`.split("\x0").partition do |f|
|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
|
17
|
+
end
|
|
18
|
+
spec.files = files
|
|
19
|
+
spec.executables = files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
20
|
+
spec.test_files = test_files
|
|
21
|
+
spec.require_paths = ["lib"]
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
|
24
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
|
25
|
+
spec.add_development_dependency "test-unit", "~> 3.0"
|
|
26
|
+
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
|
27
|
+
end
|
data/test/helper.rb
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
|
|
2
|
+
require "test-unit"
|
|
3
|
+
require "fluent/test"
|
|
4
|
+
require "fluent/test/driver/filter"
|
|
5
|
+
require "fluent/test/helpers"
|
|
6
|
+
|
|
7
|
+
Test::Unit::TestCase.include(Fluent::Test::Helpers)
|
|
8
|
+
Test::Unit::TestCase.extend(Fluent::Test::Helpers)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2021- TODO: Write your name
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
require "fluent/plugin/filter"
|
|
17
|
+
|
|
18
|
+
module Fluent
|
|
19
|
+
module Plugin
|
|
20
|
+
class SanitizerFilter < Fluent::Plugin::Filter
|
|
21
|
+
Fluent::Plugin.register_filter("sanitizer", self)
|
|
22
|
+
|
|
23
|
+
def filter(tag, time, record)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "helper"
|
|
2
|
+
require "fluent/plugin/filter_sanitizer.rb"
|
|
3
|
+
|
|
4
|
+
class SanitizerFilterTest < Test::Unit::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
Fluent::Test.setup
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "failure" do
|
|
10
|
+
flunk
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def create_driver(conf)
|
|
16
|
+
Fluent::Test::Driver::Filter.new(Fluent::Plugin::SanitizerFilter).configure(conf)
|
|
17
|
+
end
|
|
18
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fluent-plugin-sanitizer
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- TK Kubota
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.14'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.14'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '12.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '12.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: test-unit
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: fluentd
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.14.10
|
|
62
|
+
- - "<"
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: '2'
|
|
65
|
+
type: :runtime
|
|
66
|
+
prerelease: false
|
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: 0.14.10
|
|
72
|
+
- - "<"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '2'
|
|
75
|
+
description: The fluent-plugin-sanitzer is Fluentd filter plugin to sanitize sensitive
|
|
76
|
+
information with custom rules. The fluent-plugin-sanitzer provides not only options
|
|
77
|
+
to sanitize values with custom regular expression and keywords but also build-in
|
|
78
|
+
options which allows users to easily sanitize IP addresses and hostnames in complex
|
|
79
|
+
messages.
|
|
80
|
+
email:
|
|
81
|
+
- tkubota@ctc-america.com
|
|
82
|
+
executables: []
|
|
83
|
+
extensions: []
|
|
84
|
+
extra_rdoc_files: []
|
|
85
|
+
files:
|
|
86
|
+
- Gemfile
|
|
87
|
+
- LICENSE
|
|
88
|
+
- README.md
|
|
89
|
+
- Rakefile
|
|
90
|
+
- fluent-plugin-sanitizer.gemspec
|
|
91
|
+
- lib/fluent/plugin/filter_sanitizer.rb
|
|
92
|
+
- test/Gemfile
|
|
93
|
+
- test/LICENSE
|
|
94
|
+
- test/README.md
|
|
95
|
+
- test/Rakefile
|
|
96
|
+
- test/fluent-plugin-sanitizer.gemspec
|
|
97
|
+
- test/helper.rb
|
|
98
|
+
- test/lib/fluent/plugin/filter_sanitizer.rb
|
|
99
|
+
- test/plugin/test_filter_sanitizer.rb
|
|
100
|
+
homepage: https://github.com/fluent/fluent-plugin-sanitizer
|
|
101
|
+
licenses:
|
|
102
|
+
- Apache-2.0
|
|
103
|
+
metadata: {}
|
|
104
|
+
post_install_message:
|
|
105
|
+
rdoc_options: []
|
|
106
|
+
require_paths:
|
|
107
|
+
- lib
|
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
|
+
requirements:
|
|
110
|
+
- - ">="
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '0'
|
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
requirements: []
|
|
119
|
+
rubyforge_project:
|
|
120
|
+
rubygems_version: 2.7.6.2
|
|
121
|
+
signing_key:
|
|
122
|
+
specification_version: 4
|
|
123
|
+
summary: Filter plugin of Fluentd which sanitize sensitive information.
|
|
124
|
+
test_files:
|
|
125
|
+
- test/Gemfile
|
|
126
|
+
- test/LICENSE
|
|
127
|
+
- test/README.md
|
|
128
|
+
- test/Rakefile
|
|
129
|
+
- test/fluent-plugin-sanitizer.gemspec
|
|
130
|
+
- test/helper.rb
|
|
131
|
+
- test/lib/fluent/plugin/filter_sanitizer.rb
|
|
132
|
+
- test/plugin/test_filter_sanitizer.rb
|