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 Solution] Adds missing migration script execution for Endpoint policy #115969

Merged
merged 4 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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