logstash-filter-csv 3.1.0 → 3.1.1

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: 61380dfaee5f7c768ba33dbeb372644941053ccf3694c441b5f6bc5b7758af46
4
- data.tar.gz: c9a4bfd2b2a2c0f4d4ccac90ba8d01722a5ed7833294e8cb749f1b4c2685d2ba
3
+ metadata.gz: bf9f8d4119cd1f50a3456eecc603223146a3a8af699161e69620830e94a89bd2
4
+ data.tar.gz: 955a26060fa7c92bdbc4f00b632e8c33ef2ade7ed54d03084503666d5f89a583
5
5
  SHA512:
6
- metadata.gz: 472e1b1028701925b45aaa1990349cd6f277326e1151ba8eaacc7d48125d67528f8873c08bab7698237cdb1e35eaf39506de51623758327f91a29af36f4059f1
7
- data.tar.gz: 0cc77c798c6fa3319f63aa4c9d56314686fa5bab7f6cbb0d6f221532e2007aacc1545235bfbe37fb3822125b62201bd78ef7fd3e6d48732e18f7d1990674db7b
6
+ metadata.gz: 8439e88c6dac47b52866730cb04c015cb1e88f439316063da35fb9264383ac7e177d45801aa0da64756b79bbfeee5d6ee0bbd31bc04b2e33475f839288b4da36
7
+ data.tar.gz: ce650dfb546568cd8983d4949662739fbe794b097ea391b4a20b0d46d2d793ad2090e9b212248def1d32721baf26f364c2a5d4e69275a0eef4e1f959b386dd05
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.1.1
2
+ - Refactor: unified ECS target + validate field reference [#86](https://github.com/logstash-plugins/logstash-filter-csv/pull/86)
3
+
1
4
  ## 3.1.0
2
5
  - Add ECS support [#85](https://github.com/logstash-plugins/logstash-filter-csv/pull/85)
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.0
1
+ 3.1.1
@@ -1,7 +1,9 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/filters/base"
3
3
  require "logstash/namespace"
4
- require "logstash/plugin_mixins/ecs_compatibility_support"
4
+ require 'logstash/plugin_mixins/ecs_compatibility_support'
5
+ require 'logstash/plugin_mixins/ecs_compatibility_support/target_check'
6
+ require 'logstash/plugin_mixins/validator_support/field_reference_validation_adapter'
5
7
 
6
8
  require "csv"
7
9
 
@@ -10,6 +12,9 @@ require "csv"
10
12
  # This filter can also parse data with any separator, not just commas.
11
13
  class LogStash::Filters::CSV < LogStash::Filters::Base
12
14
  include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled, :v1, :v8 => :v1)
15
+ include LogStash::PluginMixins::ECSCompatibilitySupport::TargetCheck
16
+
17
+ extend LogStash::PluginMixins::ValidatorSupport::FieldReferenceValidationAdapter
13
18
 
14
19
  config_name "csv"
15
20
 
@@ -38,7 +43,7 @@ class LogStash::Filters::CSV < LogStash::Filters::Base
38
43
 
39
44
  # Define target field for placing the data.
40
45
  # Defaults to writing to the root of the event.
41
- config :target, :validate => :string
46
+ config :target, :validate => :field_reference
42
47
 
43
48
  # Define whether column names should autogenerated or not.
44
49
  # Defaults to true. If set to false, columns not having a header specified will not be parsed.
@@ -105,15 +110,6 @@ class LogStash::Filters::CSV < LogStash::Filters::Base
105
110
  CONVERTERS.default = lambda {|v| v}
106
111
  CONVERTERS.freeze
107
112
 
108
- def initialize(params)
109
- super
110
- if ecs_compatibility != :disabled && @target.nil?
111
- logger.info('ECS compatibility is enabled but no ``target`` option was specified, it is recommended'\
112
- ' to set the option to avoid potential schema conflicts (if your data is ECS compliant or'\
113
- ' non-conflicting feel free to ignore this message)')
114
- end
115
- end
116
-
117
113
  def register
118
114
  # validate conversion types to be the valid ones.
119
115
  bad_types = @convert.values.select do |type|
@@ -125,7 +121,7 @@ class LogStash::Filters::CSV < LogStash::Filters::Base
125
121
  # @convert_symbols contains the symbolized types to avoid symbol conversion in the transform method
126
122
  @convert_symbols = @convert.inject({}){|result, (k, v)| result[k] = v.to_sym; result}
127
123
 
128
- # make sure @target is in the format [field name] if defined, i.e. surrounded by brakets
124
+ # make sure @target is in the format [field name] if defined, i.e. surrounded by brackets
129
125
  @target = "[#{@target}]" if @target && !@target.start_with?("[")
130
126
 
131
127
  # if the zero byte character is entered in the config, set the value
@@ -137,7 +133,7 @@ class LogStash::Filters::CSV < LogStash::Filters::Base
137
133
  end
138
134
 
139
135
  def filter(event)
140
- @logger.debug? && @logger.debug("Running csv filter", :event => event)
136
+ @logger.debug? && @logger.debug("Running csv filter", :event => event.to_hash)
141
137
 
142
138
  if (source = event.get(@source))
143
139
  begin
@@ -178,7 +174,7 @@ class LogStash::Filters::CSV < LogStash::Filters::Base
178
174
  end
179
175
  end
180
176
 
181
- @logger.debug? && @logger.debug("Event after csv filter", :event => event)
177
+ @logger.debug? && @logger.debug("Event after csv filter", :event => event.to_hash)
182
178
  end
183
179
 
184
180
  private
@@ -23,7 +23,9 @@ Gem::Specification.new do |s|
23
23
 
24
24
  # Gem dependencies
25
25
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
26
+ s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~> 1.3'
27
+ s.add_runtime_dependency 'logstash-mixin-validator_support', '~> 1.0'
28
+
26
29
  s.add_development_dependency 'logstash-devutils'
27
- s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.2'
28
30
  end
29
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-03 00:00:00.000000000 Z
11
+ date: 2021-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -33,31 +33,45 @@ dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
- - - ">="
36
+ - - "~>"
37
37
  - !ruby/object:Gem::Version
38
- version: '0'
39
- name: logstash-devutils
38
+ version: '1.3'
39
+ name: logstash-mixin-ecs_compatibility_support
40
40
  prerelease: false
41
- type: :development
41
+ type: :runtime
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: '1.3'
47
47
  - !ruby/object:Gem::Dependency
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '1.2'
53
- name: logstash-mixin-ecs_compatibility_support
52
+ version: '1.0'
53
+ name: logstash-mixin-validator_support
54
54
  prerelease: false
55
55
  type: :runtime
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1.2'
60
+ version: '1.0'
61
+ - !ruby/object:Gem::Dependency
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ name: logstash-devutils
68
+ prerelease: false
69
+ type: :development
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
61
75
  description: This gem is a Logstash plugin required to be installed on top of the
62
76
  Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
63
77
  gem is not a stand-alone program