[Security Solution] Rules managment RBAC subfeatures#250131
[Security Solution] Rules managment RBAC subfeatures#250131dplumlee merged 122 commits intoelastic:mainfrom
Conversation
d263d07 to
9063a26
Compare
|
@pborgonovi Looking at this it seems to be something better suited to be fixed in the alerts RBAC PR since that's where most of the alerting stuff is changed |
|
/ci |
1 similar comment
|
/ci |
- relax the requirement to call GET /api/detection_engine/privileges so now roles with alert permissions can call it - enforce ALERTS_API_ALL for routes that make changes to alerts
instead of hard coding the landing tab in every place where we redirect, we will instead redirect to the rule details page and let the router determine in which tab tab the user should land based on their permissions. handle the case where a user receives a url with a tab they don't have access to.
...er/application/rule/methods/bulk_edit_params/schemas/bulk_edit_rule_params_option_schemas.ts
Fixed
Show fixed
Hide fixed
...er/application/rule/methods/bulk_edit_params/schemas/bulk_edit_rule_params_option_schemas.ts
Outdated
Show resolved
Hide resolved
rgodfrey-elastic
left a comment
There was a problem hiding this comment.
LGTM. Thanks for adding the maxSize
| }); | ||
|
|
||
| export const bulkEditParamsOperationsSchema = schema.arrayOf(bulkEditParamsOperationSchema, { | ||
| minSize: 1, |
There was a problem hiding this comment.
Thanks! Maybe you can skip calling bulkEditRuleParamsWithReadAuth if the array is empty?
| ids: schema.maybe(schema.arrayOf(schema.string(), { minSize: 1 })), | ||
| operations: bulkEditParamsOperationsSchema, | ||
| operations: schema.arrayOf(bulkEditParamsOperationSchema, { | ||
| maxSize: 2000, |
There was a problem hiding this comment.
Could we add the max size to bulkEditParamsOperationsSchema instead and keep the minSize (basically revert the change here and use bulkEditParamsOperationsSchema)? Could my suggestion to skip calling bulkEditRuleParamsWithReadAuth in your code if the array is empty? If not, could we at least be sure that inside the bulkEditRuleParamsWithReadAuth we skip if the operations array is empty?
There was a problem hiding this comment.
Talked with @cnasikas about this more in slack. Basically, removing the minSize here is the easier schema refactor of the possible options to maintain current workflows with the new RBAC logic being added. A better path in the future would probably entail adding the add and delete operations to bulkEditParamsOperationsSchema (which right now only allows set). This could allow us to reduce our dependency on the paramsModifier that we currently use in our bulk actions methods (and is responsible for the use case of an empty operations array). Made a slight modification in accordance to this comment but leaving the rest of it for now.
...er/application/rule/methods/bulk_edit_params/schemas/bulk_edit_rule_params_option_schemas.ts
Show resolved
Hide resolved
⏳ Build in-progress
Failed CI StepsTest FailuresHistory
|





Resolves: https://github.com/elastic/security-team/issues/14598
Resolves: https://github.com/elastic/security-team/issues/15244
Resolves: #246471
Based off this PR: #244637
Overview
Adds the following new subfeatures to the Rules RBAC feature within security solution:
security_solution_investigation_guide_edit: ability to modify thenotefield on detection rulessecurity_solution_custom_highlighted_fields_edit: ability to modify theinvestigation_fieldsfield on detection rulessecurity_solution_enable_disable_rules: ability to enable/disable detection rulessecurity_solution_manual_run_rules: ability to manually run detection rulessecurity_solution_rules_management_settings: ability to access rules management settingsSummary
All of these subfeatures are included in the
rules:allfeature and can be added as extra permissions to a role with onlyrules:readcapabilities.This PR modifies detection rules UI to support the new granular permissions logic. The rules table has been updated to handle new edge cases with bulk actions when a user only has
rules:readpermissions as well as the rule edit page and MITRE coverage overview page.We also modify the API behavior for the rules PUT, rules PATCH, and bulk actions endpoints to be able to edit specific rule params (e.g.
note,investigation_fields,enable, etc.) with read only permissions as long as the user has the corresponding subfeature permission. This involved implementing a new server-side permission check that is accessible via thesecuritySolutioncontext.The
exceptions_listsubfeature has also been added to the granular permission PUT route logic along with the new subfeatures added in this PR.Automated testing
Lastly, this PR adds a lot of test coverage (jest and ess integration) to the logic implemented in both this PR and #245722, and covers the many new edge cases that the granular permissions create. Unit tests have been added for the detection rules client logic in:
detection_rules_client.patch_rule.test.tsdetection_rules_client.update_rule.test.tsAnd FTR tests have been added for our CRUD and bulk actions operations in:
x-pack/solutions/security/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_patch/trial_license_complete_tier/patch_rules.tsx-pack/solutions/security/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_update/trial_license_complete_tier/update_rules.tsx-pack/solutions/security/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_enable_disable.tsx-pack/solutions/security/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action.tsx-pack/solutions/security/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action_dry_run.tsScreenshots
All taken with the
rules-read-subfeatures-alllisted in the testing utils section belowRules table bulk actions - now interact-able with
rules:readand new rules subfeaturesRules table row overflow menu - now a user can manually run a rule with read permissions if the have the correct permissions
Rule edit page - a user can now use the rule edit form if they have the permissions to modify
noteorinvestigation_fieldsTesting Utils
Testing configs and scripts
This bash script will add/update the kibana roles defined in the config.yml file into your local instance. Usernames will be the same as the role titles and all passwords are set to a default `changeme`. In this file we have `rules-all`, `rules-read`, and `rules-read-subfeatures-all` which can be modified to omit certain permissions based on whatever testing is needed.config.yaml
rbac-ess-testing-roles.sh