-
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] Endpoint generator and data loader support for Host Isolation #100813
Merged
paul-tavares
merged 4 commits into
elastic:master
from
paul-tavares:fix/kibana-100800-generator-changes
May 28, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
67e4838
[Security solution][Endpoint] Add Host Isolation related data to the …
paul-tavares a34cc45
Fix generator `randomBoolean()` to ensure it works with seeded random…
paul-tavares 58fa724
Update resolver snapshots due to additional call to randomizer
paul-tavares 83b8f03
Merge remote-tracking branch 'upstream/master' into fix/kibana-100800…
paul-tavares 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
62 changes: 62 additions & 0 deletions
62
x-pack/plugins/security_solution/common/endpoint/data_generators/fleet_action_generator.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,62 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { DeepPartial } from 'utility-types'; | ||
import { merge } from 'lodash'; | ||
import { BaseDataGenerator } from './base_data_generator'; | ||
import { EndpointAction, EndpointActionResponse, ISOLATION_ACTIONS } from '../types'; | ||
|
||
const ISOLATION_COMMANDS: ISOLATION_ACTIONS[] = ['isolate', 'unisolate']; | ||
|
||
export class FleetActionGenerator extends BaseDataGenerator { | ||
/** Generate an Action */ | ||
generate(overrides: DeepPartial<EndpointAction> = {}): EndpointAction { | ||
const timeStamp = new Date(this.randomPastDate()); | ||
|
||
return merge( | ||
{ | ||
action_id: this.randomUUID(), | ||
'@timestamp': timeStamp.toISOString(), | ||
expiration: this.randomFutureDate(timeStamp), | ||
type: 'INPUT_ACTION', | ||
input_type: 'endpoint', | ||
agents: [this.randomUUID()], | ||
user_id: 'elastic', | ||
data: { | ||
command: this.randomIsolateCommand(), | ||
comment: this.randomString(15), | ||
}, | ||
}, | ||
overrides | ||
); | ||
} | ||
|
||
/** Generates an action response */ | ||
generateResponse(overrides: DeepPartial<EndpointActionResponse> = {}): EndpointActionResponse { | ||
const timeStamp = new Date(); | ||
|
||
return merge( | ||
{ | ||
action_data: { | ||
command: this.randomIsolateCommand(), | ||
comment: '', | ||
}, | ||
action_id: this.randomUUID(), | ||
agent_id: this.randomUUID(), | ||
started_at: this.randomPastDate(), | ||
completed_at: timeStamp.toISOString(), | ||
error: 'some error happen', | ||
'@timestamp': timeStamp.toISOString(), | ||
}, | ||
overrides | ||
); | ||
} | ||
|
||
protected randomIsolateCommand() { | ||
return this.randomChoice(ISOLATION_COMMANDS); | ||
} | ||
} |
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
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.
the bug fix for the problem that was introduced originally is here. Instead of using
Math.random()
, we need to usethis.random()
which is a seeded random number generator