Skip to content

feat(slo): Assert user has correct source index privileges when creating, updating or reseting an SLO#199233

Merged
kdelemme merged 8 commits intoelastic:mainfrom
kdelemme:slo/check-source-index-privileges
Nov 12, 2024
Merged

feat(slo): Assert user has correct source index privileges when creating, updating or reseting an SLO#199233
kdelemme merged 8 commits intoelastic:mainfrom
kdelemme:slo/check-source-index-privileges

Conversation

@kdelemme
Copy link
Copy Markdown
Contributor

@kdelemme kdelemme commented Nov 6, 2024

Resolves #195254

🚗 Summary

Since we use the secondary auth to create and start the transform, a user without the read index privileges is able to create an SLO. But the SLO will never be able to work correctly: the related rollup transform will be failing due to missing privileges.

This PR asserts the user has the correct [read, view_index_metadata] index privileges on the SLO indicator index, i.e. the source index when creating, editing or reseting an SLO.

Testing

  • Create a user with a role that has no read privilege on the index you want to create an SLO with.
  • Create an SLO using the API (replace the authorization header with the new user credentials)
curl --request POST \
  --url http://localhost:5601/kibana/api/observability/slos \
  --header 'Authorization: Basic c2xvX21pc3Npbmc6Y2hhbmdlbWU=' \
  --header 'Content-Type: application/json' \
  --header 'kbn-xsrf: oui' \
  --data '{
  "name": "test",
  "description": "",
  "indicator": {
    "type": "sli.kql.custom",
    "params": {
      "index": "kbn-data-forge-fake_stack.admin-console-*",
      "filter": "",
      "good": "http.response.status_code <500",
      "total": "http.response.status_code :*",
      "timestampField": "@timestamp",
      "dataViewId": "e7744dbe-a7a4-457b-83aa-539e9c88764c"
    }
  },
  "budgetingMethod": "occurrences",
  "timeWindow": {
    "duration": "7d",
    "type": "rolling"
  },
  "objective": {
    "target": 0.98
  },
  "tags": [],
  "groupBy": [
    "*"
  ],
  "settings": {
    "preventInitialBackfill": false
  }
}'

This request should return a 403:

{
	"statusCode": 403,
	"error": "Forbidden",
	"message": "Missing ['read', 'view_index_metadata'] privileges on the source index [kbn-data-forge-fake_stack.admin-console-*]"
}

@kdelemme kdelemme marked this pull request as ready for review November 6, 2024 21:33
@kdelemme kdelemme requested a review from a team as a code owner November 6, 2024 21:33
@kdelemme kdelemme added release_note:skip Skip the PR/issue when compiling release notes v9.0.0 v8.17.0 backport:prev-minor Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. and removed v9.0.0 labels Nov 6, 2024
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label Nov 7, 2024
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 7, 2024

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Comment on lines +49 to +50
await this.assertSLOInexistant(slo);
await assertExpectedIndicatorSourceIndexPrivileges(slo, this.esClient);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could be done in parallel.

Copy link
Copy Markdown
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

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

LGTM !!

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Nov 12, 2024

💚 Build Succeeded

  • Buildkite Build
  • Commit: ee0dd91
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-199233-ee0dd91bc1ce

Metrics [docs]

✅ unchanged

History

@kdelemme kdelemme merged commit da85efe into elastic:main Nov 12, 2024
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.x

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

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.x

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

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 14, 2024
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Nov 18, 2024
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Nov 18, 2024
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

1 similar comment
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

kibanamachine added a commit that referenced this pull request Nov 20, 2024
… creating, updating or reseting an SLO (#199233) (#199875)

# Backport

This will backport the following commits from `main` to `8.x`:
- [feat(slo): Assert user has correct source index privileges when
creating, updating or reseting an SLO
(#199233)](#199233)

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

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

<!--BACKPORT [{"author":{"name":"Kevin
Delemme","email":"kevin.delemme@elastic.co"},"sourceCommit":{"committedDate":"2024-11-12T20:08:40Z","message":"feat(slo):
Assert user has correct source index privileges when creating, updating
or reseting an SLO
(#199233)","sha":"da85efe5093c148d4b91bcd3e21fd93c9f182a4f","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-management","v8.17.0"],"title":"feat(slo):
Assert user has correct source index privileges when creating, updating
or reseting an
SLO","number":199233,"url":"https://github.com/elastic/kibana/pull/199233","mergeCommit":{"message":"feat(slo):
Assert user has correct source index privileges when creating, updating
or reseting an SLO
(#199233)","sha":"da85efe5093c148d4b91bcd3e21fd93c9f182a4f"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199233","number":199233,"mergeCommit":{"message":"feat(slo):
Assert user has correct source index privileges when creating, updating
or reseting an SLO
(#199233)","sha":"da85efe5093c148d4b91bcd3e21fd93c9f182a4f"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Kevin Delemme <kevin.delemme@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. v8.17.0 v9.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SLO] Check user has necessary permissions on the source index when creating, editing and reseting an SLO

5 participants