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

[Fleet] Allow exclamation mark in enrollment token name #191807

Conversation

jillguyonnet
Copy link
Contributor

Summary

Closes #191719

Attempting to generate a Fleet enrollment token with a name that ends with ! produces a malformed ES query which causes POST agents/enrollment_api_keys to fail with 500.

This PR adds a narrow fix by escaping question marks (which is a query_string special character).

Note: this query probably wouldn't be necessary if we removed the constraint of unique name, as discussed in #155550.

@jillguyonnet jillguyonnet self-assigned this Aug 30, 2024
@jillguyonnet jillguyonnet added the Team:Fleet Team label for Observability Data Collection Fleet team label Aug 30, 2024
@obltmachine
Copy link

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@jillguyonnet jillguyonnet added the release_note:skip Skip the PR/issue when compiling release notes label Aug 30, 2024
@jillguyonnet jillguyonnet marked this pull request as ready for review August 30, 2024 09:04
@jillguyonnet jillguyonnet requested a review from a team as a code owner August 30, 2024 09:04
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM, are there any other special characters that we should escape?

@jillguyonnet
Copy link
Contributor Author

Thanks @juliaElastic!

There is a list of special characters: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax. I tried them all, most work besides some fairly unusual ones (&& for example). I thought about making a more robust function, but I wasn't sure the effort would be worth it considering we might eventually lift the name uniqueness constraint. WDYT?

@juliaElastic
Copy link
Contributor

There is a list of special characters: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax. I tried them all, most work besides some fairly unusual ones (&& for example). I thought about making a more robust function, but I wasn't sure the effort would be worth it considering we might eventually lift the name uniqueness constraint. WDYT?

I agree, probably not worth putting more effort now. Thanks for confirming.

@jillguyonnet
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jillguyonnet

@jillguyonnet jillguyonnet merged commit a57181a into elastic:main Aug 30, 2024
21 checks passed
@jillguyonnet jillguyonnet deleted the fleet/191719-allow-exclamation-mark-in-enrollment-token-name branch August 30, 2024 14:48
@kibanamachine kibanamachine added v8.16.0 backport:skip This commit does not require backporting labels Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet]: Unreadable error appears when saving an enrollment token with name exclamation mark (!)
6 participants