-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EDR Workflows] Crowdstrike - Add more routes and responses to mocked…
- Loading branch information
Showing
16 changed files
with
1,875 additions
and
69 deletions.
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
99 changes: 99 additions & 0 deletions
99
...scripts/endpoint/api_emulator/emulator_plugins/crowdstrike/routes/batch_init_rtr_route.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,99 @@ | ||
/* | ||
* 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 { buildCrowdstrikeRoutePath, TEST_AGENT_ID, TEST_BATCH_ID, TEST_SESSION_ID } from './utils'; | ||
import type { ExternalEdrServerEmulatorRouteHandlerMethod } from '../../../external_edr_server_emulator.types'; | ||
import type { EmulatorServerRouteDefinition } from '../../../lib/emulator_server.types'; | ||
|
||
export const batchInitRTRSessionRoute = (): EmulatorServerRouteDefinition => { | ||
return { | ||
path: buildCrowdstrikeRoutePath('/real-time-response/combined/batch-init-session/v1'), | ||
method: 'POST', | ||
handler: batchInitSessionSuccessHandler, | ||
}; | ||
}; | ||
// @ts-expect-error - example of error response | ||
const initSessionWrongHostIdError = async () => { | ||
return { | ||
meta: { | ||
query_time: 0.244284399, | ||
powered_by: 'empower-api', | ||
trace_id: 'xxx', | ||
}, | ||
batch_id: '', | ||
resources: { | ||
[TEST_AGENT_ID]: { | ||
session_id: '', | ||
complete: false, | ||
stdout: '', | ||
stderr: '', | ||
aid: TEST_AGENT_ID, | ||
errors: [ | ||
{ | ||
code: 500, | ||
message: `uuid: incorrect UUID length 47 in string ${TEST_AGENT_ID}`, | ||
}, | ||
], | ||
query_time: 0, | ||
offline_queued: false, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
code: 404, | ||
message: 'no successful hosts initialized on RTR', | ||
}, | ||
], | ||
}; | ||
}; | ||
// @ts-expect-error - example of error response | ||
const initSessionMissingIdsError = async () => { | ||
return { | ||
meta: { | ||
query_time: 0.00034664, | ||
powered_by: 'empower-api', | ||
trace_id: 'xxx', | ||
}, | ||
batch_id: '', | ||
resources: {}, | ||
errors: [ | ||
{ | ||
code: 400, | ||
message: | ||
'Invalid number of hosts in request: 0. Must be an integer greater than 0 and less than or equal to 10000', | ||
}, | ||
], | ||
}; | ||
}; | ||
|
||
const batchInitSessionSuccessHandler: ExternalEdrServerEmulatorRouteHandlerMethod< | ||
{}, | ||
{} | ||
> = async () => { | ||
return { | ||
meta: { | ||
query_time: 1.067267552, | ||
powered_by: 'empower-api', | ||
trace_id: 'xxx', | ||
}, | ||
batch_id: TEST_BATCH_ID, | ||
resources: { | ||
[TEST_AGENT_ID]: { | ||
session_id: TEST_SESSION_ID, | ||
task_id: 'xxx', | ||
complete: true, | ||
stdout: '/', | ||
stderr: '', | ||
base_command: 'pwd', | ||
aid: TEST_AGENT_ID, | ||
errors: [], | ||
query_time: 0, | ||
offline_queued: false, | ||
}, | ||
}, | ||
errors: [], | ||
}; | ||
}; |
56 changes: 56 additions & 0 deletions
56
...point/api_emulator/emulator_plugins/crowdstrike/routes/batch_refresh_rtr_session_route.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,56 @@ | ||
/* | ||
* 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 { buildCrowdstrikeRoutePath, TEST_AGENT_ID, TEST_SESSION_ID } from './utils'; | ||
import type { ExternalEdrServerEmulatorRouteHandlerMethod } from '../../../external_edr_server_emulator.types'; | ||
import type { EmulatorServerRouteDefinition } from '../../../lib/emulator_server.types'; | ||
|
||
export const batchRTRRefreshSessionRoute = (): EmulatorServerRouteDefinition => { | ||
return { | ||
path: buildCrowdstrikeRoutePath('/real-time-response/combined/batch-refresh-session/v1'), | ||
method: 'POST', | ||
handler: batchRTRRefreshSessionHandler, | ||
}; | ||
}; | ||
|
||
// @ts-expect-error - example of error response | ||
const batchRTRRefreshSessionInvalidSessionError = async () => { | ||
return { | ||
meta: { | ||
query_time: 0.001031577, | ||
powered_by: 'empower-api', | ||
trace_id: 'xxx', | ||
}, | ||
resources: {}, | ||
errors: [ | ||
{ | ||
code: 400, | ||
message: 'no hosts in this batch session', | ||
}, | ||
], | ||
}; | ||
}; | ||
|
||
const batchRTRRefreshSessionHandler: ExternalEdrServerEmulatorRouteHandlerMethod< | ||
{}, | ||
{} | ||
> = async () => { | ||
return { | ||
meta: { | ||
query_time: 0.068379923, | ||
powered_by: 'empower-api', | ||
trace_id: 'xxx', | ||
}, | ||
resources: { | ||
[TEST_AGENT_ID]: { | ||
aid: TEST_AGENT_ID, | ||
session_id: TEST_SESSION_ID, | ||
errors: [], | ||
}, | ||
}, | ||
errors: [], | ||
}; | ||
}; |
Oops, something went wrong.