Skip to content

Commit

Permalink
Merge branch 'main' into alerting/faad-resources-ilm
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 6, 2023
2 parents d21538d + 9a3e319 commit 41ddf43
Show file tree
Hide file tree
Showing 369 changed files with 11,552 additions and 2,382 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ enabled:
- x-pack/test/functional/config_security_basic.ts
- x-pack/test/functional/config.ccs.ts
- x-pack/test/functional/config.firefox.js
- x-pack/test/functional_cloud/config.ts
- x-pack/test/kubernetes_security/basic/config.ts
- x-pack/test/licensing_plugin/config.public.ts
- x-pack/test/licensing_plugin/config.ts
Expand Down
142 changes: 113 additions & 29 deletions docs/osquery/exported-fields-reference.asciidoc

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,19 @@
"@dnd-kit/utilities": "^2.0.0",
"@elastic/apm-rum": "^5.12.0",
"@elastic/apm-rum-react": "^1.4.2",
"@elastic/charts": "51.3.0",
"@elastic/charts": "52.0.0",
"@elastic/datemath": "5.0.3",
"@elastic/elasticsearch": "npm:@elastic/[email protected]",
"@elastic/ems-client": "8.4.0",
"@elastic/eui": "74.0.1",
"@elastic/filesaver": "1.1.2",
"@elastic/node-crypto": "1.2.1",
"@elastic/numeral": "^2.5.1",
"@elastic/react-search-ui": "^1.14.0",
"@elastic/react-search-ui": "^1.19.0",
"@elastic/request-crypto": "2.0.1",
"@elastic/search-ui-app-search-connector": "^1.14.0",
"@elastic/search-ui": "^1.19.0",
"@elastic/search-ui-app-search-connector": "^1.19.0",
"@elastic/search-ui-engines-connector": "^1.19.0",
"@emotion/cache": "^11.10.3",
"@emotion/css": "^11.10.0",
"@emotion/react": "^11.10.4",
Expand Down Expand Up @@ -421,8 +423,8 @@
"@opentelemetry/semantic-conventions": "^1.4.0",
"@reduxjs/toolkit": "1.7.2",
"@slack/webhook": "^5.0.4",
"@tanstack/react-query": "^4.23.0",
"@tanstack/react-query-devtools": "^4.23.0",
"@tanstack/react-query": "^4.24.2",
"@tanstack/react-query-devtools": "^4.24.2",
"@turf/along": "6.0.1",
"@turf/area": "6.0.1",
"@turf/bbox": "6.0.1",
Expand Down Expand Up @@ -583,7 +585,7 @@
"react-fast-compare": "^2.0.4",
"react-focus-on": "^3.7.0",
"react-grid-layout": "^1.3.4",
"react-hook-form": "^7.42.1",
"react-hook-form": "^7.43.0",
"react-intl": "^2.8.0",
"react-is": "^17.0.2",
"react-markdown": "^6.0.3",
Expand Down Expand Up @@ -1174,7 +1176,7 @@
"svgo": "^2.8.0",
"tape": "^5.0.1",
"tempy": "^0.3.0",
"terser": "^5.15.1",
"terser": "^5.16.1",
"terser-webpack-plugin": "^4.2.3",
"tough-cookie": "^4.1.2",
"tree-kill": "^1.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const termsSchema = s.object({
exclude: s.maybe(s.oneOf([s.string(), s.arrayOf(s.string())])),
include: s.maybe(s.oneOf([s.string(), s.arrayOf(s.string())])),
execution_hint: s.maybe(s.string()),
missing: s.maybe(s.number()),
missing: s.maybe(s.oneOf([s.number(), s.string(), s.boolean()])),
min_doc_count: s.maybe(s.number({ min: 1 })),
size: s.maybe(s.number()),
show_term_doc_count_error: s.maybe(s.boolean()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,22 +397,6 @@ describe('validateAndConvertAggregations', () => {
);
});

it('throws an error when an attributes is not respecting its schema definition', () => {
const aggregations: AggsMap = {
someAgg: {
terms: {
missing: 'expecting a number',
},
},
};

expect(() =>
validateAndConvertAggregations(['alert'], aggregations, mockMappings)
).toThrowErrorMatchingInlineSnapshot(
`"[someAgg.terms.missing]: expected value of type [number] but got [string]"`
);
});

it('throws an error when trying to validate an unknown aggregation type', () => {
const aggregations: AggsMap = {
someAgg: {
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
crawlerOverview: `${ENTERPRISE_SEARCH_DOCS}crawler.html`,
deployTrainedModels: `${MACHINE_LEARNING_DOCS}ml-nlp-deploy-models.html`,
documentLevelSecurity: `${ELASTICSEARCH_DOCS}document-level-security.html`,
engines: `${ENTERPRISE_SEARCH_DOCS}engines.html`,
ingestPipelines: `${ENTERPRISE_SEARCH_DOCS}ingest-pipelines.html`,
languageAnalyzers: `${ELASTICSEARCH_DOCS}analysis-lang-analyzer.html`,
languageClients: `${ENTERPRISE_SEARCH_DOCS}programming-language-clients.html`,
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export interface DocLinks {
readonly crawlerOverview: string;
readonly deployTrainedModels: string;
readonly documentLevelSecurity: string;
readonly engines: string;
readonly ingestPipelines: string;
readonly languageAnalyzers: string;
readonly languageClients: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const FieldComponent: React.FC<FieldProps> = ({
placeholder,
selectedField,
acceptsCustomOptions = false,
showMappingConflicts = false,
}): JSX.Element => {
const {
isInvalid,
Expand All @@ -44,6 +45,7 @@ export const FieldComponent: React.FC<FieldProps> = ({
isRequired,
selectedField,
fieldInputWidth,
showMappingConflicts,
onChange,
});

Expand All @@ -68,6 +70,7 @@ export const FieldComponent: React.FC<FieldProps> = ({
values: { searchValuePlaceholder: '{searchValue}' },
})}
fullWidth
renderOption={renderFields}
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-securitysolution-autocomplete/src/field/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { DataViewBase, DataViewFieldBase } from '@kbn/es-query';
import { FieldConflictsInfo } from '@kbn/securitysolution-list-utils';
import { GetGenericComboBoxPropsReturn } from '../get_generic_combo_box_props';

export interface FieldProps extends FieldBaseProps {
Expand All @@ -15,13 +16,15 @@ export interface FieldProps extends FieldBaseProps {
isLoading: boolean;
placeholder: string;
acceptsCustomOptions?: boolean;
showMappingConflicts?: boolean;
}
export interface FieldBaseProps {
indexPattern: DataViewBase | undefined;
fieldTypeFilter?: string[];
isRequired?: boolean;
selectedField?: DataViewFieldBase | undefined;
fieldInputWidth?: number;
showMappingConflicts?: boolean;
onChange: (a: DataViewFieldBase[]) => void;
}

Expand All @@ -32,6 +35,7 @@ export interface ComboBoxFields {

export interface GetFieldComboBoxPropsReturn extends GetGenericComboBoxPropsReturn {
disabledLabelTooltipTexts: { [label: string]: string };
mappingConflictsTooltipInfo: { [label: string]: FieldConflictsInfo[] };
}

export interface DataViewField extends DataViewFieldBase {
Expand Down
78 changes: 76 additions & 2 deletions packages/kbn-securitysolution-autocomplete/src/field/use_field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
*/
import React from 'react';
import { useCallback, useMemo, useState } from 'react';
import { EuiComboBoxOptionOption, EuiToolTip } from '@elastic/eui';
import {
EuiComboBoxOptionOption,
EuiIcon,
EuiSpacer,
EuiToolTip,
useEuiPaddingSize,
} from '@elastic/eui';
import { DataViewBase, DataViewFieldBase } from '@kbn/es-query';

import { FieldConflictsInfo, getMappingConflictsInfo } from '@kbn/securitysolution-list-utils';
import { getGenericComboBoxProps } from '../get_generic_combo_box_props';
import * as i18n from '../translations';
import {
ComboBoxFields,
DataViewField,
Expand Down Expand Up @@ -72,6 +80,22 @@ const getDisabledLabelTooltipTexts = (fields: ComboBoxFields) => {
);
return disabledLabelTooltipTexts;
};

const getMappingConflictsTooltipInfo = (fields: ComboBoxFields) => {
const mappingConflictsTooltipInfo = fields.availableFields.reduce(
(acc: { [label: string]: FieldConflictsInfo[] }, field: DataViewField) => {
const conflictsInfo = getMappingConflictsInfo(field);
if (!conflictsInfo) {
return acc;
}
acc[field.name] = conflictsInfo;
return acc;
},
{}
);
return mappingConflictsTooltipInfo;
};

const getComboBoxProps = (fields: ComboBoxFields): GetFieldComboBoxPropsReturn => {
const { availableFields, selectedFields } = fields;

Expand All @@ -81,9 +105,11 @@ const getComboBoxProps = (fields: ComboBoxFields): GetFieldComboBoxPropsReturn =
selectedOptions: selectedFields,
});
const disabledLabelTooltipTexts = getDisabledLabelTooltipTexts(fields);
const mappingConflictsTooltipInfo = getMappingConflictsTooltipInfo(fields);
return {
...genericProps,
disabledLabelTooltipTexts,
mappingConflictsTooltipInfo,
};
};

Expand All @@ -93,11 +119,13 @@ export const useField = ({
isRequired,
selectedField,
fieldInputWidth,
showMappingConflicts,
onChange,
}: FieldBaseProps) => {
const [touched, setIsTouched] = useState(false);

const [customOption, setCustomOption] = useState<DataViewFieldBase | null>(null);
const sPaddingSize = useEuiPaddingSize('s');

const { availableFields, selectedFields } = useMemo(() => {
const indexPatternsToUse =
Expand All @@ -107,7 +135,13 @@ export const useField = ({
return getComboBoxFields(indexPatternsToUse, selectedField, fieldTypeFilter);
}, [indexPattern, fieldTypeFilter, selectedField, customOption]);

const { comboOptions, labels, selectedComboOptions, disabledLabelTooltipTexts } = useMemo(
const {
comboOptions,
labels,
selectedComboOptions,
disabledLabelTooltipTexts,
mappingConflictsTooltipInfo,
} = useMemo(
() => getComboBoxProps({ availableFields, selectedFields }),
[availableFields, selectedFields]
);
Expand Down Expand Up @@ -168,6 +202,46 @@ export const useField = ({
</EuiToolTip>
);
}

const conflictsInfo = mappingConflictsTooltipInfo[label];
if (showMappingConflicts && conflictsInfo) {
const tooltipContent = (
<>
{i18n.FIELD_CONFLICT_INDICES_WARNING_DESCRIPTION}
{conflictsInfo.map((info) => {
const groupDetails = info.groupedIndices.map(
({ name, count }) =>
`${count > 1 ? i18n.CONFLICT_MULTIPLE_INDEX_DESCRIPTION(name, count) : name}`
);
return (
<>
<EuiSpacer size="s" />
{`${
info.totalIndexCount > 1
? i18n.CONFLICT_MULTIPLE_INDEX_DESCRIPTION(info.type, info.totalIndexCount)
: info.type
}: ${groupDetails.join(', ')}`}
</>
);
})}
</>
);
return (
<EuiToolTip position="bottom" content={tooltipContent}>
<>
{label}
<EuiIcon
tabIndex={0}
type="alert"
title={i18n.FIELD_CONFLICT_INDICES_WARNING_TITLE}
size="s"
css={{ marginLeft: `${sPaddingSize}` }}
/>
</>
</EuiToolTip>
);
}

return label;
};
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ export const SEE_DOCUMENTATION = i18n.translate('autocomplete.seeDocumentation',
defaultMessage: 'See Documentation',
});

export const FIELD_CONFLICT_INDICES_WARNING_TITLE = i18n.translate(
'autocomplete.conflictIndicesWarning.title',
{
defaultMessage: 'Mapping Conflict',
}
);

export const FIELD_CONFLICT_INDICES_WARNING_DESCRIPTION = i18n.translate(
'autocomplete.conflictIndicesWarning.description',
{
defaultMessage: 'This field is defined as several types across different indices.',
}
);

export const CONFLICT_MULTIPLE_INDEX_DESCRIPTION = (name: string, count: number): string =>
i18n.translate('autocomplete.conflictIndicesWarning.index.description', {
defaultMessage: '{name} ({count} indices)',
values: { count, name },
});

// eslint-disable-next-line import/no-default-export
export default {
LOADING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('importQuerySchema', () => {
as_new_list: false,
overwrite: true,
overwrite_exceptions: true,
overwrite_action_connectors: true,
};
const decoded = importQuerySchema.decode(payload);
const checked = exactCheck(payload, decoded);
Expand All @@ -30,6 +31,7 @@ describe('importQuerySchema', () => {
as_new_list: false,
overwrite: 'wrong',
overwrite_exceptions: true,
overwrite_action_connectors: true,
};
const decoded = importQuerySchema.decode(payload);
const checked = exactCheck(payload, decoded);
Expand All @@ -48,6 +50,7 @@ describe('importQuerySchema', () => {
as_new_list: false,
overwrite: true,
overwrite_exceptions: 'wrong',
overwrite_action_connectors: true,
};
const decoded = importQuerySchema.decode(payload);
const checked = exactCheck(payload, decoded);
Expand All @@ -58,6 +61,24 @@ describe('importQuerySchema', () => {
]);
expect(message.schema).toEqual({});
});
test('it should NOT validate a non boolean value for "overwrite_action_connectors"', () => {
const payload: Omit<ImportQuerySchema, 'overwrite_action_connectors'> & {
overwrite_action_connectors: string;
} = {
as_new_list: false,
overwrite: true,
overwrite_exceptions: true,
overwrite_action_connectors: 'wrong',
};
const decoded = importQuerySchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = foldLeftRight(checked);

expect(getPaths(left(message.errors))).toEqual([
'Invalid value "wrong" supplied to "overwrite_action_connectors"',
]);
expect(message.schema).toEqual({});
});

test('it should NOT allow an extra key to be sent in', () => {
const payload: ImportQuerySchema & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ export const importQuerySchema = t.exact(
t.partial({
overwrite: DefaultStringBooleanFalse,
overwrite_exceptions: DefaultStringBooleanFalse,
overwrite_action_connectors: DefaultStringBooleanFalse,
as_new_list: DefaultStringBooleanFalse,
})
);

export type ImportQuerySchema = t.TypeOf<typeof importQuerySchema>;
export type ImportQuerySchemaDecoded = Omit<
ImportQuerySchema,
'overwrite' | 'overwrite_exceptions' | 'as_new_list'
'overwrite' | 'overwrite_exceptions' | 'as_new_list' | 'overwrite_action_connectors'
> & {
overwrite: boolean;
overwrite_exceptions: boolean;
overwrite_action_connectors: boolean;
as_new_list: boolean;
};
Loading

0 comments on commit 41ddf43

Please sign in to comment.