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

[7.x] [Fleet] Fix circular ref by moving code & tests into Fleet (#94171) #94483

Merged
merged 1 commit into from
Mar 11, 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
18 changes: 10 additions & 8 deletions x-pack/plugins/fleet/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@ import {
} from '../constants';

import {
migratePackagePolicyToV7110,
migratePackagePolicyToV7120,
// @ts-expect-error
} from './security_solution';
import {
migrateAgentToV7100,
migrateAgentActionToV7100,
migrateAgentEventToV7100,
migrateAgentPolicyToV7100,
migrateAgentToV7100,
migrateEnrollmentApiKeysToV7100,
migratePackagePolicyToV7100,
migrateSettingsToV7100,
migrateAgentActionToV7100,
} from './migrations/to_v7_10_0';
import { migrateAgentToV7120, migrateAgentPolicyToV7120 } from './migrations/to_v7_12_0';

import { migratePackagePolicyToV7110 } from './migrations/to_v7_11_0';

import {
migrateAgentPolicyToV7120,
migrateAgentToV7120,
migratePackagePolicyToV7120,
} from './migrations/to_v7_12_0';

/*
* Saved object types and mappings
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export { migratePackagePolicyToV7110 } from './to_v7_11_0';
export { migratePackagePolicyToV7120 } from './to_v7_12_0';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
*/

import { SavedObjectMigrationContext, SavedObjectUnsanitizedDoc } from 'kibana/server';
import { PackagePolicy } from '../../../../../fleet/common';

import type { PackagePolicy } from '../../../../common';

import { migratePackagePolicyToV7110 } from './to_v7_11_0';

describe('7.11.0 Endpoint Package Policy migration', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import { SavedObjectMigrationFn, SavedObjectUnsanitizedDoc } from 'kibana/server';
import { cloneDeep } from 'lodash';
import { PackagePolicy } from '../../../../../fleet/common';

import type { PackagePolicy } from '../../../../common';

export const migratePackagePolicyToV7110: SavedObjectMigrationFn<PackagePolicy, PackagePolicy> = (
packagePolicyDoc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
*/

import { SavedObjectMigrationContext, SavedObjectUnsanitizedDoc } from 'kibana/server';
import { PackagePolicy } from '../../../../../fleet/common';
import { PolicyData, ProtectionModes } from '../../types';

import type { PackagePolicy } from '../../../../common';

import { migratePackagePolicyToV7120 } from './to_v7_12_0';

describe('7.12.0 Endpoint Package Policy migration', () => {
const migration = migratePackagePolicyToV7120;
it('adds ransomware option and notification customization', () => {
const doc: SavedObjectUnsanitizedDoc<PolicyData> = {
const doc = {
id: 'mock-saved-object-id',
attributes: {
name: 'Some Policy Name',
Expand Down Expand Up @@ -41,7 +42,6 @@ describe('7.12.0 Endpoint Package Policy migration', () => {
policy: {
value: {
windows: {
// @ts-expect-error
popup: {
malware: {
message: '',
Expand All @@ -58,9 +58,7 @@ describe('7.12.0 Endpoint Package Policy migration', () => {
type: ' nested',
};

expect(
migration(doc, {} as SavedObjectMigrationContext) as SavedObjectUnsanitizedDoc<PolicyData>
).toEqual({
expect(migration(doc, {} as SavedObjectMigrationContext)).toEqual({
attributes: {
name: 'Some Policy Name',
package: {
Expand Down Expand Up @@ -88,7 +86,7 @@ describe('7.12.0 Endpoint Package Policy migration', () => {
value: {
windows: {
ransomware: {
mode: ProtectionModes.off,
mode: 'off',
},
popup: {
malware: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import { SavedObjectMigrationFn, SavedObjectUnsanitizedDoc } from 'kibana/server';
import { cloneDeep } from 'lodash';
import { PackagePolicy } from '../../../../../fleet/common';
import { ProtectionModes } from '../../types';

import type { PackagePolicy } from '../../../../common';

export const migratePackagePolicyToV7120: SavedObjectMigrationFn<PackagePolicy, PackagePolicy> = (
packagePolicyDoc
Expand All @@ -19,7 +19,7 @@ export const migratePackagePolicyToV7120: SavedObjectMigrationFn<PackagePolicy,
if (packagePolicyDoc.attributes.package?.name === 'endpoint') {
const input = updatedPackagePolicyDoc.attributes.inputs[0];
const ransomware = {
mode: ProtectionModes.off,
mode: 'off',
};
const ransomwarePopup = {
message: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@
* 2.0.
*/

export {
migratePackagePolicyToV7110,
migratePackagePolicyToV7120,
} from '../../../security_solution/common';
export { migratePackagePolicyToV7110 } from './security_solution/to_v7_11_0';
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import type { SavedObjectMigrationFn } from 'kibana/server';

import type { Agent, AgentPolicy } from '../../types';

export { migratePackagePolicyToV7120 } from './security_solution/to_v7_12_0';

export const migrateAgentToV7120: SavedObjectMigrationFn<Agent & { shared_id?: string }, Agent> = (
agentDoc
) => {
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/security_solution/common/shared_exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ export { exactCheck } from './exact_check';
export { getPaths, foldLeftRight, removeExternalLinkText } from './test_utils';
export { validate, validateEither } from './validate';
export { formatErrors } from './format_errors';
export { migratePackagePolicyToV7110 } from './endpoint/policy/migrations/to_v7_11_0';
export { migratePackagePolicyToV7120 } from './endpoint/policy/migrations/to_v7_12_0';
export { addIdToItem, removeIdFromItem } from './add_remove_id_to_item';