[8.6] [Security Solution] Fixes bulk close alerts from exception flyout type bug (#150765) (#150783)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Security Solution] Fixes bulk close alerts from exception flyout
type bug (#150765)](https://github.com/elastic/kibana/pull/150765)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Davis
Plumlee","email":"56367316+dplumlee@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-02-09T21:00:07Z","message":"[Security
Solution] Fixes bulk close alerts from exception flyout type bug
(#150765)","sha":"216fb3a1806d67c35e7ee84353d4d6460f87ad85","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:
SecuritySolution","Team:Detection
Alerts","backport:prev-minor","v8.7.0","v8.6.2","v8.8.0"],"number":150765,"url":"https://github.com/elastic/kibana/pull/150765","mergeCommit":{"message":"[Security
Solution] Fixes bulk close alerts from exception flyout type bug
(#150765)","sha":"216fb3a1806d67c35e7ee84353d4d6460f87ad85"}},"sourceBranch":"main","suggestedTargetBranches":["8.7","8.6"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.6","label":"v8.6.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/150765","number":150765,"mergeCommit":{"message":"[Security
Solution] Fixes bulk close alerts from exception flyout type bug
(#150765)","sha":"216fb3a1806d67c35e7ee84353d4d6460f87ad85"}}]}]
BACKPORT-->

Co-authored-by: Davis Plumlee <56367316+dplumlee@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-02-09 17:26:20 -05:00 committed by GitHub
parent afa8d4edac
commit 6de41514aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -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', () => {

View file

@ -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: [] };
}
});
};