-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.14] [Security solution] Add additional properties to attack discov…
…ery telemetry (#182249) (#182997) # Backport This will backport the following commits from `main` to `8.14`: - [[Security solution] Add additional properties to attack discovery telemetry (#182249)](#182249) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Steph Milovic","email":"stephanie.milovic@elastic.co"},"sourceCommit":{"committedDate":"2024-05-02T04:48:36Z","message":"[Security solution] Add additional properties to attack discovery telemetry (#182249)","sha":"e306074aa9e8943ab342270a6f795e17ee37c1da","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team: SecuritySolution","Team:Security Generative AI","v8.14.0","v8.15.0","Feature:Attack Discovery"],"number":182249,"url":"#182249 solution] Add additional properties to attack discovery telemetry (#182249)","sha":"e306074aa9e8943ab342270a6f795e17ee37c1da"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","labelRegex":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"#182249 solution] Add additional properties to attack discovery telemetry (#182249)","sha":"e306074aa9e8943ab342270a6f795e17ee37c1da"}}]}] BACKPORT-->
- Loading branch information
1 parent
6e804fd
commit a71c51c
Showing
6 changed files
with
105 additions
and
11 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
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