kibana/packages/kbn-securitysolution-list-hooks
Kibana Machine 68bd9a95e7
[8.6] [Security Solution] [Exceptions] Fix edit the exception while adding new comment. (#145575) (#145724)
# Backport

This will backport the following commits from `main` to `8.6`:
- [[Security Solution] [Exceptions] Fix edit the exception while adding
new comment. (#145575)](https://github.com/elastic/kibana/pull/145575)

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

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

<!--BACKPORT [{"author":{"name":"Wafaa
Nasr","email":"wafaa.nasr@elastic.co"},"sourceCommit":{"committedDate":"2022-11-18T13:35:03Z","message":"[Security
Solution] [Exceptions] Fix edit the exception while adding new comment.
(#145575)\n\n## Summary\r\n\r\nAddress
https://github.com/elastic/kibana/issues/144523\r\n\r\n1. Fix type
schema check to use `updateExceptionListItemSchema` instead\r\nof
`exceptionListItemSchema` as the comments array could be empty
when\r\nthe user adds the Exceptions and in Editing with adding a new
comment(s)\r\nit will contain only (comment and id) in the newly created
comment\r\n\r\n2. Add `removeCreatedAtCreatedByFromCommentsOnUpdate` to
remove the\r\n`createdAt`, and `createdBy` from the updated exception
Item if a\r\ncomment was added before to fix the `400 Schema
validations` as per the\r\nbelow
Schema\r\n\r\nThe\r\n`packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.ts`\r\n
\r\n ```\r\n export const updateComment = t.intersection([\r\n
t.exact(\r\n t.type({\r\n comment: NonEmptyString,\r\n })\r\n ),\r\n
t.exact(\r\n t.partial({\r\n id,\r\n })\r\n ),\r\n ]);\r\n ```\r\n3.
Moving tests and mocks to the `hooks` package as well add new
tests\r\nfor the new
`removeCreatedAtCreatedByFromCommentsOnUpdate`\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\nCo-authored-by: Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"2bd2226cb259312b90ad32b1cd5618a0cc2e8b49","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:
SecuritySolution","Team:Security Solution
Platform","v8.6.0","v8.7.0"],"number":145575,"url":"https://github.com/elastic/kibana/pull/145575","mergeCommit":{"message":"[Security
Solution] [Exceptions] Fix edit the exception while adding new comment.
(#145575)\n\n## Summary\r\n\r\nAddress
https://github.com/elastic/kibana/issues/144523\r\n\r\n1. Fix type
schema check to use `updateExceptionListItemSchema` instead\r\nof
`exceptionListItemSchema` as the comments array could be empty
when\r\nthe user adds the Exceptions and in Editing with adding a new
comment(s)\r\nit will contain only (comment and id) in the newly created
comment\r\n\r\n2. Add `removeCreatedAtCreatedByFromCommentsOnUpdate` to
remove the\r\n`createdAt`, and `createdBy` from the updated exception
Item if a\r\ncomment was added before to fix the `400 Schema
validations` as per the\r\nbelow
Schema\r\n\r\nThe\r\n`packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.ts`\r\n
\r\n ```\r\n export const updateComment = t.intersection([\r\n
t.exact(\r\n t.type({\r\n comment: NonEmptyString,\r\n })\r\n ),\r\n
t.exact(\r\n t.partial({\r\n id,\r\n })\r\n ),\r\n ]);\r\n ```\r\n3.
Moving tests and mocks to the `hooks` package as well add new
tests\r\nfor the new
`removeCreatedAtCreatedByFromCommentsOnUpdate`\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\nCo-authored-by: Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"2bd2226cb259312b90ad32b1cd5618a0cc2e8b49"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145575","number":145575,"mergeCommit":{"message":"[Security
Solution] [Exceptions] Fix edit the exception while adding new comment.
(#145575)\n\n## Summary\r\n\r\nAddress
https://github.com/elastic/kibana/issues/144523\r\n\r\n1. Fix type
schema check to use `updateExceptionListItemSchema` instead\r\nof
`exceptionListItemSchema` as the comments array could be empty
when\r\nthe user adds the Exceptions and in Editing with adding a new
comment(s)\r\nit will contain only (comment and id) in the newly created
comment\r\n\r\n2. Add `removeCreatedAtCreatedByFromCommentsOnUpdate` to
remove the\r\n`createdAt`, and `createdBy` from the updated exception
Item if a\r\ncomment was added before to fix the `400 Schema
validations` as per the\r\nbelow
Schema\r\n\r\nThe\r\n`packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.ts`\r\n
\r\n ```\r\n export const updateComment = t.intersection([\r\n
t.exact(\r\n t.type({\r\n comment: NonEmptyString,\r\n })\r\n ),\r\n
t.exact(\r\n t.partial({\r\n id,\r\n })\r\n ),\r\n ]);\r\n ```\r\n3.
Moving tests and mocks to the `hooks` package as well add new
tests\r\nfor the new
`removeCreatedAtCreatedByFromCommentsOnUpdate`\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\nCo-authored-by: Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"2bd2226cb259312b90ad32b1cd5618a0cc2e8b49"}}]}]
BACKPORT-->

Co-authored-by: Wafaa Nasr <wafaa.nasr@elastic.co>
2022-11-18 08:11:25 -07:00
..
src [8.6] [Security Solution] [Exceptions] Fix edit the exception while adding new comment. (#145575) (#145724) 2022-11-18 08:11:25 -07:00
BUILD.bazel [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
index.ts [Security Solution] Value list exceptions (#133254) 2022-09-19 22:41:28 +02:00
jest.config.js Adds two more packages and moves files into the packages (#100375) 2021-05-20 12:36:07 -06:00
kibana.jsonc add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
package.json [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
README.md Adds two more packages and moves files into the packages (#100375) 2021-05-20 12:36:07 -06:00
tsconfig.json [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00

kbn-securitysolution-list-hooks

This is where shared constants for security solution should go that are going to be shared among plugins. This was originally created to remove the dependencies between security_solution and other projects such as lists.