logstash-codec-rfc6587 0.1.0 → 0.1.3

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: 5dd0b560d12d487e1dc9e3f6b8b3cbf9a43587f892a3fac6ba55f933b0c9475b
4
- data.tar.gz: ba87571c3cdb4e1b5dc1f9b119ffb0fa294ddb6397c8be2417c64ba7972d2485
3
+ metadata.gz: e5adb89a59064d2b4fa6c6456fc6316773c7dda6f212c1b5d7da598e861ead16
4
+ data.tar.gz: d4465dde3f19103840dc48a65ed6872c0f3ab222bb94c2e98af1daefc77683a7
5
5
  SHA512:
6
- metadata.gz: '069a119e9bcfb4c608aff665f1b27cebac0c686b3c67baf76456fe32187ec5dfaf6ae4aae1d2bbf14e28cf66cd01a7943decb309e29a6acd950dcd558f42e30f'
7
- data.tar.gz: 97ce3065ac9225881d3cf603387871e8fab660b2a285740824266f9cc2f65bb79ec56bbe0fe53cea1edac3fb54874d3c2d2a4fc591e66996c95bf210902a74e9
6
+ metadata.gz: 83f832296b5189bf89f6c1a1c9006be09d90d7e03572df7e4f2bfcddbb149abc0fa38a6ac04ce1245f09e997985cfe059cc400621f865c4a9fce014127fa2c93
7
+ data.tar.gz: 4cd529e5d4b922fd053fc80a8fe7538fbb3a95f0be1d3a41a446a4dddf0eccd1778e03147d45b78c63326381eda2c9238edc6c5a5eb2d7e28c44fd24c13e6323
@@ -49,6 +49,7 @@ class LogStash::Codecs::Rfc6587 < LogStash::Codecs::Base
49
49
  def read(data)
50
50
  header = ""
51
51
  while c = data.read(1)
52
+ next if ["\0", "\x00"].include?(c) # ignore null characters
52
53
  raise "Unknown header character '#{c}'" if not [@delimiter, nil, c.to_i.to_s].include?(c)
53
54
  header += c if c
54
55
  break if c == @delimiter or data.eof or c == nil
@@ -60,7 +61,8 @@ class LogStash::Codecs::Rfc6587 < LogStash::Codecs::Base
60
61
  end
61
62
 
62
63
  to_read = header.to_i
63
- line = data.gets(to_read)
64
+ line = ""
65
+ to_read.times { line += data.getc }
64
66
 
65
67
  if not line
66
68
  @leftover = header
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-codec-rfc6587'
4
- s.version = '0.1.0'
4
+ s.version = '0.1.3'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Reads lines as described in rfc6587"
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"
8
8
  s.authors = ["Elastic", "ThePsyjo"]
9
9
  s.email = 'info@elastic.co'
10
- s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
10
+ s.homepage = "https://github.com/ThePsyjo/logstash-codec-rfc6587"
11
11
  s.require_paths = ["lib"]
12
12
 
13
13
  # Files
@@ -49,6 +49,7 @@ describe LogStash::Codecs::Rfc6587, :ecs_compatibility_support do
49
49
  #end
50
50
 
51
51
  context "#decode" do
52
+
52
53
  it "should return an event from an ascii string" do
53
54
  decoded = false
54
55
  subject.decode("11 hello world") do |e|
@@ -59,6 +60,42 @@ describe LogStash::Codecs::Rfc6587, :ecs_compatibility_support do
59
60
  insist { decoded } == true
60
61
  end
61
62
 
63
+ it "should return nothing if input data is empty" do
64
+ decoded = false
65
+ subject.decode("") do |e|
66
+ decoded = true
67
+ end
68
+ insist { decoded } == false
69
+ end
70
+
71
+ it "should return nothing if input data is only '\\0' or '\\x00'" do
72
+ decoded = false
73
+ subject.decode("\0\x00") do |e|
74
+ decoded = true
75
+ end
76
+ insist { decoded } == false
77
+ end
78
+
79
+ it "should return an event from an ascii string prefixed with \\0" do
80
+ decoded = false
81
+ subject.decode("\x004 test") do |e|
82
+ decoded = true
83
+ insist { e.is_a?(LogStash::Event) }
84
+ insist { e.get("message") } == "test"
85
+ end
86
+ insist { decoded } == true
87
+ end
88
+
89
+ it "should contain correct results when input contains newline" do
90
+ result = []
91
+ subject.decode("5 line17 line2\n!5 line3") { |e| result << e }
92
+ subject.flush { |e| result << e }
93
+ expect(result.size).to eq(3)
94
+ expect(result[0].get("message")).to eq("line1")
95
+ expect(result[1].get("message")).to eq("line2\n!")
96
+ expect(result[2].get("message")).to eq("line3")
97
+ end
98
+
62
99
  ecs_compatibility_matrix(:disabled, :v1, :v8 => :v1) do |ecs_select|
63
100
 
64
101
  before(:each) do
@@ -109,6 +146,7 @@ describe LogStash::Codecs::Rfc6587, :ecs_compatibility_support do
109
146
  expect(result[1].get("message")).to eq("line2")
110
147
  expect(result[2].get("message")).to eq("line3")
111
148
  end
149
+
112
150
  end
113
151
  end
114
152
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-rfc6587
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-07-06 00:00:00.000000000 Z
12
+ date: 2024-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -21,8 +21,8 @@ dependencies:
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2.99'
23
23
  name: logstash-core-plugin-api
24
- type: :runtime
25
24
  prerelease: false
25
+ type: :runtime
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
@@ -38,8 +38,8 @@ dependencies:
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1.0'
40
40
  name: logstash-mixin-event_support
41
- type: :runtime
42
41
  prerelease: false
42
+ type: :runtime
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
@@ -52,8 +52,8 @@ dependencies:
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.3'
54
54
  name: logstash-mixin-ecs_compatibility_support
55
- type: :runtime
56
55
  prerelease: false
56
+ type: :runtime
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
@@ -66,8 +66,8 @@ dependencies:
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  name: logstash-devutils
69
- type: :development
70
69
  prerelease: false
70
+ type: :development
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -80,8 +80,8 @@ dependencies:
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  name: insist
83
- type: :development
84
83
  prerelease: false
84
+ type: :development
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -105,7 +105,7 @@ files:
105
105
  - lib/logstash/codecs/rfc6587.rb
106
106
  - logstash-codec-rfc6587.gemspec
107
107
  - spec/codecs/rfc6587_spec.rb
108
- homepage: http://www.elastic.co/guide/en/logstash/current/index.html
108
+ homepage: https://github.com/ThePsyjo/logstash-codec-rfc6587
109
109
  licenses:
110
110
  - Apache License (2.0)
111
111
  metadata: