Skip to content
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] Fix security solution tag id #164582

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.