logstash-filter-private_geoip 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTORS +11 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +10 -1
- data/LICENSE +2 -2
- data/NOTICE.TXT +5 -0
- data/README.md +96 -47
- data/lib/logstash/filters/private_geoip.rb +6 -5
- data/logstash-filter-private_geoip.gemspec +4 -8
- data/spec/filters/private_geoip_spec.rb +5 -3
- data/spec/spec_helper.rb +2 -0
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 317a05ecd4529d3cbb0a12eed49ae8537e9e09c816826f1826f93214bba1523d
|
4
|
+
data.tar.gz: 6de06e1a7ae9dfc300c26dfb3e8eae846ae237649a190310e3dca2a4db8fb1c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b554b60402c1bdd8bc349cc868bf729c7d964205b2788cb8bcb6fa38702de9f3ad69dd0631710b9373493ede45778eb7ad66269a2599545a99ac04c6c1462111
|
7
|
+
data.tar.gz: 51233d074eb95064e99a8e130d6d633897c15fe703f1e0beefd8672cf2c451059bed070e73703e95dd6255baa3d3a39f2940c40f976322fb5bdea78913b48569
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
## 3.0.2
|
2
|
+
- Docs: Add documentation template
|
3
|
+
## 2.0.0
|
4
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
5
|
+
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
6
|
+
- Dependency on logstash-core update to 2.0
|
7
|
+
|
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/DEVELOPER.md
ADDED
data/Gemfile
CHANGED
@@ -1,2 +1,11 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
|
6
|
+
use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
|
7
|
+
|
8
|
+
if Dir.exist?(logstash_path) && use_logstash_source
|
9
|
+
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
|
10
|
+
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
|
11
|
+
end
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
|
2
2
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
you may not use this file except in compliance with the License.
|
@@ -10,4 +10,4 @@ Unless required by applicable law or agreed to in writing, software
|
|
10
10
|
distributed under the License is distributed on an "AS IS" BASIS,
|
11
11
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
See the License for the specific language governing permissions and
|
13
|
-
limitations under the License.
|
13
|
+
limitations under the License.
|
data/NOTICE.TXT
ADDED
data/README.md
CHANGED
@@ -1,49 +1,98 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
[![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-private_geoip.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-private_geoip)
|
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 build documentation for this plugin. We provide a template file, index.asciidoc, where you can add documentation. The contents of this file will be converted into html and then placed with other plugin documentation in a [central location](http://www.elastic.co/guide/en/logstash/current/).
|
12
|
+
|
13
|
+
- For formatting config examples, you can use the asciidoc `[source,json]` 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=private_geoip).
|
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-private_geoip", :path => "/your/local/logstash-filter-private_geoip"
|
55
|
+
```
|
56
|
+
- Install plugin
|
45
57
|
```sh
|
46
|
-
|
47
|
-
|
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 {private_geoip {}}'
|
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-private_geoip.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.
|
48
97
|
|
49
|
-
|
98
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -5,6 +5,7 @@ require "logstash/namespace"
|
|
5
5
|
# The Private GeoIP filter add information about local private IP addresses
|
6
6
|
# This is a CIDR filter on steroids
|
7
7
|
|
8
|
+
|
8
9
|
class LogStash::Filters::PrivateGeoIP < LogStash::Filters::Base
|
9
10
|
config_name "private_geoip"
|
10
11
|
|
@@ -49,7 +50,7 @@ class LogStash::Filters::PrivateGeoIP < LogStash::Filters::Base
|
|
49
50
|
|
50
51
|
public
|
51
52
|
def filter(event)
|
52
|
-
ip = IP::Address::Util.string_to_ip(event
|
53
|
+
ip = IP::Address::Util.string_to_ip(event.get(@source))
|
53
54
|
|
54
55
|
matched_cidr_data = {}
|
55
56
|
|
@@ -62,18 +63,18 @@ class LogStash::Filters::PrivateGeoIP < LogStash::Filters::Base
|
|
62
63
|
|
63
64
|
return if matched_cidr_data.nil? || matched_cidr_data.empty?
|
64
65
|
|
65
|
-
geo_data = event
|
66
|
+
geo_data = event.get(@target).nil? ? {} : event.get(@target)
|
66
67
|
|
67
68
|
if @merge
|
68
69
|
geo_data.merge!(matched_cidr_data)
|
69
|
-
geo_data['ip'] = event
|
70
|
+
geo_data['ip'] = event.get(@source)
|
70
71
|
else
|
71
72
|
add_keys = matched_cidr_data.keys - geo_data.keys
|
72
73
|
geo_data.merge!(matched_cidr_data.select{|k,v| add_keys.include?(k)})
|
73
74
|
end
|
74
75
|
|
75
|
-
event
|
76
|
+
event.set(@target, geo_data)
|
76
77
|
|
77
78
|
filter_matched(event)
|
78
79
|
end
|
79
|
-
end
|
80
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-private_geoip'
|
4
|
-
s.version = '1.
|
4
|
+
s.version = '1.1.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "$summary"
|
7
7
|
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"
|
@@ -12,7 +12,6 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
# Files
|
14
14
|
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
15
|
-
|
16
15
|
# Tests
|
17
16
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
17
|
|
@@ -20,10 +19,7 @@ Gem::Specification.new do |s|
|
|
20
19
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
|
21
20
|
|
22
21
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency "logstash-core",
|
24
|
-
#s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
|
22
|
+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
25
23
|
s.add_runtime_dependency 'ip', "0.3.1"
|
26
|
-
|
27
|
-
|
28
|
-
s.add_development_dependency 'logstash-devutils', '~> 0'
|
29
|
-
end
|
24
|
+
s.add_development_dependency 'logstash-devutils'
|
25
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require "logstash/devutils/rspec/spec_helper"
|
2
4
|
require "logstash/filters/private_geoip"
|
3
5
|
require 'pp'
|
@@ -91,7 +93,7 @@ describe LogStash::Filters::PrivateGeoIP do
|
|
91
93
|
|
92
94
|
sample(sample_data) do
|
93
95
|
#insist {subject}.include?("geoip")
|
94
|
-
insist {subject
|
96
|
+
insist {subject.get("geoip")["city_name"]} == "KULASSOC"
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
@@ -132,9 +134,9 @@ describe LogStash::Filters::PrivateGeoIP do
|
|
132
134
|
sample(sample_data) do
|
133
135
|
insist {subject}.include?("geoip")
|
134
136
|
reject {subject}.include?("private_geoip")
|
135
|
-
insist {subject
|
137
|
+
insist {subject.get("geoip")["city_name"]} == "Leuven"
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
139
141
|
|
140
|
-
end
|
142
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-private_geoip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehmet Celik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- -
|
16
|
+
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 2.0.0
|
22
|
-
name: logstash-core
|
18
|
+
version: '2.0'
|
19
|
+
name: logstash-core-plugin-api
|
23
20
|
prerelease: false
|
24
21
|
type: :runtime
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.4.0
|
30
|
-
- - <
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: 2.0
|
26
|
+
version: '2.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
35
29
|
requirements:
|
@@ -47,7 +41,7 @@ dependencies:
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
requirement: !ruby/object:Gem::Requirement
|
49
43
|
requirements:
|
50
|
-
- -
|
44
|
+
- - ">="
|
51
45
|
- !ruby/object:Gem::Version
|
52
46
|
version: '0'
|
53
47
|
name: logstash-devutils
|
@@ -55,22 +49,29 @@ dependencies:
|
|
55
49
|
type: :development
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
|
-
- -
|
52
|
+
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
54
|
version: '0'
|
61
|
-
description: This gem is a logstash plugin required to be installed on top of the
|
55
|
+
description: This gem is a logstash plugin required to be installed on top of the
|
56
|
+
Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
|
57
|
+
a stand-alone program
|
62
58
|
email: mehmet.celik@kuleuven.libis.be
|
63
59
|
executables: []
|
64
60
|
extensions: []
|
65
61
|
extra_rdoc_files: []
|
66
62
|
files:
|
63
|
+
- CHANGELOG.md
|
64
|
+
- CONTRIBUTORS
|
65
|
+
- DEVELOPER.md
|
67
66
|
- Gemfile
|
68
67
|
- LICENSE
|
68
|
+
- NOTICE.TXT
|
69
69
|
- README.md
|
70
70
|
- lib/logstash/filters/private_geoip.rb
|
71
71
|
- logstash-filter-private_geoip.gemspec
|
72
72
|
- spec/filters/private_geoip_spec.rb
|
73
73
|
- spec/resources/cidr.json
|
74
|
+
- spec/spec_helper.rb
|
74
75
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
75
76
|
licenses:
|
76
77
|
- Apache License (2.0)
|
@@ -83,20 +84,21 @@ require_paths:
|
|
83
84
|
- lib
|
84
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
86
|
requirements:
|
86
|
-
- -
|
87
|
+
- - ">="
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
version: '0'
|
89
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
91
|
requirements:
|
91
|
-
- -
|
92
|
+
- - ">="
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
96
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.7.6
|
97
98
|
signing_key:
|
98
99
|
specification_version: 4
|
99
|
-
summary: $summary
|
100
|
+
summary: "$summary"
|
100
101
|
test_files:
|
101
102
|
- spec/filters/private_geoip_spec.rb
|
102
103
|
- spec/resources/cidr.json
|
104
|
+
- spec/spec_helper.rb
|