mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[8.13] [Security Solution][Detection Engine] fixes warning toasts on exception flyout (#180800) (#180893)
# Backport This will backport the following commits from `main` to `8.13`: - [[Security Solution][Detection Engine] fixes warning toasts on exception flyout (#180800)](https://github.com/elastic/kibana/pull/180800) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Vitalii Dmyterko","email":"92328789+vitaliidm@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-04-16T10:18:51Z","message":"[Security Solution][Detection Engine] fixes warning toasts on exception flyout (#180800)\n\n## Summary\r\n\r\n - addresses https://github.com/elastic/kibana/issues/160851\r\n\r\nwarning was displaying because of error\r\n\r\n```JSON\r\n{\r\n \"name\": \"TypeError\",\r\n \"message\": \"indexPattern.getAllowHidden is not a function\",\r\n \"stack\": \"TypeError: indexPattern.getAllowHidden is not a function\\n at DataViewsServicePublic.getFieldsForIndexPattern (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/dataViews/1.0.0/dataViews.plugin.js:2519:131)\\n at http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/securitySolution/1.0.0/securitySolution.chunk.63.js:200144:45\\n at fetchExtendedField (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/lists/1.0.0/lists.chunk.0.js:19767:38)\\n at BuilderEntryItem._entry$field3 (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/lists/1.0.0/lists.chunk.0.js:19772:5)\\n at invokePassiveEffectCreate (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:375924:20)\\n at HTMLUnknownElement.callCallback (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:356387:14)\\n at Object.invokeGuardedCallbackDev (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:356436:16)\\n at invokeGuardedCallback (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:356498:31)\\n at flushPassiveEffectsImpl (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:376011:9)\\n at unstable_runWithPriority (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:437229:12)\"\r\n}\r\n```\r\n\r\nwhich originated in\r\nhttps://github.com/elastic/kibana/blob/8.13/src/plugins/data_views/common/data_views/data_views.ts#L539\r\n\r\n```ts\r\n\r\n allowHidden:\r\n (indexPattern as DataViewSpec).allowHidden || (indexPattern as DataView)?.getAllowHidden(),\r\n\r\n```\r\n\r\nIn this case index.allowHidden is `false`, so `getAllowHidden()` is\r\ncalled. Because `getAllowHidden` is undefined, it causes error above.\r\n\r\nIn my fix, I check if `allowHidden` is set and if not, only after this\r\n`getAllowHidden()` is getting called","sha":"cefdb33a671a940103600adaaef4fa7c3afaf3af","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Detections and Resp","Team: SecuritySolution","backport:prev-minor","Team:Detection Engine","v8.14.0"],"title":"[Security Solution][Detection Engine] fixes warning toasts on exception flyout","number":180800,"url":"https://github.com/elastic/kibana/pull/180800","mergeCommit":{"message":"[Security Solution][Detection Engine] fixes warning toasts on exception flyout (#180800)\n\n## Summary\r\n\r\n - addresses https://github.com/elastic/kibana/issues/160851\r\n\r\nwarning was displaying because of error\r\n\r\n```JSON\r\n{\r\n \"name\": \"TypeError\",\r\n \"message\": \"indexPattern.getAllowHidden is not a function\",\r\n \"stack\": \"TypeError: indexPattern.getAllowHidden is not a function\\n at DataViewsServicePublic.getFieldsForIndexPattern (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/dataViews/1.0.0/dataViews.plugin.js:2519:131)\\n at http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/securitySolution/1.0.0/securitySolution.chunk.63.js:200144:45\\n at fetchExtendedField (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/lists/1.0.0/lists.chunk.0.js:19767:38)\\n at BuilderEntryItem._entry$field3 (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/lists/1.0.0/lists.chunk.0.js:19772:5)\\n at invokePassiveEffectCreate (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:375924:20)\\n at HTMLUnknownElement.callCallback (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:356387:14)\\n at Object.invokeGuardedCallbackDev (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:356436:16)\\n at invokeGuardedCallback (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:356498:31)\\n at flushPassiveEffectsImpl (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:376011:9)\\n at unstable_runWithPriority (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:437229:12)\"\r\n}\r\n```\r\n\r\nwhich originated in\r\nhttps://github.com/elastic/kibana/blob/8.13/src/plugins/data_views/common/data_views/data_views.ts#L539\r\n\r\n```ts\r\n\r\n allowHidden:\r\n (indexPattern as DataViewSpec).allowHidden || (indexPattern as DataView)?.getAllowHidden(),\r\n\r\n```\r\n\r\nIn this case index.allowHidden is `false`, so `getAllowHidden()` is\r\ncalled. Because `getAllowHidden` is undefined, it causes error above.\r\n\r\nIn my fix, I check if `allowHidden` is set and if not, only after this\r\n`getAllowHidden()` is getting called","sha":"cefdb33a671a940103600adaaef4fa7c3afaf3af"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/180800","number":180800,"mergeCommit":{"message":"[Security Solution][Detection Engine] fixes warning toasts on exception flyout (#180800)\n\n## Summary\r\n\r\n - addresses https://github.com/elastic/kibana/issues/160851\r\n\r\nwarning was displaying because of error\r\n\r\n```JSON\r\n{\r\n \"name\": \"TypeError\",\r\n \"message\": \"indexPattern.getAllowHidden is not a function\",\r\n \"stack\": \"TypeError: indexPattern.getAllowHidden is not a function\\n at DataViewsServicePublic.getFieldsForIndexPattern (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/dataViews/1.0.0/dataViews.plugin.js:2519:131)\\n at http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/securitySolution/1.0.0/securitySolution.chunk.63.js:200144:45\\n at fetchExtendedField (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/lists/1.0.0/lists.chunk.0.js:19767:38)\\n at BuilderEntryItem._entry$field3 (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/plugin/lists/1.0.0/lists.chunk.0.js:19772:5)\\n at invokePassiveEffectCreate (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:375924:20)\\n at HTMLUnknownElement.callCallback (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:356387:14)\\n at Object.invokeGuardedCallbackDev (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:356436:16)\\n at invokeGuardedCallback (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:356498:31)\\n at flushPassiveEffectsImpl (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:376011:9)\\n at unstable_runWithPriority (http://localhost:5601/kbn/XXXXXXXXXXXX/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:437229:12)\"\r\n}\r\n```\r\n\r\nwhich originated in\r\nhttps://github.com/elastic/kibana/blob/8.13/src/plugins/data_views/common/data_views/data_views.ts#L539\r\n\r\n```ts\r\n\r\n allowHidden:\r\n (indexPattern as DataViewSpec).allowHidden || (indexPattern as DataView)?.getAllowHidden(),\r\n\r\n```\r\n\r\nIn this case index.allowHidden is `false`, so `getAllowHidden()` is\r\ncalled. Because `getAllowHidden` is undefined, it causes error above.\r\n\r\nIn my fix, I check if `allowHidden` is set and if not, only after this\r\n`getAllowHidden()` is getting called","sha":"cefdb33a671a940103600adaaef4fa7c3afaf3af"}}]}] BACKPORT--> Co-authored-by: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com>
This commit is contained in:
parent
860b2aa971
commit
99ccbf71e4
2 changed files with 80 additions and 2 deletions
|
@ -177,7 +177,7 @@ describe('IndexPatterns', () => {
|
|||
expect(apiClient.getFieldsForWildcard).toBeCalledWith(args);
|
||||
});
|
||||
|
||||
test('getFieldsForWildcard called with allowNoIndex set to true as default ', async () => {
|
||||
test('getFieldsForWildcard called with allowNoIndex set to true as default', async () => {
|
||||
const id = '1';
|
||||
await indexPatterns.get(id);
|
||||
expect(apiClient.getFieldsForWildcard).toBeCalledWith({
|
||||
|
@ -190,6 +190,82 @@ describe('IndexPatterns', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('getFieldsForIndexPattern called with allowHidden set to undefined as default', async () => {
|
||||
await indexPatterns.getFieldsForIndexPattern({ id: '1' } as DataViewSpec, {
|
||||
pattern: 'something',
|
||||
});
|
||||
expect(apiClient.getFieldsForWildcard).toBeCalledWith({
|
||||
allowHidden: undefined,
|
||||
allowNoIndex: true,
|
||||
metaFields: false,
|
||||
pattern: undefined,
|
||||
rollupIndex: undefined,
|
||||
type: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
test('getFieldsForIndexPattern called with allowHidden set to true', async () => {
|
||||
await indexPatterns.getFieldsForIndexPattern({ id: '1', allowHidden: true } as DataViewSpec, {
|
||||
pattern: 'something',
|
||||
});
|
||||
expect(apiClient.getFieldsForWildcard).toBeCalledWith({
|
||||
allowHidden: true,
|
||||
allowNoIndex: true,
|
||||
metaFields: false,
|
||||
pattern: undefined,
|
||||
rollupIndex: undefined,
|
||||
type: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
test('getFieldsForIndexPattern called with allowHidden set to false', async () => {
|
||||
await indexPatterns.getFieldsForIndexPattern({ id: '1', allowHidden: false } as DataViewSpec, {
|
||||
pattern: 'something',
|
||||
});
|
||||
expect(apiClient.getFieldsForWildcard).toBeCalledWith({
|
||||
allowHidden: false,
|
||||
allowNoIndex: true,
|
||||
metaFields: false,
|
||||
pattern: undefined,
|
||||
rollupIndex: undefined,
|
||||
type: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
test('getFieldsForIndexPattern called with getAllowHidden returning true', async () => {
|
||||
await indexPatterns.getFieldsForIndexPattern(
|
||||
{ id: '1', getAllowHidden: () => true } as DataView,
|
||||
{
|
||||
pattern: 'something',
|
||||
}
|
||||
);
|
||||
expect(apiClient.getFieldsForWildcard).toBeCalledWith({
|
||||
allowHidden: true,
|
||||
allowNoIndex: true,
|
||||
metaFields: false,
|
||||
pattern: undefined,
|
||||
rollupIndex: undefined,
|
||||
type: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
test('getFieldsForIndexPattern called with getAllowHidden returning false', async () => {
|
||||
await indexPatterns.getFieldsForIndexPattern(
|
||||
{ id: '1', getAllowHidden: () => false } as DataView,
|
||||
{
|
||||
pattern: 'something',
|
||||
}
|
||||
);
|
||||
expect(apiClient.getFieldsForWildcard).toBeCalledWith({
|
||||
allowHidden: false,
|
||||
allowNoIndex: true,
|
||||
metaFields: false,
|
||||
pattern: undefined,
|
||||
rollupIndex: undefined,
|
||||
type: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
test('does cache ad-hoc data views', async () => {
|
||||
const id = '1';
|
||||
|
||||
|
|
|
@ -536,7 +536,9 @@ export class DataViewsService {
|
|||
...options,
|
||||
pattern: indexPattern.title as string,
|
||||
allowHidden:
|
||||
(indexPattern as DataViewSpec).allowHidden || (indexPattern as DataView)?.getAllowHidden(),
|
||||
(indexPattern as DataViewSpec).allowHidden == null
|
||||
? (indexPattern as DataView)?.getAllowHidden?.()
|
||||
: (indexPattern as DataViewSpec).allowHidden,
|
||||
});
|
||||
|
||||
private getFieldsAndIndicesForDataView = async (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue