Skip to content

Commit

Permalink
[Fleet] Fix secrets exception when installing CSPM or other integrati…
Browse files Browse the repository at this point in the history
…ons (elastic#174264)

Closes elastic#173718

## Summary

Fix secrets exception when installing CSPM or other integrations

### Steps to reproduce:

- Install `cloud_security_posture-1.8.0-preview02` (note that a licence
is needed to install CSPM)
- Select Setup access: manual and Preferred manual method: Direct access
keys
- Add some test values a secrets and try to install
- The integration should install correctly with no exceptions.

### Checklist
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

---------

Co-authored-by: Kyle Pollich <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
3 people authored and delanni committed Jan 11, 2024
1 parent f5cd3cd commit 0edaaa2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions x-pack/plugins/fleet/server/services/secrets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1198,6 +1200,7 @@ describe('secrets', () => {
value: 'pkg-secret-1-val',
},
'pkg-secret-2': {},
'dot-notation.pkg-secret-3': {},
},
inputs: [],
} as unknown as PackagePolicy;
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/fleet/server/services/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0edaaa2

Please sign in to comment.