fluent-plugin-filter-base64-decode 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fdf78a3d00d136d7ec6972e053db5d38f23e8a49
4
+ data.tar.gz: 159cf9be8fbad6a643ea3fa77943f9a12886b993
5
+ SHA512:
6
+ metadata.gz: f455800ccee0bdc6345517d2332751bc2075b3d6b5955115a75dec80a9e7f8b806e64423140ccbc6d6d04f172e998fd7b8030952951663cee3c8dfe288f9447d
7
+ data.tar.gz: 19988209ad840f7c17008d30b506b70d69f770da333c278b9d33f1ce1b129d05de9c648affe59ad1476f0c7ea0d856a4152c94c1f3711d1d90a0f3d922f1f9af
@@ -0,0 +1,11 @@
1
+ ~*
2
+ #*
3
+ *~
4
+ [._]*.s[a-w][a-z]
5
+ .DS_Store
6
+
7
+ *.gem
8
+ .bundle
9
+ Gemfile.lock
10
+ vendor
11
+ .ruby-version
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.1
5
+ - 2.2.2
6
+ - 2.3.3
7
+ - 2.4.0
8
+
9
+ gemfile:
10
+ - Gemfile
11
+
12
+ branches:
13
+ only:
14
+ - master
15
+
16
+ script: bundle exec rake test
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
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.
@@ -0,0 +1,29 @@
1
+ # fluent-plugin-filter-base64-decode
2
+
3
+ [![Build Status](https://travis-ci.org/MerlinDMC/fluent-plugin-filter-base64-decode.svg?branch=master)](https://travis-ci.org/MerlinDMC/fluent-plugin-filter-base64-decode)
4
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-filter-base64-decode.svg)](http://badge.fury.io/rb/fluent-plugin-filter-base64-decode)
5
+
6
+ ## Overview
7
+
8
+ A base64 decode filter for [Fluentd](http://www.fluentd.org/).
9
+
10
+ ### Configuration
11
+
12
+ Decode base64 encoded fields
13
+
14
+ ```
15
+ <source>
16
+ @type dummy
17
+ tag example
18
+ dummy {"message": "SGVsbG8gV29ybGQhCg=="}
19
+ </source>
20
+
21
+ <filter example>
22
+ @type base64_decode
23
+ fields message
24
+ </filter>
25
+
26
+ <match **>
27
+ @type stdout
28
+ </match>
29
+ ```
@@ -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-base64-decode"
6
+ gem.description = "A filter plugin to decode base64 encoded fields"
7
+ gem.license = "MIT"
8
+ gem.homepage = "https://github.com/MerlinDMC/fluent-plugin-filter-base64-decode"
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 'base64'
3
+
4
+ require 'fluent/plugin/filter'
5
+
6
+ module Fluent
7
+ class Base64DecodeFilter < Filter
8
+ Plugin.register_filter('base64_decode', 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] = Base64.decode64(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 Base64DecodeFilterTest < 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::Base64DecodeFilter).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' => "T0s=",
32
+ 'field3' => "T0s="
33
+ })
34
+
35
+ es.each { |time, record|
36
+ assert_equal 'OK', record['field1']
37
+ assert_equal 'T0s=', record['field3']
38
+ assert_equal false, record.has_key?('field2')
39
+ }
40
+ end
41
+
42
+ end
@@ -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_base64_decode'
27
+
28
+ class Test::Unit::TestCase
29
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-filter-base64-decode
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 base64 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-base64-decode.gemspec
82
+ - lib/fluent/plugin/filter_base64_decode.rb
83
+ - test/plugin/test_filter_base64_decode.rb
84
+ - test/test_helper.rb
85
+ homepage: https://github.com/MerlinDMC/fluent-plugin-filter-base64-decode
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 base64 encoded fields
109
+ test_files:
110
+ - test/plugin/test_filter_base64_decode.rb
111
+ - test/test_helper.rb