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

[ResponseOps][Cases] Fix edit cases settings privilege #202053

Merged
merged 5 commits into from
Dec 4, 2024

Conversation

js-jankisalvi
Copy link
Contributor

@js-jankisalvi js-jankisalvi commented Nov 27, 2024

Summary

Fixes #197650

Also fixes an issue where user has cases: all and edit case settings: false, user was able to edit settings.

Used permissions.settings instead of permissions.update and permissions.create for custom fields and templates.

How to test

  • Verify by creating a user with different combinations of cases and edit case settings privileges

Checklist

@js-jankisalvi js-jankisalvi self-assigned this Nov 27, 2024
@js-jankisalvi js-jankisalvi added bug Fixes for quality problems that affect the customer experience Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Cases Cases feature v8.17.0 v8.18.0 labels Nov 28, 2024
@js-jankisalvi js-jankisalvi marked this pull request as ready for review November 28, 2024 14:05
@js-jankisalvi js-jankisalvi requested a review from a team as a code owner November 28, 2024 14:05
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops-cases (Feature:Cases)

@js-jankisalvi js-jankisalvi added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) v9.0.0 labels Nov 28, 2024
Copy link
Contributor

@adcoelho adcoelho left a comment

Choose a reason for hiding this comment

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

I went over the code and now during testing I was thinking:

Do we even need to check for permissions.settings inside custom_fields/index and templates/index? Those components and the settings page will not be reachabable if the user does not have permissions.settings so I am not sure it makes sense to do the check.

We check permissions.connectors for editing connectors on the page. If we had permissions.custom_fields or permissions.templates then we could also check those, but if this page is already behind a permissions check I don't think we should be making it again.

wdyt?

Outside of that I tested different roles and it seems to be working as expected. I left some small comments.

@js-jankisalvi
Copy link
Contributor Author

js-jankisalvi commented Dec 3, 2024

We check permissions.connectors for editing connectors on the page. If we had permissions.custom_fields or permissions.templates then we could also check those, but if this page is already behind a permissions check I don't think we should be making it again.

Good point, we should just rely on settings page for all features inside settings. I will remove the check from custom_fields, templates and verify if something breaks.

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

Similar to what Antonio expressed, because the settings feature privilege governs the whole settings page, what if when you do not have permissions for the settings a) hide the "Settings" button and b) if someone navigates through the URL, we show a non-privileged page?

Screenshot 2024-12-03 at 5 45 26 PM Screenshot 2024-12-03 at 5 42 46 PM

@cnasikas
Copy link
Member

cnasikas commented Dec 3, 2024

Ok, forget what I said :). I noticed that in x-pack/plugins/cases/public/components/app/routes.tsx, we do check for the permissions.settings. Same with the button here x-pack/plugins/cases/public/components/all_cases/nav_buttons.tsx.

Copy link
Contributor

@Zacqary Zacqary left a comment

Choose a reason for hiding this comment

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

Other than @adcoelho's feedback, LGTM

@js-jankisalvi
Copy link
Contributor Author

Removed permission.settings checks from custom fields and templates 17f3682

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

Tested and LGMT!

@js-jankisalvi js-jankisalvi enabled auto-merge (squash) December 4, 2024 15:05
@js-jankisalvi js-jankisalvi merged commit 8e8ba53 into elastic:main Dec 4, 2024
8 checks passed
@js-jankisalvi js-jankisalvi deleted the edit-case-settings-bug branch December 4, 2024 15:55
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.16, 8.17, 8.x

https://github.com/elastic/kibana/actions/runs/12163480753

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cases 492.7KB 492.6KB -128.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cases 159.5KB 159.5KB -4.0B

History

cc @js-jankisalvi

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 4, 2024
## Summary

Fixes elastic#197650

Also fixes an issue where user has `cases: all ` and `edit case
settings: false`, user was able to edit settings.

Used `permissions.settings` instead of `permissions.update` and
`permissions.create` for custom fields and templates.

### How to test
- Verify by creating a user with different combinations of cases and
edit case settings privileges

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 8e8ba53)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 4, 2024
## Summary

Fixes elastic#197650

Also fixes an issue where user has `cases: all ` and `edit case
settings: false`, user was able to edit settings.

Used `permissions.settings` instead of `permissions.update` and
`permissions.create` for custom fields and templates.

### How to test
- Verify by creating a user with different combinations of cases and
edit case settings privileges

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 8e8ba53)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.16 Backport failed because of merge conflicts
8.17
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 202053

Questions ?

Please refer to the Backport tool documentation

@js-jankisalvi
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.16

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

js-jankisalvi added a commit to js-jankisalvi/kibana that referenced this pull request Dec 4, 2024
## Summary

Fixes elastic#197650

Also fixes an issue where user has `cases: all ` and `edit case
settings: false`, user was able to edit settings.

Used `permissions.settings` instead of `permissions.update` and
`permissions.create` for custom fields and templates.

### How to test
- Verify by creating a user with different combinations of cases and
edit case settings privileges

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 8e8ba53)

# Conflicts:
#	x-pack/plugins/cases/common/utils/capabilities.test.tsx
#	x-pack/plugins/cases/public/components/configure_cases/index.tsx
kibanamachine added a commit that referenced this pull request Dec 4, 2024
… (#202970)

# Backport

This will backport the following commits from `main` to `8.17`:
- [[ResponseOps][Cases] Fix edit cases settings privilege
(#202053)](#202053)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Janki
Salvi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T15:55:08Z","message":"[ResponseOps][Cases]
Fix edit cases settings privilege (#202053)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/197650\r\n\r\nAlso fixes an
issue where user has `cases: all ` and `edit case\r\nsettings: false`,
user was able to edit settings.\r\n\r\nUsed `permissions.settings`
instead of `permissions.update` and\r\n`permissions.create` for custom
fields and templates.\r\n\r\n### How to test\r\n- Verify by creating a
user with different combinations of cases and\r\nedit case settings
privileges\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"8e8ba53116c16cc9b9122de27415cf8519cc1863","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","v9.0.0","Feature:Cases","backport:prev-minor","v8.17.0","v8.18.0","v8.16.2"],"title":"[ResponseOps][Cases]
Fix edit cases settings
privilege","number":202053,"url":"https://github.com/elastic/kibana/pull/202053","mergeCommit":{"message":"[ResponseOps][Cases]
Fix edit cases settings privilege (#202053)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/197650\r\n\r\nAlso fixes an
issue where user has `cases: all ` and `edit case\r\nsettings: false`,
user was able to edit settings.\r\n\r\nUsed `permissions.settings`
instead of `permissions.update` and\r\n`permissions.create` for custom
fields and templates.\r\n\r\n### How to test\r\n- Verify by creating a
user with different combinations of cases and\r\nedit case settings
privileges\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"8e8ba53116c16cc9b9122de27415cf8519cc1863"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202053","number":202053,"mergeCommit":{"message":"[ResponseOps][Cases]
Fix edit cases settings privilege (#202053)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/197650\r\n\r\nAlso fixes an
issue where user has `cases: all ` and `edit case\r\nsettings: false`,
user was able to edit settings.\r\n\r\nUsed `permissions.settings`
instead of `permissions.update` and\r\n`permissions.create` for custom
fields and templates.\r\n\r\n### How to test\r\n- Verify by creating a
user with different combinations of cases and\r\nedit case settings
privileges\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"8e8ba53116c16cc9b9122de27415cf8519cc1863"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Janki Salvi <[email protected]>
kibanamachine added a commit that referenced this pull request Dec 4, 2024
#202971)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Cases] Fix edit cases settings privilege
(#202053)](#202053)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Janki
Salvi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T15:55:08Z","message":"[ResponseOps][Cases]
Fix edit cases settings privilege (#202053)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/197650\r\n\r\nAlso fixes an
issue where user has `cases: all ` and `edit case\r\nsettings: false`,
user was able to edit settings.\r\n\r\nUsed `permissions.settings`
instead of `permissions.update` and\r\n`permissions.create` for custom
fields and templates.\r\n\r\n### How to test\r\n- Verify by creating a
user with different combinations of cases and\r\nedit case settings
privileges\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"8e8ba53116c16cc9b9122de27415cf8519cc1863","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","v9.0.0","Feature:Cases","backport:prev-minor","v8.17.0","v8.18.0","v8.16.2"],"title":"[ResponseOps][Cases]
Fix edit cases settings
privilege","number":202053,"url":"https://github.com/elastic/kibana/pull/202053","mergeCommit":{"message":"[ResponseOps][Cases]
Fix edit cases settings privilege (#202053)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/197650\r\n\r\nAlso fixes an
issue where user has `cases: all ` and `edit case\r\nsettings: false`,
user was able to edit settings.\r\n\r\nUsed `permissions.settings`
instead of `permissions.update` and\r\n`permissions.create` for custom
fields and templates.\r\n\r\n### How to test\r\n- Verify by creating a
user with different combinations of cases and\r\nedit case settings
privileges\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"8e8ba53116c16cc9b9122de27415cf8519cc1863"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202053","number":202053,"mergeCommit":{"message":"[ResponseOps][Cases]
Fix edit cases settings privilege (#202053)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/197650\r\n\r\nAlso fixes an
issue where user has `cases: all ` and `edit case\r\nsettings: false`,
user was able to edit settings.\r\n\r\nUsed `permissions.settings`
instead of `permissions.update` and\r\n`permissions.create` for custom
fields and templates.\r\n\r\n### How to test\r\n- Verify by creating a
user with different combinations of cases and\r\nedit case settings
privileges\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"8e8ba53116c16cc9b9122de27415cf8519cc1863"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Janki Salvi <[email protected]>
js-jankisalvi added a commit that referenced this pull request Dec 5, 2024
… (#202987)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[ResponseOps][Cases] Fix edit cases settings privilege
(#202053)](#202053)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Janki
Salvi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T15:55:08Z","message":"[ResponseOps][Cases]
Fix edit cases settings privilege (#202053)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/197650\r\n\r\nAlso fixes an
issue where user has `cases: all ` and `edit case\r\nsettings: false`,
user was able to edit settings.\r\n\r\nUsed `permissions.settings`
instead of `permissions.update` and\r\n`permissions.create` for custom
fields and templates.\r\n\r\n### How to test\r\n- Verify by creating a
user with different combinations of cases and\r\nedit case settings
privileges\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"8e8ba53116c16cc9b9122de27415cf8519cc1863","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","v9.0.0","Feature:Cases","backport:prev-minor","v8.17.0","v8.18.0","v8.16.2"],"number":202053,"url":"https://github.com/elastic/kibana/pull/202053","mergeCommit":{"message":"[ResponseOps][Cases]
Fix edit cases settings privilege (#202053)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/197650\r\n\r\nAlso fixes an
issue where user has `cases: all ` and `edit case\r\nsettings: false`,
user was able to edit settings.\r\n\r\nUsed `permissions.settings`
instead of `permissions.update` and\r\n`permissions.create` for custom
fields and templates.\r\n\r\n### How to test\r\n- Verify by creating a
user with different combinations of cases and\r\nedit case settings
privileges\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"8e8ba53116c16cc9b9122de27415cf8519cc1863"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202053","number":202053,"mergeCommit":{"message":"[ResponseOps][Cases]
Fix edit cases settings privilege (#202053)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/197650\r\n\r\nAlso fixes an
issue where user has `cases: all ` and `edit case\r\nsettings: false`,
user was able to edit settings.\r\n\r\nUsed `permissions.settings`
instead of `permissions.update` and\r\n`permissions.create` for custom
fields and templates.\r\n\r\n### How to test\r\n- Verify by creating a
user with different combinations of cases and\r\nedit case settings
privileges\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"8e8ba53116c16cc9b9122de27415cf8519cc1863"}},{"branch":"8.17","label":"v8.17.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/202970","number":202970,"state":"OPEN"},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/202971","number":202971,"state":"OPEN"},{"branch":"8.16","label":"v8.16.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Dec 9, 2024
## Summary

Fixes elastic#197650

Also fixes an issue where user has `cases: all ` and `edit case
settings: false`, user was able to edit settings.

Used `permissions.settings` instead of `permissions.update` and
`permissions.create` for custom fields and templates.

### How to test
- Verify by creating a user with different combinations of cases and
edit case settings privileges

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Dec 9, 2024
## Summary

Fixes elastic#197650

Also fixes an issue where user has `cases: all ` and `edit case
settings: false`, user was able to edit settings.

Used `permissions.settings` instead of `permissions.update` and
`permissions.create` for custom fields and templates.

### How to test
- Verify by creating a user with different combinations of cases and
edit case settings privileges

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 9, 2024
## Summary

Fixes elastic#197650

Also fixes an issue where user has `cases: all ` and `edit case
settings: false`, user was able to edit settings.

Used `permissions.settings` instead of `permissions.update` and
`permissions.create` for custom fields and templates.

### How to test
- Verify by creating a user with different combinations of cases and
edit case settings privileges

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
Samiul-TheSoccerFan pushed a commit to Samiul-TheSoccerFan/kibana that referenced this pull request Dec 10, 2024
## Summary

Fixes elastic#197650

Also fixes an issue where user has `cases: all ` and `edit case
settings: false`, user was able to edit settings.

Used `permissions.settings` instead of `permissions.update` and
`permissions.create` for custom fields and templates.

### How to test
- Verify by creating a user with different combinations of cases and
edit case settings privileges

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
## Summary

Fixes elastic#197650

Also fixes an issue where user has `cases: all ` and `edit case
settings: false`, user was able to edit settings.

Used `permissions.settings` instead of `permissions.update` and
`permissions.create` for custom fields and templates.

### How to test
- Verify by creating a user with different combinations of cases and
edit case settings privileges

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) bug Fixes for quality problems that affect the customer experience Feature:Cases Cases feature release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.16.2 v8.17.0 v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User with Edit case settings cannot edit case settings
6 participants