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

[Security Solutions][Endpoint] Use id instead of identifier to get fleet artifact #154810

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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