-
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.
[Security solution] Add additional properties to attack discovery tel…
…emetry (#182249)
- Loading branch information
1 parent
7d97184
commit e306074
Showing
7 changed files
with
107 additions
and
12 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
50 changes: 50 additions & 0 deletions
50
x-pack/plugins/security_solution/public/attack_discovery/use_attack_discovery/helpers.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,50 @@ | ||
/* | ||
* 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 type { ActionConnector } from '@kbn/triggers-actions-ui-plugin/public'; | ||
import type { ActionConnectorProps } from '@kbn/triggers-actions-ui-plugin/public/types'; | ||
|
||
// aligns with OpenAiProviderType from '@kbn/stack-connectors-plugin/common/openai/types' | ||
enum OpenAiProviderType { | ||
OpenAi = 'OpenAI', | ||
AzureAi = 'Azure OpenAI', | ||
} | ||
|
||
interface GenAiConfig { | ||
apiProvider?: OpenAiProviderType; | ||
apiUrl?: string; | ||
defaultModel?: string; | ||
} | ||
|
||
/** | ||
* Returns the GenAiConfig for a given ActionConnector. Note that if the connector is preconfigured, | ||
* the config will be undefined as the connector is neither available nor editable. | ||
* | ||
* @param connector | ||
*/ | ||
export const getGenAiConfig = (connector: ActionConnector | undefined): GenAiConfig | undefined => { | ||
if (!connector?.isPreconfigured) { | ||
const config = (connector as ActionConnectorProps<GenAiConfig, unknown>)?.config; | ||
const { apiProvider, apiUrl, defaultModel } = config ?? {}; | ||
|
||
return { | ||
apiProvider, | ||
apiUrl, | ||
defaultModel: | ||
apiProvider === OpenAiProviderType.AzureAi | ||
? getAzureApiVersionParameter(apiUrl ?? '') | ||
: defaultModel, | ||
}; | ||
} | ||
|
||
return undefined; // the connector is neither available nor editable | ||
}; | ||
|
||
const getAzureApiVersionParameter = (url: string): string | undefined => { | ||
const urlSearchParams = new URLSearchParams(new URL(url).search); | ||
return urlSearchParams.get('api-version') ?? undefined; | ||
}; |
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