fluent-plugin-filter-urldecode 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +16 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +29 -0
- data/Rakefile +12 -0
- data/fluent-plugin-filter-urldecode.gemspec +24 -0
- data/lib/fluent/plugin/filter_urldecode.rb +28 -0
- data/test/plugin/test_filter_urldecode.rb +42 -0
- data/test/test_helper.rb +29 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4dfbd61c04e1ce198de4b342a02ad9ae81302a5f
|
4
|
+
data.tar.gz: 0c230fdaaee56ff2bd5c25f5a6433ea8619e4859
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c78d25e6ff4ef67dc9b5478ac0053a56ac5419501ba3bd6f6ab2e82f8e90b40d339e77ead692b8b07ef5ccccf5c32373e6270f170eb91dbfc346b17eebea9148
|
7
|
+
data.tar.gz: 2c3e57b56d0eb51dba71700f2ac1d2b1603d9e8227d0992c020aa3b52ae8631bf11894821cc0793a7c0f2d72bca3ea5694b7b81465d0eea0e7e70622a2ab01b7
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Daniel Malon
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# fluent-plugin-filter-urldecode
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/MerlinDMC/fluent-plugin-filter-urldecode.svg?branch=master)](https://travis-ci.org/MerlinDMC/fluent-plugin-filter-urldecode)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-filter-urldecode.svg)](http://badge.fury.io/rb/fluent-plugin-filter-urldecode)
|
5
|
+
|
6
|
+
## Overview
|
7
|
+
|
8
|
+
A percent decode filter for [Fluentd](http://www.fluentd.org/).
|
9
|
+
|
10
|
+
### Configuration
|
11
|
+
|
12
|
+
Decode percent encoded fields
|
13
|
+
|
14
|
+
```
|
15
|
+
<source>
|
16
|
+
@type dummy
|
17
|
+
tag example
|
18
|
+
dummy {"message": "1%202%203"}
|
19
|
+
</source>
|
20
|
+
|
21
|
+
<filter example>
|
22
|
+
@type urldecode
|
23
|
+
fields message
|
24
|
+
</filter>
|
25
|
+
|
26
|
+
<match **>
|
27
|
+
@type stdout
|
28
|
+
</match>
|
29
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |test|
|
7
|
+
test.libs << 'lib' << 'test'
|
8
|
+
test.test_files = FileList['test/plugin/test_*.rb']
|
9
|
+
test.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => [:build]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "fluent-plugin-filter-urldecode"
|
6
|
+
gem.description = "A filter plugin to decode percent encoded fields"
|
7
|
+
gem.license = "MIT"
|
8
|
+
gem.homepage = "https://github.com/MerlinDMC/fluent-plugin-filter-urldecode"
|
9
|
+
gem.summary = gem.description
|
10
|
+
gem.version = "0.1.0"
|
11
|
+
gem.authors = ["Daniel Malon"]
|
12
|
+
gem.email = "daniel.malon@me.com"
|
13
|
+
gem.has_rdoc = false
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
gem.require_paths = ['lib']
|
18
|
+
|
19
|
+
gem.add_runtime_dependency "fluentd", ">= 0.12"
|
20
|
+
|
21
|
+
gem.add_development_dependency "bundler"
|
22
|
+
gem.add_development_dependency "rake"
|
23
|
+
gem.add_development_dependency "test-unit"
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'cgi'
|
3
|
+
|
4
|
+
require 'fluent/plugin/filter'
|
5
|
+
|
6
|
+
module Fluent
|
7
|
+
class URLDecodeFilter < Filter
|
8
|
+
Plugin.register_filter('urldecode', self)
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
config_param :fields, :array, value_type: :string
|
15
|
+
|
16
|
+
def configure(conf)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def filter(tag, time, record)
|
21
|
+
@fields.each { |key|
|
22
|
+
record[key] = CGI.unescape(record[key]) if record.has_key? key
|
23
|
+
}
|
24
|
+
record
|
25
|
+
end
|
26
|
+
|
27
|
+
end if defined?(Filter) # Support only >= v0.12
|
28
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class URLDecodeFilterTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
@time = Fluent::Engine.now
|
7
|
+
end
|
8
|
+
|
9
|
+
CONFIG = %[
|
10
|
+
fields field1,field2
|
11
|
+
]
|
12
|
+
|
13
|
+
def create_driver(conf=CONFIG)
|
14
|
+
Fluent::Test::FilterTestDriver.new(Fluent::URLDecodeFilter).configure(conf, true)
|
15
|
+
end
|
16
|
+
|
17
|
+
def emit(config, record)
|
18
|
+
d = create_driver(config)
|
19
|
+
d.run {
|
20
|
+
d.emit(record, @time)
|
21
|
+
}.filtered
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'configure' do
|
25
|
+
d = create_driver(CONFIG)
|
26
|
+
assert_equal ['field1', 'field2'], d.instance.fields
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'decode' do
|
30
|
+
es = emit(CONFIG, {
|
31
|
+
'field1' => "1%202%203",
|
32
|
+
'field3' => "1%202%203"
|
33
|
+
})
|
34
|
+
|
35
|
+
es.each { |time, record|
|
36
|
+
assert_equal '1 2 3', record['field1']
|
37
|
+
assert_equal '1%202%203', record['field3']
|
38
|
+
assert_equal false, record.has_key?('field2')
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
|
15
|
+
require 'fluent/test'
|
16
|
+
unless ENV.has_key?('VERBOSE')
|
17
|
+
nulllogger = Object.new
|
18
|
+
nulllogger.instance_eval {|obj|
|
19
|
+
def method_missing(method, *args)
|
20
|
+
# pass
|
21
|
+
end
|
22
|
+
}
|
23
|
+
$log = nulllogger
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'fluent/plugin/filter_urldecode'
|
27
|
+
|
28
|
+
class Test::Unit::TestCase
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-filter-urldecode
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Malon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.12'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A filter plugin to decode percent encoded fields
|
70
|
+
email: daniel.malon@me.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- ".gitignore"
|
76
|
+
- ".travis.yml"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- fluent-plugin-filter-urldecode.gemspec
|
82
|
+
- lib/fluent/plugin/filter_urldecode.rb
|
83
|
+
- test/plugin/test_filter_urldecode.rb
|
84
|
+
- test/test_helper.rb
|
85
|
+
homepage: https://github.com/MerlinDMC/fluent-plugin-filter-urldecode
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.5.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: A filter plugin to decode percent encoded fields
|
109
|
+
test_files:
|
110
|
+
- test/plugin/test_filter_urldecode.rb
|
111
|
+
- test/test_helper.rb
|