logstash-filter-geoip 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30e2584417507ee61d735a0ac1561cd3da49f425
4
- data.tar.gz: b336ef9064c855a6c85b3dfd186e2525296f4a2d
3
+ metadata.gz: 4cb9d672a670ac659f61fa7604bc57274eabd759
4
+ data.tar.gz: d697817443b57ce1ef55e4dbdd19caf657e90cc6
5
5
  SHA512:
6
- metadata.gz: 697448b24bbf6be8bb130d39833b1ebc121ef4899af5a679407710fa4b317beb2dcd45163dc69f14d05d0e7058bc6f20180ea1db03a9d7d2eefead1570b5cc20
7
- data.tar.gz: ee3689eb177b71a8a737a9b40e366d42fca22b3e72f3aa3ea513d916007ceed90eb61f4b0b4a4d58190b3bfd875cc78205d1a34677fc286a2c41c65a88daaba8
6
+ metadata.gz: 95c606eb5c2df267eb7476b91247bf14e9c4758ea1c27b720342fc6d624091473b754c11cf1b42ed13204e321910e288f17bc95e90e61fe4abd3a2e73083c213
7
+ data.tar.gz: 62ba7bd2e0a890969d6e2ca3c1a0575ab1ccdd8e84232d468bee03bcab0294e4d9850d889160ec5973093313cd6263ab4554897d47fe8c15400b2208bfdc886b
data/README.md CHANGED
@@ -37,6 +37,12 @@ bundle install
37
37
  bundle install
38
38
  ```
39
39
 
40
+ - Pull down GeoIP database files
41
+
42
+ ```sh
43
+ bundle exec rake vendor
44
+ ```
45
+
40
46
  - Run tests
41
47
 
42
48
  ```sh
@@ -109,9 +109,9 @@ class LogStash::Filters::GeoIP < LogStash::Filters::Base
109
109
  ip = ip.first if ip.is_a? Array
110
110
  geo_data = Thread.current[@threadkey].send(@geoip_type, ip)
111
111
  rescue SocketError => e
112
- @logger.error("IP Field contained invalid IP address or hostname", :field => @field, :event => event)
112
+ @logger.error("IP Field contained invalid IP address or hostname", :field => @source, :event => event)
113
113
  rescue Exception => e
114
- @logger.error("Unknown error while looking up GeoIP data", :exception => e, :field => @field, :event => event)
114
+ @logger.error("Unknown error while looking up GeoIP data", :exception => e, :field => @source, :event => event)
115
115
  end
116
116
 
117
117
  return if geo_data.nil? || !geo_data.respond_to?(:to_hash)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-geoip'
4
- s.version = '1.0.1'
4
+ s.version = '1.0.2'
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"
@@ -171,4 +171,56 @@ describe LogStash::Filters::GeoIP do
171
171
  it_behaves_like "an event with a [geoip][location] field"
172
172
  end
173
173
  end
174
+
175
+ describe "an invalid IP" do
176
+ config <<-CONFIG
177
+ filter {
178
+ geoip {
179
+ source => "ip"
180
+ database => "#{ASNDB}"
181
+ }
182
+ }
183
+ CONFIG
184
+
185
+ context "should not raise an error" do
186
+ sample("ip" => "-") do
187
+ expect{
188
+ subject
189
+ }.to_not raise_error
190
+ end
191
+
192
+ sample("ip" => "~") do
193
+ expect{
194
+ subject
195
+ }.to_not raise_error
196
+ end
197
+ end
198
+
199
+ context "should return the correct source field in the logging message" do
200
+ sample("ip" => "-") do
201
+ expect(LogStash::Filters::GeoIP.logger).to receive(:error).with(anything, include(:field => "ip"))
202
+ subject
203
+ end
204
+ end
205
+
206
+ end
207
+
208
+ describe "an invalid database" do
209
+ config <<-CONFIG
210
+ filter {
211
+ geoip {
212
+ source => "ip"
213
+ database => "./Gemfile"
214
+ }
215
+ }
216
+ CONFIG
217
+
218
+ context "should return the correct sourcefield in the logging message" do
219
+ sample("ip" => "8.8.8.8") do
220
+ expect(LogStash::Filters::GeoIP.logger).to receive(:error).with(anything, include(:field => "ip"))
221
+ subject
222
+ end
223
+ end
224
+
225
+ end
174
226
  end
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-30 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core