logstash-filter-phpserialized 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e0abfc15c2f8469a0f46d6cbc1d854ee97c27b4
4
+ data.tar.gz: 1be8ff2ff35bb546dd0a3eb36a8fbd30d3f595a4
5
+ SHA512:
6
+ metadata.gz: 010a9ea631f60e0eeca8610f48e9bce49a92d17762d02349b867c5aa0da357a1d35b5178f20264c87b08af0d1c58358551039c6ef8aed805a1bb80d967a18832
7
+ data.tar.gz: 0ce94f79c74350b7ed7d1366ffa7b5a2f31504c5f05ac884c58080c8ddf47e802c794daa467455aaf619df118e869a508a15e4a8d284fc4d5cb423869b64e266
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.1.0
2
+
data/CONTRIBUTORS ADDED
@@ -0,0 +1,11 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Aaron Mildenstein (untergeek)
6
+ * Pier-Hugues Pellerin (ph)
7
+
8
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
9
+ Logstash, and you aren't on the list above and want to be, please let us know
10
+ and we'll make sure you're here. Contributions from folks like you are what make
11
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+ gem 'php-serialization', '~> 0.5.3'
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/NOTICE.TXT ADDED
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Logstash Plugin PHPSerialized
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
+
5
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
+
7
+ ## Need Help?
8
+
9
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
10
+
11
+ ## Developing
12
+
13
+ ### 1. Plugin Developement and Testing
14
+
15
+ #### Test
16
+
17
+ - Update your dependencies
18
+
19
+ ```sh
20
+ bundle install
21
+ ```
22
+
23
+ - Run tests
24
+
25
+ ```sh
26
+ bundle exec rspec
27
+ ```
28
+
29
+ ### 2. Running your unpublished Plugin in Logstash
30
+
31
+ #### 2.1 Run in a local Logstash clone
32
+
33
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
34
+ ```ruby
35
+ gem "logstash-filter-phpserialized", :path => "/your/local/logstash-filter-phpserialized"
36
+ ```
37
+ - Install plugin
38
+ ```sh
39
+ bin/plugin install --no-verify
40
+ ```
41
+ - Run Logstash with your plugin
42
+ ```sh
43
+ bin/logstash -e 'filter {phpserialized {}}'
44
+ ```
45
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+ require "php_serialization"
5
+
6
+ class LogStash::Filters::PHPSerialized < LogStash::Filters::Base
7
+
8
+ config_name "phpserialized"
9
+
10
+ # Replace the message with this value.
11
+ config :target, :validate => :string, :default => "message"
12
+ config :source, :validate => :string, :default => "message"
13
+
14
+
15
+ public
16
+ def register
17
+ end
18
+
19
+
20
+ public
21
+ def filter(event)
22
+
23
+ value = event[@source]
24
+ unless value.empty?
25
+ begin
26
+ data = PhpSerialization.load(value.gsub(/O:8:"stdClass"/, 'O:8:"StdClass"'))
27
+ event["[#{@target}]"] = data
28
+ rescue
29
+ @logger.warn("phpunserialized failed to unserialize")
30
+ end
31
+ end
32
+
33
+ filter_matched(event)
34
+ end
35
+ end
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-phpserialized'
3
+ s.version = '0.1.0'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "unserialize php serialized data"
6
+ s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
7
+ s.authors = ["mhoffmann"]
8
+ s.email = 'info@elastic.co'
9
+ s.homepage = "https://github.com/mhoffmann/logstash-filter-phpserialized"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*', 'spec/**/*', 'vendor/**/*', '*.gemspec', '*.md', 'CONTRIBUTORS', 'Gemfile', 'LICENSE', 'NOTICE.TXT']
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = {"logstash_plugin" => "true", "logstash_group" => "filter"}
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
22
+ s.add_runtime_dependency 'php-serialization', '~> 0.5.3'
23
+ s.add_development_dependency 'logstash-devutils'
24
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'logstash/filters/phpserialized'
4
+
5
+ describe LogStash::Filters::PHPSerialized do
6
+ describe "unserialize something" do
7
+ let(:config) do
8
+ <<-CONFIG
9
+ filter {
10
+ phpserialized {
11
+ target => "t"
12
+ source => "s"
13
+ }
14
+ }
15
+ CONFIG
16
+ end
17
+
18
+ #php > echo serialize([true, 0.1, 1, "test" => "test", null, (object)["a" => "b"]]);
19
+ sample('s' => 'a:6:{i:0;b:1;i:1;d:0.10000000000000001;i:2;i:1;s:4:"test";s:4:"test";i:3;N;i:4;O:8:"stdClass":1:{s:1:"a";s:1:"b";}}') do
20
+ expect(subject).to include('t')
21
+ expect(subject['[t][test]']).to eq('test')
22
+ end
23
+
24
+ sample("s" => "") do
25
+ expect(subject).to_not include('t')
26
+ end
27
+ end
28
+ describe "test default config" do
29
+ let(:config) do
30
+ <<-CONFIG
31
+ filter { phpserialized {} }
32
+ CONFIG
33
+ end
34
+
35
+ #php > echo serialize(["test" => "test"]);
36
+ sample('message' => 'a:1:{s:4:"test";s:4:"test";}') do
37
+ expect(subject['[message][test]']).to eq('test')
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-phpserialized
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mhoffmann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '>='
17
+ - !ruby/object:Gem::Version
18
+ version: 2.0.0
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ name: logstash-core
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 0.5.3
39
+ name: php-serialization
40
+ prerelease: false
41
+ type: :runtime
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 0.5.3
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ name: logstash-devutils
54
+ prerelease: false
55
+ type: :development
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
62
+ email: info@elastic.co
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - CHANGELOG.md
68
+ - CONTRIBUTORS
69
+ - Gemfile
70
+ - LICENSE
71
+ - NOTICE.TXT
72
+ - README.md
73
+ - lib/logstash/filters/phpserialized.rb
74
+ - logstash-filter-phpserialized.gemspec
75
+ - spec/filters/phpserialized_spec.rb
76
+ - spec/spec_helper.rb
77
+ homepage: https://github.com/mhoffmann/logstash-filter-phpserialized
78
+ licenses:
79
+ - Apache License (2.0)
80
+ metadata:
81
+ logstash_plugin: 'true'
82
+ logstash_group: filter
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.4.5
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: unserialize php serialized data
103
+ test_files:
104
+ - spec/filters/phpserialized_spec.rb
105
+ - spec/spec_helper.rb