From ed210ef4ad3b9bbcd4ac865bd094cccffe45f762 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 8 Jan 2024 05:31:54 -0500 Subject: [PATCH] [8.12] [Fleet] Fix secrets exception when installing CSPM or other integrations (#174264) (#174432) # Backport This will backport the following commits from `main` to `8.12`: - [[Fleet] Fix secrets exception when installing CSPM or other integrations (#174264)](https://github.com/elastic/kibana/pull/174264) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Cristina Amico --- x-pack/plugins/fleet/server/services/secrets.test.ts | 7 +++++-- x-pack/plugins/fleet/server/services/secrets.ts | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/fleet/server/services/secrets.test.ts b/x-pack/plugins/fleet/server/services/secrets.test.ts index 8e92836e3fbf4..729c74a3ddec0 100644 --- a/x-pack/plugins/fleet/server/services/secrets.test.ts +++ b/x-pack/plugins/fleet/server/services/secrets.test.ts @@ -1018,9 +1018,11 @@ describe('secrets', () => { it('returns single secret reference for required secret', async () => { const mockPackagePolicy = { vars: { - 'pkg-secret-1': { - value: 'pkg-secret-1-val', + 'pkg-secret-1': {}, + 'pkg-secret-2': { + value: 'pkg-secret-2-val', }, + 'dot-notation.stream.pkg-secret-3': {}, }, inputs: [], } as unknown as NewPackagePolicy; @@ -1198,6 +1200,7 @@ describe('secrets', () => { value: 'pkg-secret-1-val', }, 'pkg-secret-2': {}, + 'dot-notation.pkg-secret-3': {}, }, inputs: [], } as unknown as PackagePolicy; diff --git a/x-pack/plugins/fleet/server/services/secrets.ts b/x-pack/plugins/fleet/server/services/secrets.ts index 6f50b2cd8b73b..c01c64e37e59e 100644 --- a/x-pack/plugins/fleet/server/services/secrets.ts +++ b/x-pack/plugins/fleet/server/services/secrets.ts @@ -241,7 +241,11 @@ export async function extractAndWriteSecrets(opts: { values: secretsToCreate.map((secretPath) => secretPath.value.value), }); - const policyWithSecretRefs = getPolicyWithSecretReferences(secretPaths, secrets, packagePolicy); + const policyWithSecretRefs = getPolicyWithSecretReferences( + secretsToCreate, + secrets, + packagePolicy + ); return { packagePolicy: policyWithSecretRefs,