-
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.
[Attack discovery] Add utils for testing (#182918)
## Summary Add `load_attack_discovery_data` script that populates alerts data for Attack discovery testing To load Attack discovery data to the existing instance: ``` node x-pack/solutions/security/plugins/security_solution/scripts/load_attack_discovery_data.js --kibanaUrl http://127.0.0.1:5620 --elasticsearchUrl http://127.0.0.1:9220 ``` --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Mark Hopkin <[email protected]>
- Loading branch information
1 parent
0640f38
commit 2c9e55d
Showing
22 changed files
with
116,346 additions
and
1 deletion.
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
64 changes: 64 additions & 0 deletions
64
x-pack/solutions/security/plugins/security_solution/scripts/attack_discovery/index.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,64 @@ | ||
/* | ||
* 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 { run } from '@kbn/dev-cli-runner'; | ||
import { createEsClient, createKbnClient } from '../endpoint/common/stack_services'; | ||
import { HORIZONTAL_LINE } from '../endpoint/common/constants'; | ||
import { createToolingLogger } from '../../common/endpoint/data_loaders/utils'; | ||
import { loadAttackDiscoveryData } from './load'; | ||
|
||
export const cli = () => { | ||
run( | ||
async (cliContext) => { | ||
createToolingLogger.setDefaultLogLevelFromCliFlags(cliContext.flags); | ||
|
||
const log = cliContext.log; | ||
const kbnClient = createKbnClient({ | ||
log, | ||
url: cliContext.flags.kibanaUrl as string, | ||
username: cliContext.flags.username as string, | ||
password: cliContext.flags.password as string, | ||
}); | ||
const esClient = createEsClient({ | ||
log, | ||
url: cliContext.flags.elasticsearchUrl as string, | ||
username: cliContext.flags.username as string, | ||
password: cliContext.flags.password as string, | ||
}); | ||
|
||
log.info(`${HORIZONTAL_LINE} | ||
Environment Data Loader | ||
${HORIZONTAL_LINE} | ||
`); | ||
log.info(`Loading data to: ${kbnClient.resolveUrl('')}`); | ||
|
||
await loadAttackDiscoveryData({ kbnClient, esClient, log }); | ||
}, | ||
|
||
// Options | ||
{ | ||
description: `Loads data into a environment for testing/development`, | ||
flags: { | ||
string: ['kibanaUrl', 'elasticsearchUrl', 'username', 'password'], | ||
default: { | ||
kibanaUrl: 'http://127.0.0.1:5601', | ||
elasticsearchUrl: 'http://127.0.0.1:9200', | ||
username: 'elastic', | ||
password: 'changeme', | ||
}, | ||
allowUnexpected: false, | ||
help: ` | ||
--username User name to be used for auth against elasticsearch and | ||
kibana (Default: elastic). | ||
--password User name Password (Default: changeme) | ||
--kibanaUrl The url to Kibana (Default: http://127.0.0.1:5601) | ||
--elasticsearchUrl The url to Elasticsearch (Default: http://127.0.0.1:9200) | ||
`, | ||
}, | ||
} | ||
); | ||
}; |
Oops, something went wrong.