Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] [Security Solution] [Attack discovery] Updates Attack discovery directory structure (#200613) #200652

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
RECONNAISSANCE,
replaceNewlineLiterals,
} from './helpers';
import { mockAttackDiscovery } from './mock/mock_attack_discovery';
import { mockAttackDiscovery } from './pages/mock/mock_attack_discovery';
import * as i18n from './translations';

const expectedTactics = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import { mockHistory } from '../../common/utils/route/mocks';
import { AttackDiscoveryPage } from '.';
import { mockTimelines } from '../../common/mock/mock_timelines_plugin';
import { UpsellingProvider } from '../../common/components/upselling_provider';
import { mockFindAnonymizationFieldsResponse } from '../mock/mock_find_anonymization_fields_response';
import { mockFindAnonymizationFieldsResponse } from './mock/mock_find_anonymization_fields_response';
import {
getMockUseAttackDiscoveriesWithCachedAttackDiscoveries,
getMockUseAttackDiscoveriesWithNoAttackDiscoveriesLoading,
} from '../mock/mock_use_attack_discovery';
} from './mock/mock_use_attack_discovery';
import { ATTACK_DISCOVERY_PAGE_TITLE } from './page_title/translations';
import { useAttackDiscovery } from '../use_attack_discovery';
import { useAttackDiscovery } from './use_attack_discovery';
import { useLoadConnectors } from '@kbn/elastic-assistant/impl/connectorland/use_load_connectors';

const mockConnectors: unknown[] = [
Expand Down Expand Up @@ -75,7 +75,7 @@ jest.mock('../../common/links', () => ({
}),
}));

jest.mock('../use_attack_discovery', () => ({
jest.mock('./use_attack_discovery', () => ({
useAttackDiscovery: jest.fn().mockReturnValue({
approximateFutureTime: null,
attackDiscoveries: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { CONNECTOR_ID_LOCAL_STORAGE_KEY, getSize, showLoading } from './helpers'
import { LoadingCallout } from './loading_callout';
import { PageTitle } from './page_title';
import { Results } from './results';
import { useAttackDiscovery } from '../use_attack_discovery';
import { useAttackDiscovery } from './use_attack_discovery';

const AttackDiscoveryPageComponent: React.FC = () => {
const spaceId = useSpaceId() ?? 'default';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { render, screen } from '@testing-library/react';
import React from 'react';

import { TestProviders } from '../../../common/mock';
import { TestProviders } from '../../../../../common/mock';
import { getFieldMarkdownRenderer } from '../field_markdown_renderer';
import { AttackDiscoveryMarkdownParser } from '.';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { useExpandableFlyoutApi } from '@kbn/expandable-flyout';
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';

import { TestProviders } from '../../../common/mock';
import { TestProviders } from '../../../../../common/mock';
import { getFieldMarkdownRenderer } from '.';
import { createExpandableFlyoutApiMock } from '../../../common/mock/expandable_flyout';
import { createExpandableFlyoutApiMock } from '../../../../../common/mock/expandable_flyout';

jest.mock('@kbn/expandable-flyout');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiBadge, EuiButtonEmpty, EuiToolTip } from '@elastic/eui';
import React, { useCallback, useMemo } from 'react';
import { useExpandableFlyoutApi } from '@kbn/expandable-flyout';

import { DraggableBadge } from '../../../common/components/draggables';
import { DraggableBadge } from '../../../../../common/components/draggables';
import { getFlyoutPanelProps } from './helpers';
import type { ParsedField } from '../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { render, screen } from '@testing-library/react';
import React from 'react';

import { TestProviders } from '../../common/mock';
import { TestProviders } from '../../../../common/mock';
import { AttackDiscoveryMarkdownFormatter } from '.';

describe('AttackDiscoveryMarkdownFormatter', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { QueryOperator } from '../../../common/types';
import type { QueryOperator } from '../../../../../common/types';

export interface ParsedField {
icon?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { render, screen } from '@testing-library/react';
import React from 'react';

import { ActionableSummary } from '.';
import { TestProviders } from '../../../common/mock';
import { mockAttackDiscovery } from '../../mock/mock_attack_discovery';
import { TestProviders } from '../../../../../common/mock';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';

describe('ActionableSummary', () => {
const mockReplacements = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { render, screen } from '@testing-library/react';
import React from 'react';

import { Actions } from '.';
import { TestProviders } from '../../../common/mock';
import { mockAttackDiscovery } from '../../mock/mock_attack_discovery';
import { TestProviders } from '../../../../../common/mock';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';
import { ATTACK_CHAIN, ALERTS } from './translations';

describe('Actions', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { AttackDiscovery, Replacements } from '@kbn/elastic-assistant-commo
import React from 'react';

import { AlertsBadge } from './alerts_badge';
import { MiniAttackChain } from '../../attack/mini_attack_chain';
import { MiniAttackChain } from '../tabs/attack_discovery_tab/attack/mini_attack_chain';
import { TakeAction } from './take_action';
import * as i18n from './translations';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';

import { TestProviders } from '../../../../common/mock';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';
import { TestProviders } from '../../../../../../common/mock';
import { mockAttackDiscovery } from '../../../../mock/mock_attack_discovery';
import { TakeAction } from '.';

describe('TakeAction', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
} from '@elastic/eui';
import React, { useCallback, useMemo, useState } from 'react';

import { useKibana } from '../../../../common/lib/kibana';
import { APP_ID } from '../../../../../common';
import { getAttackDiscoveryMarkdown } from '../../../get_attack_discovery_markdown/get_attack_discovery_markdown';
import { useKibana } from '../../../../../../common/lib/kibana';
import { APP_ID } from '../../../../../../../common';
import { getAttackDiscoveryMarkdown } from '../../get_attack_discovery_markdown/get_attack_discovery_markdown';
import * as i18n from './translations';
import { useAddToNewCase } from '../use_add_to_case';
import { useAddToExistingCase } from '../use_add_to_existing_case';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { act, renderHook } from '@testing-library/react-hooks';

import { useAddToNewCase } from '.';
import { TestProviders } from '../../../../common/mock';
import { TestProviders } from '../../../../../../common/mock';

jest.mock('../../../../common/lib/kibana', () => ({
jest.mock('../../../../../../common/lib/kibana', () => ({
useKibana: jest.fn().mockReturnValue({
services: {
cases: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useAssistantContext } from '@kbn/elastic-assistant';
import type { Replacements } from '@kbn/elastic-assistant-common';
import React, { useCallback, useMemo } from 'react';

import { useKibana } from '../../../../common/lib/kibana';
import { useKibana } from '../../../../../../common/lib/kibana';
import * as i18n from './translations';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import { act, renderHook } from '@testing-library/react-hooks';

import { useAddToExistingCase } from '.';
import { useKibana } from '../../../../common/lib/kibana';
import { TestProviders } from '../../../../common/mock';
import { useKibana } from '../../../../../../common/lib/kibana';
import { TestProviders } from '../../../../../../common/mock';

jest.mock('../../../../common/lib/kibana', () => ({
jest.mock('../../../../../../common/lib/kibana', () => ({
useKibana: jest.fn().mockReturnValue({
services: {
cases: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useAssistantContext } from '@kbn/elastic-assistant';
import type { Replacements } from '@kbn/elastic-assistant-common';
import { useCallback } from 'react';

import { useKibana } from '../../../../common/lib/kibana';
import { useKibana } from '../../../../../../common/lib/kibana';
import * as i18n from './translations';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
getMarkdownFields,
getMarkdownWithOriginalValues,
} from './get_attack_discovery_markdown';
import { mockAttackDiscovery } from '../mock/mock_attack_discovery';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';

describe('getAttackDiscoveryMarkdown', () => {
describe('getMarkdownFields', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import type { AttackDiscovery, Replacements } from '@kbn/elastic-assistant-common';

import { getTacticLabel, getTacticMetadata } from '../helpers';
import { getTacticLabel, getTacticMetadata } from '../../../../helpers';

export const getMarkdownFields = (markdown: string): string => {
const regex = new RegExp('{{\\s*(\\S+)\\s+(\\S+)\\s*}}', 'gm');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { render, screen } from '@testing-library/react';
import React from 'react';

import { AttackDiscoveryPanel } from '.';
import { TestProviders } from '../../common/mock';
import { mockAttackDiscovery } from '../mock/mock_attack_discovery';
import { TestProviders } from '../../../../common/mock';
import { mockAttackDiscovery } from '../../mock/mock_attack_discovery';

describe('AttackDiscoveryPanel', () => {
it('renders the attack discovery accordion', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import { render, screen } from '@testing-library/react';
import React from 'react';

import { TestProviders } from '../../../../common/mock';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';
import { TestProviders } from '../../../../../../common/mock';
import { mockAttackDiscovery } from '../../../../mock/mock_attack_discovery';
import { AlertsTab } from '.';

describe('AlertsTab', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type { AttackDiscovery, Replacements } from '@kbn/elastic-assistant-commo
import { AlertConsumers } from '@kbn/rule-registry-plugin/common/technical_rule_data_field_names';
import React, { useMemo } from 'react';

import { ALERTS_TABLE_REGISTRY_CONFIG_IDS } from '../../../../../common/constants';
import { useKibana } from '../../../../common/lib/kibana';
import { ALERTS_TABLE_REGISTRY_CONFIG_IDS } from '../../../../../../../common/constants';
import { useKibana } from '../../../../../../common/lib/kibana';

interface Props {
attackDiscovery: AttackDiscovery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import { render, screen } from '@testing-library/react';
import React from 'react';

import { getTacticMetadata } from '../../helpers';
import { getTacticMetadata } from '../../../../../../../helpers';
import { AttackChain } from '.';

import { mockAttackDiscovery } from '../../mock/mock_attack_discovery';
import { mockAttackDiscovery } from '../../../../../../mock/mock_attack_discovery';

describe('AttackChain', () => {
it('renders the expected tactics', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import React, { useMemo } from 'react';

import type { AttackDiscovery } from '@kbn/elastic-assistant-common';
import { Tactic } from './tactic';
import { getTacticMetadata } from '../../helpers';
import { getTacticMetadata } from '../../../../../../../helpers';

interface Props {
attackDiscovery: AttackDiscovery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { render, screen } from '@testing-library/react';
import React from 'react';

import type { TacticMetadata } from '../../helpers';
import { getTacticMetadata } from '../../helpers';
import { mockAttackDiscovery } from '../../mock/mock_attack_discovery';
import type { TacticMetadata } from '../../../../../../../helpers';
import { getTacticMetadata } from '../../../../../../../helpers';
import { mockAttackDiscovery } from '../../../../../../mock/mock_attack_discovery';
import { MiniAttackChain } from '.';

describe('MiniAttackChain', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiText, EuiToolTip, useEuiTheme } from '@el
import React, { useMemo } from 'react';

import type { AttackDiscovery } from '@kbn/elastic-assistant-common';
import { getTacticMetadata } from '../../helpers';
import { getTacticMetadata } from '../../../../../../../helpers';
import { ATTACK_CHAIN_TOOLTIP } from './translations';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import React from 'react';

import { AttackDiscoveryTab } from '.';
import type { Replacements } from '@kbn/elastic-assistant-common';
import { TestProviders } from '../../../../common/mock';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';
import { TestProviders } from '../../../../../../common/mock';
import { mockAttackDiscovery } from '../../../../mock/mock_attack_discovery';
import { ATTACK_CHAIN, DETAILS, SUMMARY } from './translations';

describe('AttackDiscoveryTab', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiSpacer, EuiTitle, useEuiTheme }
import { css } from '@emotion/react';
import React, { useMemo } from 'react';

import { AttackChain } from '../../../attack/attack_chain';
import { InvestigateInTimelineButton } from '../../../../common/components/event_details/investigate_in_timeline_button';
import { buildAlertsKqlFilter } from '../../../../detections/components/alerts_table/actions';
import { getTacticMetadata } from '../../../helpers';
import { AttackChain } from './attack/attack_chain';
import { InvestigateInTimelineButton } from '../../../../../../common/components/event_details/investigate_in_timeline_button';
import { buildAlertsKqlFilter } from '../../../../../../detections/components/alerts_table/actions';
import { getTacticMetadata } from '../../../../../helpers';
import { AttackDiscoveryMarkdownFormatter } from '../../../attack_discovery_markdown_formatter';
import * as i18n from './translations';
import { ViewInAiAssistant } from '../../view_in_ai_assistant';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { render, screen } from '@testing-library/react';
import React from 'react';

import { getTabs } from './get_tabs';
import { TestProviders } from '../../../common/mock';
import { mockAttackDiscovery } from '../../mock/mock_attack_discovery';
import { TestProviders } from '../../../../../common/mock';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';
import { ALERTS, ATTACK_DISCOVERY } from './translations';

describe('getTabs', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';

import { Tabs } from '.';
import { TestProviders } from '../../../common/mock';
import { mockAttackDiscovery } from '../../mock/mock_attack_discovery';
import { TestProviders } from '../../../../../common/mock';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';

describe('Tabs', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { render, screen } from '@testing-library/react';
import React from 'react';

import { ViewInAiAssistant } from '.';
import { TestProviders } from '../../../common/mock';
import { mockAttackDiscovery } from '../../mock/mock_attack_discovery';
import { TestProviders } from '../../../../../common/mock';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';
import { VIEW_IN_AI_ASSISTANT } from './translations';

describe('ViewInAiAssistant', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import { renderHook } from '@testing-library/react-hooks';
import { useAssistantOverlay } from '@kbn/elastic-assistant';

import { useAssistantAvailability } from '../../../assistant/use_assistant_availability';
import { getAttackDiscoveryMarkdown } from '../../get_attack_discovery_markdown/get_attack_discovery_markdown';
import { mockAttackDiscovery } from '../../mock/mock_attack_discovery';
import { useAssistantAvailability } from '../../../../../assistant/use_assistant_availability';
import { getAttackDiscoveryMarkdown } from '../get_attack_discovery_markdown/get_attack_discovery_markdown';
import { mockAttackDiscovery } from '../../../mock/mock_attack_discovery';
import { useViewInAiAssistant } from './use_view_in_ai_assistant';

jest.mock('@kbn/elastic-assistant');
jest.mock('../../../assistant/use_assistant_availability');
jest.mock('../../get_attack_discovery_markdown/get_attack_discovery_markdown');
jest.mock('../../../../../assistant/use_assistant_availability');
jest.mock('../get_attack_discovery_markdown/get_attack_discovery_markdown');
const mockUseAssistantOverlay = useAssistantOverlay as jest.Mock;
describe('useViewInAiAssistant', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import { useMemo, useCallback } from 'react';
import { useAssistantOverlay } from '@kbn/elastic-assistant';
import type { AttackDiscovery, Replacements } from '@kbn/elastic-assistant-common';
import { useAssistantAvailability } from '../../../assistant/use_assistant_availability';
import { getAttackDiscoveryMarkdown } from '../../get_attack_discovery_markdown/get_attack_discovery_markdown';
import { useAssistantAvailability } from '../../../../../assistant/use_assistant_availability';
import { getAttackDiscoveryMarkdown } from '../get_attack_discovery_markdown/get_attack_discovery_markdown';

/**
* This category is provided in the prompt context for the assistant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';

import { EmptyPrompt } from '.';
import { useAssistantAvailability } from '../../../assistant/use_assistant_availability';
import { TestProviders } from '../../../common/mock';
import { useAssistantAvailability } from '../../../../../assistant/use_assistant_availability';
import { TestProviders } from '../../../../../common/mock';

jest.mock('../../../assistant/use_assistant_availability');
jest.mock('../../../../../assistant/use_assistant_availability');

describe('EmptyPrompt', () => {
const alertsCount = 20;
Expand Down
Loading