[Security Solution] Prepare for unattended endpoint transforms (#179762)

This commit is contained in:
Dan Panzarella 2024-04-03 07:33:55 -04:00 committed by GitHub
parent 0a3a8bb971
commit 60a4989f18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 10 deletions

View file

@ -5,17 +5,10 @@
* 2.0.
*/
// import semverLte from 'semver/functions/lte';
import semverLte from 'semver/functions/lte';
// function parseSemver(semver: string) {
// return semver.includes('-') ? semver.substring(0, semver.indexOf('-')) : semver;
// }
// until a release is confirmed, or another feature-detection method is used, do not automatically
// switch to "v2" logic
// const MIN_ENDPOINT_PACKAGE_V2_VERSION = '8.13.0';
const MIN_ENDPOINT_PACKAGE_V2_VERSION = '8.14.0-prerelease.1';
export function isEndpointPackageV2(version: string) {
// const parsedVersion = parseSemver(version);
// return semverLte(MIN_ENDPOINT_PACKAGE_V2_VERSION, parsedVersion);
return false;
return semverLte(MIN_ENDPOINT_PACKAGE_V2_VERSION, version);
}

View file

@ -21,6 +21,8 @@ import {
METADATA_UNITED_TRANSFORM,
metadataCurrentIndexPattern,
metadataTransformPrefix,
METADATA_CURRENT_TRANSFORM_V2,
METADATA_UNITED_TRANSFORM_V2,
POLICY_RESPONSE_INDEX,
} from '../../../../../common/endpoint/constants';
import { EndpointDocGenerator } from '../../../../../common/endpoint/generate_data';
@ -80,7 +82,9 @@ export const cyLoadEndpointDataHandler = async (
// need this before indexing docs so that the united transform doesn't
// create a checkpoint with a timestamp after the doc timestamps
await stopTransform(esClient, metadataTransformPrefix);
await stopTransform(esClient, METADATA_CURRENT_TRANSFORM_V2);
await stopTransform(esClient, METADATA_UNITED_TRANSFORM);
await stopTransform(esClient, METADATA_UNITED_TRANSFORM_V2);
}
// load data into the system
@ -105,12 +109,15 @@ export const cyLoadEndpointDataHandler = async (
);
if (waitUntilTransformed) {
// missing transforms are ignored, start either name
await startTransform(esClient, metadataTransformPrefix);
await startTransform(esClient, METADATA_CURRENT_TRANSFORM_V2);
const metadataIds = Array.from(new Set(indexedData.hosts.map((host) => host.agent.id)));
await waitForEndpoints(esClient, 'endpoint_index', metadataIds);
await startTransform(esClient, METADATA_UNITED_TRANSFORM);
await startTransform(esClient, METADATA_UNITED_TRANSFORM_V2);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const agentIds = Array.from(new Set(indexedData.agents.map((agent) => agent.agent!.id)));