-
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
Merged
parkiino
merged 20 commits into
elastic:master
from
parkiino:task/malware-user-notification
Oct 21, 2020
Merged
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4267f8c
basic user notification checkbox
parkiino 72a4be0
Merge remote-tracking branch 'upstream/master' into task/malware-user…
parkiino c9af419
Merge remote-tracking branch 'upstream/master' into task/malware-user…
parkiino bc20a81
Merge remote-tracking branch 'upstream/master' into task/malware-user…
parkiino b9ce8c1
working migration, user notification tied to prevent or detect
parkiino f652794
fix existing jest test
parkiino 6d5c35e
fixed existing functional test
parkiino 1c1f11a
add mac migration
parkiino 0cd6e0a
migration unit test
parkiino 872fcf3
Merge remote-tracking branch 'upstream/master' into task/malware-user…
parkiino 190ecac
add mac stuff
parkiino 8bcd5b9
move migration from ingest manager to endpoint
parkiino c195a63
moving to common folder
parkiino dad57cc
didn't even push the actual changes...
parkiino 32de69d
Merge remote-tracking branch 'upstream/master' into task/malware-user…
parkiino 57b8993
migration works for sure now
parkiino a7add0d
completed ui
parkiino aee43b3
fix test
parkiino ee04d14
2nd migration test
parkiino 6b1801c
add type to test variable
parkiino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
x-pack/plugins/security_solution/server/endpoint/lib/policy/saved_object_mappings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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 { SavedObjectsType } from '../../../../../../../src/core/server/types'; | ||
import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../../../../ingest_manager/common'; | ||
import { migratePackagePolicyToV7110 } from './to_v7_11.0'; | ||
|
||
export const packagePolicyType: SavedObjectsType = { | ||
name: PACKAGE_POLICY_SAVED_OBJECT_TYPE, | ||
hidden: false, | ||
namespaceType: 'agnostic', | ||
management: { | ||
importableAndExportable: false, | ||
}, | ||
mappings: { | ||
properties: { | ||
name: { type: 'keyword' }, | ||
description: { type: 'text' }, | ||
namespace: { type: 'keyword' }, | ||
enabled: { type: 'boolean' }, | ||
policy_id: { type: 'keyword' }, | ||
output_id: { type: 'keyword' }, | ||
package: { | ||
properties: { | ||
name: { type: 'keyword' }, | ||
title: { type: 'keyword' }, | ||
version: { type: 'keyword' }, | ||
}, | ||
}, | ||
inputs: { | ||
type: 'nested', | ||
enabled: false, | ||
properties: { | ||
type: { type: 'keyword' }, | ||
enabled: { type: 'boolean' }, | ||
vars: { type: 'flattened' }, | ||
config: { type: 'flattened' }, | ||
streams: { | ||
type: 'nested', | ||
properties: { | ||
id: { type: 'keyword' }, | ||
enabled: { type: 'boolean' }, | ||
data_stream: { | ||
properties: { | ||
dataset: { type: 'keyword' }, | ||
type: { type: 'keyword' }, | ||
}, | ||
}, | ||
vars: { type: 'flattened' }, | ||
config: { type: 'flattened' }, | ||
compiled_stream: { type: 'flattened' }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
revision: { type: 'integer' }, | ||
updated_at: { type: 'date' }, | ||
updated_by: { type: 'keyword' }, | ||
created_at: { type: 'date' }, | ||
created_by: { type: 'keyword' }, | ||
}, | ||
}, | ||
migrations: { | ||
'7.11.0': migratePackagePolicyToV7110, | ||
}, | ||
}; |
94 changes: 94 additions & 0 deletions
94
x-pack/plugins/security_solution/server/endpoint/lib/policy/to_v7_11.0.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* 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 = { | ||
attributes: { | ||
name: 'endpoint', | ||
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: 'endpoint', | ||
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', | ||
}); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/security_solution/server/endpoint/lib/policy/to_v7_11.0.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '../../types'; | ||
|
||
export const migratePackagePolicyToV7110: SavedObjectMigrationFn<PackagePolicy, PackagePolicy> = ( | ||
packagePolicyDoc | ||
) => { | ||
const updatedPackagePolicyDoc: SavedObjectUnsanitizedDoc<PackagePolicy> = cloneDeep( | ||
packagePolicyDoc | ||
); | ||
if (packagePolicyDoc.attributes.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; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is it a problem that we define this here as well as in Ingest? If it is OK, should we import the mapping, clone it, and add our own migration? What happens if there are 2 migrations for 7.11? One in Ingest and one in Security?
cc @jfsiii @jen-huang
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.
judging from the test failures, it certainly looks like this is an issue
https://kibana-ci.elastic.co/job/elastic+kibana+pipeline-pull-request/82038/execution/node/636/log/
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.
hmmm so then should i just have the code for the migration in endpoint, but then add our migration line to the one in ingest for package policy saved objects then?
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.
This seems like what needs to happen. We can't define a duplicate mapping for an existing SO. Unless there's a way that we import the SO mapping from ingest in our app and simply add another migration to it.