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
* 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 <[email protected]>
  • Loading branch information
XavierM and kqualters-elastic authored Mar 9, 2021
1 parent 023d9a0 commit af8d5eb
Show file tree
Hide file tree
Showing 17 changed files with 478 additions and 11 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
10 changes: 3 additions & 7 deletions x-pack/plugins/security_solution/cypress/tasks/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,9 @@ export const closeTimeline = () => {
};

export const createNewTimeline = () => {
cy.get(TIMELINE_SETTINGS_ICON)
.filter(':visible')
.click({ force: true })
.then(() => {
cy.get(CREATE_NEW_TIMELINE).should('be.visible');
cy.get(CREATE_NEW_TIMELINE).click();
});
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').click({ force: true });
cy.get(CREATE_NEW_TIMELINE).should('be.visible');
cy.get(CREATE_NEW_TIMELINE).click();
};

export const createNewTimelineTemplate = () => {
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 @@ -172,6 +172,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 @@ -183,6 +195,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.

Loading

0 comments on commit af8d5eb

Please sign in to comment.