From b7f412a4c28c085c88bdcadef2023ead1ee70953 Mon Sep 17 00:00:00 2001 From: Davis Plumlee <56367316+dplumlee@users.noreply.github.com> Date: Thu, 9 Feb 2023 16:00:07 -0500 Subject: [PATCH] [Security Solution] Fixes bulk close alerts from exception flyout type bug (#150765) (cherry picked from commit 216fb3a1806d67c35e7ee84353d4d6460f87ad85) --- .../rule_exceptions/utils/helpers.test.tsx | 10 ++++++++++ .../detection_engine/rule_exceptions/utils/helpers.tsx | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/utils/helpers.test.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/utils/helpers.test.tsx index d3875415c49c72..97a6a00c9cf0ae 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/utils/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/utils/helpers.test.tsx @@ -384,6 +384,16 @@ describe('Exception helpers', () => { const result = prepareExceptionItemsForBulkClose(payload); expect(result).toEqual(expected); }); + + test("should strip out any comments in the exceptions for bulk close'", () => { + const exceptionItemWithComment = { + ...getExceptionListItemSchemaMock(), + comments: getCommentsArrayMock(), + }; + const payload = [exceptionItemWithComment]; + const result = prepareExceptionItemsForBulkClose(payload); + expect(result).toEqual([getExceptionListItemSchemaMock()]); + }); }); describe('#lowercaseHashValues', () => { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/utils/helpers.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/utils/helpers.tsx index 6a739fd34a05ae..aaaffb0e70d2ca 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/utils/helpers.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/utils/helpers.tsx @@ -154,9 +154,10 @@ export const prepareExceptionItemsForBulkClose = ( return { ...item, entries: newEntries, + comments: [], // Strips out unneeded comments attribute for bulk close as they are not needed and are throwing type errors }; } else { - return item; + return { ...item, comments: [] }; } }); };