Skip to content

Commit

Permalink
[Security solution] Assistant package + plugin dead code removal (#20…
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic authored Nov 18, 2024
1 parent 598076e commit cc38d8d
Show file tree
Hide file tree
Showing 49 changed files with 37 additions and 2,209 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import { fromUtf8, toUtf8 } from '@smithy/util-utf8';
* @param {Uint8Array[]} chunks - Array of Uint8Array chunks to be parsed.
* @returns {string} - Parsed string from the Bedrock buffer.
*/
export const parseBedrockBuffer = (chunks: Uint8Array[], logger: Logger): string => {
export const parseBedrockBuffer = (chunks: Uint8Array[]): string => {
// Initialize an empty Uint8Array to store the concatenated buffer.
let bedrockBuffer: Uint8Array = new Uint8Array(0);

// Map through each chunk to process the Bedrock buffer.
return chunks
.map((chunk) => {
const processedChunk = handleBedrockChunk({ chunk, bedrockBuffer, logger });
const processedChunk = handleBedrockChunk({ chunk, bedrockBuffer });
bedrockBuffer = processedChunk.bedrockBuffer;
return processedChunk.decodedChunk;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DefinedUseQueryResult, UseQueryResult } from '@tanstack/react-query';
import useLocalStorage from 'react-use/lib/useLocalStorage';
import useSessionStorage from 'react-use/lib/useSessionStorage';
import { QuickPrompts } from './quick_prompts/quick_prompts';
import { mockAssistantAvailability, TestProviders } from '../mock/test_providers/test_providers';
import { TestProviders } from '../mock/test_providers/test_providers';
import { useFetchCurrentUserConversations } from './api';
import { Conversation } from '../assistant_context/types';
import * as all from './chat_send/use_chat_send';
Expand Down Expand Up @@ -54,7 +54,7 @@ const mockData = {
},
};

const renderAssistant = async (extraProps = {}, providerProps = {}) => {
const renderAssistant = async (extraProps = {}) => {
const chatSendSpy = jest.spyOn(all, 'useChatSend');
const assistant = render(
<TestProviders>
Expand Down Expand Up @@ -310,12 +310,7 @@ describe('Assistant', () => {

describe('when not authorized', () => {
it('should be disabled', async () => {
const { queryByTestId } = await renderAssistant(
{},
{
assistantAvailability: { ...mockAssistantAvailability, isAssistantEnabled: false },
}
);
const { queryByTestId } = await renderAssistant({});
expect(queryByTestId('prompt-textarea')).toHaveProperty('disabled');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const QuickPromptSettingsEditorComponent = ({
);

const handleColorChange = useCallback<EuiSetColorMethod>(
(color, { hex, isValid }) => {
(color) => {
if (selectedQuickPrompt != null) {
setUpdatedQuickPromptSettings((prev) => {
const alreadyExists = prev.some((qp) => qp.name === selectedQuickPrompt.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ export const AssistantSettings: React.FC<Props> = React.memo(
)}
{selectedSettingsTab === ANONYMIZATION_TAB && (
<AnonymizationSettings
defaultPageSize={5}
anonymizationFields={updatedAnonymizationData}
anonymizationFieldsBulkActions={anonymizationFieldsBulkActions}
setAnonymizationFieldsBulkActions={setAnonymizationFieldsBulkActions}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ export const SETTINGS = i18n.translate(
}
);

export const SETTINGS_TOOLTIP = i18n.translate(
'xpack.elasticAssistant.assistant.settings.settingsTooltip',
{
defaultMessage: 'Settings',
}
);

export const SECURITY_AI_SETTINGS = i18n.translate(
'xpack.elasticAssistant.assistant.settings.securityAiSettingsTitle',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { AnonymizationSettings } from '.';
import type { Props } from '.';

const props: Props = {
defaultPageSize: 5,
anonymizationFields: {
total: 4,
page: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import * as i18n from './translations';
import { useAnonymizationListUpdate } from './use_anonymization_list_update';

export interface Props {
defaultPageSize?: number;
anonymizationFields: FindAnonymizationFieldsResponse;
anonymizationFieldsBulkActions: PerformAnonymizationFieldsBulkActionRequestBody;
setAnonymizationFieldsBulkActions: React.Dispatch<
Expand All @@ -28,7 +27,6 @@ export interface Props {
}

const AnonymizationSettingsComponent: React.FC<Props> = ({
defaultPageSize,
anonymizationFields,
anonymizationFieldsBulkActions,
setAnonymizationFieldsBulkActions,
Expand Down Expand Up @@ -60,7 +58,6 @@ const AnonymizationSettingsComponent: React.FC<Props> = ({
anonymizationFields={anonymizationFields}
onListUpdated={onListUpdated}
rawData={null}
pageSize={defaultPageSize}
compressed={true}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ import {
} from '../../../assistant/settings/translations';

export interface Props {
defaultPageSize?: number;
modalMode?: boolean;
onClose?: () => void;
}

const AnonymizationSettingsManagementComponent: React.FC<Props> = ({
defaultPageSize = 5,
modalMode = false,
onClose,
}) => {
Expand Down Expand Up @@ -151,7 +149,6 @@ const AnonymizationSettingsManagementComponent: React.FC<Props> = ({
compressed={false}
onListUpdated={onListUpdated}
rawData={null}
pageSize={defaultPageSize}
/>
</EuiModalBody>
<EuiModalFooter>
Expand Down Expand Up @@ -187,7 +184,6 @@ const AnonymizationSettingsManagementComponent: React.FC<Props> = ({
compressed={false}
onListUpdated={onListUpdated}
rawData={null}
pageSize={defaultPageSize}
/>
</EuiPanel>
<AssistantSettingsBottomBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export interface Props {
compressed?: boolean;
onListUpdated: (updates: BatchUpdateListItem[]) => void;
rawData: Record<string, string[]> | null;
pageSize?: number;
}

const search: EuiSearchBarProps = {
Expand All @@ -71,7 +70,6 @@ const ContextEditorComponent: React.FC<Props> = ({
compressed = true,
onListUpdated,
rawData,
pageSize = DEFAULT_PAGE_SIZE,
}) => {
const isAllSelected = useRef(false); // Must be a ref and not state in order not to re-render `selectionValue`, which fires `onSelectionChange` twice
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,41 +56,19 @@ export const COLUMN_ENTRIES = i18n.translate(
}
);

export const COLUMN_SPACE = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.columnSpaceLabel',
{
defaultMessage: 'Space',
}
);

export const COLUMN_CREATED = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.columnCreatedLabel',
{
defaultMessage: 'Created',
}
);

export const COLUMN_ACTIONS = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.columnActionsLabel',
{
defaultMessage: 'Actions',
}
);

export const SEARCH_PLACEHOLDER = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.searchPlaceholder',
{
defaultMessage: 'Search for an entry',
}
);

export const DEFAULT_FLYOUT_TITLE = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.defaultFlyoutTitle',
{
defaultMessage: 'Knowledge Base',
}
);

export const NEW_INDEX_FLYOUT_TITLE = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.newIndexEntryFlyoutTitle',
{
Expand Down Expand Up @@ -126,27 +104,6 @@ export const MANUAL = i18n.translate(
}
);

export const CREATE_INDEX_TITLE = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.createIndexTitle',
{
defaultMessage: 'New Index entry',
}
);

export const NEW_ENTRY_TITLE = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.newEntryTitle',
{
defaultMessage: 'New entry',
}
);

export const DELETE_ENTRY_DEFAULT_TITLE = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.deleteEntryDefaultTitle',
{
defaultMessage: 'Delete item',
}
);

export const ENTRY_NAME_INPUT_LABEL = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.entryNameInputLabel',
{
Expand Down Expand Up @@ -309,13 +266,6 @@ export const ENTRY_OUTPUT_FIELDS_HELP_LABEL = i18n.translate(
}
);

export const ENTRY_INPUT_PLACEHOLDER = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.entryInputPlaceholder',
{
defaultMessage: 'Input',
}
);

export const ENTRY_FIELD_PLACEHOLDER = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettingsManagement.entryFieldPlaceholder',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ export const ALERTS_LABEL = i18n.translate(
}
);

export const SEND_ALERTS_LABEL = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettings.sendAlertsLabel',
{
defaultMessage: 'Send Alerts',
}
);

export const LATEST_AND_RISKIEST_OPEN_ALERTS = (alertsCount: number) =>
i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettings.latestAndRiskiestOpenAlertsLabel',
Expand Down Expand Up @@ -115,24 +108,3 @@ export const KNOWLEDGE_BASE_ELSER_LABEL = i18n.translate(
defaultMessage: 'ELSER Configured',
}
);

export const ESQL_LABEL = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettings.esqlLabel',
{
defaultMessage: 'ES|QL Knowledge Base Documents',
}
);

export const ESQL_DESCRIPTION = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettings.esqlDescription',
{
defaultMessage: 'Knowledge Base docs for generating ES|QL queries',
}
);

export const ESQL_DESCRIPTION_INSTALLED = i18n.translate(
'xpack.elasticAssistant.assistant.settings.knowledgeBaseSettings.esqlInstalledDescription',
{
defaultMessage: 'ES|QL Knowledge Base docs loaded',
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function _formatMessages(messages: BaseMessage[]) {
if (!messages.length) {
throw new Error('No messages provided.');
}
return messages.map((message, i) => {
return messages.map((message) => {
if (typeof message.content !== 'string') {
throw new Error('Multimodal messages are not supported.');
}
Expand Down
Loading

0 comments on commit cc38d8d

Please sign in to comment.