logstash-filter-naxsi 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6a6c0e6c10d3871300429a20c8ac1073fb04f5cb
4
+ data.tar.gz: ddba81e78af44c33c1a761b3cfd55841b0a9c9fc
5
+ SHA512:
6
+ metadata.gz: 0fcd5c784f64395c4b38141df6a00f6280bcaadaea9e1a02878541c709dc647bc05a2b8c176ff89778a02dd2cf7d897ea1956712087040a441ef479dd6209630
7
+ data.tar.gz: 21ed4914392513fe28649c06dc8885654a53c78ea6756dee164de388b2b8eb66d2eb6977c88d4438ece1c7a240b435ef534dd4df5d87c3995433c24eb09877a9
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 NextGxDx <https://www.nextgxdx.com>
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/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # Logstash Plugin
2
+
3
+ [![Build
4
+ Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-example-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-example-unit/)
5
+
6
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
7
+
8
+ 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.
9
+
10
+ ## Documentation
11
+
12
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
13
+
14
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
15
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
16
+
17
+ ## Need Help?
18
+
19
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
20
+
21
+ ## Developing
22
+
23
+ ### 1. Plugin Developement and Testing
24
+
25
+ #### Code
26
+ - To get started, you'll need JRuby with the Bundler gem installed.
27
+
28
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
29
+
30
+ - Install dependencies
31
+ ```sh
32
+ bundle install
33
+ ```
34
+
35
+ #### Test
36
+
37
+ - Update your dependencies
38
+
39
+ ```sh
40
+ bundle install
41
+ ```
42
+
43
+ - Run tests
44
+
45
+ ```sh
46
+ bundle exec rspec
47
+ ```
48
+
49
+ ### 2. Running your unpublished Plugin in Logstash
50
+
51
+ #### 2.1 Run in a local Logstash clone
52
+
53
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
54
+ ```ruby
55
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
56
+ ```
57
+ - Install plugin
58
+ ```sh
59
+ bin/plugin install --no-verify
60
+ ```
61
+ - Run Logstash with your plugin
62
+ ```sh
63
+ bin/logstash -e 'filter {awesome {}}'
64
+ ```
65
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
66
+
67
+ #### 2.2 Run in an installed Logstash
68
+
69
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
70
+
71
+ - Build your plugin gem
72
+ ```sh
73
+ gem build logstash-filter-awesome.gemspec
74
+ ```
75
+ - Install the plugin from the Logstash home
76
+ ```sh
77
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
78
+ ```
79
+ - Start Logstash and proceed to test the plugin
80
+
81
+ ## Contributing
82
+
83
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
84
+
85
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
86
+
87
+ It is more important to the community that you are able to contribute.
88
+
89
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+
5
+ class LogStash::Filters::Naxsi < LogStash::Filters::Base
6
+
7
+ # Setting the config_name here is required. This is how you
8
+ # configure this filter from your Logstash config.
9
+ #
10
+ # filter {
11
+ # naxsi {}
12
+ # }
13
+ #
14
+ config_name "naxsi"
15
+
16
+ public
17
+ def register
18
+ # Add instance variables
19
+ end # def register
20
+
21
+ public
22
+ def filter(event)
23
+
24
+ # Get all of your idN keys from the event
25
+ ids = event.keys.select { |a| /id\d+/ =~ a }
26
+
27
+ ids.each do |id|
28
+
29
+ new_event = LogStash::Event.new()
30
+
31
+ # Copy all the keys that are not tied to the exceptions
32
+ event.keys.each do |key|
33
+ next if /id\d+|score\d+|var_name\d+|zone\d+|cscore\d+/ =~ key
34
+ new_event[key] = event[key]
35
+ end
36
+
37
+ exception_num = id[-1,1]
38
+
39
+ new_event["exception_num"] = exception_num
40
+
41
+ # Add the properties for the exception
42
+ ["id","score","var_name","zone","cscore"].each do |prop|
43
+ next if event.has_key?(prop + exception_num)
44
+ new_event[prop] = event[prop + exception_num]
45
+ end
46
+
47
+ # Create the new event
48
+ yield new_event
49
+ end
50
+
51
+ # Cancel the original event
52
+ event.cancel
53
+
54
+ # filter_matched should go in the last line of our successful code
55
+ filter_matched(event)
56
+ end # def filter
57
+ end # class LogStash::Filters::Naxsi
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-naxsi'
3
+ s.version = '0.9.0'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "This filter plugin will split a naxsi event into multiple in conjunction with other filters."
6
+ s.description = ""
7
+ s.authors = ["NextGxDx"]
8
+ s.email = 'engineering@nextgxdx.com'
9
+ s.homepage = "https://github.org/nextgxdx/logstash-filter-naxsi"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','Gemfile','LICENSE']
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", ">= 1.4.0"
22
+ s.add_development_dependency 'logstash-devutils'
23
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require "logstash/filters/naxsi"
3
+
4
+ describe LogStash::Filters::Naxsi do
5
+ describe "Split into multiple events" do
6
+ let(:config) do <<-CONFIG
7
+ filter {
8
+ naxsi {}
9
+ }
10
+ CONFIG
11
+ end
12
+
13
+ sample("message" => "some text", "id0" => "1", "id1" => "2") do
14
+ insist { subject.length } == 2
15
+ insist { subject[0]["id"] } == 1
16
+ insist { subject[1]["id"] } == 2
17
+ end
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-naxsi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - NextGxDx
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-06 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: 1.4.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: 1.4.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ name: logstash-devutils
40
+ prerelease: false
41
+ type: :development
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: ''
48
+ email: engineering@nextgxdx.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - Gemfile
54
+ - LICENSE
55
+ - README.md
56
+ - lib/logstash/filters/naxsi.rb
57
+ - logstash-filter-naxsi.gemspec
58
+ - spec/filters/naxsi.rb
59
+ - spec/spec_helper.rb
60
+ homepage: https://github.org/nextgxdx/logstash-filter-naxsi
61
+ licenses:
62
+ - Apache License (2.0)
63
+ metadata:
64
+ logstash_plugin: 'true'
65
+ logstash_group: filter
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.5
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: This filter plugin will split a naxsi event into multiple in conjunction with other filters.
86
+ test_files:
87
+ - spec/filters/naxsi.rb
88
+ - spec/spec_helper.rb