-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Add timelines installation to the new rule upgrad…
…e/install endpoints (#159694) **Resolves: #152860 To replicate the behavior of the legacy prebuilt rule endpoint, this PR introduces a call to install prebuilt timeline templates each time any of the following endpoints are invoked: - `POST /internal/detection_engine/prebuilt_rules/installation/_perform` - `POST /internal/detection_engine/prebuilt_rules/upgrade/_perform`
- Loading branch information
Showing
4 changed files
with
70 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...lution/server/lib/detection_engine/prebuilt_rules/logic/perform_timelines_installation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { validate } from '@kbn/securitysolution-io-ts-utils'; | ||
import { importTimelineResultSchema } from '../../../../../common/types/timeline/api'; | ||
import type { SecuritySolutionApiRequestHandlerContext } from '../../../../types'; | ||
import { installPrepackagedTimelines } from '../../../timeline/routes/prepackaged_timelines/install_prepackaged_timelines'; | ||
|
||
export const performTimelinesInstallation = async ( | ||
securitySolutionContext: SecuritySolutionApiRequestHandlerContext | ||
) => { | ||
const timeline = await installPrepackagedTimelines( | ||
securitySolutionContext.getConfig()?.maxTimelineImportExportSize, | ||
securitySolutionContext.getFrameworkRequest(), | ||
true | ||
); | ||
const [result, error] = validate(timeline, importTimelineResultSchema); | ||
|
||
return { | ||
result, | ||
error, | ||
}; | ||
}; |