-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fleet] Tag assets based on definitions in integration tag.yml #162643
[Fleet] Tag assets based on definitions in integration tag.yml #162643
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
@elasticmachine merge upstream |
@elasticmachine merge upstream |
Pinging @elastic/fleet (Team:Fleet) |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks great, it would be good to have a functional test for making sure the tag isn't duplicated if it already exists, do you think that would be do-able?
Actually I forgot to add that test, I'll add it now |
return; | ||
} | ||
const packageSpecAssets = await getPackageSpecTags(taggableAssets, opts); | ||
const groupedAssets = groupByAssetId(packageSpecAssets); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of data manipulation here, trying to explain why.
I was previously trying to update call updateTagAssignments
iterating directly on packageSpecAssets
, calling by tagId
, but for some reason the assets didn't get applied correctly. I suspect that calling the same assets on different ids asynchronously was overriding some of the assets.
So I decided to group by assetId
instead, so every asset gets assigned to the tag only once.
@elasticmachine merge upstream |
x-pack/plugins/fleet/server/services/epm/kibana/assets/tag_assets.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/fleet/server/services/epm/kibana/assets/tag_assets.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few comments, overall looks good, I suggested to make the tag ids more readable instead of using uuid, this would make the tests more readable too.
x-pack/plugins/fleet/server/services/epm/kibana/assets/tag_assets.test.ts
Show resolved
Hide resolved
x-pack/plugins/fleet/server/services/epm/kibana/assets/tag_assets.test.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the changes.
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Public APIs missing exports
History
To update your PR or re-run it, just comment with: cc @criamico |
Related to #152814 ## Summary Fix for a bug found in #162643 : The security solution tag is actually created with "Security Solution" name and "security-solution-default" id (instead of `SecuritySolution`): ``` { "id": "security-solution-default", "name": "Security Solution", "description": "", "color": "#D36086" } ``` I found that in same cases the tag is duplicated, since[ is not created with an unique id](https://github.com/elastic/kibana/blob/dd0938bea3ebd745a49ac164a7a5f053ba6a138b/x-pack/plugins/security_solution/public/dashboards/containers/use_fetch_security_tags.ts#L44-L51): <img width="3079" alt="Screenshot 2023-08-23 at 15 07 09" src="https://github.com/elastic/kibana/assets/16084106/ef885d8f-2e68-4695-aa14-1adc2e326ab0"> I think it's acceptable to use the "security-solution-default", at least it will create the correct tag name. ### Test For testing I used a package built locally that uses the `Security Solution` tag The steps are the same as described in #162643 - Additionally, check that the `tags` endpoint in the Tags page has name and id as described above: <img width="2521" alt="Screenshot 2023-08-23 at 14 55 05" src="https://github.com/elastic/kibana/assets/16084106/48b3ddd0-3d04-4ff6-8a24-946902687b13">
Related to elastic#152814 ## Summary Fix for a bug found in elastic#162643 : The security solution tag is actually created with "Security Solution" name and "security-solution-default" id (instead of `SecuritySolution`): ``` { "id": "security-solution-default", "name": "Security Solution", "description": "", "color": "#D36086" } ``` I found that in same cases the tag is duplicated, since[ is not created with an unique id](https://github.com/elastic/kibana/blob/dd0938bea3ebd745a49ac164a7a5f053ba6a138b/x-pack/plugins/security_solution/public/dashboards/containers/use_fetch_security_tags.ts#L44-L51): <img width="3079" alt="Screenshot 2023-08-23 at 15 07 09" src="https://github.com/elastic/kibana/assets/16084106/ef885d8f-2e68-4695-aa14-1adc2e326ab0"> I think it's acceptable to use the "security-solution-default", at least it will create the correct tag name. ### Test For testing I used a package built locally that uses the `Security Solution` tag The steps are the same as described in elastic#162643 - Additionally, check that the `tags` endpoint in the Tags page has name and id as described above: <img width="2521" alt="Screenshot 2023-08-23 at 14 55 05" src="https://github.com/elastic/kibana/assets/16084106/48b3ddd0-3d04-4ff6-8a24-946902687b13"> (cherry picked from commit da8d3b2)
# Backport This will backport the following commits from `main` to `8.10`: - [[Fleet] Fix security solution tag id (#164582)](#164582) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Cristina Amico","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-08-24T07:20:13Z","message":"[Fleet] Fix security solution tag id (#164582)\n\nRelated to https://github.com/elastic/kibana/issues/152814\r\n\r\n## Summary\r\n\r\nFix for a bug found in #162643 :\r\nThe security solution tag is actually created with \"Security Solution\"\r\nname and \"security-solution-default\" id (instead of `SecuritySolution`):\r\n\r\n```\r\n {\r\n \"id\": \"security-solution-default\",\r\n \"name\": \"Security Solution\",\r\n \"description\": \"\",\r\n \"color\": \"#D36086\"\r\n }\r\n```\r\n\r\nI found that in same cases the tag is duplicated, since[ is not created\r\nwith an unique\r\nid](https://github.com/elastic/kibana/blob/dd0938bea3ebd745a49ac164a7a5f053ba6a138b/x-pack/plugins/security_solution/public/dashboards/containers/use_fetch_security_tags.ts#L44-L51):\r\n\r\n<img width=\"3079\" alt=\"Screenshot 2023-08-23 at 15 07 09\"\r\nsrc=\"https://github.com/elastic/kibana/assets/16084106/ef885d8f-2e68-4695-aa14-1adc2e326ab0\">\r\n\r\nI think it's acceptable to use the \"security-solution-default\", at least\r\nit will create the correct tag name.\r\n\r\n### Test\r\nFor testing I used a package built locally that uses the `Security\r\nSolution` tag\r\nThe steps are the same as described in\r\nhttps://github.com//pull/162643\r\n\r\n- Additionally, check that the `tags` endpoint in the Tags page has name\r\nand id as described above:\r\n<img width=\"2521\" alt=\"Screenshot 2023-08-23 at 14 55 05\"\r\nsrc=\"https://github.com/elastic/kibana/assets/16084106/48b3ddd0-3d04-4ff6-8a24-946902687b13\">","sha":"da8d3b25c91deaba383a6d6a40d00522f7c6f463","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-minor","v8.11.0"],"number":164582,"url":"https://github.com/elastic/kibana/pull/164582","mergeCommit":{"message":"[Fleet] Fix security solution tag id (#164582)\n\nRelated to https://github.com/elastic/kibana/issues/152814\r\n\r\n## Summary\r\n\r\nFix for a bug found in #162643 :\r\nThe security solution tag is actually created with \"Security Solution\"\r\nname and \"security-solution-default\" id (instead of `SecuritySolution`):\r\n\r\n```\r\n {\r\n \"id\": \"security-solution-default\",\r\n \"name\": \"Security Solution\",\r\n \"description\": \"\",\r\n \"color\": \"#D36086\"\r\n }\r\n```\r\n\r\nI found that in same cases the tag is duplicated, since[ is not created\r\nwith an unique\r\nid](https://github.com/elastic/kibana/blob/dd0938bea3ebd745a49ac164a7a5f053ba6a138b/x-pack/plugins/security_solution/public/dashboards/containers/use_fetch_security_tags.ts#L44-L51):\r\n\r\n<img width=\"3079\" alt=\"Screenshot 2023-08-23 at 15 07 09\"\r\nsrc=\"https://github.com/elastic/kibana/assets/16084106/ef885d8f-2e68-4695-aa14-1adc2e326ab0\">\r\n\r\nI think it's acceptable to use the \"security-solution-default\", at least\r\nit will create the correct tag name.\r\n\r\n### Test\r\nFor testing I used a package built locally that uses the `Security\r\nSolution` tag\r\nThe steps are the same as described in\r\nhttps://github.com//pull/162643\r\n\r\n- Additionally, check that the `tags` endpoint in the Tags page has name\r\nand id as described above:\r\n<img width=\"2521\" alt=\"Screenshot 2023-08-23 at 14 55 05\"\r\nsrc=\"https://github.com/elastic/kibana/assets/16084106/48b3ddd0-3d04-4ff6-8a24-946902687b13\">","sha":"da8d3b25c91deaba383a6d6a40d00522f7c6f463"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164582","number":164582,"mergeCommit":{"message":"[Fleet] Fix security solution tag id (#164582)\n\nRelated to https://github.com/elastic/kibana/issues/152814\r\n\r\n## Summary\r\n\r\nFix for a bug found in #162643 :\r\nThe security solution tag is actually created with \"Security Solution\"\r\nname and \"security-solution-default\" id (instead of `SecuritySolution`):\r\n\r\n```\r\n {\r\n \"id\": \"security-solution-default\",\r\n \"name\": \"Security Solution\",\r\n \"description\": \"\",\r\n \"color\": \"#D36086\"\r\n }\r\n```\r\n\r\nI found that in same cases the tag is duplicated, since[ is not created\r\nwith an unique\r\nid](https://github.com/elastic/kibana/blob/dd0938bea3ebd745a49ac164a7a5f053ba6a138b/x-pack/plugins/security_solution/public/dashboards/containers/use_fetch_security_tags.ts#L44-L51):\r\n\r\n<img width=\"3079\" alt=\"Screenshot 2023-08-23 at 15 07 09\"\r\nsrc=\"https://github.com/elastic/kibana/assets/16084106/ef885d8f-2e68-4695-aa14-1adc2e326ab0\">\r\n\r\nI think it's acceptable to use the \"security-solution-default\", at least\r\nit will create the correct tag name.\r\n\r\n### Test\r\nFor testing I used a package built locally that uses the `Security\r\nSolution` tag\r\nThe steps are the same as described in\r\nhttps://github.com//pull/162643\r\n\r\n- Additionally, check that the `tags` endpoint in the Tags page has name\r\nand id as described above:\r\n<img width=\"2521\" alt=\"Screenshot 2023-08-23 at 14 55 05\"\r\nsrc=\"https://github.com/elastic/kibana/assets/16084106/48b3ddd0-3d04-4ff6-8a24-946902687b13\">","sha":"da8d3b25c91deaba383a6d6a40d00522f7c6f463"}}]}] BACKPORT--> Co-authored-by: Cristina Amico <[email protected]>
Closes #152814
Summary
Tag assets based on definitions in integrations file
tag.yml
following these guidelines:fleet-shared-tag-${pkgName}-${uniqueId}-${spaceId}
SecuritySolution
it generates aSecuritySolution
tag to maintain compatibility with security requirementsTesting
To test it, I generated a customized version of a the AWS package that has a
kibana/tags.yml
file that follows this template, since currently there are no existing published packages of this type.See related package-spec PR
Note that
manifest.yml
needs to have at least:I then verified that the tags are correctly generated and associated with correct assets:
Checklist