logstash-filter-dns 3.0.11 → 3.0.12

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
  SHA256:
3
- metadata.gz: e49f024b4c80ef883b2293e4360c9bc8db1fed00f341291097372d0e43fda374
4
- data.tar.gz: 6560e0fb3de4628f6cc40250d82c0de7d2a80db8116aeb66acfb43b7c2d994ea
3
+ metadata.gz: 2fecd0c2688b23a9c5da63dc4ac117c8f4e76868772fdf70ac0ec0372b8898e5
4
+ data.tar.gz: b57f5fe1078cafdd5581d3b2b4f2c00ddb77d6880648b6f83b28d0ed36acb86f
5
5
  SHA512:
6
- metadata.gz: 3c5f59c303e6cf2a5631c132d1d51c37cd1423f021acb79988a233652e1401a0a9bb2cbe5dfd9bb692ab7a981d3f85720552f6acecea6ad022f6c6643b953782
7
- data.tar.gz: 95fa82bd33893694c0bd091a5e79969c4d1f1400b30cdba790fbdb33870dc081e38a34edbad0b0914dddb916b9e32299b40312cc1e92dacdbea538b2e303ad88
6
+ metadata.gz: 95fb7b4dc6a26a12aee442d2f191d040090ee9b705acf6e5b07d4aca927d406a3ac2997306a00424d9e5083fbe26459bcfb2c76df10a9b22fb085a1756787c7a
7
+ data.tar.gz: 9efb520db0550bec7401aee447d4f283c10884110020ea44fb873fec5f58c6a36fbb09cfeaa5dcc93283dbc92ef78a277e2c8d01c76d7853756883fcbdd63af7
@@ -1,3 +1,7 @@
1
+ ## 3.0.12
2
+ - Fixed issue where unqualified domains would fail to resolve when running this plugin with Logstash 5.x [#48](https://github.com/logstash-plugins/logstash-filter-dns/pull/48)
3
+ - Fixed crash that could occur when encountering certain classes of invalid inputs [#49](https://github.com/logstash-plugins/logstash-filter-dns/pull/49)
4
+
1
5
  ## 3.0.11
2
6
  - Fixed JRuby resolver bug for versions prior to 9.1.16.0 [#45](https://github.com/logstash-plugins/logstash-filter-dns/pull/45)
3
7
 
@@ -4,7 +4,7 @@ require "logstash/namespace"
4
4
  require "lru_redux"
5
5
  require "resolv"
6
6
  require "timeout"
7
- require "logstash/filters/resolv_patch"
7
+ require "logstash/filters/dns/resolv_patch"
8
8
 
9
9
  java_import 'java.net.IDN'
10
10
 
@@ -166,6 +166,14 @@ class LogStash::Filters::DNS < LogStash::Filters::Base
166
166
  @logger.error("DNS: Encountered SocketError.",
167
167
  :field => field, :value => raw, :message => e.message)
168
168
  return
169
+ rescue Java::JavaLang::IllegalArgumentException => e
170
+ @logger.error("DNS: Unable to parse address.",
171
+ :field => field, :value => raw, :message => e.message)
172
+ return
173
+ rescue => e
174
+ @logger.error("DNS: Unexpected Error.",
175
+ :field => field, :value => raw, :message => e.message)
176
+ return
169
177
  end
170
178
 
171
179
  if @action == "replace"
@@ -238,6 +246,14 @@ class LogStash::Filters::DNS < LogStash::Filters::Base
238
246
  @logger.error("DNS: Encountered SocketError.",
239
247
  :field => field, :value => raw, :message => e.message)
240
248
  return
249
+ rescue Java::JavaLang::IllegalArgumentException => e
250
+ @logger.error("DNS: Unable to parse address.",
251
+ :field => field, :value => raw, :message => e.message)
252
+ return
253
+ rescue => e
254
+ @logger.error("DNS: Unexpected Error.",
255
+ :field => field, :value => raw, :message => e.message)
256
+ return
241
257
  end
242
258
 
243
259
  if @action == "replace"
@@ -1,5 +1,7 @@
1
1
  require "resolv"
2
2
 
3
+ jruby_gem_version = Gem::Version.new(JRUBY_VERSION)
4
+
3
5
  # ref: https://github.com/logstash-plugins/logstash-filter-dns/issues/40
4
6
  #
5
7
  # JRuby 9k versions prior to 9.1.16.0 have a bug which crashes IP address
@@ -10,10 +12,7 @@ require "resolv"
10
12
  #
11
13
  # The code below is copied from JRuby 9.1.16.0 resolv.rb:
12
14
  # https://github.com/jruby/jruby/blob/9.1.16.0/lib/ruby/stdlib/resolv.rb#L775-L784
13
-
14
- JRUBY_GEM_VERSION = Gem::Version.new(JRUBY_VERSION)
15
-
16
- if JRUBY_GEM_VERSION >= Gem::Version.new("9.1.13.0") && JRUBY_GEM_VERSION < Gem::Version.new("9.1.16.0")
15
+ if jruby_gem_version >= Gem::Version.new("9.1.13.0") && jruby_gem_version < Gem::Version.new("9.1.16.0")
17
16
  class Resolv
18
17
  class DNS
19
18
  class Requester
@@ -32,4 +31,29 @@ if JRUBY_GEM_VERSION >= Gem::Version.new("9.1.13.0") && JRUBY_GEM_VERSION < Gem:
32
31
  end
33
32
  end
34
33
  end
35
- end
34
+ end
35
+
36
+ # JRuby 1.x ships with a Ruby stdlib that has a bug in its resolv implementation
37
+ # in which it fails to correctly canonicalise unqualified or underqualified
38
+ # domains (e.g., domain names with fewer than the configured ndots, which defaults
39
+ # to 1).
40
+ #
41
+ # See: https://bugs.ruby-lang.org/issues/10412
42
+ #
43
+ # Conditionally apply the patch to the method definition by wrapping it at runtime.
44
+ if jruby_gem_version < Gem::Version.new("9.0")
45
+ class Resolv::DNS
46
+ class Config
47
+ alias generate_candidates_without_toplevel generate_candidates
48
+ def generate_candidates_with_toplevel(name)
49
+ candidates = generate_candidates_without_toplevel(name)
50
+ fname = Name.create("#{name}.")
51
+ if !candidates.include?(fname)
52
+ candidates << fname
53
+ end
54
+ candidates
55
+ end
56
+ alias generate_candidates generate_candidates_with_toplevel
57
+ end
58
+ end
59
+ end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-dns'
4
- s.version = '3.0.11'
4
+ s.version = '3.0.12'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Performs a standard or reverse DNS lookup"
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"
@@ -389,6 +389,14 @@ describe LogStash::Filters::DNS do
389
389
  end
390
390
  end
391
391
 
392
+ context 'with a label too long' do
393
+ let(:host) { "#{'0' * 64}.com" }
394
+
395
+ it 'should not raise' do
396
+ subject.filter(event)
397
+ end
398
+ end
399
+
392
400
  context "when failing temporarily" do
393
401
  before(:each) do
394
402
  allow(subject).to receive(:getaddress) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.11
4
+ version: 3.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-18 00:00:00.000000000 Z
11
+ date: 2019-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ files:
74
74
  - README.md
75
75
  - docs/index.asciidoc
76
76
  - lib/logstash/filters/dns.rb
77
- - lib/logstash/filters/resolv_patch.rb
77
+ - lib/logstash/filters/dns/resolv_patch.rb
78
78
  - logstash-filter-dns.gemspec
79
79
  - spec/filters/dns_spec.rb
80
80
  - spec/fixtures/hosts