logstash-filter-cidr 3.0.0-java

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: fc20034061b8c2ea9294b5884d653114da871e01
4
+ data.tar.gz: 4999e731e86f0fdd83980cd2ae823467e15dbace
5
+ SHA512:
6
+ metadata.gz: 396dafe3c78338f3872aa1676e90708e61f9e9e6636c5f7b2e3bbcb1a69cbbbd2bad017f7e6231e7b59fd8d699f53830c828ca8fd137b15d329aee2684aa5f29
7
+ data.tar.gz: a7f534efc92e10580b5bd05089671f4823e917338b0506a3bd099e0a8f906a331cbd38b7ddc1c16dcd1c1b561607168dca89a99290e0ee3be6e896a679e4a6af
@@ -0,0 +1,13 @@
1
+ ## 3.0.0
2
+ - breaking: Updated plugin to use new Java Event APIs
3
+
4
+ ## 2.0.4
5
+ - internal,deps: Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
6
+
7
+ ## 2.0.3
8
+ - internal,deps: New dependency requirements for logstash-core for the 5.0 release
9
+
10
+ ## 2.0.0
11
+ - internal: Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
12
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
13
+ - internal,deps: Dependency on logstash-core update to 2.0
@@ -0,0 +1,18 @@
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
+ Maintainers:
5
+ * Magnus Bäck (magnusbaeck)
6
+
7
+ Contributors:
8
+ * Aaron Mildenstein (untergeek)
9
+ * Jordan Sissel (jordansissel)
10
+ * Matt Dainty (bodgit)
11
+ * Pier-Hugues Pellerin (ph)
12
+ * Richard Pijnenburg (electrical)
13
+ * Suyog Rao (suyograo)
14
+
15
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
16
+ Logstash, and you aren't on the list above and want to be, please let us know
17
+ and we'll make sure you're here. Contributions from folks like you are what make
18
+ open source awesome.
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–2016 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.
@@ -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/).
@@ -0,0 +1,98 @@
1
+ # Logstash Plugin
2
+
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-cidr.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-cidr)
4
+
5
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
+
7
+ 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.
8
+
9
+ ## Documentation
10
+
11
+ 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/).
12
+
13
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
14
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
15
+
16
+ ## Need Help?
17
+
18
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
19
+
20
+ ## Developing
21
+
22
+ ### 1. Plugin Developement and Testing
23
+
24
+ #### Code
25
+ - To get started, you'll need JRuby with the Bundler gem installed.
26
+
27
+ - 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).
28
+
29
+ - Install dependencies
30
+ ```sh
31
+ bundle install
32
+ ```
33
+
34
+ #### Test
35
+
36
+ - Update your dependencies
37
+
38
+ ```sh
39
+ bundle install
40
+ ```
41
+
42
+ - Run tests
43
+
44
+ ```sh
45
+ bundle exec rspec
46
+ ```
47
+
48
+ ### 2. Running your unpublished Plugin in Logstash
49
+
50
+ #### 2.1 Run in a local Logstash clone
51
+
52
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
53
+ ```ruby
54
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
55
+ ```
56
+ - Install plugin
57
+ ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
62
+ bin/plugin install --no-verify
63
+
64
+ ```
65
+ - Run Logstash with your plugin
66
+ ```sh
67
+ bin/logstash -e 'filter {awesome {}}'
68
+ ```
69
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
70
+
71
+ #### 2.2 Run in an installed Logstash
72
+
73
+ 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:
74
+
75
+ - Build your plugin gem
76
+ ```sh
77
+ gem build logstash-filter-awesome.gemspec
78
+ ```
79
+ - Install the plugin from the Logstash home
80
+ ```sh
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
87
+ ```
88
+ - Start Logstash and proceed to test the plugin
89
+
90
+ ## Contributing
91
+
92
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
93
+
94
+ 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.
95
+
96
+ It is more important to the community that you are able to contribute.
97
+
98
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,74 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+ require "ipaddr"
5
+
6
+
7
+ # The CIDR filter is for checking IP addresses in events against a list of
8
+ # network blocks that might contain it. Multiple addresses can be checked
9
+ # against multiple networks, any match succeeds. Upon success additional tags
10
+ # and/or fields can be added to the event.
11
+
12
+ class LogStash::Filters::CIDR < LogStash::Filters::Base
13
+
14
+ config_name "cidr"
15
+
16
+ # The IP address(es) to check with. Example:
17
+ # [source,ruby]
18
+ # filter {
19
+ # %PLUGIN% {
20
+ # add_tag => [ "testnet" ]
21
+ # address => [ "%{src_ip}", "%{dst_ip}" ]
22
+ # network => [ "192.0.2.0/24" ]
23
+ # }
24
+ # }
25
+ config :address, :validate => :array, :default => []
26
+
27
+ # The IP network(s) to check against. Example:
28
+ # [source,ruby]
29
+ # filter {
30
+ # %PLUGIN% {
31
+ # add_tag => [ "linklocal" ]
32
+ # address => [ "%{clientip}" ]
33
+ # network => [ "169.254.0.0/16", "fe80::/64" ]
34
+ # }
35
+ # }
36
+ config :network, :validate => :array, :default => []
37
+
38
+ public
39
+ def register
40
+ # Nothing
41
+ end # def register
42
+
43
+ public
44
+ def filter(event)
45
+ address = @address.collect do |a|
46
+ begin
47
+ IPAddr.new(event.sprintf(a))
48
+ rescue ArgumentError => e
49
+ @logger.warn("Invalid IP address, skipping", :address => a, :event => event)
50
+ nil
51
+ end
52
+ end
53
+ address.compact!
54
+
55
+ network = @network.collect do |n|
56
+ begin
57
+ IPAddr.new(event.sprintf(n))
58
+ rescue ArgumentError => e
59
+ @logger.warn("Invalid IP network, skipping", :network => n, :event => event)
60
+ nil
61
+ end
62
+ end
63
+ network.compact!
64
+
65
+ # Try every combination of address and network, first match wins
66
+ address.product(network).each do |a, n|
67
+ @logger.debug("Checking IP inclusion", :address => a, :network => n)
68
+ if n.include?(a)
69
+ filter_matched(event)
70
+ return
71
+ end
72
+ end
73
+ end # def filter
74
+ end # class LogStash::Filters::CIDR
@@ -0,0 +1,28 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-filter-cidr'
4
+ s.version = '3.0.0'
5
+ s.platform = 'java'
6
+ s.licenses = ['Apache License (2.0)']
7
+ s.summary = "The CIDR filter is for checking IP addresses in events against a list of network blocks that might contain it."
8
+ s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
9
+ s.authors = ["Elastic"]
10
+ s.email = 'info@elastic.co'
11
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
12
+ s.require_paths = ["lib"]
13
+
14
+ # Files
15
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
16
+
17
+ # Tests
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+
20
+ # Special flag to let us know this is actually a logstash plugin
21
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
22
+
23
+ # Gem dependencies
24
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
25
+
26
+ s.add_development_dependency 'logstash-devutils'
27
+ end
28
+
@@ -0,0 +1,106 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/filters/cidr"
3
+
4
+ describe LogStash::Filters::CIDR do
5
+
6
+ # IPV4
7
+ describe "IPV4 match test" do
8
+ config <<-CONFIG
9
+ filter {
10
+ cidr {
11
+ address => [ "%{clientip}" ]
12
+ network => [ "192.168.0.0/24" ]
13
+ add_tag => [ "matched" ]
14
+ }
15
+ }
16
+ CONFIG
17
+
18
+ sample("clientip" => "192.168.0.30") do
19
+ insist { subject.get("tags") }.include?("matched")
20
+ end
21
+ end
22
+
23
+ describe "IPV4 non match" do
24
+ config <<-CONFIG
25
+ filter {
26
+ cidr {
27
+ address => [ "%{clientip}" ]
28
+ network => [ "192.168.0.0/24" ]
29
+ add_tag => [ "matched" ]
30
+ }
31
+ }
32
+ CONFIG
33
+
34
+ sample("clientip" => "123.52.122.33") do
35
+ insist { subject.get("tags") }.nil?
36
+ end
37
+ end
38
+
39
+ # Test multple CIDR blocks passed into 'network'. Make sure we try an
40
+ # IP in every range.
41
+
42
+ describe "IPV4 match, passing a list to network [192.168.0.30]" do
43
+ config <<-CONFIG
44
+ filter {
45
+ cidr {
46
+ address => [ "%{clientip}"]
47
+ network => [ "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
48
+ add_tag => [ "matched" ]
49
+ }
50
+ }
51
+ CONFIG
52
+
53
+ sample("clientip" => "192.168.0.30") do
54
+ insist { subject.get("tags") }.include?("matched")
55
+ end
56
+
57
+ sample("clientip" => "10.10.220.3") do
58
+ insist { subject.get("tags") }.include?("matched")
59
+ end
60
+
61
+ sample("clientip" => "172.16.45.50") do
62
+ insist { subject.get("tags") }.include?("matched")
63
+ end
64
+
65
+ # No match
66
+ sample("clientip" => "8.8.8.8") do
67
+ insist { subject.get("tags") }.nil?
68
+ end
69
+
70
+ end
71
+
72
+ # IPV6
73
+
74
+ describe "IPV6 match test" do
75
+ config <<-CONFIG
76
+ filter {
77
+ cidr {
78
+ address => [ "%{clientip}" ]
79
+ network => [ "fe80::/64" ]
80
+ add_tag => [ "matched" ]
81
+ }
82
+ }
83
+ CONFIG
84
+
85
+ sample("clientip" => "fe80:0:0:0:0:0:0:1") do
86
+ insist { subject.get("tags") }.include?("matched")
87
+ end
88
+ end
89
+
90
+ describe "IPV6 non match" do
91
+ config <<-CONFIG
92
+ filter {
93
+ cidr {
94
+ address => [ "%{clientip}" ]
95
+ network => [ "fe80::/64" ]
96
+ add_tag => [ "matched" ]
97
+ }
98
+ }
99
+ CONFIG
100
+
101
+ sample("clientip" => "fd82:0:0:0:0:0:0:1") do
102
+ insist { subject.get("tags") }.nil?
103
+ end
104
+ end
105
+
106
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-cidr
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ platform: java
6
+ authors:
7
+ - Elastic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-24 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: '1.60'
19
+ - - "<="
20
+ - !ruby/object:Gem::Version
21
+ version: '2.99'
22
+ name: logstash-core-plugin-api
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.60'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: '2.99'
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: This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
48
+ email: info@elastic.co
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - CHANGELOG.md
54
+ - CONTRIBUTORS
55
+ - Gemfile
56
+ - LICENSE
57
+ - NOTICE.TXT
58
+ - README.md
59
+ - lib/logstash/filters/cidr.rb
60
+ - logstash-filter-cidr.gemspec
61
+ - spec/filters/cidr_spec.rb
62
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
63
+ licenses:
64
+ - Apache License (2.0)
65
+ metadata:
66
+ logstash_plugin: 'true'
67
+ logstash_group: filter
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.4.8
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: The CIDR filter is for checking IP addresses in events against a list of network blocks that might contain it.
88
+ test_files:
89
+ - spec/filters/cidr_spec.rb