Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into apm-rule-types-package
Browse files Browse the repository at this point in the history
  • Loading branch information
js-jankisalvi committed Jan 2, 2025
2 parents 35e8e62 + a921224 commit 03456f5
Show file tree
Hide file tree
Showing 2,195 changed files with 8,167 additions and 6,076 deletions.
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,20 @@ module.exports = {
],
},
},
{
files: [
'x-pack/solutions/observability/plugins/apm/**/*.{js,mjs,ts,tsx}',
'x-pack/solutions/observability/plugins/apm_data_access/**/*.{js,mjs,ts,tsx}',
'x-pack/solutions/observability/plugins/infra/**/*.{js,mjs,ts,tsx}',
'x-pack/solutions/observability/plugins/inventory/**/*.{js,mjs,ts,tsx}',
'x-pack/solutions/observability/plugins/metrics_data_access/**/*.{js,mjs,ts,tsx}',
'x-pack/solutions/observability/plugins/profiling/**/*.{js,mjs,ts,tsx}',
'x-pack/solutions/observability/plugins/profiling_data_access/**/*.{js,mjs,ts,tsx}',
],
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
},
},

/**
* Fleet overrides
Expand Down
15 changes: 15 additions & 0 deletions oas_docs/output/kibana.serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46989,6 +46989,20 @@ components:
type: string
required:
- name
service:
type: object
properties:
asset:
type: object
properties:
criticality:
$ref: '#/components/schemas/Security_Entity_Analytics_API_AssetCriticalityLevel'
required:
- criticality
name:
type: string
required:
- name
user:
type: object
properties:
Expand Down Expand Up @@ -47307,6 +47321,7 @@ components:
enum:
- host.name
- user.name
- service.name
type: string
Security_Entity_Analytics_API_IndexPattern:
type: string
Expand Down
15 changes: 15 additions & 0 deletions oas_docs/output/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53865,6 +53865,20 @@ components:
type: string
required:
- name
service:
type: object
properties:
asset:
type: object
properties:
criticality:
$ref: '#/components/schemas/Security_Entity_Analytics_API_AssetCriticalityLevel'
required:
- criticality
name:
type: string
required:
- name
user:
type: object
properties:
Expand Down Expand Up @@ -54183,6 +54197,7 @@ components:
enum:
- host.name
- user.name
- service.name
type: string
Security_Entity_Analytics_API_IndexPattern:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('handleSystemColorModeChange', () => {
expect(notifications.toasts.addSuccess).not.toHaveBeenCalled();
expect(type).toBe('change');
cb({ matches: true } as any); // The system changed to dark mode
expect(notifications.toasts.addSuccess).toHaveBeenCalledWith(
expect(notifications.toasts.addInfo).toHaveBeenCalledWith(
expect.objectContaining({
text: expect.any(Function),
title: 'System color mode updated',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export async function handleSystemColorModeChange({
// we actually apply set the dark/light color mode of the page.
currentDarkModeValue = isDarkMode;
} else if (currentDarkModeValue !== isDarkMode) {
notifications.toasts.addSuccess(
notifications.toasts.addInfo(
{
title: i18n.translate('core.ui.chrome.appearanceChange.successNotificationTitle', {
defaultMessage: 'System color mode updated',
Expand Down
4 changes: 3 additions & 1 deletion packages/kbn-management/storybook/config/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { defaultConfig } from '@kbn/storybook';

module.exports = {
...defaultConfig,
stories: ['../../**/*.stories.+(tsx|mdx)'],
stories: [
'../../../../src/platform/packages/(private|shared)/kbn-management/**/*.stories.+(tsx|mdx)',
],
reactOptions: {
strictMode: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36783,7 +36783,6 @@
"xpack.securitySolution.assetCriticality.csvUpload.expectedColumnsError": "Trois colonnes attendues, {rowLength} reçues",
"xpack.securitySolution.assetCriticality.csvUpload.idTooLongError": "L’identificateur est trop long. Il devrait contenir moins de {maxChars} caractères, mais en contient {idLength}",
"xpack.securitySolution.assetCriticality.csvUpload.invalidCriticalityError": "Niveau de criticité non valide \"{criticalityLevel}\", un des {validLevels} attendu",
"xpack.securitySolution.assetCriticality.csvUpload.invalidEntityTypeError": "Type d'entité \"{entityType}\" non valide, hôte ou utilisateur attendu",
"xpack.securitySolution.assetCriticality.csvUpload.missingCriticalityError": "Niveau de criticité manquant",
"xpack.securitySolution.assetCriticality.csvUpload.missingEntityTypeError": "Type d'entité manquant",
"xpack.securitySolution.assetCriticality.csvUpload.missingIdError": "Identificateur manquant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36642,7 +36642,6 @@
"xpack.securitySolution.assetCriticality.csvUpload.expectedColumnsError": "3列でなければなりませんが、{rowLength}列でした",
"xpack.securitySolution.assetCriticality.csvUpload.idTooLongError": "識別子が長すぎます。{maxChars}未満でなければなりませんが、{idLength}でした",
"xpack.securitySolution.assetCriticality.csvUpload.invalidCriticalityError": "無効な重要度レベル\"{criticalityLevel}\"です。{validLevels}のいずれかでなければなりません",
"xpack.securitySolution.assetCriticality.csvUpload.invalidEntityTypeError": "無効なエンティティタイプ\"{entityType}\"です。ホストまたはユーザーでなければなりません",
"xpack.securitySolution.assetCriticality.csvUpload.missingCriticalityError": "重要度レベルがありません",
"xpack.securitySolution.assetCriticality.csvUpload.missingEntityTypeError": "エンティティタイプがありません",
"xpack.securitySolution.assetCriticality.csvUpload.missingIdError": "識別子がありません",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ const ConnectorResilientTypeFieldsRt = rt.strict({
* ServiceNow
*/

export const ServiceNowITSMFieldsRt = rt.strict({
impact: rt.union([rt.string, rt.null]),
severity: rt.union([rt.string, rt.null]),
urgency: rt.union([rt.string, rt.null]),
category: rt.union([rt.string, rt.null]),
subcategory: rt.union([rt.string, rt.null]),
});
export const ServiceNowITSMFieldsRt = rt.intersection([
rt.strict({
impact: rt.union([rt.string, rt.null]),
severity: rt.union([rt.string, rt.null]),
urgency: rt.union([rt.string, rt.null]),
category: rt.union([rt.string, rt.null]),
subcategory: rt.union([rt.string, rt.null]),
}),
rt.exact(
rt.partial({
additionalFields: rt.union([rt.string, rt.null]),
})
),
]);

export type ServiceNowITSMFieldsType = rt.TypeOf<typeof ServiceNowITSMFieldsRt>;

Expand All @@ -81,15 +88,22 @@ const ConnectorServiceNowITSMTypeFieldsRt = rt.strict({
fields: rt.union([ServiceNowITSMFieldsRt, rt.null]),
});

export const ServiceNowSIRFieldsRt = rt.strict({
category: rt.union([rt.string, rt.null]),
destIp: rt.union([rt.boolean, rt.null]),
malwareHash: rt.union([rt.boolean, rt.null]),
malwareUrl: rt.union([rt.boolean, rt.null]),
priority: rt.union([rt.string, rt.null]),
sourceIp: rt.union([rt.boolean, rt.null]),
subcategory: rt.union([rt.string, rt.null]),
});
export const ServiceNowSIRFieldsRt = rt.intersection([
rt.strict({
category: rt.union([rt.string, rt.null]),
destIp: rt.union([rt.boolean, rt.null]),
malwareHash: rt.union([rt.boolean, rt.null]),
malwareUrl: rt.union([rt.boolean, rt.null]),
priority: rt.union([rt.string, rt.null]),
sourceIp: rt.union([rt.boolean, rt.null]),
subcategory: rt.union([rt.string, rt.null]),
}),
rt.exact(
rt.partial({
additionalFields: rt.union([rt.string, rt.null]),
})
),
]);

export type ServiceNowSIRFieldsType = rt.TypeOf<typeof ServiceNowSIRFieldsRt>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ describe('CommonFlyout ', () => {
impact: null,
category: 'software',
subcategory: null,
additionalFields: null,
},
},
settings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,32 @@ describe('ConnectorCard ', () => {
expect(getByText(`${item.title}: ${item.description}`)).toBeInTheDocument();
}
});

it('shows a codeblock when applicable', async () => {
render(
<ConnectorCard
connectorType={ConnectorTypes.none}
title="My connector"
listItems={[{ title: 'some title', description: 'some code', displayAsCodeBlock: true }]}
isLoading={false}
/>
);

expect(await screen.findByTestId('card-list-item')).toBeInTheDocument();
expect(await screen.findByTestId('card-list-code-block')).toBeInTheDocument();
});

it('does not show a codeblock when not necessary', async () => {
render(
<ConnectorCard
connectorType={ConnectorTypes.none}
title="My connector"
listItems={[{ title: 'some title', description: 'some code' }]}
isLoading={false}
/>
);

expect(await screen.findByTestId('card-list-item')).toBeInTheDocument();
expect(screen.queryByTestId('card-list-code-block')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
*/

import React, { memo } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiSkeletonText, EuiText } from '@elastic/eui';
import {
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiSkeletonText,
EuiText,
EuiCodeBlock,
} from '@elastic/eui';

import type { ConnectorTypes } from '../../../common/types/domain';
import { useKibana } from '../../common/lib/kibana';
Expand All @@ -15,7 +22,7 @@ import { getConnectorIcon } from '../utils';
interface ConnectorCardProps {
connectorType: ConnectorTypes;
title: string;
listItems: Array<{ title: string; description: React.ReactNode }>;
listItems: Array<{ title: string; description: React.ReactNode; displayAsCodeBlock?: boolean }>;
isLoading: boolean;
}

Expand Down Expand Up @@ -47,12 +54,28 @@ const ConnectorCardDisplay: React.FC<ConnectorCardProps> = ({
</EuiFlexGroup>
<EuiFlexItem data-test-subj="connector-card-details">
{listItems.length > 0 &&
listItems.map((item, i) => (
<EuiText size="xs" data-test-subj="card-list-item" key={`${item.title}-${i}`}>
<strong>{`${item.title}: `}</strong>
{`${item.description}`}
</EuiText>
))}
listItems.map((item, i) =>
item.displayAsCodeBlock ? (
<>
<EuiText size="xs" data-test-subj="card-list-item" key={`${item.title}-${i}`}>
<strong>{`${item.title}:`}</strong>
</EuiText>
<EuiCodeBlock
data-test-subj="card-list-code-block"
language="json"
fontSize="s"
paddingSize="s"
>
{`${item.description}`}
</EuiCodeBlock>
</>
) : (
<EuiText size="xs" data-test-subj="card-list-item" key={`${item.title}-${i}`}>
<strong>{`${item.title}: `}</strong>
{`${item.description}`}
</EuiText>
)
)}
</EuiFlexItem>
</EuiFlexGroup>
</EuiSkeletonText>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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 React, { type ComponentProps } from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import { JsonEditorField } from './json_editor_field';
import { MockedCodeEditor } from '@kbn/code-editor-mock';
import type { FieldHook } from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib';
import type { MockedMonacoEditor } from '@kbn/code-editor-mock/monaco_mock';

jest.mock('@kbn/code-editor', () => {
const original = jest.requireActual('@kbn/code-editor');
return {
...original,
CodeEditor: (props: ComponentProps<typeof MockedMonacoEditor>) => (
<MockedCodeEditor {...props} />
),
};
});

const setXJson = jest.fn();
const XJson = {
useXJsonMode: (value: unknown) => ({
convertToJson: (toJson: unknown) => toJson,
setXJson,
xJson: value,
}),
};

jest.mock('@kbn/es-ui-shared-plugin/public', () => {
const original = jest.requireActual('@kbn/es-ui-shared-plugin/public');
return {
...original,
XJson,
};
});

describe('JsonEditorField', () => {
const setValue = jest.fn();
const props = {
field: {
label: 'my label',
helpText: 'help',
value: 'foobar',
setValue,
errors: [],
} as unknown as FieldHook<unknown, string>,
paramsProperty: 'myField',
label: 'label',
dataTestSubj: 'foobarTestSubj',
};

beforeEach(() => jest.resetAllMocks());

it('renders as expected', async () => {
render(<JsonEditorField {...props} />);

expect(await screen.findByTestId('foobarTestSubj')).toBeInTheDocument();
expect(await screen.findByTestId('myFieldJsonEditor')).toBeInTheDocument();
expect(await screen.findByText('my label')).toBeInTheDocument();
});

it('calls setValue and xJson on editor change', async () => {
render(<JsonEditorField {...props} />);

await userEvent.click(await screen.findByTestId('myFieldJsonEditor'));
await userEvent.paste('JSON');

await waitFor(() => {
expect(setValue).toBeCalledWith('foobarJSON');
});

expect(setXJson).toBeCalledWith('foobarJSON');
});
});
Loading

0 comments on commit 03456f5

Please sign in to comment.