Skip to content

Commit

Permalink
[Security Solution] Add nested field inside of data provider (#93721) (
Browse files Browse the repository at this point in the history
…#94080)

* add nested field inside of dataprovider

* make sure to get nested

* fix elq server side

* add mock for nested attributes

* Add basic tests for nested fields query generation

* Update snapshots and failing tests with nestedFields

* fix nested date

Co-authored-by: Kevin Qualters <kevin.qualters@elastic.co>

Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Co-authored-by: Kevin Qualters <kevin.qualters@elastic.co>
Co-authored-by: MadameSheema <snootchie.boochies@gmail.com>
  • Loading branch information
4 people authored Mar 10, 2021
1 parent 19cffe5 commit 158bfc6
Show file tree
Hide file tree
Showing 16 changed files with 475 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ export interface BrowserField {
name: string;
searchable: boolean;
type: string;
subType?: {
[key: string]: unknown;
nested?: {
path: string;
};
};
}

export type BrowserFields = Readonly<Record<string, Partial<BrowserField>>>;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ describe('QueryBar ', () => {
searchable: true,
type: 'string',
},
{
aggregatable: false,
name: 'nestedField.firstAttributes',
searchable: true,
type: 'string',
},
{
aggregatable: false,
name: 'nestedField.secondAttributes',
searchable: true,
type: 'string',
},
],
title: 'filebeat-*,auditbeat-*,packetbeat-*',
},
Expand All @@ -174,6 +186,7 @@ describe('QueryBar ', () => {
query: 'here: query',
},
refreshInterval: undefined,
savedQuery: undefined,
showAutoRefreshOnly: false,
showDatePicker: false,
showFilterBar: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,38 @@ export const mocksSource = {
searchable: true,
type: 'date',
},
{
aggregatable: false,
category: 'nestedField',
description: '',
example: '',
format: '',
indexes: ['auditbeat', 'filebeat', 'packetbeat'],
name: 'nestedField.firstAttributes',
searchable: true,
type: 'string',
subType: {
nested: {
path: 'nestedField',
},
},
},
{
aggregatable: false,
category: 'nestedField',
description: '',
example: '',
format: '',
indexes: ['auditbeat', 'filebeat', 'packetbeat'],
name: 'nestedField.secondAttributes',
searchable: true,
type: 'string',
subType: {
nested: {
path: 'nestedField',
},
},
},
],
};

Expand Down Expand Up @@ -646,6 +678,42 @@ export const mockBrowserFields: BrowserFields = {
},
},
},
nestedField: {
fields: {
'nestedField.firstAttributes': {
aggregatable: false,
category: 'nestedField',
description: '',
example: '',
format: '',
indexes: ['auditbeat', 'filebeat', 'packetbeat'],
name: 'nestedField.firstAttributes',
searchable: true,
type: 'string',
subType: {
nested: {
path: 'nestedField',
},
},
},
'nestedField.secondAttributes': {
aggregatable: false,
category: 'nestedField',
description: '',
example: '',
format: '',
indexes: ['auditbeat', 'filebeat', 'packetbeat'],
name: 'nestedField.secondAttributes',
searchable: true,
type: 'string',
subType: {
nested: {
path: 'nestedField',
},
},
},
},
},
};

export const mockDocValueFields: DocValueFields[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ export const useInitSourcerer = (
selectedPatterns: [signalIndexName],
})
);
} else if (signalIndexNameSelector != null && initialTimelineSourcerer.current) {
} else if (
scopeId === SourcererScopeName.detections &&
signalIndexNameSelector != null &&
initialTimelineSourcerer.current
) {
initialDetectionSourcerer.current = false;
dispatch(
sourcererActions.setSelectedIndexPatterns({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ export const mockIndexPattern: IIndexPattern = {
type: 'string',
aggregatable: true,
},
{
name: 'nestedField.firstAttributes',
searchable: true,
type: 'string',
aggregatable: false,
},
{
name: 'nestedField.secondAttributes',
searchable: true,
type: 'string',
aggregatable: false,
},
],
title: 'filebeat-*,auditbeat-*,packetbeat-*',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ describe('body', () => {
{ name: 'agent.test7', searchable: true, type: 'string', aggregatable: true },
{ name: 'agent.test8', searchable: true, type: 'string', aggregatable: true },
{ name: 'host.name', searchable: true, type: 'string', aggregatable: true },
{
aggregatable: false,
name: 'nestedField.firstAttributes',
searchable: true,
type: 'string',
},
{
aggregatable: false,
name: 'nestedField.secondAttributes',
searchable: true,
type: 'string',
},
],
title: 'filebeat-*,auditbeat-*,packetbeat-*',
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ describe('helpers', () => {
],
},
{ label: 'event', options: [{ label: 'event.end' }] },
{
label: 'nestedField',
options: [
{
label: 'nestedField.firstAttributes',
},
{
label: 'nestedField.secondAttributes',
},
],
},
{ label: 'source', options: [{ label: 'source.ip' }, { label: 'source.port' }] },
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe('Header', () => {
);

expect(wrapper.find('[data-test-subj="categories-count"]').first().text()).toEqual(
'9 categories'
'10 categories'
);
});

Expand Down Expand Up @@ -254,6 +254,6 @@ describe('Header', () => {
</TestProviders>
);

expect(wrapper.find('[data-test-subj="fields-count"]').first().text()).toEqual('25 fields');
expect(wrapper.find('[data-test-subj="fields-count"]').first().text()).toEqual('27 fields');
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 158bfc6

Please sign in to comment.