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

Add support to add and remove multiple keystore keys in a single operation #15612

Merged

Conversation

edmocosta
Copy link
Contributor

Release notes

  • Added support to add and remove multiple keystore keys in a single operation
  • Fixed the empty value validation for editing existing key values
  • Added ASCII validation for key values

What does this PR do?

  • Added support to add and remove multiple keys in a single operation, example:
    bin/logstash-keystore add FOO BAR
    bin/logstash-keystore remove FOO BAR 
  • Fixed the empty value validation for editing existing key values
  • Added ASCII validation for key values

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

Currently, adding keys to the keystore need to call command logstash-keystore add YOUR_KEY one by one for each key, which is very time-consuming because it starts and stops JVM each time.

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

How to test this PR locally

  • Add and remove multiple keys

Related issues

Fixed/Added empty and ASCII value validation
@edmocosta edmocosta force-pushed the add-keystore-multi-operation-support branch from 2385532 to f36a46d Compare November 24, 2023 14:38
final SecretIdentifier id = new SecretIdentifier(argument);
final byte[] existingValue = secretStore.retrieveSecret(id);
if (existingValue != null) {
SecretStoreUtil.clearBytes(existingValue);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wondering if it's really needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to keep it to avoid jvm dump leak the value

@edmocosta edmocosta changed the title [WIP] Add support to add and remove multiple keystore keys in a single operation Add support to add and remove multiple keystore keys in a single operation Nov 24, 2023
@edmocosta edmocosta marked this pull request as ready for review November 24, 2023 16:08
Copy link
Contributor

@kaisecheng kaisecheng left a comment

Choose a reason for hiding this comment

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

Nice work. It works as described. I suggested to add ASCII limitation to the docs.
Otherwise, LGTM


["source","sh",subs="attributes"]
----------------------------------------------------------------
bin/logstash-keystore remove ES_PWD
bin/logstash-keystore remove ES_USER ES_PWD
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a note to remind user that the value should only be ASCII.

final SecretIdentifier id = new SecretIdentifier(argument);
final byte[] existingValue = secretStore.retrieveSecret(id);
if (existingValue != null) {
SecretStoreUtil.clearBytes(existingValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to keep it to avoid jvm dump leak the value

Copy link
Contributor

@kaisecheng kaisecheng left a comment

Choose a reason for hiding this comment

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

LGTM

docs/static/keystore.asciidoc Outdated Show resolved Hide resolved
Copy link

@elasticmachine
Copy link
Collaborator

elasticmachine commented Nov 29, 2023

💔 Build Failed

Failed CI Steps

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants