Skip to content

Commit e8866bb

Browse files
committed
Fix to show the security rule name in the integration assets accordian.
Security rule object don't have a title, they only have a name. Use the name field if there's no value in title.
1 parent 5765fe0 commit e8866bb

2 files changed

Lines changed: 72 additions & 4 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import type { ISavedObjectTypeRegistry, SavedObjectsClientContract } from '@kbn/core/server';
9+
10+
import { KibanaSavedObjectType } from '../../../../common/types';
11+
12+
import { getBulkAssets } from './get_bulk_assets';
13+
14+
describe('getBulkAssets', () => {
15+
it('uses attributes.name as the display title when attributes.title is unavailable', async () => {
16+
const soClient = {
17+
bulkResolve: jest.fn().mockResolvedValue({
18+
resolved_objects: [
19+
{
20+
saved_object: {
21+
id: 'sample_security_rule',
22+
type: KibanaSavedObjectType.securityRule,
23+
updated_at: '2026-05-28T00:00:00.000Z',
24+
attributes: {
25+
name: 'Svchost spawning Cmd',
26+
description:
27+
'Identifies a suspicious parent child process relationship with cmd.exe descending from svchost.exe',
28+
},
29+
},
30+
},
31+
],
32+
}),
33+
} as unknown as SavedObjectsClientContract;
34+
35+
const soTypeRegistry = {
36+
getType: jest.fn().mockReturnValue({
37+
management: {},
38+
}),
39+
} as unknown as ISavedObjectTypeRegistry;
40+
41+
const assets = await getBulkAssets(soClient, soTypeRegistry, [
42+
{
43+
id: 'sample_security_rule',
44+
type: KibanaSavedObjectType.securityRule,
45+
},
46+
]);
47+
48+
expect(assets).toEqual([
49+
{
50+
id: 'sample_security_rule',
51+
type: KibanaSavedObjectType.securityRule,
52+
updatedAt: '2026-05-28T00:00:00.000Z',
53+
attributes: {
54+
title: 'Svchost spawning Cmd',
55+
description:
56+
'Identifies a suspicious parent child process relationship with cmd.exe descending from svchost.exe',
57+
},
58+
appLink: '',
59+
},
60+
]);
61+
});
62+
});

x-pack/platform/plugins/shared/fleet/server/services/epm/packages/get_bulk_assets.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { displayedAssetTypesLookup } from '../../../../common/constants';
1818

1919
import type { SimpleSOAssetAttributes } from '../../../types';
2020

21+
type DisplayableSOAssetAttributes = SimpleSOAssetAttributes & {
22+
name?: string;
23+
};
24+
2125
const getKibanaLinkForESAsset = (type: ElasticsearchAssetType, id: string): string => {
2226
switch (type) {
2327
case 'index':
@@ -48,9 +52,8 @@ export async function getBulkAssets(
4852
soTypeRegistry: ISavedObjectTypeRegistry,
4953
assetIds: AssetSOObject[]
5054
) {
51-
const { resolved_objects: resolvedObjects } = await soClient.bulkResolve<SimpleSOAssetAttributes>(
52-
assetIds
53-
);
55+
const { resolved_objects: resolvedObjects } =
56+
await soClient.bulkResolve<DisplayableSOAssetAttributes>(assetIds);
5457
const types: Record<string, SavedObjectsType | undefined> = {};
5558

5659
const res: SimpleSOAssetType[] = resolvedObjects
@@ -88,7 +91,10 @@ export async function getBulkAssets(
8891
}
8992
}
9093

91-
const title = types[obj.type]?.management?.getTitle?.(obj) ?? obj.attributes?.title;
94+
const title =
95+
types[obj.type]?.management?.getTitle?.(obj) ??
96+
obj.attributes?.title ??
97+
obj.attributes?.name;
9298

9399
return {
94100
id: obj.id,

0 commit comments

Comments
 (0)