Skip to content

Commit

Permalink
[Security Solution] Adds missing migration script execution for Endpo…
Browse files Browse the repository at this point in the history
…int policy (elastic#115969)
  • Loading branch information
kevinlog authored and shivindera committed Oct 25, 2021
1 parent 3a0b257 commit 7ed001c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion x-pack/plugins/fleet/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
} from './migrations/to_v7_13_0';
import { migratePackagePolicyToV7140, migrateInstallationToV7140 } from './migrations/to_v7_14_0';
import { migratePackagePolicyToV7150 } from './migrations/to_v7_15_0';
import { migrateInstallationToV7160 } from './migrations/to_v7_16_0';
import { migrateInstallationToV7160, migratePackagePolicyToV7160 } from './migrations/to_v7_16_0';

/*
* Saved object types and mappings
Expand Down Expand Up @@ -294,6 +294,7 @@ const getSavedObjectTypes = (
'7.13.0': migratePackagePolicyToV7130,
'7.14.0': migratePackagePolicyToV7140,
'7.15.0': migratePackagePolicyToV7150,
'7.16.0': migratePackagePolicyToV7160,
},
},
[PACKAGES_SAVED_OBJECT_TYPE]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

import type { SavedObjectMigrationFn } from 'kibana/server';

import type { Installation } from '../../../common';
import type { Installation, PackagePolicy } from '../../../common';
import { AUTO_UPDATE_PACKAGES, DEFAULT_PACKAGES } from '../../../common';

import { migratePackagePolicyToV7160 as SecSolMigratePackagePolicyToV7160 } from './security_solution';

export const migrateInstallationToV7160: SavedObjectMigrationFn<Installation, Installation> = (
installationDoc,
migrationContext
Expand All @@ -26,3 +28,17 @@ export const migrateInstallationToV7160: SavedObjectMigrationFn<Installation, In

return updatedInstallationDoc;
};

export const migratePackagePolicyToV7160: SavedObjectMigrationFn<PackagePolicy, PackagePolicy> = (
packagePolicyDoc,
migrationContext
) => {
let updatedPackagePolicyDoc = packagePolicyDoc;

// Endpoint specific migrations
if (packagePolicyDoc.attributes.package?.name === 'endpoint') {
updatedPackagePolicyDoc = SecSolMigratePackagePolicyToV7160(packagePolicyDoc, migrationContext);
}

return updatedPackagePolicyDoc;
};

0 comments on commit 7ed001c

Please sign in to comment.