logstash-output-elasticsearch 9.3.0-java → 9.3.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c6ed2c43c43667688e700d6f8db2b714b865a5653c0fc8892a8de479857397d
4
- data.tar.gz: bf24c972d847db154b5feb1290341e92b53fdbf5673ea7916d651b77633f9e30
3
+ metadata.gz: d94e36b467260ee9b470252edef5d67e3d1915a1f1e5d3c7edac1dec879de06d
4
+ data.tar.gz: 65a256a1b84f2f1ae8de8915423cb3c7e32a756428d2f1110fcaa36e9175181e
5
5
  SHA512:
6
- metadata.gz: 51939e7522f9370efdc381bf5d981c0efb7a42aa9fc68a873c2281eba9bd4497ec63c40ac951c1b1f2c9c65398073632b13a9870dad05a6d15685dae7c9c6e38
7
- data.tar.gz: 18b48cd4103103fcf957718afcaa5f24cfdf429e5ce5949a16a6674ea79035c4801f53049bda2d2a6693469abaf9bb5699547301705961d51159383b1c05a96a
6
+ metadata.gz: 19f7d8f5ac61a23caf78d0fa919e7a99b35b491a505620f00f3699a5112a38d64c0599f4db543fd9a90e51286393db1ce8e980d5bec0e49ca3d14f7218657def
7
+ data.tar.gz: ab59d63c93734f63f33d3750bdbd873976f637c57155787c2ebb0aef2459573ba07d74bc85deff9242dfb2bfb144080e56e721117f55fa626beb30b75ddfe126
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 9.3.1
2
+ - Fixed issue with escaping index names which was causing writing aliases for ILM to fail [#831](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/831)
3
+
1
4
  ## 9.3.0
2
5
  - Adds support for Index Lifecycle Management for Elasticsearch 6.6.0 and above, running with at least a Basic License(Beta) [#805](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/805)
3
6
 
@@ -65,8 +65,8 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
65
65
  end
66
66
 
67
67
  request_uri = format_url(url, path)
68
-
69
- resp = @manticore.send(method.downcase, request_uri.to_s, params)
68
+ request_uri_as_string = remove_double_escaping(request_uri.to_s)
69
+ resp = @manticore.send(method.downcase, request_uri_as_string, params)
70
70
 
71
71
  # Manticore returns lazy responses by default
72
72
  # We want to block for our usage, this will wait for the repsonse
@@ -83,6 +83,7 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
83
83
  resp
84
84
  end
85
85
 
86
+ # Returned urls from this method should be checked for double escaping.
86
87
  def format_url(url, path_and_query=nil)
87
88
  request_uri = url.clone
88
89
 
@@ -92,23 +93,33 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
92
93
  request_uri.password = nil
93
94
 
94
95
  return request_uri.to_s if path_and_query.nil?
95
-
96
+
96
97
  parsed_path_and_query = java.net.URI.new(path_and_query)
97
-
98
+
98
99
  query = request_uri.query
99
100
  parsed_query = parsed_path_and_query.query
100
-
101
+
101
102
  new_query_parts = [request_uri.query, parsed_path_and_query.query].select do |part|
102
103
  part && !part.empty? # Skip empty nil and ""
103
104
  end
104
105
 
105
106
  request_uri.query = new_query_parts.join("&") unless new_query_parts.empty?
106
107
 
108
+ # use `raw_path`` as `path` will unescape any escaped '/' in the path
107
109
  request_uri.path = "#{request_uri.path}/#{parsed_path_and_query.raw_path}".gsub(/\/{2,}/, "/")
108
-
109
110
  request_uri
110
111
  end
111
112
 
113
+ # Later versions of SafeURI will also escape the '%' sign in an already escaped URI.
114
+ # (If the path variable is used, it constructs a new java.net.URI object using the multi-arg constructor,
115
+ # which will escape any '%' characters in the path, as opposed to the single-arg constructor which requires illegal
116
+ # characters to be already escaped, and will throw otherwise)
117
+ # The URI needs to have been previously escaped, as it does not play nice with an escaped '/' in the
118
+ # middle of a URI, as required by date math, treating it as a path separator
119
+ def remove_double_escaping(url)
120
+ url.gsub(/%25([0-9A-F]{2})/i, '%\1')
121
+ end
122
+
112
123
  def close
113
124
  @manticore.close
114
125
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-elasticsearch'
3
- s.version = '9.3.0'
3
+ s.version = '9.3.1'
4
4
  s.licenses = ['apache-2.0']
5
5
  s.summary = "Stores logs in Elasticsearch"
6
6
  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"
@@ -30,13 +30,19 @@ module ESHelper
30
30
  Time.now.strftime("%Y.%m.%d")
31
31
  end
32
32
 
33
- def mapping_name
33
+
34
+ def default_mapping_from_mappings(mappings)
34
35
  if ESHelper.es_version_satisfies?(">=7")
35
- "_doc"
36
+ mappings
36
37
  else
37
- "_default_"
38
+ mappings["_default_"]
38
39
  end
40
+ end
39
41
 
42
+ def field_properties_from_template(template_name, field)
43
+ mappings = @es.indices.get_template(name: template_name)[template_name]["mappings"]
44
+ mapping = default_mapping_from_mappings(mappings)
45
+ mapping["properties"][field]["properties"]
40
46
  end
41
47
 
42
48
  def routing_field_name
@@ -76,7 +76,15 @@ if ESHelper.es_version_satisfies?(">= 5.6")
76
76
 
77
77
  shared_examples "a join field based parent indexer" do
78
78
  let(:index) { 10.times.collect { rand(10).to_s }.join("") }
79
- let(:type) { 10.times.collect { rand(10).to_s }.join("") }
79
+
80
+ let(:type) do
81
+ if ESHelper.es_version_satisfies?('<7')
82
+ 10.times.collect { rand(10).to_s }.join("")
83
+ else
84
+ "_doc"
85
+ end
86
+ end
87
+
80
88
  let(:event_count) { 10000 + rand(500) }
81
89
  let(:parent) { "not_implemented" }
82
90
  let(:config) { "not_implemented" }
@@ -82,7 +82,7 @@ if ESHelper.es_version_satisfies?(">= 5")
82
82
  end
83
83
 
84
84
  it "make [geoip][location] a geo_point" do
85
- expect(@es.indices.get_template(name: "logstash")["logstash"]["mappings"][mapping_name]["properties"]["geoip"]["properties"]["location"]["type"]).to eq("geo_point")
85
+ expect(field_properties_from_template("logstash", "geoip")["location"]["type"]).to eq("geo_point")
86
86
  end
87
87
 
88
88
  it "aggregate .keyword results correctly " do
@@ -102,6 +102,7 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::ManticoreAdapter do
102
102
 
103
103
  it "should add the path correctly" do
104
104
  expect(formatted.path).to eq("#{url.path}special_bulk")
105
+ expect(subject.remove_double_escaping(formatted.path)).to eq("#{url.path}special_bulk")
105
106
  end
106
107
 
107
108
  it "should add the query parameters correctly" do
@@ -117,6 +118,26 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::ManticoreAdapter do
117
118
  expect(formatted.userinfo).to be_nil
118
119
  end
119
120
  end
121
+
122
+ context 'when uri contains date math' do
123
+ let(:url) { ::LogStash::Util::SafeURI.new("http://localhost:9200") }
124
+ let(:path) { CGI.escape("<logstash-{now/d}-0001>") }
125
+ let(:formatted) { subject.format_url(url, path) }
126
+
127
+ it 'should escape the uri correctly' do
128
+ expect(subject.remove_double_escaping(formatted.path)).to eq("/%3Clogstash-%7Bnow%2Fd%7D-0001%3E")
129
+ end
130
+ end
131
+
132
+ context 'when uri does not contain date math' do
133
+ let(:url) { ::LogStash::Util::SafeURI.new("http://localhost:9200") }
134
+ let(:path) { CGI.escape("logstash-0001") }
135
+ let(:formatted) { subject.format_url(url, path) }
136
+
137
+ it 'should escape the uri correctly' do
138
+ expect(subject.remove_double_escaping(formatted.path)).to eq("/logstash-0001")
139
+ end
140
+ end
120
141
  end
121
142
 
122
143
  describe "integration specs", :integration => true do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.3.0
4
+ version: 9.3.1
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-18 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement