logstash-input-file 4.1.16 → 4.1.17

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: dfc29a2b231d1d04667f304746d22fd1beec91cabeb8f6e05772395bc45e86a5
4
- data.tar.gz: 952de67a21b89420a91e787935ed0617a798a4c738632f0870d1c54c1162b110
3
+ metadata.gz: cdb425f23de3ef4ccd1a1358ce48789001145a9a4620405bac4dc6a75d2b7f69
4
+ data.tar.gz: b7c856e75936d99912a8a517b81e23be1603e4032a255e6340b2c4da7faa6639
5
5
  SHA512:
6
- metadata.gz: 10b29419ea0fd69945fd0f9634d1a5c247516c14cec0b2d22e48155d4a53e71fd83551ffdd8df3dbff71e560bd5ba649deed94c549be92f582d05ec36c329ce1
7
- data.tar.gz: 16b160f663671c865c72a09b991c6f58bc915b29266d21ffa9f2c5130f62ad1feb469d9cb850f7997cd5bd6a8ae261e24920892ec27cc1ae6196dd4bf93e2b9a
6
+ metadata.gz: d0641b7f747964983a6f2e3b8c68a19efc74bb085e6a635cc110cd8d1c43efe330a899a951933f228cf59015785cc00730bd196a84a63dd36241045d36614ebf
7
+ data.tar.gz: 834e9ad07ed15beaee47e0cd3d6d6f5e5494e41a6d5a2f4871f79df4d63837ef3c480f033eaac0d092794f4c0a36fe4d3466728d98cf2ad55ac564cd8dec0f4f
@@ -1,3 +1,10 @@
1
+ ## 4.1.17
2
+ - Added configuration setting `check_archive_validity` settings to enable
3
+ gzipped files verification, issue
4
+ [#261](https://github.com/logstash-plugins/logstash-input-file/issues/261)
5
+ - [DOC] Added clarification for settings available with `read` mode [#235](https://github.com/logstash-plugins/logstash-input-file/pull/235)
6
+ - [DOC] Rearranged text and fixed formatting for `mode` setting [266](https://github.com/logstash-plugins/logstash-input-file/pull/266)
7
+
1
8
  ## 4.1.16
2
9
  - Added configuration setting exit_after_read to read to EOF and terminate
3
10
  the input [#240](https://github.com/logstash-plugins/logstash-input-file/pull/240)
data/LICENSE CHANGED
@@ -1,13 +1,202 @@
1
- Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
2
1
 
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
6
5
 
7
- http://www.apache.org/licenses/LICENSE-2.0
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
7
 
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2020 Elastic and contributors
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -164,6 +164,7 @@ see <<plugins-{type}s-{plugin}-string_duration,string_duration>> for the details
164
164
  [cols="<,<,<",options="header",]
165
165
  |=======================================================================
166
166
  |Setting |Input type|Required
167
+ | <<plugins-{type}s-{plugin}-check_archive_validity>> |<<boolean,boolean>>|No
167
168
  | <<plugins-{type}s-{plugin}-close_older>> |<<number,number>> or <<plugins-{type}s-{plugin}-string_duration,string_duration>>|No
168
169
  | <<plugins-{type}s-{plugin}-delimiter>> |<<string,string>>|No
169
170
  | <<plugins-{type}s-{plugin}-discover_interval>> |<<number,number>>|No
@@ -191,6 +192,20 @@ input plugins.
191
192
 
192
193
  &nbsp;
193
194
 
195
+ [id="plugins-{type}s-{plugin}-check_archive_validity"]
196
+ ===== `check_archive_validity`
197
+
198
+ * Value type is <<boolean,boolean>>
199
+ * The default is `false`.
200
+
201
+ When set to `true`, this setting verifies that a compressed file is valid before
202
+ processing it. There are two passes through the file--one pass to
203
+ verify that the file is valid, and another pass to process the file.
204
+
205
+ Validating a compressed file requires more processing time, but can prevent a
206
+ corrupt archive from causing looping.
207
+
208
+
194
209
  [id="plugins-{type}s-{plugin}-close_older"]
195
210
  ===== `close_older`
196
211
 
@@ -355,16 +370,17 @@ A default of 4095 is set in internally.
355
370
 
356
371
  What mode do you want the file input to operate in. Tail a few files or
357
372
  read many content-complete files. Read mode now supports gzip file processing.
358
- If "read" is specified then the following other settings are ignored:
359
373
 
360
- . `start_position` (files are always read from the beginning)
361
- . `close_older` (files are automatically 'closed' when EOF is reached)
374
+ If `read` is specified, these settings can be used:
375
+
376
+ * `ignore_older` (older files are not processed)
377
+ * `file_completed_action` (what action should be taken when the file is processed)
378
+ * `file_completed_log_path` (which file should the completed file path be logged to)
362
379
 
363
- If "read" is specified then the following settings are heeded:
380
+ If `read` is specified, these settings are ignored:
364
381
 
365
- . `ignore_older` (older files are not processed)
366
- . `file_completed_action` (what action should be taken when the file is processed)
367
- . `file_completed_log_path` (which file should the completed file path be logged to)
382
+ * `start_position` (files are always read from the beginning)
383
+ * `close_older` (files are automatically 'closed' when EOF is reached)
368
384
 
369
385
  [id="plugins-{type}s-{plugin}-path"]
370
386
  ===== `path`
@@ -18,34 +18,40 @@ module FileWatch module ReadMode module Handlers
18
18
  # fast forward through the lines until we reach unseen content?
19
19
  # meaning that we can quit in the middle of a zip file
20
20
  key = watched_file.sincedb_key
21
- begin
22
- file_stream = FileInputStream.new(watched_file.path)
23
- gzip_stream = GZIPInputStream.new(file_stream)
24
- decoder = InputStreamReader.new(gzip_stream, "UTF-8")
25
- buffered = BufferedReader.new(decoder)
26
- while (line = buffered.readLine(false))
27
- watched_file.listener.accept(line)
28
- # can't quit, if we did then we would incorrectly write a 'completed' sincedb entry
29
- # what do we do about quit when we have just begun reading the zipped file (e.g. pipeline reloading)
30
- # should we track lines read in the sincedb and
31
- # fast forward through the lines until we reach unseen content?
32
- # meaning that we can quit in the middle of a zip file
33
- end
34
- watched_file.listener.eof
35
- rescue ZipException => e
36
- logger.error("Cannot decompress the gzip file at path: #{watched_file.path}")
37
- watched_file.listener.error
38
- else
39
- sincedb_collection.store_last_read(key, watched_file.last_stat_size)
40
- sincedb_collection.request_disk_flush
41
- watched_file.listener.deleted
21
+
22
+ if @settings.check_archive_validity && corrupted?(watched_file)
42
23
  watched_file.unwatch
43
- ensure
44
- # rescue each close individually so all close attempts are tried
45
- close_and_ignore_ioexception(buffered) unless buffered.nil?
46
- close_and_ignore_ioexception(decoder) unless decoder.nil?
47
- close_and_ignore_ioexception(gzip_stream) unless gzip_stream.nil?
48
- close_and_ignore_ioexception(file_stream) unless file_stream.nil?
24
+ else
25
+ begin
26
+ file_stream = FileInputStream.new(watched_file.path)
27
+ gzip_stream = GZIPInputStream.new(file_stream)
28
+ decoder = InputStreamReader.new(gzip_stream, "UTF-8")
29
+ buffered = BufferedReader.new(decoder)
30
+ while (line = buffered.readLine(false))
31
+ watched_file.listener.accept(line)
32
+ # can't quit, if we did then we would incorrectly write a 'completed' sincedb entry
33
+ # what do we do about quit when we have just begun reading the zipped file (e.g. pipeline reloading)
34
+ # should we track lines read in the sincedb and
35
+ # fast forward through the lines until we reach unseen content?
36
+ # meaning that we can quit in the middle of a zip file
37
+ end
38
+ watched_file.listener.eof
39
+ rescue ZipException => e
40
+ logger.error("Cannot decompress the gzip file at path: #{watched_file.path}", :exception => e.class,
41
+ :message => e.message, :backtrace => e.backtrace)
42
+ watched_file.listener.error
43
+ else
44
+ sincedb_collection.store_last_read(key, watched_file.last_stat_size)
45
+ sincedb_collection.request_disk_flush
46
+ watched_file.listener.deleted
47
+ watched_file.unwatch
48
+ ensure
49
+ # rescue each close individually so all close attempts are tried
50
+ close_and_ignore_ioexception(buffered) unless buffered.nil?
51
+ close_and_ignore_ioexception(decoder) unless decoder.nil?
52
+ close_and_ignore_ioexception(gzip_stream) unless gzip_stream.nil?
53
+ close_and_ignore_ioexception(file_stream) unless file_stream.nil?
54
+ end
49
55
  end
50
56
  sincedb_collection.clear_watched_file(key)
51
57
  end
@@ -56,7 +62,28 @@ module FileWatch module ReadMode module Handlers
56
62
  begin
57
63
  closeable.close
58
64
  rescue Exception => e # IOException can be thrown by any of the Java classes that implement the Closable interface.
59
- logger.warn("Ignoring an IOException when closing an instance of #{closeable.class.name}", "exception" => e)
65
+ logger.warn("Ignoring an IOException when closing an instance of #{closeable.class.name}",
66
+ :exception => e.class, :message => e.message, :backtrace => e.backtrace)
67
+ end
68
+ end
69
+
70
+ def corrupted?(watched_file)
71
+ begin
72
+ file_stream = FileInputStream.new(watched_file.path)
73
+ gzip_stream = GZIPInputStream.new(file_stream)
74
+ buffer = Java::byte[8192].new
75
+ start = Time.new
76
+ until gzip_stream.read(buffer) == -1
77
+ end
78
+ return false
79
+ rescue ZipException => e
80
+ duration = Time.now - start
81
+ logger.warn("Detected corrupted archive #{watched_file.path} file won't be processed", :message => e.message,
82
+ :duration => duration.round(3))
83
+ return true
84
+ ensure
85
+ close_and_ignore_ioexception(gzip_stream) unless gzip_stream.nil?
86
+ close_and_ignore_ioexception(file_stream) unless file_stream.nil?
60
87
  end
61
88
  end
62
89
  end
@@ -9,6 +9,7 @@ module FileWatch
9
9
  attr_reader :sincedb_path, :sincedb_write_interval, :sincedb_expiry_duration
10
10
  attr_reader :file_sort_by, :file_sort_direction
11
11
  attr_reader :exit_after_read
12
+ attr_reader :check_archive_validity
12
13
 
13
14
  def self.from_options(opts)
14
15
  new.add_options(opts)
@@ -52,6 +53,7 @@ module FileWatch
52
53
  @file_sort_by = @opts[:file_sort_by]
53
54
  @file_sort_direction = @opts[:file_sort_direction]
54
55
  @exit_after_read = @opts[:exit_after_read]
56
+ @check_archive_validity = @opts[:check_archive_validity]
55
57
  self
56
58
  end
57
59
 
Binary file
@@ -227,6 +227,11 @@ class File < LogStash::Inputs::Base
227
227
  # Sincedb still works, if you run LS once again after doing some changes - only new values will be read
228
228
  config :exit_after_read, :validate => :boolean, :default => false
229
229
 
230
+ # Before start read a compressed file, checks for its validity.
231
+ # This request a full read of the archive, so potentially could cost time.
232
+ # If not specified to true, and the file is corrupted, could end in cyclic processing of the broken file.
233
+ config :check_archive_validity, :validate => :boolean, :default => false
234
+
230
235
  public
231
236
 
232
237
  class << self
@@ -266,6 +271,7 @@ class File < LogStash::Inputs::Base
266
271
  :file_sort_by => @file_sort_by,
267
272
  :file_sort_direction => @file_sort_direction,
268
273
  :exit_after_read => @exit_after_read,
274
+ :check_archive_validity => @check_archive_validity,
269
275
  }
270
276
 
271
277
  @completed_file_handlers = []
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-file'
4
- s.version = '4.1.16'
4
+ s.version = '4.1.17'
5
5
  s.licenses = ['Apache-2.0']
6
6
  s.summary = "Streams events from files"
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"
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  s.add_runtime_dependency 'logstash-codec-multiline', ['~> 3.0']
35
35
 
36
36
  s.add_development_dependency 'stud', ['~> 0.0.19']
37
- s.add_development_dependency 'logstash-devutils', '~> 1.3'
37
+ s.add_development_dependency 'logstash-devutils'
38
38
  s.add_development_dependency 'logstash-codec-json'
39
39
  s.add_development_dependency 'rspec-sequencing'
40
40
  s.add_development_dependency "rspec-wait"
@@ -73,7 +73,8 @@ module FileWatch
73
73
  FileUtils.mv(directory.join("1.logtmp").to_path, file1_path)
74
74
  end
75
75
  .then("wait for expectation") do
76
- wait(2).for{listener1.calls}.to eq([:open, :accept, :accept, :accept])
76
+ sleep(0.25) # if ENV['CI']
77
+ wait(2).for { listener1.calls }.to eq([:open, :accept, :accept, :accept])
77
78
  end
78
79
  .then("quit") do
79
80
  tailing.quit
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require "rspec_sequencing"
3
- # require 'rspec/wait'
3
+ require 'rspec/wait'
4
4
  require "logstash/devutils/rspec/spec_helper"
5
5
  require "concurrent"
6
6
  require "timecop"
@@ -16,6 +16,13 @@ module FileInput
16
16
  ::File.utime(time, time, path)
17
17
  end
18
18
 
19
+ def self.corrupt_gzip(file_path)
20
+ f = File.open(file_path, "w")
21
+ f.seek(12)
22
+ f.puts 'corrupting_string'
23
+ f.close()
24
+ end
25
+
19
26
  class TracerBase
20
27
  def initialize
21
28
  @tracer = Concurrent::Array.new
@@ -70,7 +70,7 @@ describe LogStash::Inputs::File do
70
70
  end
71
71
 
72
72
  events = input(conf) do |pipeline, queue|
73
- wait(0.5).for{IO.read(log_completed_path)}.to match(/A\.log/)
73
+ wait(0.75).for { IO.read(log_completed_path) }.to match(/A\.log/)
74
74
  2.times.collect { queue.pop }
75
75
  end
76
76
  expect(events.map{|e| e.get("message")}).to contain_exactly("hello", "world")
@@ -137,7 +137,7 @@ describe LogStash::Inputs::File do
137
137
  CONFIG
138
138
 
139
139
  events = input(conf) do |pipeline, queue|
140
- wait(0.5).for{IO.read(log_completed_path)}.to match(/#{file_path.to_s}/)
140
+ wait(0.75).for { IO.read(log_completed_path) }.to match(/#{file_path.to_s}/)
141
141
  2.times.collect { queue.pop }
142
142
  end
143
143
 
@@ -171,7 +171,7 @@ describe LogStash::Inputs::File do
171
171
  CONFIG
172
172
 
173
173
  events = input(conf) do |pipeline, queue|
174
- wait(0.5).for{IO.read(log_completed_path)}.to match(/uncompressed\.log/)
174
+ wait(0.75).for{ IO.read(log_completed_path) }.to match(/uncompressed\.log/)
175
175
  2.times.collect { queue.pop }
176
176
  end
177
177
 
@@ -205,7 +205,7 @@ describe LogStash::Inputs::File do
205
205
  CONFIG
206
206
 
207
207
  events = input(conf) do |pipeline, queue|
208
- wait(0.5).for{IO.read(log_completed_path).scan(/compressed\.log\.gz(ip)?/).size}.to eq(2)
208
+ wait(0.75).for { IO.read(log_completed_path).scan(/compressed\.log\.gz(ip)?/).size }.to eq(2)
209
209
  4.times.collect { queue.pop }
210
210
  end
211
211
 
@@ -214,6 +214,37 @@ describe LogStash::Inputs::File do
214
214
  expect(events[2].get("message")).to start_with("2010-03-12 23:51")
215
215
  expect(events[3].get("message")).to start_with("2010-03-12 23:51")
216
216
  end
217
+
218
+ it "the corrupted file is untouched" do
219
+ directory = Stud::Temporary.directory
220
+ file_path = fixture_dir.join('compressed.log.gz')
221
+ corrupted_file_path = ::File.join(directory, 'corrupted.gz')
222
+ FileUtils.cp(file_path, corrupted_file_path)
223
+
224
+ FileInput.corrupt_gzip(corrupted_file_path)
225
+
226
+ log_completed_path = ::File.join(directory, "C_completed.txt")
227
+ f = File.new(log_completed_path, "w")
228
+ f.close()
229
+
230
+ conf = <<-CONFIG
231
+ input {
232
+ file {
233
+ type => "blah"
234
+ path => "#{corrupted_file_path}"
235
+ mode => "read"
236
+ file_completed_action => "log_and_delete"
237
+ file_completed_log_path => "#{log_completed_path}"
238
+ check_archive_validity => true
239
+ }
240
+ }
241
+ CONFIG
242
+
243
+ events = input(conf) do |pipeline, queue|
244
+ wait(1)
245
+ expect(IO.read(log_completed_path)).to be_empty
246
+ end
247
+ end
217
248
  end
218
249
  end
219
250
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require "helpers/spec_helper"
4
+ require "logstash/devutils/rspec/shared_examples"
4
5
  require "logstash/inputs/file"
5
6
 
6
7
  require "tempfile"
@@ -66,7 +67,7 @@ describe LogStash::Inputs::File do
66
67
  path => "#{path_path}"
67
68
  start_position => "beginning"
68
69
  sincedb_path => "#{sincedb_path}"
69
- "file_sort_by" => "path"
70
+ file_sort_by => "path"
70
71
  delimiter => "#{TEST_FILE_DELIMITER}"
71
72
  }
72
73
  }
@@ -175,7 +176,7 @@ describe LogStash::Inputs::File do
175
176
  context "when sincedb_path is a directory" do
176
177
  let(:name) { "E" }
177
178
  subject { LogStash::Inputs::File.new("path" => path_path, "sincedb_path" => directory) }
178
-
179
+
179
180
  after :each do
180
181
  FileUtils.rm_rf(sincedb_path)
181
182
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.16
4
+ version: 4.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-20 00:00:00.000000000 Z
11
+ date: 2020-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -89,17 +89,17 @@ dependencies:
89
89
  - !ruby/object:Gem::Dependency
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - "~>"
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
- version: '1.3'
94
+ version: '0'
95
95
  name: logstash-devutils
96
96
  prerelease: false
97
97
  type: :development
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: '1.3'
102
+ version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  requirement: !ruby/object:Gem::Requirement
105
105
  requirements: