Skip to content

Commit 15e7623

Browse files
paul-tavareskevinlogparkiino
authored
[SECURITY_SOLUTION][ENDPOINT] Improve Endpoint Host data generator to 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>
1 parent df86dcb commit 15e7623

File tree

5 files changed

+489
-55
lines changed

5 files changed

+489
-55
lines changed

packages/kbn-dev-utils/src/kbn_client/kbn_client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export class KbnClient {
5454
/**
5555
* Make a direct request to the Kibana server
5656
*/
57-
async request(options: ReqOptions) {
58-
return await this.requester.request(options);
57+
async request<T>(options: ReqOptions) {
58+
return await this.requester.request<T>(options);
5959
}
6060

6161
resolveUrl(relativeUrl: string) {

x-pack/plugins/security_solution/common/endpoint/generate_data.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ const Mac: OSFields[] = [];
110110

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

113+
const POLICY_RESPONSE_STATUSES: HostPolicyResponseActionStatus[] = [
114+
HostPolicyResponseActionStatus.success,
115+
HostPolicyResponseActionStatus.failure,
116+
HostPolicyResponseActionStatus.warning,
117+
];
118+
113119
const APPLIED_POLICIES: Array<{
114120
name: string;
115121
id: string;
@@ -125,6 +131,11 @@ const APPLIED_POLICIES: Array<{
125131
id: 'C2A9093E-E289-4C0A-AA44-8C32A414FA7A',
126132
status: HostPolicyResponseActionStatus.success,
127133
},
134+
{
135+
name: 'Detect Malware Only',
136+
id: '47d7965d-6869-478b-bd9c-fb0d2bb3959f',
137+
status: HostPolicyResponseActionStatus.success,
138+
},
128139
];
129140

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

366377
/**
367-
* Creates new random policy id for the host to simulate new policy application
378+
* Updates the current Host common record applied Policy to a different one from the list
379+
* of random choices and gives it a random policy response status.
368380
*/
369-
public updatePolicyId() {
370-
this.commonInfo.Endpoint.policy.applied.id = this.randomChoice(APPLIED_POLICIES).id;
371-
this.commonInfo.Endpoint.policy.applied.status = this.randomChoice([
372-
HostPolicyResponseActionStatus.success,
373-
HostPolicyResponseActionStatus.failure,
374-
HostPolicyResponseActionStatus.warning,
375-
]);
381+
public updateHostPolicyData() {
382+
this.commonInfo.Endpoint.policy.applied = this.randomChoice(APPLIED_POLICIES);
383+
this.commonInfo.Endpoint.policy.applied.status = this.randomChoice(POLICY_RESPONSE_STATUSES);
376384
}
377385

378386
private createHostData(): HostInfo {

0 commit comments

Comments
 (0)