Skip to content

Commit 40da239

Browse files
[AI4DSOC] Fix logic that renders the group title when grouping by integrations
1 parent 903581d commit 40da239

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_get_integration_from_rule_id.test.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ describe('useGetIntegrationFromRuleId', () => {
2626
expect(result.current.integration).toBe(undefined);
2727
});
2828

29+
it('should return undefined integration when the rule does not have the expected related_integrations', () => {
30+
const packages: PackageListItem[] = [
31+
{
32+
id: 'splunk',
33+
icons: [{ src: 'icon.svg', path: 'mypath/icon.svg', type: 'image/svg+xml' }],
34+
name: 'splunk',
35+
status: installationStatuses.NotInstalled,
36+
title: 'Splunk',
37+
version: '0.1.0',
38+
},
39+
];
40+
const ruleId = 'rule_id';
41+
const rules: RuleResponse[] = [
42+
{
43+
id: 'rule_id',
44+
related_integrations: [{ package: 'wrong_integrations' }],
45+
} as RuleResponse,
46+
];
47+
48+
const { result } = renderHook(() => useGetIntegrationFromRuleId({ packages, ruleId, rules }));
49+
50+
expect(result.current.integration).toBe(undefined);
51+
});
52+
2953
it('should render a matching integration', () => {
3054
const packages: PackageListItem[] = [
3155
{
@@ -38,7 +62,12 @@ describe('useGetIntegrationFromRuleId', () => {
3862
},
3963
];
4064
const ruleId = 'rule_id';
41-
const rules: RuleResponse[] = [{ id: 'rule_id', name: 'splunk' } as RuleResponse];
65+
const rules: RuleResponse[] = [
66+
{
67+
id: 'rule_id',
68+
related_integrations: [{ package: 'splunk' }],
69+
} as RuleResponse,
70+
];
4271

4372
const { result } = renderHook(() => useGetIntegrationFromRuleId({ packages, ruleId, rules }));
4473

x-pack/solutions/security/plugins/security_solution/public/detections/hooks/alert_summary/use_get_integration_from_rule_id.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const useGetIntegrationFromRuleId = ({
5151
return undefined;
5252
}
5353

54-
return packages.find((p) => p.name === rule.name);
54+
return packages.find((p) => rule.related_integrations.map((ri) => ri.package).includes(p.name));
5555
}, [packages, rules, ruleId]);
5656

5757
return useMemo(

0 commit comments

Comments
 (0)