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

Make alerting properly space aware #42081

Merged
merged 15 commits into from
Aug 2, 2019

Conversation

mikecote
Copy link
Contributor

Extracted from #41389. This PR makes alerting properly space aware by capturing spaceId and passing it along anywhere that is needed.

@mikecote mikecote self-assigned this Jul 26, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-stack-services

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@mikecote
Copy link
Contributor Author

Pending on #42133.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

Copy link
Member

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

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

looking good to me so far, made a few comments

@elasticmachine
Copy link
Contributor

💔 Build Failed

@mikecote mikecote marked this pull request as ready for review July 31, 2019 13:50
@mikecote mikecote requested a review from a team July 31, 2019 13:50
@mikecote mikecote requested a review from legrego July 31, 2019 14:07
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

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

Code LGTM, just some minor comments.

x-pack/legacy/plugins/actions/server/init.ts Outdated Show resolved Hide resolved
x-pack/legacy/plugins/actions/server/init.ts Outdated Show resolved Hide resolved
@@ -75,6 +81,9 @@ export function init(server: Legacy.Server) {
const fireFn = createFireFunction({
Copy link
Member

Choose a reason for hiding this comment

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

fireFn, which we expose via server.expose, allows consumers to specify their own space id. Do we know of any scenarios where consumers will need this capability? If not, we could potentially create a "scoped" fire function, where the space id is derived from the current request, or similar.

If we do need to allow consumers to specify their own space id, then you'll likely want to update this so that it can handle spaces being disabled, and handle cases where a space id is required, but missing. Currently, spaceIdToNamespace will throw an error if a space id is not provided.

Also, the underlying fireFn uses callWithInternalUser in an unguarded fashion, so there isn't any authorization being applied there. This would be less of a concern if it wasn't exposed to consumers, but since this is a consumer-facing function, we should have protections in place there. (perhaps out of scope for this PR?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I can tell, consumers will need to specify their own space id. The example I can think of is task manager wants to fire action a in space b and uses this function to indicate that. We should be ok when spaces is disabled due to spaceIdToNamespace being passed as https://github.com/elastic/kibana/pull/42081/files#diff-c2af122155b3536ee79e8b5384fdaa6eR94.

In regards to callWithInternalUser being unguarded, we'll have this fixed when API keys are implemented. We will do the callWithInternalUser first, setup a connection with the keys and re-load the same object via the saved objects client.

@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mikecote
Copy link
Contributor Author

mikecote commented Aug 2, 2019

retest

Copy link
Member

@legrego legrego left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for the changes, Mike!

@mikecote
Copy link
Contributor Author

mikecote commented Aug 2, 2019

As discussed with @kobelb, it would be great to have high-level tests to ensure denied access to spaces when users don't have access. But since this requires API keys to work, we will defer the tests for the PR implementing API keys. Right now alerting doesn't support security enabled in kibana and is pending API keys to support it.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mikecote mikecote merged commit b94e94e into elastic:master Aug 2, 2019
mikecote added a commit to mikecote/kibana that referenced this pull request Aug 2, 2019
* Make alerting properly space aware

* Fix broken jest tests

* Fix broken integration test

* Cleanup pt1

* Add spaces integration tests

* Fix type check failure

* Apply PR feedback pt1

* Use TS types from spaces plugin

* Fix broken tests

* Apply PR feedback pt1

* Fix getBasePath to return server.basePath when spaces is disabled

* Apply new API changes to tests
mikecote added a commit that referenced this pull request Aug 2, 2019
* Make alerting properly space aware

* Fix broken jest tests

* Fix broken integration test

* Cleanup pt1

* Add spaces integration tests

* Fix type check failure

* Apply PR feedback pt1

* Use TS types from spaces plugin

* Fix broken tests

* Apply PR feedback pt1

* Fix getBasePath to return server.basePath when spaces is disabled

* Apply new API changes to tests
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 5, 2019
…-or-edit-existing-rollup-job

* 'master' of github.com:elastic/kibana: (67 commits)
  [TSVB] Shim new platform (elastic#39169)
  [Metric Vis] Shim new platform (elastic#42240)
  [Tag Cloud] Shim new platform (elastic#42348)
  Disable flaky request lib tests. Add es_ui_shared plugin to CODEOWNERS.
  Add disk space percentage to node listing (elastic#42145)
  [SIEM] Add chart interactions - update date picker after brush selection on charts (elastic#42440)
  Document HTTP service (elastic#42331)
  [Reporting] Sanitize 409 error log message (elastic#42495)
  [docs][skip ci] Maps read only access (elastic#35561)
  [x-pack/ftr] refactor types to be more accurate/consistent wit… (elastic#42407)
  [DOCS] Updates images and content in Dashboard docs (elastic#42500)
  Allow sorting on multiple columns in Discover (elastic#41918)
  [Infra UI][Logs UI] Fix autocomplete to use proper derived index pattern (elastic#42287)
  [ftr/cheerio] improve cheerio types to include test subject me… (elastic#42534)
  Upgraded EUI 13.0.0 -> 13.1.1 (elastic#42298)
  Increase max-old-space-size for builds (elastic#42218)
  [Infra UI] Add cloud metrics and cloud/host info to metadata endpoint (elastic#41836)
  [Logs UI][a11y] Announce name of column on remove column button (elastic#41695)
  Inspector 👉 New Platform (elastic#42164)
  Make alerting properly space aware (elastic#42081)
  ...
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 5, 2019
…s_autocomplete

* 'master' of github.com:elastic/kibana: (189 commits)
  [TSVB] Shim new platform (elastic#39169)
  [Metric Vis] Shim new platform (elastic#42240)
  [Tag Cloud] Shim new platform (elastic#42348)
  Disable flaky request lib tests. Add es_ui_shared plugin to CODEOWNERS.
  Add disk space percentage to node listing (elastic#42145)
  [SIEM] Add chart interactions - update date picker after brush selection on charts (elastic#42440)
  Document HTTP service (elastic#42331)
  [Reporting] Sanitize 409 error log message (elastic#42495)
  [docs][skip ci] Maps read only access (elastic#35561)
  [x-pack/ftr] refactor types to be more accurate/consistent wit… (elastic#42407)
  [DOCS] Updates images and content in Dashboard docs (elastic#42500)
  Allow sorting on multiple columns in Discover (elastic#41918)
  [Infra UI][Logs UI] Fix autocomplete to use proper derived index pattern (elastic#42287)
  [ftr/cheerio] improve cheerio types to include test subject me… (elastic#42534)
  Upgraded EUI 13.0.0 -> 13.1.1 (elastic#42298)
  Increase max-old-space-size for builds (elastic#42218)
  [Infra UI] Add cloud metrics and cloud/host info to metadata endpoint (elastic#41836)
  [Logs UI][a11y] Announce name of column on remove column button (elastic#41695)
  Inspector 👉 New Platform (elastic#42164)
  Make alerting properly space aware (elastic#42081)
  ...
@cachedout
Copy link
Contributor

Hi @mikecote I see that there were updates to the README for Actions in this PR and those make perfect sense but it's a little unclear to me after reading this whether there are also changes to the security model for the Alerting plugin.

Could you help me understand if that plugin is also Spaces-aware and if so, whether there are changes needed for a user of the Alerting plugin?

@mikecote
Copy link
Contributor Author

Hi @cachedout,

tl;dr: no changes required.

Yes both plugins alerting and actions are space aware end to end with this PR. There isn't any changes required from your end. It's a bit hidden to the consumer just like regular saved objects in the system.

One thing you may notice between alerts and actions is we currently don't validate the actions array when creating / editing an alert. There's a task to implement that once security enabled is supported (#41389). That PR will also change the savedObjectsClient & callCluster provided to the executors to be scoped to the user who created the alert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Alerting release_note:skip Skip the PR/issue when compiling release notes review v7.4.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants