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

x-pack/filebeat : Sanitize cel input resource trace filename #35154

Merged
merged 17 commits into from
Apr 25, 2023

Conversation

bhapas
Copy link
Contributor

@bhapas bhapas commented Apr 20, 2023

What does this PR do?

This PR sanitizes the request.tracer.filename in filebeat config to replace : and / characters with _ character.

  • Also contains fixes for httpjson input

Why is it important?

There is a problem with different path separators between HFS+ (colon, ':') and UFS (slash, '/'). This also means that HFS+ file names may contain the slash character and not colons, while the opposite is true for UFS file names. Reference

So the file structure seems to be corrupted in MacOS if the filename has : and the same happens in Unix based systems if the filename has /. Hence replacing them with _.

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.

@bhapas bhapas self-assigned this Apr 20, 2023
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 20, 2023
@mergify
Copy link
Contributor

mergify bot commented Apr 20, 2023

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @bhapas? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

* Also contains fixes for httpjson input
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Apr 20, 2023
@bhapas bhapas added the bugfix label Apr 20, 2023
@elasticmachine
Copy link
Collaborator

elasticmachine commented Apr 20, 2023

💚 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: 2023-04-24T15:42:16.569+0000

  • Duration: 74 min 58 sec

Test stats 🧪

Test Results
Failed 0
Passed 2888
Skipped 175
Total 3063

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the 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!)

@mergify
Copy link
Contributor

mergify bot commented Apr 20, 2023

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 log-path-cel upstream/log-path-cel
git merge upstream/main
git push upstream log-path-cel

@bhapas bhapas marked this pull request as ready for review April 21, 2023 14:49
@bhapas bhapas requested a review from a team as a code owner April 21, 2023 14:49
@elasticmachine
Copy link
Collaborator

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

@mergify
Copy link
Contributor

mergify bot commented Apr 21, 2023

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 log-path-cel upstream/log-path-cel
git merge upstream/main
git push upstream log-path-cel

@bhapas bhapas requested a review from andrewkroh April 22, 2023 07:17
@bhapas bhapas requested a review from efd6 April 22, 2023 14:14
@bhapas bhapas requested a review from andrewkroh April 24, 2023 18:19
@@ -25,12 +26,14 @@ import (
)

func TestInput(t *testing.T) {
tempDirectory := t.TempDir()
Copy link
Member

Choose a reason for hiding this comment

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

I would rather see each sub-test use its own unique temp dir to ensure test isolation. But with only one test using this directory it's only a minor concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to change the structure to achieve this. To inject tempDir into the config which is currently a Map I felt difficult with current setup. As you said for one test using it , this should be a big change for the value it gives.

@bhapas
Copy link
Contributor Author

bhapas commented Apr 25, 2023

Merging the PR as the golangci-lint errors are unrelated.

@bhapas bhapas merged commit bebe337 into elastic:main Apr 25, 2023
@bhapas bhapas deleted the log-path-cel branch April 25, 2023 04:59
mergify bot pushed a commit that referenced this pull request Apr 25, 2023
* Sanitize cel input resource trace filename

* Also contains fixes for httpjson input

* Send expected file through config

* Fix windows tests

(cherry picked from commit bebe337)
bhapas added a commit that referenced this pull request Apr 25, 2023
…#35201)

* Sanitize cel input resource trace filename

* Also contains fixes for httpjson input

* Send expected file through config

* Fix windows tests

(cherry picked from commit bebe337)

Co-authored-by: Bharat Pasupula <[email protected]>
bhapas added a commit that referenced this pull request Apr 25, 2023
@@ -31,594 +31,655 @@ import (
"github.com/elastic/elastic-agent-libs/mapstr"
)

var inputTests = []struct {
Copy link
Contributor

@efd6 efd6 Apr 26, 2023

Choose a reason for hiding this comment

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

I didn't notice this (hidden for GitHub folding changes). It should not have been changed; large change with no reason.

Fix #35220

leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…#35154)

* Sanitize cel input resource trace filename

* Also contains fixes for httpjson input

* Send expected file through config

* Fix windows tests
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
* Sanitize cel input resource trace filename

* Also contains fixes for httpjson input

* Send expected file through config

* Fix windows tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.7.0 Automated backport with mergify bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants