Skip to content

Commit

Permalink
Updating preconfigured connector name (elastic#211927)
Browse files Browse the repository at this point in the history
## Summary

Update Preconfigured connector name to `Elastic LLM`.

<img width="1504" alt="Screenshot 2025-02-20 at 11 29 02 AM"
src="https://github.com/user-attachments/assets/aa0a32f7-f1b2-4496-8c2e-7773f017c153"
/>

### ES3 Testing instruction
No additional config needed. Once run in local machine, the changes
should reflect automatically.

### ESS instructions
In `kibana.dev.yml` file, add
```
# xpack.actions.preconfigured:
   Elastic-LLM:
     name: Elastic LLM
     actionTypeId: .inference
     exposeConfig: true
     config:
       provider: 'elastic'
       taskType: 'chat_completion'
       inferenceId: '.rainbow-sprinkles-elastic'
       providerConfig:
         model_id: 'rainbow-sprinkles'
```
and the preconfigured endpoint with updated name should be visible.

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [X] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 0e02a32)

# Conflicts:
#	config/serverless.yml
#	x-pack/solutions/security/plugins/security_solution/public/management/cypress/tasks/insights.ts
  • Loading branch information
Samiul-TheSoccerFan committed Feb 25, 2025
1 parent 171541e commit d5cb928
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 4 deletions.
14 changes: 12 additions & 2 deletions config/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,15 @@ xpack.dataUsage.enableExperimental: ['dataUsageDisabled']
# Ensure Serverless is using the Amsterdam theme
uiSettings.experimental.defaultTheme: "amsterdam"

# This feature is disabled in Serverless until Inference Endpoint become enabled within a Serverless environment
xpack.stack_connectors.enableExperimental: ['inferenceConnectorOff']
# This is the definition introducing pre-configured Kibana Connector for Elastic default LLM
xpack.actions.preconfigured:
Elastic-LLM:
name: Elastic LLM
actionTypeId: .inference
exposeConfig: true
config:
provider: 'elastic'
taskType: 'chat_completion'
inferenceId: '.rainbow-sprinkles-elastic'
providerConfig:
model_id: 'rainbow-sprinkles'
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const request = <T = unknown>({
...options,
});
};
export const INTERNAL_INFERENCE_CONNECTORS = ['Elastic-Inference-Rainbow-Sprinkles'];
export const INTERNAL_INFERENCE_CONNECTORS = ['Elastic-LLM'];
export const INTERNAL_CLOUD_CONNECTORS = ['Elastic-Cloud-SMTP'];

export const getConnectors = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,212 @@ import {
WORKFLOW_INSIGHTS_UPDATE_ROUTE,
} from '../../../../common/endpoint/constants';

const INTERNAL_CLOUD_CONNECTORS = ['Elastic-Cloud-SMTP'];
const INTERNAL_INFERENCE_CONNECTORS = ['Elastic-LLM'];
const INTERNAL_CONNECTORS = [...INTERNAL_CLOUD_CONNECTORS, ...INTERNAL_INFERENCE_CONNECTORS];

export const createBedrockAIConnector = (connectorName?: string) =>
request<ConnectorResponse>({
method: 'POST',
url: '/api/actions/connector',
body: {
connector_type_id: '.bedrock',
secrets: {
accessKey: '123',
secret: '123',
},
config: {
apiUrl: 'https://bedrock.com',
},
name: connectorName || 'Bedrock cypress test e2e connector',
},
});

export const getConnectors = () =>
request<AllConnectorsResponse[]>({
method: 'GET',
url: 'api/actions/connectors',
});

export const deleteConnectors = () => {
getConnectors().then(($response) => {
if ($response.body.length > 0) {
const ids = $response.body.map((connector) => {
return connector.id;
});
ids.forEach((id) => {
if (!INTERNAL_CONNECTORS.includes(id)) {
request({
method: 'DELETE',
url: `api/actions/connector/${id}`,
});
}
});
}
});
};

export const setConnectorIdInLocalStorage = (res: { body: { id: string } }) => {
window.localStorage.setItem(
`elasticAssistantDefault.defendInsights.default.connectorId`,
`"${res.body.id}"`
);
};

export const validateUserGotRedirectedToTrustedApps = () => {
cy.url().should('include', '/app/security/administration/trusted_apps');
};

export const validateUserGotRedirectedToEndpointDetails = (endpointId: string) => {
cy.url().should(
'include',
`/app/security/administration/endpoints?selected_endpoint=${endpointId}&show=details`
);
};

export const interceptGetWorkflowInsightsApiCall = () => {
cy.intercept({ method: 'GET', url: '**/internal/api/endpoint/workflow_insights**' }).as(
'getWorkflowInsights'
);
};

export const expectWorkflowInsightsApiToBeCalled = () => {
cy.wait('@getWorkflowInsights', { timeout: 30 * 1000 });
};

export const interceptGetDefendInsightsApiCall = () => {
cy.intercept({ method: 'GET', url: '**/internal/elastic_assistant/defend_insights**' }).as(
'getDefendInsights'
);
};

export const expectDefendInsightsApiToBeCalled = () => {
cy.wait('@getDefendInsights', { timeout: 30 * 1000 });
};

export const interceptPostDefendInsightsApiCall = () => {
cy.intercept({ method: 'POST', url: '**/internal/elastic_assistant/defend_insights**' }).as(
'createInsights'
);
};

export const expectPostDefendInsightsApiToBeCalled = () => {
cy.wait('@createInsights', { timeout: 30 * 1000 });
};

export const stubPutWorkflowInsightsApiResponse = () => {
cy.intercept('PUT', '**/internal/api/endpoint/workflow_insights/**', (req) => {
req.continue((res) => {
return res.send(200, {
status: 'ok',
});
});
});
};

export const stubDefendInsightsApiResponse = (
overrides: Record<string, string> = {},
config: { times?: number } = {}
) => {
cy.intercept(
{
method: 'GET',
url: '**/internal/elastic_assistant/defend_insights?status=running**',
...(config.times ? { times: config.times } : {}),
},
(req) => {
req.continue((res) => {
return res.send(200, {
data: [
{
timestamp: '2024-12-16T13:44:52.633Z',
id: 'd95561cb-1f75-4a6c-8be4-cb7529ddd5e0',
backingIndex:
'.ds-.kibana-elastic-ai-assistant-defend-insights-default-2024.12.16-000001',
createdAt: '2024-12-16T13:44:52.633Z',
updatedAt: '2024-12-16T13:44:52.633Z',
lastViewedAt: '2024-12-16T13:44:53.866Z',
users: [
{
id: 'u_mGBROF_q5bmFCATbLXAcCwKa0k8JvONAwSruelyKA5E_0',
name: 'elastic',
},
],
namespace: 'default',
status: 'running',
apiConfig: {
connectorId: 'db760d65-6722-4646-955f-fbdc9851df86',
actionTypeId: '.bedrock',
},
endpointIds: ['33581c4f-bef1-4162-9809-4c208e2e1991'],
insightType: 'incompatible_antivirus',
insights: [],
generationIntervals: [],
averageIntervalMs: 0,
...overrides,
},
],
});
});
}
);
};

export const stubWorkflowInsightsApiResponse = (endpointId: string) => {
cy.intercept('GET', '**/internal/api/endpoint/workflow_insights**', (req) => {
req.continue((res) => {
return res.send(200, [
{
remediation: {
exception_list_items: [
{
entries: [
{
field: 'process.executable.caseless',
type: 'match',
value: '/usr/bin/clamscan',
operator: 'included',
},
],
list_id: 'endpoint_trusted_apps',
name: 'ClamAV',
os_types: ['linux'],
description: 'Suggested by Security Workflow Insights',
tags: ['policy:all'],
},
],
},
metadata: {
notes: {
llm_model: '',
},
},
'@timestamp': '2024-12-16T13:45:03.055Z',
action: {
type: 'refreshed',
timestamp: '2024-12-16T13:45:03.055Z',
},
source: {
data_range_end: '2024-12-17T13:45:03.055Z',
id: 'db760d65-6722-4646-955f-fbdc9851df86',
type: 'llm-connector',
data_range_start: '2024-12-16T13:45:03.055Z',
},
message: 'Incompatible antiviruses detected',
category: 'endpoint',
type: 'incompatible_antivirus',
value: 'ClamAV',
target: {
ids: [endpointId],
type: 'endpoint',
},
id: 'CMm3z5MBPx3JiizjFx5g',
},
]);
});
});
};

export const triggerRunningDefendInsights = () => {
return request({
method: 'POST',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const API_HEADERS = Object.freeze({
});

export const INTERNAL_CLOUD_CONNECTORS = ['Elastic-Cloud-SMTP'];
export const INTERNAL_INFERENCE_CONNECTORS = ['Elastic-Inference-Rainbow-Sprinkles'];
export const INTERNAL_INFERENCE_CONNECTORS = ['Elastic-LLM'];

export const rootRequest = <T = unknown>({
headers: optionHeaders = {},
Expand Down

0 comments on commit d5cb928

Please sign in to comment.