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] Add SSL options to fleet server hosts settings #208091

Merged
merged 99 commits into from
Mar 3, 2025

Conversation

criamico
Copy link
Contributor

@criamico criamico commented Jan 23, 2025

Fixes #207322

Summary

Show SSL options for fleet server host in Fleet server settings section and in add fleet server host flyout

  • Registered fleet server host as a encrypted save object and the new mappings added under ssl property, mirroring what's already existing for logstash and kafka outputs
  • The new options are displayed in the UI, both when adding a new fleet server host from the flyout and when editing an existing one.
  • The values are then added to the full agent policy
  • The values for ssh.key and ssh.es_key can additionally be saved as secrets but for now this option is not enabled until fleet server supports it - I used the feature flag enableSSLSecrets
Screenshots Screenshot 2025-02-14 at 10 23 41 Screenshot 2025-02-14 at 10 23 36 Screenshot 2025-02-04 at 14 34 52 Screenshot 2025-02-04 at 14 35 00 Screenshot 2025-02-04 at 09 25 28

Generated policy:
Screenshot 2025-02-24 at 16 43 58
Screenshot 2025-02-24 at 16 44 15

Checklist

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@criamico criamico self-assigned this Jan 27, 2025
@criamico criamico added v9.0.0 Team:Fleet Team label for Observability Data Collection Fleet team release_note:feature Makes this part of the condensed release notes labels Jan 27, 2025
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/fleet --include-path /api/dashboards --update'
@criamico criamico changed the title 207322 fleetserver ssl options [Fleet] Add SSL options to fleet server hosts settings Jan 27, 2025
kibanamachine and others added 6 commits January 27, 2025 12:32
… src/core/server/integration_tests/ci_checks'
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/fleet --include-path /api/dashboards --update'
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/fleet --include-path /api/dashboards --update'
@criamico criamico added backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) v8.18.0 labels Jan 27, 2025
@criamico criamico marked this pull request as ready for review January 27, 2025 16:40
@criamico criamico requested review from a team as code owners January 27, 2025 16:40
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/fleet --include-path /api/dashboards --update'
changes: [
{
type: 'mappings_addition',
addedMappings: {},
Copy link
Member

Choose a reason for hiding this comment

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

question: what does empty addedMappings mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This "empty migration" is needed as I'm using dynamic: false here. This way new mappings can be added without explicitly declaring them.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see, thanks for clarifying!

encryptedSavedObjects.registerType({
type: FLEET_SERVER_HOST_SAVED_OBJECT_TYPE,
attributesToEncrypt: FLEET_SERVER_HOST_ENCRYPTED_FIELDS,
enforceRandomId: false,
Copy link
Member

Choose a reason for hiding this comment

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

question: does it mean you're making the ssl property, which was previously unencrypted, encrypted? Or am I missing something? If so, what about existing objects where ssl property is stored in non-encrypted form? How would that work right now?

The reason why I explicitly added this line is that our POST endpoint supports the creation of an explicit id by the user and having an UUID instead would be a major breaking change.

It'd be great if you could leave a comment in the code explaining this to help future readers.

@@ -1258,6 +1267,10 @@ export const OUTPUT_ENCRYPTED_FIELDS = new Set([
{ key: 'password', dangerouslyExposeValue: true },
]);

export const FLEET_SERVER_HOST_ENCRYPTED_FIELDS = new Set([
{ key: 'ssl', dangerouslyExposeValue: true },
Copy link
Member

Choose a reason for hiding this comment

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

question: Why do we need dangerouslyExposeValue: true? Do we have to expose this value to our users in unencrypted form? If so, is it a requirement?

If we decide to keep this property, it'd be helpful to include a code comment with justification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well I'am showing the content of the ssl property in the UI to allow the user to see/edit it. This was a request by product. I can add a comment to explain it for sure.

Copy link
Member

@azasypkin azasypkin Feb 26, 2025

Choose a reason for hiding this comment

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

How do you retrieve this object? If you have a dedicated endpoint, wouldn't it be possible to use getDecryptedAsInternalUser internally to retrieve it (https://docs.elastic.dev/kibana-dev-docs/api/encryptedSavedObjects#if1e0a8f1-f453-11ef-ad72-4922219b4f76)?

What I'm trying to say is that dangerouslyExposeValue: true should be a last-resort solution for cases where you need to retrieve encrypted saved objects using standard SO APIs and are willing to accept the risk of these secrets being leaked accidentally, since ESO will never strip them down.

to allow the user to see/edit it

I see, thanks. That's interesting - usually, existing secrets are never revealed once entered or saved to reduce the risk of leakage (e.g., you typically can't see an API key or password after saving it, since there's no need to view the existing value if you're going to change it). But I guess I'm just missing context and if you have such a product requirement, then I guess that's fine.

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 looked at the use ofgetDecryptedAsInternalUser but at the moment it's not really feasible as it would mean rewriting the service in a totally different way.

I know that this solution is not ideal, but it's a temporary one and in fact this PR is also adding secrets.ssl field that has the same capability and can store those values in a secure way by using secrets. The plan is to remove the use of the encrypted SO field once that's enabled. The only reason why is not already available is that we still need to add the secret reading capabilities to fleet server, but it is absolutely a temporary solution.
cc @kpollich

Copy link
Member

Choose a reason for hiding this comment

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

Great, thanks for looking into this and clarifying it for me. Having this as a temporary solution sounds reasonable to me.

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

LGTM from the AppEx Security side - temporarily using dangerouslyExposeValue: true for a new field sounds tolerable.

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@criamico
Copy link
Contributor Author

criamico commented Mar 3, 2025

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 1200 1201 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fleet 1331 1332 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 1.7MB 1.7MB +11.9KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
fleet 85 86 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 156.8KB 156.9KB +103.0B
Unknown metric groups

API count

id before after diff
fleet 1458 1459 +1

History

cc @criamico

@criamico criamico merged commit 151fa26 into elastic:main Mar 3, 2025
9 checks passed
@criamico criamico deleted the 207322_fleetserver_ssl_options branch March 3, 2025 12:23
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.18, 8.x, 9.0

https://github.com/elastic/kibana/actions/runs/13630799063

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.18 Backport failed because of merge conflicts
8.x Backport failed because of merge conflicts
9.0 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 208091

Questions ?

Please refer to the Backport tool documentation

@criamico criamico removed v9.0.0 backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) v8.18.0 labels Mar 3, 2025
@kibanamachine kibanamachine added backport:skip This commit does not require backporting labels Mar 3, 2025
criamico added a commit that referenced this pull request Mar 4, 2025
…212918)

## Summary

Small follow up of #208091 

The editor autocompletion added an incorrect import and so I'm removing
it, plus a few comments that should have been removed.

Co-authored-by: Elastic Machine <[email protected]>
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:feature Makes this part of the condensed release notes Team:Fleet Team label for Observability Data Collection Fleet team v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Show SSL options for fleet server host in UI
9 participants