Skip to content

Commit

Permalink
[Security Solutions][Endpoint] Use id instead of identifier to get fl…
Browse files Browse the repository at this point in the history
…eet artifact (elastic#154810)

## Summary

Get fleet artifacts by `artifact.id` instead of by `artifact.identifier`
before pushing them to the endpoint manifest.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit fbe0243)
  • Loading branch information
dasansol92 committed Apr 12, 2023
1 parent 27ec312 commit 388a599
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pMap from 'p-map';
import semver from 'semver';
import type LRU from 'lru-cache';
import { isEqual, isEmpty, keyBy } from 'lodash';
import { isEqual, isEmpty } from 'lodash';
import { type Logger, type SavedObjectsClientContract } from '@kbn/core/server';
import {
ENDPOINT_EVENT_FILTERS_LIST_ID,
Expand Down Expand Up @@ -365,11 +365,15 @@ export class ManifestManager {
}

if (fleetArtifacts) {
const fleetArtfactsByIdentifier = keyBy(fleetArtifacts, 'identifier');
const fleetArtfactsByIdentifier: { [key: string]: InternalArtifactCompleteSchema } = {};
fleetArtifacts.forEach((fleetArtifact) => {
fleetArtfactsByIdentifier[getArtifactId(fleetArtifact)] = fleetArtifact;
});
artifactsToCreate.forEach((artifact) => {
const fleetArtifact = fleetArtfactsByIdentifier[artifact.identifier];
if (!fleetArtifact) return;
const artifactId = getArtifactId(artifact);
const fleetArtifact = fleetArtfactsByIdentifier[artifactId];

if (!fleetArtifact) return;
// Cache the compressed body of the artifact
this.cache.set(artifactId, Buffer.from(artifact.body, 'base64'));
newManifest.replaceArtifact(fleetArtifact);
Expand Down

0 comments on commit 388a599

Please sign in to comment.