logstash-filter-geoip 7.1.3-java → 7.2.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/docs/index.asciidoc +25 -3
- data/lib/logstash/filters/geoip.rb +32 -23
- data/logstash-filter-geoip.gemspec +3 -1
- data/spec/filters/geoip_offline_spec.rb +16 -0
- data/spec/filters/geoip_online_spec.rb +9 -9
- data/spec/filters/geoip_spec.rb +4 -4
- data/spec/filters/test_helper.rb +8 -2
- data/vendor/jar-dependencies/org/logstash/filters/logstash-filter-geoip/6.0.0/logstash-filter-geoip-6.0.0.jar +0 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 285fa554ef1f4455e341836fd13e7b1af1a07c52b81d41854adfe6640d831eba
|
4
|
+
data.tar.gz: e7dfba0e36f8255f15b27dcc8e55325b273941f277a6b9e3004e2c00e350778c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6495b6e4a085cca0b2e23310621bbd6543ad0118dc3cd35aa97224795a12ff3e3714194460974fb86961e74e2653b3926e2d94b4941a5f80582700319ae73f18
|
7
|
+
data.tar.gz: ce5b1b5bbc3b103de2cb0760bb3ab9d2b125e2d70d92fec20ef8f84b40f9e92cdbaf95ffd0954d7c2eacd85bd3865284a5d021f81e328fa82566dcaf42a0b3ec
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 7.2.1
|
2
|
+
- Republish the gem due to missing jars in 7.2.0 [#186](https://github.com/logstash-plugins/logstash-filter-geoip/pull/186)
|
3
|
+
|
4
|
+
## 7.2.0
|
5
|
+
- YANKED
|
6
|
+
- Add EULA GeoIP2 Database with auto-update [#181](https://github.com/logstash-plugins/logstash-filter-geoip/pull/181)
|
7
|
+
Available in Logstash 7.14+
|
8
|
+
- Support multiple pipelines using the same database
|
9
|
+
- Add EULA doc
|
10
|
+
|
1
11
|
## 7.1.3
|
2
12
|
- Fixed resolving wrong `fields` name `AUTONOMOUS_SYSTEM_NUMBER` and `AUTONOMOUS_SYSTEM_ORGANIZATION` [#185](https://github.com/logstash-plugins/logstash-filter-geoip/pull/185)
|
3
13
|
|
data/docs/index.asciidoc
CHANGED
@@ -37,6 +37,26 @@ can be https://dev.maxmind.com/geoip/geoip2/geolite2[downloaded from here].
|
|
37
37
|
|
38
38
|
If you would like to get Autonomous System Number(ASN) information, you can use the GeoLite2-ASN database.
|
39
39
|
|
40
|
+
[id="plugins-{type}s-{plugin}-database_license"]
|
41
|
+
==== Database License
|
42
|
+
|
43
|
+
https://www.maxmind.com[MaxMind] changed from releasing the GeoIP database under
|
44
|
+
a Creative Commons (CC) license to a proprietary end-user license agreement
|
45
|
+
(EULA). The MaxMind EULA requires Logstash to update the MaxMind database
|
46
|
+
within 30 days of a database update. If Logstash fails to download the database
|
47
|
+
for 30 days, the geoip filter will stop enriching events in order to maintain compliance.
|
48
|
+
Events will be tagged with `_geoip_expired_database` tag to facilitate the handling of this situation.
|
49
|
+
|
50
|
+
The GeoIP filter plugin can manage the database for users running the Logstash default
|
51
|
+
distribution, or you can manage
|
52
|
+
database updates on your own. The behavior is controlled by the `database` setting.
|
53
|
+
When you use the default `database` setting, the auto-update feature ensures that the plugin is
|
54
|
+
using the latest version of the database.
|
55
|
+
Otherwise, you are responsible for maintaining compliance.
|
56
|
+
|
57
|
+
The Logstash open source distribution uses the MaxMind Creative Commons license
|
58
|
+
database by default.
|
59
|
+
|
40
60
|
==== Details
|
41
61
|
|
42
62
|
A `[geoip][location]` field is created if
|
@@ -110,14 +130,16 @@ number of cache misses and waste memory.
|
|
110
130
|
===== `database`
|
111
131
|
|
112
132
|
* Value type is <<path,path>>
|
113
|
-
*
|
133
|
+
* If not specified, the database defaults to the GeoLite2 City database that ships with Logstash.
|
114
134
|
|
115
135
|
The path to MaxMind's database file that Logstash should use. The default database is GeoLite2-City.
|
116
136
|
GeoLite2-City, GeoLite2-Country, GeoLite2-ASN are the free databases from MaxMind that are supported.
|
117
137
|
GeoIP2-City, GeoIP2-ISP, GeoIP2-Country are the commercial databases from MaxMind that are supported.
|
118
138
|
|
119
|
-
|
120
|
-
|
139
|
+
Database auto-update applies to default distribution. When `database` points to user's database path,
|
140
|
+
auto-update will be disabled.
|
141
|
+
See
|
142
|
+
<<plugins-{type}s-{plugin}-database_license,Database License>> for more information.
|
121
143
|
|
122
144
|
[id="plugins-{type}s-{plugin}-default_database_type"]
|
123
145
|
===== `default_database_type`
|
@@ -144,54 +144,63 @@ class LogStash::Filters::GeoIP < LogStash::Filters::Base
|
|
144
144
|
"requires a `target` when `source` is not an `ip` sub-field, eg. [client][ip]")
|
145
145
|
end
|
146
146
|
|
147
|
-
|
148
147
|
def setup_filter(database_path)
|
149
|
-
@healthy_database =
|
148
|
+
@healthy_database = !database_path.nil?
|
149
|
+
return if database_path.nil?
|
150
|
+
|
150
151
|
@database = database_path
|
151
|
-
@logger.info("Using geoip database", :path => @database, :healthy_database => @healthy_database)
|
152
152
|
@geoipfilter = org.logstash.filters.geoip.GeoIPFilter.new(@source, @target, @fields, @database, @cache_size, ecs_compatibility.to_s)
|
153
153
|
end
|
154
154
|
|
155
155
|
# call by DatabaseManager
|
156
|
-
def
|
157
|
-
|
156
|
+
def update_filter(action, *args)
|
157
|
+
@logger.trace("update filter", :action => action, :args => args) if @logger.trace?
|
158
|
+
|
159
|
+
case action
|
160
|
+
when :update
|
161
|
+
setup_filter(*args)
|
162
|
+
when :expire
|
163
|
+
fail_filter
|
164
|
+
else
|
165
|
+
@logger.warn("invalid action: #{action}")
|
166
|
+
end
|
158
167
|
end
|
159
168
|
|
160
169
|
def fail_filter
|
161
170
|
@healthy_database = false
|
162
|
-
@logger.warn("geoip plugin will stop filtering and will tag all events with the '_geoip_expired_database' tag.",
|
163
|
-
:healthy_database => @healthy_database)
|
164
|
-
end
|
165
|
-
|
166
|
-
def terminate_filter
|
167
|
-
@logger.info("geoip plugin is terminating")
|
168
|
-
pipeline_id = execution_context.pipeline_id
|
169
|
-
execution_context.agent.stop_pipeline(pipeline_id)
|
170
171
|
end
|
171
172
|
|
172
173
|
def close
|
173
|
-
@database_manager.
|
174
|
+
@database_manager.unsubscribe_database_path(@default_database_type, self) if @database_manager
|
174
175
|
end
|
175
176
|
|
176
177
|
def select_database_path
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
178
|
+
path =
|
179
|
+
if load_database_manager?
|
180
|
+
@database_manager = LogStash::Filters::Geoip::DatabaseManager.instance
|
181
|
+
@database_manager.subscribe_database_path(@default_database_type, @database, self)
|
182
|
+
else
|
183
|
+
vendor_path = ::File.expand_path(::File.join("..", "..", "..", "..", "vendor"), __FILE__)
|
184
|
+
@database.nil? ? ::File.join(vendor_path, "GeoLite2-#{@default_database_type}.mmdb") : @database
|
185
|
+
end
|
186
|
+
|
187
|
+
@logger.info("Using geoip database", :path => path)
|
188
|
+
path
|
185
189
|
end
|
186
190
|
|
187
191
|
def load_database_manager?
|
188
192
|
begin
|
189
193
|
require_relative ::File.join(LogStash::Environment::LOGSTASH_HOME, "x-pack", "lib", "filters", "geoip", "database_manager")
|
190
|
-
|
194
|
+
compatible_logstash_version?
|
191
195
|
rescue LoadError => e
|
192
196
|
@logger.info("DatabaseManager is not in classpath", :version => LOGSTASH_VERSION, :exception => e)
|
193
197
|
false
|
194
198
|
end
|
195
199
|
end
|
196
200
|
|
201
|
+
MINIMUM_LOGSTASH_VERSION=">= 7.14.0".freeze
|
202
|
+
def compatible_logstash_version?
|
203
|
+
Gem::Requirement.new(MINIMUM_LOGSTASH_VERSION).satisfied_by?(Gem::Version.new(LOGSTASH_VERSION))
|
204
|
+
end
|
205
|
+
|
197
206
|
end # class LogStash::Filters::GeoIP
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-geoip'
|
4
|
-
s.version = '7.1
|
4
|
+
s.version = '7.2.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Adds geographical information about an IP address"
|
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/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -26,4 +26,6 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency 'logstash-devutils'
|
27
27
|
s.add_development_dependency 'insist'
|
28
28
|
s.add_development_dependency 'benchmark-ips'
|
29
|
+
# only compatible with 7.14+ because of the dependency of DatabaseManager
|
30
|
+
s.add_runtime_dependency "logstash-core", ">= 7.14.0"
|
29
31
|
end
|
@@ -195,6 +195,22 @@ describe LogStash::Filters::GeoIP do
|
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
|
+
describe "empty database path" do
|
199
|
+
let(:plugin) { LogStash::Filters::GeoIP.new("source" => "message") }
|
200
|
+
let(:event) { LogStash::Event.new("message" => "8.8.8.8") }
|
201
|
+
|
202
|
+
context "when database manager give nil database path" do
|
203
|
+
it "should tag expired database" do
|
204
|
+
expect(plugin).to receive(:select_database_path).and_return(nil)
|
205
|
+
|
206
|
+
plugin.register
|
207
|
+
plugin.filter(event)
|
208
|
+
|
209
|
+
expect(event.get("tags")).to include("_geoip_expired_database")
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
198
214
|
describe "filter method outcomes" do
|
199
215
|
let(:plugin) { LogStash::Filters::GeoIP.new("source" => "message", "add_tag" => "done", "database" => CITYDB) }
|
200
216
|
let(:event) { LogStash::Event.new("message" => ipstring) }
|
@@ -10,7 +10,7 @@ describe LogStash::Filters::GeoIP do
|
|
10
10
|
::File.delete(METADATA_PATH) if ::File.exist?(METADATA_PATH)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
describe "config without database path in LS >= 7.14", :aggregate_failures do
|
14
14
|
before(:each) do
|
15
15
|
dir_path = Stud::Temporary.directory
|
16
16
|
File.open(dir_path + '/uuid', 'w') { |f| f.write(SecureRandom.uuid) }
|
@@ -33,20 +33,20 @@ describe LogStash::Filters::GeoIP do
|
|
33
33
|
plugin.register
|
34
34
|
plugin.filter(event)
|
35
35
|
plugin.close
|
36
|
-
|
36
|
+
first_dirname = get_metadata_city_database_name
|
37
37
|
plugin.register
|
38
38
|
plugin.filter(event2)
|
39
39
|
plugin.close
|
40
|
-
|
40
|
+
second_dirname = get_metadata_city_database_name
|
41
41
|
|
42
|
-
expect(
|
43
|
-
expect(
|
44
|
-
expect(
|
42
|
+
expect(first_dirname).not_to be_nil
|
43
|
+
expect(first_dirname).to eq(second_dirname)
|
44
|
+
expect(File).to exist(get_file_path(first_dirname))
|
45
45
|
end
|
46
46
|
end
|
47
|
-
end if MAJOR >= 8 || (MAJOR == 7 && MINOR >=
|
47
|
+
end if MAJOR >= 8 || (MAJOR == 7 && MINOR >= 14)
|
48
48
|
|
49
|
-
describe "config without database path in LS < 7.
|
49
|
+
describe "config without database path in LS < 7.14" do
|
50
50
|
context "should run in offline mode" do
|
51
51
|
config <<-CONFIG
|
52
52
|
filter {
|
@@ -61,5 +61,5 @@ describe LogStash::Filters::GeoIP do
|
|
61
61
|
expect(::File.exist?(METADATA_PATH)).to be_falsey
|
62
62
|
end
|
63
63
|
end
|
64
|
-
end if MAJOR < 7 || (MAJOR == 7 && MINOR
|
64
|
+
end if MAJOR < 7 || (MAJOR == 7 && MINOR < 14)
|
65
65
|
end
|
data/spec/filters/geoip_spec.rb
CHANGED
@@ -19,13 +19,13 @@ describe LogStash::Filters::GeoIP do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe "
|
22
|
+
describe ">= 7.14" do
|
23
23
|
it "load_database_manager? should be true" do
|
24
24
|
expect(plugin.load_database_manager?).to be_truthy
|
25
25
|
end
|
26
|
-
end if MAJOR >= 8 || (MAJOR == 7 && MINOR >=
|
26
|
+
end if MAJOR >= 8 || (MAJOR == 7 && MINOR >= 14)
|
27
27
|
|
28
|
-
describe "<= 7.
|
28
|
+
describe "<= 7.13" do
|
29
29
|
it "load_database_manager? should be false" do
|
30
30
|
expect(plugin.load_database_manager?).to be_falsey
|
31
31
|
end
|
@@ -37,6 +37,6 @@ describe LogStash::Filters::GeoIP do
|
|
37
37
|
expect(plugin.select_database_path).to eql(DEFAULT_CITY_DB_PATH)
|
38
38
|
end
|
39
39
|
end
|
40
|
-
end if MAJOR < 7 || (MAJOR == 7 && MINOR <=
|
40
|
+
end if MAJOR < 7 || (MAJOR == 7 && MINOR <= 13)
|
41
41
|
end
|
42
42
|
end
|
data/spec/filters/test_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "logstash-core/logstash-core"
|
2
2
|
require "digest"
|
3
|
+
require "csv"
|
3
4
|
|
4
5
|
def get_vendor_path(filename)
|
5
6
|
::File.join(::File.expand_path("../../vendor/", ::File.dirname(__FILE__)), filename)
|
@@ -13,8 +14,13 @@ def get_file_path(filename)
|
|
13
14
|
::File.join(get_data_dir, filename)
|
14
15
|
end
|
15
16
|
|
16
|
-
def
|
17
|
-
::File.exist?(METADATA_PATH)
|
17
|
+
def get_metadata_city_database_name
|
18
|
+
if ::File.exist?(METADATA_PATH)
|
19
|
+
city = ::CSV.read(METADATA_PATH, headers: false).select { |row| row[0].eql?("City") }.last
|
20
|
+
city[3]
|
21
|
+
else
|
22
|
+
nil
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
METADATA_PATH = get_file_path("metadata.csv")
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-geoip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.1
|
4
|
+
version: 7.2.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 7.14.0
|
95
|
+
name: logstash-core
|
96
|
+
prerelease: false
|
97
|
+
type: :runtime
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 7.14.0
|
89
103
|
description: This gem is a Logstash plugin required to be installed on top of the
|
90
104
|
Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
|
91
105
|
gem is not a stand-alone program
|