Skip to content
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 @@ -516,4 +516,7 @@ export const JEST_ENVIRONMENT = typeof jest !== 'undefined';
/*
* The tag to mark promotion rules that are related to the AI for SOC integrations
*/
export const PROMOTION_RULE_TAG = 'Promotion';
export const PROMOTION_RULE_TAGS = [
'Promotion', // This is the legacy tag for promotion rules and can be safely removed once promotion rules go live
'Promotion: External Alerts',
];
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import type {
} from '../../../../../../common/api/detection_engine/prebuilt_rules/bootstrap_prebuilt_rules/bootstrap_prebuilt_rules.gen';
import { getErrorMessage } from '../../../../../utils/error_helpers';
import type { EndpointInternalFleetServicesInterface } from '../../../../../endpoint/services/fleet';
import { PROMOTION_RULE_TAG } from '../../../../../../common/constants';
import { PROMOTION_RULE_TAGS } from '../../../../../../common/constants';
import type { PrebuiltRuleAsset } from '../../model/rule_assets/prebuilt_rule_asset';

interface InstallPromotionRulesParams {
rulesClient: RulesClient;
Expand Down Expand Up @@ -70,7 +71,7 @@ export async function installPromotionRules({
const latestPromotionRules = latestRuleAssets.filter((rule) => {
// Rule should be tagged as 'Promotion' and should be related to an enabled integration
return (
(rule.tags ?? []).includes(PROMOTION_RULE_TAG) &&
isPromotionRule(rule) &&
rule.related_integrations?.some((integration) =>
installedIntegrations.has(integration.package)
)
Expand Down Expand Up @@ -146,3 +147,7 @@ export async function installPromotionRules({
errors: allErrors.size > 0 ? Array.from(allErrors.values()) : [],
};
}

function isPromotionRule(rule: PrebuiltRuleAsset): boolean {
return (rule.tags ?? []).some((tag) => PROMOTION_RULE_TAGS.includes(tag));
}