Skip to content

Commit

Permalink
[SECURITY_SOLUTION][ENDPOINT] Improve Endpoint Host data generator to…
Browse files Browse the repository at this point in the history
… also integrate with Ingest (#74305)

* Endpoint generator connects host with a real policy and enrolls agent

Co-authored-by: Paul Tavares <paul.tavares@elastic.co>
Co-authored-by: kevinlog <kevin.logan@elastic.co>
Co-authored-by: Candace Park <candace.park@elastic.co>
  • Loading branch information
4 people committed Sep 30, 2020
1 parent 7e8798e commit d96c1ed
Show file tree
Hide file tree
Showing 5 changed files with 489 additions and 55 deletions.
4 changes: 2 additions & 2 deletions packages/kbn-dev-utils/src/kbn_client/kbn_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class KbnClient {
/**
* Make a direct request to the Kibana server
*/
async request(options: ReqOptions) {
return await this.requester.request(options);
async request<T>(options: ReqOptions) {
return await this.requester.request<T>(options);
}

resolveUrl(relativeUrl: string) {
Expand Down
24 changes: 16 additions & 8 deletions x-pack/plugins/security_solution/common/endpoint/generate_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ const Mac: OSFields[] = [];

const OS: OSFields[] = [...Windows, ...Mac, ...Linux];

const POLICY_RESPONSE_STATUSES: HostPolicyResponseActionStatus[] = [
HostPolicyResponseActionStatus.success,
HostPolicyResponseActionStatus.failure,
HostPolicyResponseActionStatus.warning,
];

const APPLIED_POLICIES: Array<{
name: string;
id: string;
Expand All @@ -125,6 +131,11 @@ const APPLIED_POLICIES: Array<{
id: 'C2A9093E-E289-4C0A-AA44-8C32A414FA7A',
status: HostPolicyResponseActionStatus.success,
},
{
name: 'Detect Malware Only',
id: '47d7965d-6869-478b-bd9c-fb0d2bb3959f',
status: HostPolicyResponseActionStatus.success,
},
];

const FILE_OPERATIONS: string[] = ['creation', 'open', 'rename', 'execution', 'deletion'];
Expand Down Expand Up @@ -364,15 +375,12 @@ export class EndpointDocGenerator {
}

/**
* Creates new random policy id for the host to simulate new policy application
* Updates the current Host common record applied Policy to a different one from the list
* of random choices and gives it a random policy response status.
*/
public updatePolicyId() {
this.commonInfo.Endpoint.policy.applied.id = this.randomChoice(APPLIED_POLICIES).id;
this.commonInfo.Endpoint.policy.applied.status = this.randomChoice([
HostPolicyResponseActionStatus.success,
HostPolicyResponseActionStatus.failure,
HostPolicyResponseActionStatus.warning,
]);
public updateHostPolicyData() {
this.commonInfo.Endpoint.policy.applied = this.randomChoice(APPLIED_POLICIES);
this.commonInfo.Endpoint.policy.applied.status = this.randomChoice(POLICY_RESPONSE_STATUSES);
}

private createHostData(): HostInfo {
Expand Down
Loading

0 comments on commit d96c1ed

Please sign in to comment.