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

[UII] Allow Fleet Fleet post secret and get secret to accept array of strings #124607

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jen-huang
Copy link

  • Have you signed the contributor license agreement?
  • Have you followed the contributor guidelines?
  • If submitting code, have you built your formula locally prior to submission with gradle check?
  • If submitting code, is your pull request against main? Unless there is a good reason otherwise, we prefer pull requests against main and will backport as needed.
  • If submitting code, have you checked that your submission is for an OS and architecture that we support?
  • If you are submitting this code for a class then read our policy for that.

Add tests

Fix tests

[CI] Auto commit changes from spotless
@jen-huang jen-huang force-pushed the jh/fleet-multi-secrets branch from b6ac015 to 4fe3ef9 Compare March 12, 2025 00:41
@jen-huang jen-huang requested a review from Copilot March 12, 2025 21:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the Fleet secret APIs to allow storing and retrieving secrets as an array of strings in addition to a single string. Key changes include updating the secret request/response classes to support multiple value types, adding appropriate parser logic, and extending YAML tests to cover the multi-value scenarios.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/action/TransportGetSecretAction.java Adjusts GET secret handling to support a list of strings
x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/action/PostSecretRequest.java Updates parsing, serialization, and validation to handle multi-value secrets
x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/action/GetSecretResponse.java Modifies response serialization to support returning a string array
x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/40_secrets_get.yml Adds integration test for retrieving multi-value secrets
x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/30_secrets_post.yml Adds integration test for creating multi-value secrets
x-pack/plugin/fleet/src/test/java/org/elasticsearch/xpack/fleet/action/PostSecretRequestTests.java Introduces unit tests for validating behavior with multiple and invalid secret values
Comments suppressed due to low confidence (1)

x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/action/PostSecretRequest.java:60

  • The StreamInput deserialization only reads a String, which does not support the new array type. Update the deserialization logic to distinguish between a single string and an array of strings.
this.value = in.readString();

id = in.readString();
value = in.readString();
this.id = in.readString();
this.value = in.readString();
Copy link
Preview

Copilot AI Mar 12, 2025

Choose a reason for hiding this comment

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

The StreamInput deserialization for 'value' only handles a single String. When a multi-value secret is returned, the stream reading should be updated to properly deserialize a String array.

Suggested change
this.value = in.readString();
if (in.readBoolean()) {
this.value = in.readString();
} else {
this.value = in.readStringArray();
}

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants