Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] DetectionRulesClient: return RuleResponse from createCustomRule and createPrebuiltRule #185748

Merged

Conversation

nikitaindik
Copy link
Contributor

@nikitaindik nikitaindik commented Jun 10, 2024

Partially addresses: #184364

Summary

This PR changes createCustomRule and createPrebuiltRule methods to return RuleResponse instead of RuleAlertType.

This is a continuation of the effort to improve DetectionRulesClient. As a part of it we want to make the client return RuleResponse from all its public methods. This is good because it lets us hide rule's internal structure and centralise conversions in one place – in the client. So in this and upcoming PRs we are going to convert RuleAlertType to RuleResponse within the client's methods and return the RuleResponse object.

@nikitaindik nikitaindik self-assigned this Jun 10, 2024
@nikitaindik nikitaindik added refactoring backport:skip This commit does not require backporting Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Feature:Rule Management Security Solution Detection Rule Management Team:Detection Rule Management Security Detection Rule Management Team v8.15.0 labels Jun 10, 2024
@nikitaindik nikitaindik changed the title [Security Solution] DetectionRulesClient: return RuleResponse from public methods [Security Solution] DetectionRulesClient: return RuleResponse from createCustomRule and createPrebuiltRule Jun 10, 2024
@nikitaindik nikitaindik marked this pull request as ready for review June 10, 2024 10:02
@nikitaindik nikitaindik requested review from a team as code owners June 10, 2024 10:02
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management)

@nikitaindik nikitaindik added the release_note:skip Skip the PR/issue when compiling release notes label Jun 10, 2024
@nikitaindik nikitaindik marked this pull request as draft June 10, 2024 10:29
@nikitaindik nikitaindik marked this pull request as ready for review June 10, 2024 11:11
@nikitaindik
Copy link
Contributor Author

/ci

Copy link
Contributor

@banderror banderror left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the changes but held off testing the PR.

Let's revisit the solution with DetectionRulesClientValidationError and try to find a cleaner one. Also, there's inconsistency in error handling between the createCustomRule and createPrebuiltRule methods.

@nikitaindik
Copy link
Contributor Author

Thanks for the review folks! Moving it to Draft now while I do the changes. Will notify you guys once it's ready for another look.

@nikitaindik nikitaindik marked this pull request as draft June 11, 2024 10:19
@nikitaindik
Copy link
Contributor Author

Addressed the feedback. Reopening the PR for review.

@nikitaindik nikitaindik marked this pull request as ready for review June 12, 2024 13:35
@nikitaindik
Copy link
Contributor Author

/ci

@nikitaindik
Copy link
Contributor Author

/ci

@nikitaindik nikitaindik force-pushed the detection-rules-client-rule-response branch from cc2382c to 74ff7a0 Compare June 18, 2024 10:52
@nikitaindik
Copy link
Contributor Author

/ci

@nikitaindik nikitaindik marked this pull request as ready for review June 18, 2024 12:48
@nikitaindik nikitaindik enabled auto-merge (squash) June 18, 2024 12:56
@kibana-ci
Copy link
Collaborator

kibana-ci commented Jun 18, 2024

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #10 / Cloud Security Posture Test adding Cloud Security Posture Integrations KSPM EKS KSPM EKS Shared Credentials KSPM EKS Shared Credentials Workflow

Metrics [docs]

Unknown metric groups

ESLint disabled in files

id before after diff
securitySolution 82 83 +1

Total ESLint disabled count

id before after diff
securitySolution 608 609 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @nikitaindik

@nikitaindik nikitaindik merged commit c49cfbe into elastic:main Jun 18, 2024
40 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 18, 2024
bhapas pushed a commit to bhapas/kibana that referenced this pull request Jun 18, 2024
…m `createCustomRule` and `createPrebuiltRule` (elastic#185748)

**Partially addresses: elastic#184364

## Summary
This PR changes `createCustomRule` and `createPrebuiltRule` methods to
return `RuleResponse` instead of `RuleAlertType`.

This is a continuation of the effort to improve `DetectionRulesClient`.
As a part of it we want to make the client return `RuleResponse` from
all its public methods. This is good because it lets us hide rule's
internal structure and centralise conversions in one place – in the
client. So in this and upcoming PRs we are going to convert
`RuleAlertType` to `RuleResponse` within the client's methods and return
the `RuleResponse` object.
nikitaindik added a commit that referenced this pull request Jun 21, 2024
…m all methods (#186179)

**Partially addresses: #184364

## Summary

This PR is a follow-up to [PR
#185748](#185748) and it converts
the remaining `DetectionRulesClient` methods to return `RuleResponse`.

Changes in this PR:
- These methods now return `RuleResponse` instead of internal
`RuleAlertType` type:
  - `updateRule`
  - `patchRule`
  - `upgradePrebuiltRule`
  - `importRule`
bhapas pushed a commit to bhapas/kibana that referenced this pull request Jun 24, 2024
…m all methods (elastic#186179)

**Partially addresses: elastic#184364

## Summary

This PR is a follow-up to [PR
elastic#185748](elastic#185748) and it converts
the remaining `DetectionRulesClient` methods to return `RuleResponse`.

Changes in this PR:
- These methods now return `RuleResponse` instead of internal
`RuleAlertType` type:
  - `updateRule`
  - `patchRule`
  - `upgradePrebuiltRule`
  - `importRule`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:project-deploy-security Create a Security Serverless Project Feature:Rule Management Security Solution Detection Rule Management refactoring release_note:skip Skip the PR/issue when compiling release notes 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. v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants