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

[7.17](backport #30658) Fix dissect trim panics from DELETE (\u007f) character #30866

Merged
merged 2 commits into from
Mar 17, 2022
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
2 changes: 1 addition & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix the ability for subcommands to be ran properly from the beats containers. {pull}30452[30452]
- Log errors when parsing and applying config blocks and if the input is disabled. {pull}30534[30534]
- Fixes Beats crashing when glibc >= 2.35 is used {issue}30576[30576]

- Fix dissect trim panics from DELETE (127)(\u007f) character {issue}30657[30657] {pull}30658[30658]

*Auditbeat*

Expand Down
2 changes: 1 addition & 1 deletion libbeat/processors/dissect/trim.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func newTrimmer(trimChars string, trimLeft, trimRight bool) (t trimmer, err erro
}

type asciiTrimmer struct {
chars [127]byte
chars [asciiLimit]byte
left, right bool
}

Expand Down
40 changes: 40 additions & 0 deletions libbeat/processors/dissect/trim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,46 @@ func TestTrimmer(t *testing.T) {
input: "\t\t༄𑅀߹꧁߹𑁍 ÿ",
expected: "༄𑅀߹꧁߹𑁍",
},
{ // demonstrates that unicode \u is converted to char in golang strings
name: "trim ASCII TILDE",
cutset: " ",
left: true,
right: true,
input: " hello world! \u007e ",
expected: "hello world! ~",
},
{
name: "trim ASCII DELETE",
cutset: " ",
left: true,
right: true,
input: " hello world! \u007f ",
expected: "hello world! \u007f",
},
{
name: "trim UTF-8 CONTROL",
cutset: " ",
left: true,
right: true,
input: " hello world! \u0080 ",
expected: "hello world! \u0080",
},
{
name: "trim ASCII DELETE cutset in UTF-8 input",
cutset: " \u007f",
left: true,
right: true,
input: " hello world! \u0080 \u007f",
expected: "hello world! \u0080",
},
{
name: "trim UTF-8 CONTROL cutset in UTF-8 input",
cutset: " \u0080",
left: true,
right: true,
input: " hello world! \u007f \u0080",
expected: "hello world! \u007f",
},
} {
t.Run(test.name, func(t *testing.T) {
trimmer, err := newTrimmer(test.cutset, test.left, test.right)
Expand Down