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 dissect trim panics from DELETE (\u007f) character #30658

Merged
merged 9 commits into from
Mar 16, 2022
Merged

Fix dissect trim panics from DELETE (\u007f) character #30658

merged 9 commits into from
Mar 16, 2022

Conversation

montaguethomas
Copy link
Contributor

@montaguethomas montaguethomas commented Mar 2, 2022

What does this PR do?

Fixes an index out of range panic with asciiTrimmer.Trim().

Why is it important?

Should a string begin or end with the DELETE (\u007f)(127) ASCII character (with or without a leading/trailing space), asciiTrimmer.Trim() will throw a panic.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

Run the updated tests without the fix in trim.go.

Related issues

Logs

panic: runtime error: index out of range [127] with length 127

goroutine 52 [running]:
github.com/elastic/beats/v7/libbeat/processors/dissect.asciiTrimmer.Trim(...)
	/go/src/github.com/elastic/beats/libbeat/processors/dissect/trim.go:66
github.com/elastic/beats/v7/libbeat/processors/dissect.(*Dissector).Dissect(0xc000a0da40, 0xc001517d10, 0xe5, 0x108528980, 0xc0015b1060, 0x0)
	/go/src/github.com/elastic/beats/libbeat/processors/dissect/dissect.go:73 +0x104
github.com/elastic/beats/v7/libbeat/processors/dissect.(*processor).Run(0xc0005b5280, 0xc0015c81c0, 0x107d95b74, 0x1e, 0xc000b8bad0)
	/go/src/github.com/elastic/beats/libbeat/processors/dissect/processor.go:91 +0x3e5

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Mar 2, 2022
@cla-checker-service
Copy link

cla-checker-service bot commented Mar 2, 2022

💚 CLA has been signed

@mergify
Copy link
Contributor

mergify bot commented Mar 2, 2022

This pull request does not have a backport label. Could you fix it @montaguethomas? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Mar 2, 2022
@montaguethomas montaguethomas changed the title Fix dissect trim panics from unicode DELETE (\u007f) char Fix dissect trim panics from unicode DELETE (\u007f) character Mar 2, 2022
@montaguethomas montaguethomas changed the title Fix dissect trim panics from unicode DELETE (\u007f) character Fix dissect trim panics from DELETE (\u007f) character Mar 2, 2022
@elasticmachine
Copy link
Collaborator

elasticmachine commented Mar 2, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-03-15T17:36:59.544+0000

  • Duration: 89 min 39 sec

Test stats 🧪

Test Results
Failed 0
Passed 25714
Skipped 2203
Total 27917

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@montaguethomas
Copy link
Contributor Author

montaguethomas commented Mar 3, 2022

Seems I do not have permissions to set labels on the PR. Suggest this should be backported.

@mergify
Copy link
Contributor

mergify bot commented Mar 7, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b bugfix/dissect-trim upstream/bugfix/dissect-trim
git merge upstream/main
git push upstream bugfix/dissect-trim

@mergify
Copy link
Contributor

mergify bot commented Mar 9, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b bugfix/dissect-trim upstream/bugfix/dissect-trim
git merge upstream/main
git push upstream bugfix/dissect-trim

@montaguethomas montaguethomas requested a review from a team as a code owner March 10, 2022 12:07
@cmacknz cmacknz added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Mar 10, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Mar 10, 2022
@cmacknz
Copy link
Member

cmacknz commented Mar 10, 2022

/test

@cmacknz cmacknz requested a review from adriansr March 10, 2022 16:48
@cmacknz
Copy link
Member

cmacknz commented Mar 15, 2022

@adriansr you were the original author here, can you review this fix?

@adriansr adriansr added backport-v8.0.0 Automated backport with mergify backport-v8.1.0 Automated backport with mergify backport-7.17 Automated backport to the 7.17 branch with mergify bug labels Mar 15, 2022
@mergify mergify bot removed the backport-skip Skip notification from the automated backport with mergify label Mar 15, 2022
Copy link
Contributor

@adriansr adriansr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for fixing. I'm adding some corrections to the changelog

CHANGELOG.next.asciidoc Outdated Show resolved Hide resolved
CHANGELOG.next.asciidoc Outdated Show resolved Hide resolved
@mergify
Copy link
Contributor

mergify bot commented Mar 15, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b bugfix/dissect-trim upstream/bugfix/dissect-trim
git merge upstream/main
git push upstream bugfix/dissect-trim

@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@jlind23
Copy link
Collaborator

jlind23 commented Mar 16, 2022

@adriansr could we please merge it as it has been approved?

@adriansr adriansr merged commit 9396deb into elastic:main Mar 16, 2022
mergify bot pushed a commit that referenced this pull request Mar 16, 2022
Fixes an index out of range panic with asciiTrimmer.Trim().

Closes #30657

(cherry picked from commit 9396deb)
mergify bot pushed a commit that referenced this pull request Mar 16, 2022
Fixes an index out of range panic with asciiTrimmer.Trim().

Closes #30657

(cherry picked from commit 9396deb)
mergify bot pushed a commit that referenced this pull request Mar 16, 2022
Fixes an index out of range panic with asciiTrimmer.Trim().

Closes #30657

(cherry picked from commit 9396deb)
adriansr pushed a commit that referenced this pull request Mar 17, 2022
…haracter (#30868)

* Fix dissect trim panics from DELETE (\u007f) character (#30658)

Fixes an index out of range panic with asciiTrimmer.Trim().

Closes #30657

(cherry picked from commit 9396deb)

Co-authored-by: Thomas Montague <montague.thomas@gmail.com>
adriansr pushed a commit that referenced this pull request Mar 17, 2022
…haracter (#30867)

Fixes an index out of range panic with asciiTrimmer.Trim().

Closes #30657

(cherry picked from commit 9396deb)

Co-authored-by: Thomas Montague <montague.thomas@gmail.com>
adriansr pushed a commit that referenced this pull request Mar 17, 2022
…character (#30866)

Fixes an index out of range panic with asciiTrimmer.Trim().

Closes #30657

(cherry picked from commit 9396deb)

Co-authored-by: Thomas Montague <montague.thomas@gmail.com>
kush-elastic pushed a commit to kush-elastic/beats that referenced this pull request May 2, 2022
Fixes an index out of range panic with asciiTrimmer.Trim().

Closes elastic#30657
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…007f) character (elastic#30867)

Fixes an index out of range panic with asciiTrimmer.Trim().

Closes elastic#30657

(cherry picked from commit 70298dd)

Co-authored-by: Thomas Montague <montague.thomas@gmail.com>
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
Fixes an index out of range panic with asciiTrimmer.Trim().

Closes #30657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-7.17 Automated backport to the 7.17 branch with mergify backport-v8.0.0 Automated backport with mergify backport-v8.1.0 Automated backport with mergify bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dissect trim panics from unicode DELETE (\u007f) char
5 participants