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 Solutions] Fixes the permissions to require cluster.manage for upgrades of solutions #89947

Merged
merged 2 commits into from
Feb 2, 2021

Conversation

FrankHassanabad
Copy link
Contributor

@FrankHassanabad FrankHassanabad commented Feb 1, 2021

Summary

Fixes error toaster on signals upgrades as well as creation of new signals if you have a user without a cluster manage privilege.

Simplest way to manually test both situations of a user on creating a new signal as well as upgrade is to first create a new role like so in dev tools:

PUT _security/role/reduced_permissions
{
   "indices":[
      {
         "names":[
            ".siem-signals-*",
            ".lists-*",
            ".items-*"
         ],
         "privileges":[
            "all"
         ],
         "field_security":{
            "grant":[
               "*"
            ]
         },
         "allow_restricted_indices":false
      }
   ],
   "applications":[
      {
         "application":"kibana-.kibana",
         "privileges":[
            "space_all"
         ],
         "resources":[
            "space:default"
         ]
      }
   ]
}

You might have to change this line above to match what your kibana.index is set to if it is set:

 "application" : "kibana-.kibana-hassanabad8",

Double check things in Stack Management to ensure you have access to at least default space:
Screen Shot 2021-02-01 at 5 45 54 PM

Next add a user which has this role of reduced_permissions to login as that user. Next for testing that this causes an error toaster when there is no signals index is to either manually delete your signals index or change your kibana.dev.yml so that it thinks you have a new index:

xpack.securitySolution.signalsIndex: .siem-signals-some-new-index-name

Start up Kibana, login with the new user and visit any page and notice you get an error toaster like below:
Screen Shot 2021-02-01 at 5 04 17 PM

And also notice that you are blocked from viewing signals at this point:
Screen Shot 2021-02-01 at 5 04 43 PM

For upgrading signals manually, you can change the version number from dev tools or increment the number directly within this file and restart Kibana:
https://github.com/elastic/kibana/blob/master/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.ts#L10

When you visit the detection page you will see the same error toaster and also be blocked. With this PR you will no longer be blocked.

Checklist

Delete any items that are not applicable to this PR.

@FrankHassanabad FrankHassanabad self-assigned this Feb 1, 2021
@FrankHassanabad FrankHassanabad marked this pull request as ready for review February 1, 2021 23:45
@FrankHassanabad FrankHassanabad requested review from a team as code owners February 1, 2021 23:45
@FrankHassanabad FrankHassanabad added v8.0.0 v7.12.0 v7.13.0 v7.14.0 Feature:Detection Alerts Security Solution Detection Alerts Feature release_note:skip Skip the PR/issue when compiling release notes labels Feb 1, 2021
@FrankHassanabad FrankHassanabad changed the title Fixes the permissions to require cluster.manage in order to create an… [Security Solutions] Fixes the permissions to require cluster.manage for upgrades of solutions Feb 1, 2021
Copy link
Member

@spong spong left a comment

Choose a reason for hiding this comment

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

LGTM! Code check now matches permissions outlined in docs. If you have a chance to add a test that would be greatly appreciated! @dhurley14 has made some helpers (#81866) so should be pretty straight forward. Thanks @FrankHassanabad! 💎 🙌 🚀

@FrankHassanabad
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
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
securitySolution 7.5MB 7.5MB +26.0B

History

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

@FrankHassanabad FrankHassanabad merged commit 2e5341d into elastic:master Feb 2, 2021
@FrankHassanabad FrankHassanabad deleted the fix-admin-viewing branch February 2, 2021 04:36
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Feb 2, 2021
… index and in order to update an index (elastic#89947)

## Summary

Fixes error toaster on signals upgrades as well as creation of new signals if you have a user without a cluster manage privilege.

Simplest way to manually test both situations of a user on creating a new signal as well as upgrade is to first create a new role like so in dev tools:

```ts
PUT _security/role/reduced_permissions
{
   "indices":[
      {
         "names":[
            ".siem-signals-*",
            ".lists-*",
            ".items-*"
         ],
         "privileges":[
            "all"
         ],
         "field_security":{
            "grant":[
               "*"
            ]
         },
         "allow_restricted_indices":false
      }
   ],
   "applications":[
      {
         "application":"kibana-.kibana",
         "privileges":[
            "space_all"
         ],
         "resources":[
            "space:default"
         ]
      }
   ]
}
```

You might have to change this line above to match what your `kibana.index` is set to if it is set:
```ts
 "application" : "kibana-.kibana-hassanabad8",
```

Double check things in Stack Management to ensure you have access to at least default space:
<img width="1304" alt="Screen Shot 2021-02-01 at 5 45 54 PM" src="https://user-images.githubusercontent.com/1151048/106536383-906f3f00-64b5-11eb-97d3-060fa6f6206e.png">

Next add a user which has this role of `reduced_permissions` to login as that user. Next for testing that this causes an error toaster when there is no signals index is to either manually delete your signals index or change your `kibana.dev.yml` so that it thinks you have a new index:

```ts
xpack.securitySolution.signalsIndex: .siem-signals-some-new-index-name
```

Start up Kibana, login with the new user and visit any page and notice you get an error toaster like below:
<img width="808" alt="Screen Shot 2021-02-01 at 5 04 17 PM" src="https://user-images.githubusercontent.com/1151048/106535815-4afe4200-64b4-11eb-89b3-947b0e4ff7d5.png">

And also notice that you are blocked from viewing signals at this point:
<img width="1195" alt="Screen Shot 2021-02-01 at 5 04 43 PM" src="https://user-images.githubusercontent.com/1151048/106535835-56516d80-64b4-11eb-883c-2745b68843cf.png">

For upgrading signals manually, you can change the version number from dev tools or increment the number directly within this file and restart Kibana:
https://github.com/elastic/kibana/blob/master/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.ts#L10

When you visit the detection page you will see the same error toaster and also be blocked. With this PR you will no longer be blocked.

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [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
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Feb 2, 2021
… index and in order to update an index (elastic#89947)

## Summary

Fixes error toaster on signals upgrades as well as creation of new signals if you have a user without a cluster manage privilege.

Simplest way to manually test both situations of a user on creating a new signal as well as upgrade is to first create a new role like so in dev tools:

```ts
PUT _security/role/reduced_permissions
{
   "indices":[
      {
         "names":[
            ".siem-signals-*",
            ".lists-*",
            ".items-*"
         ],
         "privileges":[
            "all"
         ],
         "field_security":{
            "grant":[
               "*"
            ]
         },
         "allow_restricted_indices":false
      }
   ],
   "applications":[
      {
         "application":"kibana-.kibana",
         "privileges":[
            "space_all"
         ],
         "resources":[
            "space:default"
         ]
      }
   ]
}
```

You might have to change this line above to match what your `kibana.index` is set to if it is set:
```ts
 "application" : "kibana-.kibana-hassanabad8",
```

Double check things in Stack Management to ensure you have access to at least default space:
<img width="1304" alt="Screen Shot 2021-02-01 at 5 45 54 PM" src="https://user-images.githubusercontent.com/1151048/106536383-906f3f00-64b5-11eb-97d3-060fa6f6206e.png">

Next add a user which has this role of `reduced_permissions` to login as that user. Next for testing that this causes an error toaster when there is no signals index is to either manually delete your signals index or change your `kibana.dev.yml` so that it thinks you have a new index:

```ts
xpack.securitySolution.signalsIndex: .siem-signals-some-new-index-name
```

Start up Kibana, login with the new user and visit any page and notice you get an error toaster like below:
<img width="808" alt="Screen Shot 2021-02-01 at 5 04 17 PM" src="https://user-images.githubusercontent.com/1151048/106535815-4afe4200-64b4-11eb-89b3-947b0e4ff7d5.png">

And also notice that you are blocked from viewing signals at this point:
<img width="1195" alt="Screen Shot 2021-02-01 at 5 04 43 PM" src="https://user-images.githubusercontent.com/1151048/106535835-56516d80-64b4-11eb-883c-2745b68843cf.png">

For upgrading signals manually, you can change the version number from dev tools or increment the number directly within this file and restart Kibana:
https://github.com/elastic/kibana/blob/master/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.ts#L10

When you visit the detection page you will see the same error toaster and also be blocked. With this PR you will no longer be blocked.

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [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
FrankHassanabad added a commit that referenced this pull request Feb 2, 2021
… index and in order to update an index (#89947) (#89968)

## Summary

Fixes error toaster on signals upgrades as well as creation of new signals if you have a user without a cluster manage privilege.

Simplest way to manually test both situations of a user on creating a new signal as well as upgrade is to first create a new role like so in dev tools:

```ts
PUT _security/role/reduced_permissions
{
   "indices":[
      {
         "names":[
            ".siem-signals-*",
            ".lists-*",
            ".items-*"
         ],
         "privileges":[
            "all"
         ],
         "field_security":{
            "grant":[
               "*"
            ]
         },
         "allow_restricted_indices":false
      }
   ],
   "applications":[
      {
         "application":"kibana-.kibana",
         "privileges":[
            "space_all"
         ],
         "resources":[
            "space:default"
         ]
      }
   ]
}
```

You might have to change this line above to match what your `kibana.index` is set to if it is set:
```ts
 "application" : "kibana-.kibana-hassanabad8",
```

Double check things in Stack Management to ensure you have access to at least default space:
<img width="1304" alt="Screen Shot 2021-02-01 at 5 45 54 PM" src="https://user-images.githubusercontent.com/1151048/106536383-906f3f00-64b5-11eb-97d3-060fa6f6206e.png">

Next add a user which has this role of `reduced_permissions` to login as that user. Next for testing that this causes an error toaster when there is no signals index is to either manually delete your signals index or change your `kibana.dev.yml` so that it thinks you have a new index:

```ts
xpack.securitySolution.signalsIndex: .siem-signals-some-new-index-name
```

Start up Kibana, login with the new user and visit any page and notice you get an error toaster like below:
<img width="808" alt="Screen Shot 2021-02-01 at 5 04 17 PM" src="https://user-images.githubusercontent.com/1151048/106535815-4afe4200-64b4-11eb-89b3-947b0e4ff7d5.png">

And also notice that you are blocked from viewing signals at this point:
<img width="1195" alt="Screen Shot 2021-02-01 at 5 04 43 PM" src="https://user-images.githubusercontent.com/1151048/106535835-56516d80-64b4-11eb-883c-2745b68843cf.png">

For upgrading signals manually, you can change the version number from dev tools or increment the number directly within this file and restart Kibana:
https://github.com/elastic/kibana/blob/master/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.ts#L10

When you visit the detection page you will see the same error toaster and also be blocked. With this PR you will no longer be blocked.

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [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
FrankHassanabad added a commit that referenced this pull request Feb 2, 2021
… index and in order to update an index (#89947) (#89967)

## Summary

Fixes error toaster on signals upgrades as well as creation of new signals if you have a user without a cluster manage privilege.

Simplest way to manually test both situations of a user on creating a new signal as well as upgrade is to first create a new role like so in dev tools:

```ts
PUT _security/role/reduced_permissions
{
   "indices":[
      {
         "names":[
            ".siem-signals-*",
            ".lists-*",
            ".items-*"
         ],
         "privileges":[
            "all"
         ],
         "field_security":{
            "grant":[
               "*"
            ]
         },
         "allow_restricted_indices":false
      }
   ],
   "applications":[
      {
         "application":"kibana-.kibana",
         "privileges":[
            "space_all"
         ],
         "resources":[
            "space:default"
         ]
      }
   ]
}
```

You might have to change this line above to match what your `kibana.index` is set to if it is set:
```ts
 "application" : "kibana-.kibana-hassanabad8",
```

Double check things in Stack Management to ensure you have access to at least default space:
<img width="1304" alt="Screen Shot 2021-02-01 at 5 45 54 PM" src="https://user-images.githubusercontent.com/1151048/106536383-906f3f00-64b5-11eb-97d3-060fa6f6206e.png">

Next add a user which has this role of `reduced_permissions` to login as that user. Next for testing that this causes an error toaster when there is no signals index is to either manually delete your signals index or change your `kibana.dev.yml` so that it thinks you have a new index:

```ts
xpack.securitySolution.signalsIndex: .siem-signals-some-new-index-name
```

Start up Kibana, login with the new user and visit any page and notice you get an error toaster like below:
<img width="808" alt="Screen Shot 2021-02-01 at 5 04 17 PM" src="https://user-images.githubusercontent.com/1151048/106535815-4afe4200-64b4-11eb-89b3-947b0e4ff7d5.png">

And also notice that you are blocked from viewing signals at this point:
<img width="1195" alt="Screen Shot 2021-02-01 at 5 04 43 PM" src="https://user-images.githubusercontent.com/1151048/106535835-56516d80-64b4-11eb-883c-2745b68843cf.png">

For upgrading signals manually, you can change the version number from dev tools or increment the number directly within this file and restart Kibana:
https://github.com/elastic/kibana/blob/master/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.ts#L10

When you visit the detection page you will see the same error toaster and also be blocked. With this PR you will no longer be blocked.

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [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
gmmorris added a commit to lizozom/kibana that referenced this pull request Feb 2, 2021
…om/kibana into pr/89570

* 'sessions/save-all-sessions' of https://github.com/lizozom/kibana: (44 commits)
  [ML] Functional tests - skip DFA clone tests
  [Uptime] Fix synthetics detail step count (elastic#89940)
  Fixes the permissions to require cluster.manage in order to create an index and in order to update an index (elastic#89947)
  [Security Solution] [Detections] adds log info level for logging in cloud (elastic#89941)
  [Time to Visualize] Dashboard By Value Testing Lens (elastic#89581)
  [Uptime] Expand synthetic journey step thumbnail on hover (elastic#89179)
  TS project refs: Migrates snapshot_restore to a TS Project (elastic#89653)
  docs: APM 7.11 updates (elastic#89789)
  move skip to higher level (elastic#86952)
  Revert "Migrations v2: don't auto-create indices + FTR/esArchiver support (elastic#85778)"
  Revert "Revert "Enable v2 so migrations, disable in FTR tests (elastic#89297)""
  Revert "Enable v2 so migrations, disable in FTR tests (elastic#89297)"
  [data.search] Allow search response to follow new hits format (elastic#88115)
  [Maps] Change 'create multi-layer map' title to be use-case focused (elastic#89520)
  skip flaky suite (elastic#86952)
  [Security Solution] Remove focustrap (elastic#89905)
  [Workplace Search] Add remaining i18n support for the Content Sources tree (elastic#89910)
  [esArchiver] log when migrations complete and we're done loading data (elastic#89938)
  Add --ssl flag to make resolver generator use ssl with kbn and elasticsearch clients (elastic#89873)
  TS project refs: Migrates grokdebugger (elastic#89652)
  ...
FrankHassanabad added a commit that referenced this pull request Feb 2, 2021
…89947  (#89973)

## Summary

Adds e2e and unit tests for PR:
#89947

* Adds e2e tests for create_index
* Adds e2e tests for get_privileges
* Adds unit test for use_privilege_user
* Adds exhaustive switch for the roles in the e2e tests
* Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports 
* Fixes some of the types that were not matched up with the recent privilege endpoint

### 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
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Feb 2, 2021
…lastic#89947  (elastic#89973)

## Summary

Adds e2e and unit tests for PR:
elastic#89947

* Adds e2e tests for create_index
* Adds e2e tests for get_privileges
* Adds unit test for use_privilege_user
* Adds exhaustive switch for the roles in the e2e tests
* Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports 
* Fixes some of the types that were not matched up with the recent privilege endpoint

### 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
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Feb 2, 2021
…lastic#89947  (elastic#89973)

## Summary

Adds e2e and unit tests for PR:
elastic#89947

* Adds e2e tests for create_index
* Adds e2e tests for get_privileges
* Adds unit test for use_privilege_user
* Adds exhaustive switch for the roles in the e2e tests
* Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports 
* Fixes some of the types that were not matched up with the recent privilege endpoint

### 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
FrankHassanabad added a commit that referenced this pull request Feb 3, 2021
…for PR #89947  (#89973) (#90091)

* [Security Solutions][Detection Engine] Adds e2e and unit tests for PR #89947  (#89973)

## Summary

Adds e2e and unit tests for PR:
#89947

* Adds e2e tests for create_index
* Adds e2e tests for get_privileges
* Adds unit test for use_privilege_user
* Adds exhaustive switch for the roles in the e2e tests
* Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports 
* Fixes some of the types that were not matched up with the recent privilege endpoint

### 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

* Fixes the backport for test to work correctly as the messages are different

* Fixes one permission change issue between versions
FrankHassanabad added a commit that referenced this pull request Feb 3, 2021
… for PR #89947  (#89973) (#90092)

* [Security Solutions][Detection Engine] Adds e2e and unit tests for PR #89947  (#89973)

## Summary

Adds e2e and unit tests for PR:
#89947

* Adds e2e tests for create_index
* Adds e2e tests for get_privileges
* Adds unit test for use_privilege_user
* Adds exhaustive switch for the roles in the e2e tests
* Adds some typescript barrel rolls for the .json scripts to make TypeScript a bit more readable when doing imports 
* Fixes some of the types that were not matched up with the recent privilege endpoint

### 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

* Updated to work with the right messages

* Fixes permissions that are slightly different
@FrankHassanabad FrankHassanabad added release_note:fix and removed v7.14.0 release_note:skip Skip the PR/issue when compiling release notes v7.11.0 labels Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants