Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a panic when dealing with remaining at the end of a delimiter #7449

Merged
merged 2 commits into from
Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ https://github.com/elastic/beats/compare/v6.2.3...master[Check the HEAD diff]
- Allow to override the `ignore_above` option when defining new field with the type keyword. {pull}7238[7238]
- Allow index-pattern only setup when setup.dashboards.only_index=true. {pull}7285[7285]
- Fix duplicating dynamic_fields in template when overwriting the template. {pull}7352[7352]
- Fix a panic on the Dissect processor when we have data remaining after the last delimiter. {pull}7449[7449]

*Auditbeat*

Expand Down
3 changes: 2 additions & 1 deletion libbeat/processors/dissect/dissect.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func (d *Dissector) extract(s string) (positions, error) {
dl = dl.Next()
}

if offset < len(s) {
// If we have remaining contents and have not captured all the requested fields
if offset < len(s) && i < len(d.parser.fields) {
positions[i] = position{start: offset, end: len(s)}
}
return positions, nil
Expand Down
11 changes: 11 additions & 0 deletions libbeat/processors/dissect/dissect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ type dissectTest struct {
}

var tests = []dissectTest{
{
Name: "When all the defined fields are captured by we have remaining data",
Tok: "level=%{level} ts=%{timestamp} caller=%{caller} msg=\"%{message}\"",
Msg: "level=info ts=2018-06-27T17:19:13.036579993Z caller=main.go:222 msg=\"Starting OK\" version=\"(version=2.3.1, branch=HEAD, revision=188ca45bd85ce843071e768d855722a9d9dabe03)\"}",
Expected: Map{
"level": "info",
"timestamp": "2018-06-27T17:19:13.036579993Z",
"caller": "main.go:222",
"message": "Starting OK",
},
},
{
Name: "Complex stack trace",
Tok: "%{day}-%{month}-%{year} %{hour} %{severity} [%{thread_id}] %{origin} %{message}",
Expand Down