[Security Solution] Improve bulk action executor #142748
Labels
8.6 candidate
Feature:Rule Management
Security Solution Detection Rule Management area
refactoring
Team:Detection Rule Management
Security Detection Rule Management Team
Team:Detections and Resp
Security Detection Response Team
Team: SecuritySolution
Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc.
technical debt
Improvement of the software architecture and operational architecture
v8.6.0
Relates to: #139897
Summary
Current bulk action executor violates single responsibility principle so that it blocks concise feature development.
Details
While working on #139897 I've discovered that bulk action executor function violates single responsibility principle which makes it harder to extend its functionality by composition. The major part of the input parameters are optional and related to some of the actions. It makes it harder to use TypeScript guarding against passing unrelated parameters and requires good understanding of the function internals before its usage.
Obviously there is a room for improvement here. It can be achieved by splitting the logic by responsibility and improve typings. Decisions about the next steps like on success or on error should be done by the driver code. Taking that into account there are two ways
To handle errors and perform any other actions it's enough to wrap a function from above to
try/catch/finally
or create a reusable wrapper function. Unspecified arguments should be used by the driver code.defaultSuccessHandler
anddefaultErrorHandler
should be split into pure message generator functions to be exported separately and used by the driver code.The text was updated successfully, but these errors were encountered: