Skip to content

Conversation

mashhurs
Copy link
Contributor

@mashhurs mashhurs commented Mar 19, 2025

Release notes

  • The keystore has improved validation, and will no longer allow the creation of secrets that cannot be accessed with config replacement parameters (${ ... }).

What does this PR do?

Before this change, key-value can be added to keystore but it might impossible to reference the key because ConfigVariableExpander ignores if key name doesn't align with SUBSTITUTION_PLACEHOLDER_REGEX
Improves user experience with the secret store CLI that when providing key name, LS validates to accept a value which can be used in pipeline (aligns with ConfigVariableExpander#SUBSTITUTION_PLACEHOLDER_REGEX).
If already invalid key(s) were added, it warns to remove/replace the keys.

Why is it important/What is the impact to the user?

No user impact. Keystore CLI restricts adding meaningless keys to keystore.

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 (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

Copy link
Contributor

mergify bot commented Mar 19, 2025

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

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • backport-8.x is the label to automatically backport to the 8.x branch.
  • If no backport is necessary, please add the backport-skip label
@mashhurs mashhurs self-assigned this Mar 19, 2025
@mashhurs mashhurs added backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches labels Mar 19, 2025
@mashhurs mashhurs marked this pull request as ready for review March 19, 2025 16:00
@yaauie
Copy link
Member

yaauie commented Mar 19, 2025

No users should be impacted unless they are using restricted symbols (["?", "..", "/", "\", "'", """, "$", "*", "|", "<", ">", " "]) in the key.

This sounds like a breaking change.

  • What was the prior experience when using a key that includes now-restricted characters?
  • What determined that these specific characters are restricted (while allowing a bunch of non-printing characters in the lower-ascii plane and the gamut of unicode characters above the lower-ascii plane)?
Copy link
Contributor

@mashhurs
Copy link
Contributor Author

No users should be impacted unless they are using restricted symbols (["?", "..", "/", "", "'", """, "$", "*", "|", "<", ">", " "]) in the key.

This sounds like a breaking change.

  • What was the prior experience when using a key that includes now-restricted characters?
  • What determined that these specific characters are restricted (while allowing a bunch of non-printing characters in the lower-ascii plane and the gamut of unicode characters above the lower-ascii plane)?

Yeah, didn't think of the case if keystore had invalid keys already included.
a3372c5 commit changes the approach:

  • to restrict adding invalid keys to keystore with CLI. Invalid means here outside of ConfigVariableExpander#SUBSTITUTION_PLACEHOLDER_REGEX ;
  • warns/guides users if their keystore already contains invalid keys;
@mashhurs mashhurs requested a review from yaauie March 24, 2025 15:32
Copy link
Member

@yaauie yaauie left a comment

Choose a reason for hiding this comment

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

Mechanically, this works, and safely guards against adding keys that cannot be referenced in the pipelines without breaking users whose keystores include offending keys.

I've left suggestions about DRY-ing it up a bit, and improving the admitedly-difficult description of the effective key pattern requirement.

Copy link
Contributor

github-actions bot commented Apr 9, 2025

1 similar comment
Copy link
Contributor

github-actions bot commented Apr 9, 2025

@mashhurs mashhurs force-pushed the secret-identifier-key-validator branch from 9139460 to 6ac79ce Compare April 9, 2025 18:13
Copy link
Contributor

github-actions bot commented Apr 9, 2025

mashhurs and others added 4 commits April 9, 2025 13:33
…ey names to the keystore through keystore CLI. Keysotre now warns on invalid keys if they were already added.
 [doc] better explanation of accepting key format. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com>
…ription. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com>
@mashhurs mashhurs force-pushed the secret-identifier-key-validator branch from 6ac79ce to bfea29d Compare April 9, 2025 20:33
@mashhurs
Copy link
Contributor Author

mashhurs commented Apr 9, 2025

Rebased against main as we were having CI issues, fixed by #17531

Copy link
Contributor

github-actions bot commented Apr 9, 2025

@mashhurs mashhurs requested a review from yaauie April 9, 2025 21:04
Copy link
Member

@yaauie yaauie left a comment

Choose a reason for hiding this comment

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

👍🏼 looking on-track.

I've left a comment about message format, and suggested more useful random key generation for tests.

 Warning and error messages well formatted. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com>
Copy link
Contributor

Copy link
Contributor

@mashhurs mashhurs requested a review from yaauie April 11, 2025 18:31
Copy link
Member

@yaauie yaauie left a comment

Choose a reason for hiding this comment

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

Works as advertised.

I've left one nit-pick about making the validation step more cohesive, but you're free to decide whether to resolve it or not.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mashhurs

@mashhurs mashhurs merged commit d24675a into elastic:main Apr 24, 2025
9 checks passed
Copy link
Contributor

@Mergifyio backport 8.17 8.18 8.19 9.0

Copy link
Contributor

mergify bot commented Apr 24, 2025

backport 8.17 8.18 8.19 9.0

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Apr 24, 2025
* Improve the key validation in secret identifier. * Restrict adding invalid (from ConfigVariableExpander point of view) key names to the keystore through keystore CLI. Keystore now warns on invalid keys if they were already added. * Key pattern is moved to a central config expander class with its description. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com> (cherry picked from commit d24675a) # Conflicts: #	docs/reference/keystore.md
mergify bot pushed a commit that referenced this pull request Apr 24, 2025
* Improve the key validation in secret identifier. * Restrict adding invalid (from ConfigVariableExpander point of view) key names to the keystore through keystore CLI. Keystore now warns on invalid keys if they were already added. * Key pattern is moved to a central config expander class with its description. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com> (cherry picked from commit d24675a) # Conflicts: #	docs/reference/keystore.md
mergify bot pushed a commit that referenced this pull request Apr 24, 2025
* Improve the key validation in secret identifier. * Restrict adding invalid (from ConfigVariableExpander point of view) key names to the keystore through keystore CLI. Keystore now warns on invalid keys if they were already added. * Key pattern is moved to a central config expander class with its description. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com> (cherry picked from commit d24675a) # Conflicts: #	docs/reference/keystore.md
mergify bot pushed a commit that referenced this pull request Apr 24, 2025
* Improve the key validation in secret identifier. * Restrict adding invalid (from ConfigVariableExpander point of view) key names to the keystore through keystore CLI. Keystore now warns on invalid keys if they were already added. * Key pattern is moved to a central config expander class with its description. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com> (cherry picked from commit d24675a)
mashhurs added a commit that referenced this pull request Apr 24, 2025
* Improve the key validation in secret identifier. * Restrict adding invalid (from ConfigVariableExpander point of view) key names to the keystore through keystore CLI. Keystore now warns on invalid keys if they were already added. * Key pattern is moved to a central config expander class with its description. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com> (cherry picked from commit d24675a) Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com>
@mashhurs mashhurs deleted the secret-identifier-key-validator branch April 24, 2025 04:59
mashhurs added a commit that referenced this pull request Apr 24, 2025
…ier. (#17585) * Improve the key validation in secret identifier. (#17351) * Improve the key validation in secret identifier. * Restrict adding invalid (from ConfigVariableExpander point of view) key names to the keystore through keystore CLI. Keystore now warns on invalid keys if they were already added. * Key pattern is moved to a central config expander class with its description. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com> (cherry picked from commit d24675a) # Conflicts: #	docs/reference/keystore.md * Adjust the doc against 8.x --------- Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com> Co-authored-by: Mashhur <mashhur.sattorov@elastic.co>
mashhurs added a commit that referenced this pull request Apr 24, 2025
…ier. (#17586) * Improve the key validation in secret identifier. (#17351) * Improve the key validation in secret identifier. * Restrict adding invalid (from ConfigVariableExpander point of view) key names to the keystore through keystore CLI. Keystore now warns on invalid keys if they were already added. * Key pattern is moved to a central config expander class with its description. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com> (cherry picked from commit d24675a) # Conflicts: #	docs/reference/keystore.md * Adjust docs against 8.x --------- Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com> Co-authored-by: Mashhur <mashhur.sattorov@elastic.co>
mashhurs added a commit that referenced this pull request Apr 24, 2025
…ier. (#17587) * Improve the key validation in secret identifier. (#17351) * Improve the key validation in secret identifier. * Restrict adding invalid (from ConfigVariableExpander point of view) key names to the keystore through keystore CLI. Keystore now warns on invalid keys if they were already added. * Key pattern is moved to a central config expander class with its description. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com> (cherry picked from commit d24675a) # Conflicts: #	docs/reference/keystore.md * Adjust docs against 8.x --------- Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com> Co-authored-by: Mashhur <mashhur.sattorov@elastic.co>
colleenmcginnis added a commit to colleenmcginnis/logstash that referenced this pull request Jul 28, 2025
colleenmcginnis added a commit that referenced this pull request Aug 14, 2025
* add applies_to badge to changes introduced in #17351 * add applies_to badge to changes introduced in #17759 * reorder list items * use 9.0.1 not 9.1.0 * Update docs/reference/keystore.md Co-authored-by: Karen Metts <35154725+karenzone@users.noreply.github.com> --------- Co-authored-by: Karen Metts <35154725+karenzone@users.noreply.github.com>
mergify bot pushed a commit that referenced this pull request Aug 14, 2025
* add applies_to badge to changes introduced in #17351 * add applies_to badge to changes introduced in #17759 * reorder list items * use 9.0.1 not 9.1.0 * Update docs/reference/keystore.md Co-authored-by: Karen Metts <35154725+karenzone@users.noreply.github.com> --------- Co-authored-by: Karen Metts <35154725+karenzone@users.noreply.github.com> (cherry picked from commit aed28eb)
colleenmcginnis added a commit that referenced this pull request Aug 14, 2025
* add applies_to badge to changes introduced in #17351 * add applies_to badge to changes introduced in #17759 * reorder list items * use 9.0.1 not 9.1.0 * Update docs/reference/keystore.md --------- (cherry picked from commit aed28eb) Co-authored-by: Colleen McGinnis <colleen.mcginnis@elastic.co> Co-authored-by: Karen Metts <35154725+karenzone@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches

3 participants