-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security] Adds pre-packaged rule updates through the "Prebuilt Secur…
…ity Detection Rules" Fleet integration (#96698) * Make the prepackaged rules functions async * Fix type for getPrepackagedRules mock * Install updates from saved objects & FS * Mock getLatestPrepackagedRules instead of getPrepackagedRules * Cleanup ruleAssetSavedObjectsClientFactory.all * Fix comment for "most recent version" * Switch to ruleMap.get() for less typescript errors * Remove unneeded constants * Fix SO.attributes sig and use custom validation
- Loading branch information
Showing
8 changed files
with
146 additions
and
14 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
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
47 changes: 47 additions & 0 deletions
47
...ns/security_solution/server/lib/detection_engine/rules/rule_asset_saved_objects_client.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,47 @@ | ||
/* | ||
* 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 { | ||
SavedObjectsClientContract, | ||
SavedObjectsFindOptions, | ||
SavedObjectsFindResponse, | ||
} from '../../../../../../../src/core/server'; | ||
import { ruleAssetSavedObjectType } from '../rules/saved_object_mappings'; | ||
import { IRuleAssetSavedObject } from '../rules/types'; | ||
|
||
const DEFAULT_PAGE_SIZE = 100; | ||
|
||
export interface RuleAssetSavedObjectsClient { | ||
find: ( | ||
options?: Omit<SavedObjectsFindOptions, 'type'> | ||
) => Promise<SavedObjectsFindResponse<IRuleAssetSavedObject>>; | ||
all: () => Promise<IRuleAssetSavedObject[]>; | ||
} | ||
|
||
export const ruleAssetSavedObjectsClientFactory = ( | ||
savedObjectsClient: SavedObjectsClientContract | ||
): RuleAssetSavedObjectsClient => { | ||
return { | ||
find: (options) => | ||
savedObjectsClient.find<IRuleAssetSavedObject>({ | ||
...options, | ||
type: ruleAssetSavedObjectType, | ||
}), | ||
all: async () => { | ||
const finder = savedObjectsClient.createPointInTimeFinder({ | ||
perPage: DEFAULT_PAGE_SIZE, | ||
type: ruleAssetSavedObjectType, | ||
}); | ||
const responses: IRuleAssetSavedObject[] = []; | ||
for await (const response of finder.find()) { | ||
responses.push(...response.saved_objects.map((so) => so as IRuleAssetSavedObject)); | ||
} | ||
await finder.close(); | ||
return responses; | ||
}, | ||
}; | ||
}; |
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