Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
e40pud committed Dec 19, 2024
1 parent 3881cc2 commit ee2cb33
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import {
RuleMigrationResourceType,
RuleMigrationResource,
} from '../../rule_migration.gen';
import { RelatedIntegration } from '../../../../api/detection_engine/model/rule_schema/common_attributes.gen';
import { NonEmptyString } from '../../../../api/model/primitives.gen';
import { ConnectorId, LangSmithOptions } from '../../common.gen';
import { RelatedIntegration } from '../../../../api/detection_engine/model/rule_schema/common_attributes.gen';

export type CreateRuleMigrationRequestParams = z.infer<typeof CreateRuleMigrationRequestParams>;
export const CreateRuleMigrationRequestParams = z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ paths:
items:
$ref: '../../rule_migration.schema.yaml#/components/schemas/RuleMigrationTaskStats'

/internal/siem_migrations/rules/integrations:
get:
summary: Retrieves all related integrations for a specific migration
operationId: GetRuleMigrationIntegrations
x-codegen-enabled: true
x-internal: true
description: Retrieves all related integrations
tags:
- SIEM Rule Migrations
responses:
200:
description: Indicates that related integrations have been retrieved correctly.
content:
application/json:
schema:
type: object
description: The map of related integrations, with the integration id as a key
additionalProperties:
$ref: '../../../../../common/api/detection_engine/model/rule_schema/common_attributes.schema.yaml#/components/schemas/RelatedIntegration'

## Specific rule migration APIs

/internal/siem_migrations/rules/{migration_id}:
Expand Down Expand Up @@ -396,26 +416,6 @@ paths:
additionalProperties:
$ref: '../../rule_migration.schema.yaml#/components/schemas/PrebuiltRuleVersion'

/internal/siem_migrations/rules/{migration_id}/integrations:
get:
summary: Retrieves all related integrations for a specific migration
operationId: GetRuleMigrationIntegrations
x-codegen-enabled: true
x-internal: true
description: Retrieves all related integrations
tags:
- SIEM Rule Migrations
responses:
200:
description: Indicates that related integrations have been retrieved correctly.
content:
application/json:
schema:
type: object
description: The map of related integrations, with the integration id as a key
additionalProperties:
$ref: '../../../../../common/api/detection_engine/model/rule_schema/common_attributes.schema.yaml#/components/schemas/RelatedIntegration'

# Rule migration resources APIs

/internal/siem_migrations/rules/{migration_id}/resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { createPrebuiltRules } from '../../../../detection_engine/prebuilt_rules
import type { IDetectionRulesClient } from '../../../../detection_engine/rule_management/logic/detection_rules_client/detection_rules_client_interface';
import type { RuleResponse } from '../../../../../../common/api/detection_engine';
import type { StoredRuleMigration } from '../../types';
import { getPrebuiltRulesByIds, getUniquePrebuiltRuleIds } from './prebuilt_rules';
import { getPrebuiltRules, getUniquePrebuiltRuleIds } from './prebuilt_rules';
import {
MAX_CUSTOM_RULES_TO_CREATE_IN_PARALLEL,
MAX_TRANSLATED_RULES_TO_INSTALL,
Expand All @@ -35,11 +35,7 @@ const installPrebuiltRules = async (
): Promise<UpdateRuleMigrationData[]> => {
// Get required prebuilt rules
const prebuiltRulesIds = getUniquePrebuiltRuleIds(rulesToInstall);
const prebuiltRules = await getPrebuiltRulesByIds(
rulesClient,
savedObjectsClient,
prebuiltRulesIds
);
const prebuiltRules = await getPrebuiltRules(rulesClient, savedObjectsClient, prebuiltRulesIds);

const { installed: alreadyInstalledRules, installable } = Object.values(prebuiltRules).reduce(
(acc, item) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface PrebuiltRulesResults {
* @param rulesIds The list of IDs to filter requested prebuilt rules. If not specified, all available prebuilt rules will be returned.
* @returns
*/
export const getPrebuiltRulesByIds = async (
export const getPrebuiltRules = async (
rulesClient: RulesClient,
savedObjectsClient: SavedObjectsClientContract,
rulesIds?: string[]
Expand Down Expand Up @@ -113,11 +113,7 @@ export const getPrebuiltRulesForMigration = async (
}
const prebuiltRulesIds = Array.from(rulesIds);

const prebuiltRules = await getPrebuiltRulesByIds(
rulesClient,
savedObjectsClient,
prebuiltRulesIds
);
const prebuiltRules = await getPrebuiltRules(rulesClient, savedObjectsClient, prebuiltRulesIds);

return prebuiltRules;
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class SiemMigrationsService {
}

createRulesClient(params: SiemRuleMigrationsCreateClientParams): SiemRuleMigrationsClient {
return this.rules.createClient({ ...params });
return this.rules.createClient(params);
}

stop() {
Expand Down

0 comments on commit ee2cb33

Please sign in to comment.