-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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][Endpoint][Admin] Malware user notification checkbox #78084
Changes from 18 commits
4267f8c
72a4be0
c9af419
bc20a81
b9ce8c1
f652794
6d5c35e
1c1f11a
0cd6e0a
872fcf3
190ecac
8bcd5b9
c195a63
dad57cc
32de69d
57b8993
a7add0d
aee43b3
ee04d14
6b1801c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { SavedObjectMigrationContext, SavedObjectUnsanitizedDoc } from 'kibana/server'; | ||
import { PackagePolicy } from '../../../../../ingest_manager/common'; | ||
import { migratePackagePolicyToV7110 } from './to_v7_11.0'; | ||
|
||
describe('7.11.0 Endpoint Package Policy migration', () => { | ||
const migration = migratePackagePolicyToV7110; | ||
it('adds malware notification checkbox and optional message', () => { | ||
const doc = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe add a Type to |
||
attributes: { | ||
name: 'Some Policy Name', | ||
package: { | ||
name: 'endpoint', | ||
title: '', | ||
version: '', | ||
}, | ||
id: 'endpoint', | ||
policy_id: '', | ||
enabled: true, | ||
namespace: '', | ||
output_id: '', | ||
revision: 0, | ||
updated_at: '', | ||
updated_by: '', | ||
created_at: '', | ||
created_by: '', | ||
inputs: [ | ||
{ | ||
type: 'endpoint', | ||
enabled: true, | ||
streams: [], | ||
config: { | ||
policy: { | ||
value: { | ||
windows: {}, | ||
mac: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
type: ' nested', | ||
}; | ||
|
||
expect( | ||
migration(doc, {} as SavedObjectMigrationContext) as SavedObjectUnsanitizedDoc<PackagePolicy> | ||
).toEqual({ | ||
attributes: { | ||
name: 'Some Policy Name', | ||
package: { | ||
name: 'endpoint', | ||
title: '', | ||
version: '', | ||
}, | ||
id: 'endpoint', | ||
policy_id: '', | ||
enabled: true, | ||
namespace: '', | ||
output_id: '', | ||
revision: 0, | ||
updated_at: '', | ||
updated_by: '', | ||
created_at: '', | ||
created_by: '', | ||
inputs: [ | ||
{ | ||
type: 'endpoint', | ||
enabled: true, | ||
streams: [], | ||
config: { | ||
policy: { | ||
value: { | ||
windows: { | ||
popup: { | ||
malware: { | ||
message: '', | ||
enabled: false, | ||
}, | ||
}, | ||
}, | ||
mac: { | ||
popup: { | ||
malware: { | ||
message: '', | ||
enabled: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
type: ' nested', | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { SavedObjectMigrationFn, SavedObjectUnsanitizedDoc } from 'kibana/server'; | ||
import { cloneDeep } from 'lodash'; | ||
import { PackagePolicy } from '../../../../../ingest_manager/common'; | ||
|
||
export const migratePackagePolicyToV7110: SavedObjectMigrationFn<PackagePolicy, PackagePolicy> = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only used by server code correct? @nnamdifrankie what do you think? ⬆️ |
||
packagePolicyDoc | ||
) => { | ||
const updatedPackagePolicyDoc: SavedObjectUnsanitizedDoc<PackagePolicy> = cloneDeep( | ||
packagePolicyDoc | ||
); | ||
if (packagePolicyDoc.attributes.package?.name === 'endpoint') { | ||
const input = updatedPackagePolicyDoc.attributes.inputs[0]; | ||
const popup = { | ||
malware: { | ||
message: '', | ||
enabled: false, | ||
}, | ||
}; | ||
if (input && input.config) { | ||
input.config.policy.value.windows.popup = popup; | ||
input.config.policy.value.mac.popup = popup; | ||
} | ||
} | ||
|
||
return updatedPackagePolicyDoc; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add another test case that ensures package policies are not modified for non-endpoint package policies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yesss will do!