Skip to content

Commit

Permalink
[8.x] [Security Solution] [Attack discovery] Updates Attack discovery…
Browse files Browse the repository at this point in the history
… directory structure (#200613) (#200652)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution] [Attack discovery] Updates Attack discovery
directory structure
(#200613)](#200613)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Andrew
Macri","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-18T20:32:43Z","message":"[Security
Solution] [Attack discovery] Updates Attack discovery directory
structure (#200613)\n\n### [Security Solution] [Attack discovery]
Updates Attack discovery directory structure\r\n\r\nThis PR updates the
Attack discovery directory structure to align it with the latest
implementation.\r\n\r\nThe scope of this update is limited to file paths
and
imports.","sha":"974293fa0118c3f40bc4b39052f0141cb4f379ce","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:
SecuritySolution","Team:Security Generative
AI","backport:version","v8.17.0"],"title":"[Security Solution] [Attack
discovery] Updates Attack discovery directory
structure","number":200613,"url":"https://github.com/elastic/kibana/pull/200613","mergeCommit":{"message":"[Security
Solution] [Attack discovery] Updates Attack discovery directory
structure (#200613)\n\n### [Security Solution] [Attack discovery]
Updates Attack discovery directory structure\r\n\r\nThis PR updates the
Attack discovery directory structure to align it with the latest
implementation.\r\n\r\nThe scope of this update is limited to file paths
and
imports.","sha":"974293fa0118c3f40bc4b39052f0141cb4f379ce"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200613","number":200613,"mergeCommit":{"message":"[Security
Solution] [Attack discovery] Updates Attack discovery directory
structure (#200613)\n\n### [Security Solution] [Attack discovery]
Updates Attack discovery directory structure\r\n\r\nThis PR updates the
Attack discovery directory structure to align it with the latest
implementation.\r\n\r\nThe scope of this update is limited to file paths
and
imports.","sha":"974293fa0118c3f40bc4b39052f0141cb4f379ce"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Andrew Macri <[email protected]>
  • Loading branch information
kibanamachine and andrew-goldstein authored Nov 18, 2024
1 parent 017b92f commit 6e90b7c
Show file tree
Hide file tree
Showing 104 changed files with 98 additions and 98 deletions.
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

0 comments on commit 6e90b7c

Please sign in to comment.