Skip to content

Commit

Permalink
[8.10] [Fleet] Fix security solution tag id (#164582) (#164664)
Browse files Browse the repository at this point in the history
# 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]>
  • Loading branch information
kibanamachine and criamico authored Aug 24, 2023
1 parent 1e077b1 commit 834fde2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ describe('tagKibanaAssets', () => {
} as any;
const assetTags = [
{
text: 'SecuritySolution',
text: 'Security Solution',
asset_types: ['dashboard'],
},
];
Expand Down Expand Up @@ -733,9 +733,9 @@ describe('tagKibanaAssets', () => {
{
color: expect.any(String),
description: 'Tag defined in package-spec',
name: 'SecuritySolution',
name: 'Security Solution',
},
{ id: 'SecuritySolution', overwrite: true, refresh: false }
{ id: 'security-solution-default', overwrite: true, refresh: false }
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const MANAGED_TAG_COLOR = '#0077CC';
const PACKAGE_TAG_COLOR = '#4DD2CA';
const MANAGED_TAG_NAME = 'Managed';
const LEGACY_MANAGED_TAG_ID = 'managed';
const SECURITY_SOLUTION_TAG_ID = 'SecuritySolution';
const SECURITY_SOLUTION_TAG_NAME = 'Security Solution';
const SECURITY_SOLUTION_TAG_ID = 'security-solution-default';

// the tag service only accepts 6-digits hex colors
const TAG_COLORS = [
Expand All @@ -61,10 +62,10 @@ const getLegacyPackageTagId = (pkgName: string) => pkgName;
/*
This function is exported via fleet/plugin.ts to make it available to other plugins
The `SecuritySolution` tag is a special case that needs to be handled separately
In that case simply return `SecuritySolution`
In that case return id `security-solution-default`
*/
export const getPackageSpecTagId = (spaceId: string, pkgName: string, tagName: string) => {
if (tagName.toLowerCase() === SECURITY_SOLUTION_TAG_ID.toLowerCase())
if (tagName.toLowerCase() === SECURITY_SOLUTION_TAG_NAME.toLowerCase())
return SECURITY_SOLUTION_TAG_ID;
// UUID v5 needs a namespace (uuid.DNS) to generate a predictable uuid
const uniqueId = uuidv5(`${tagName.toLowerCase()}`, uuidv5.DNS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default function (providerContext: FtrProviderContext) {

describe('Handles presence of tags inside integration package', async () => {
const testPackage = 'assets_with_tags';
const testPackageVersion = '0.1.0';
const testPackageVersion = '0.1.1';
// tag corresponding to `OnlySomeAssets`
const ONLY_SOME_ASSETS_TAG = `fleet-shared-tag-${testPackage}-ef823f10-b5af-5fcb-95da-2340a5257599-default`;
// tag corresponding to `MixedTypesTag`
Expand All @@ -167,7 +167,7 @@ export default function (providerContext: FtrProviderContext) {

const testPkgArchiveZip = path.join(
path.dirname(__filename),
'../fixtures/direct_upload_packages/assets_with_tags-0.1.0.zip'
'../fixtures/direct_upload_packages/assets_with_tags-0.1.1.zip'
);
const buf = fs.readFileSync(testPkgArchiveZip);
await supertest
Expand All @@ -187,7 +187,7 @@ export default function (providerContext: FtrProviderContext) {
const managedTag = await getTag('fleet-managed-default');
expect(managedTag).not.equal(undefined);

const securitySolutionTag = await getTag('SecuritySolution');
const securitySolutionTag = await getTag('security-solution-default');
expect(securitySolutionTag).not.equal(undefined);

const pkgTag1 = await getTag(ONLY_SOME_ASSETS_TAG);
Expand Down
Binary file not shown.

0 comments on commit 834fde2

Please sign in to comment.