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

fix(deploys): Fix permissions for deploy endpoint projects #78026

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

szokeasaurusrex
Copy link
Member

Currently, in order to link specific projects to a deploy, e.g. via the sentry-cli deploys new command, users must provide a token with the project:read scope. This is inconsistent with the sentry-cli releases new command, which allows users to create a new release associated with only some projects by using the org:read and project:release scopes.

This PR proposes allowing specifying projects for a deploy using a token with project:releases scope.

Fixes #78025

@szokeasaurusrex szokeasaurusrex requested a review from a team September 24, 2024 15:52
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 24, 2024
@oioki
Copy link
Member

oioki commented Sep 25, 2024

Will this break a corresponding endpoint calls for tokens that have project:read scope?

@szokeasaurusrex
Copy link
Member Author

szokeasaurusrex commented Sep 25, 2024

@oioki, a token that only has project:read (and org:read) will not be able to access the endpoint at all, but a token with project:write can and such a token will break with this change.

I think it would be possible to make this change in a way which would be backwards compatible. Should I do that?

Currently, in order to link specific projects to a deploy, e.g. via the `sentry-cli deploys new` command, users must provide a token with the `project:read` scope. This is inconsistent with the `sentry-cli releases new` command, which allows users to create a new release associated with only some projects by using the `org:read` and `project:release` scopes.

This PR proposes allowing specifying projects for a deploy using a token with `project:releases` scope.

Fixes #78025
Changing the scope to `project:releases` breaks this endpoint for tokens that could previously specify specific projects for the deploy via this endpoint via `project:read` (in practice, `project:write` was also required, since the endpoint cannot be accessed only with `project:read`).
@szokeasaurusrex
Copy link
Member Author

@oioki, I changed the code so it should now remain backwards-compatible with tokens that have project:read but not project:releases

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...c/sentry/api/serializers/rest_framework/project.py 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #78026      +/-   ##
==========================================
- Coverage   78.40%   78.29%   -0.12%     
==========================================
  Files        7154     7077      -77     
  Lines      316431   314216    -2215     
  Branches    43612    43300     -312     
==========================================
- Hits       248112   246002    -2110     
+ Misses      61982    56530    -5452     
- Partials     6337    11684    +5347     

@szokeasaurusrex
Copy link
Member Author

@getsentry/security Can I get a review here?

@oioki
Copy link
Member

oioki commented Oct 16, 2024

Mind creating a test that covers this case?

@szokeasaurusrex
Copy link
Member Author

Mind creating a test that covers this case?

I am not really sure how to test this @oioki. I have already spent more than an hour trying to figure it out without making much progress, so it is probably more productive if someone more familiar with this code adds the test

@iamrajjoshi or @snigdhas, would either of you know how to test this change? Looks like you all edited the code most recently. If you need time to investigate, we can merge this change and open an issue to add tests.

@snigdhas
Copy link
Member

@szokeasaurusrex this test looks like it might mimic similar behavior of setting a specific scope and using the API token to test behavior

@getsantry getsantry bot added the Stale label Nov 21, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Nov 21, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot removed the Stale label Nov 22, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Dec 14, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added Stale and removed Stale labels Dec 14, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Jan 6, 2025

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added Stale and removed Stale labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sentry-cli releases 2.36.2 breaks with existing auth token
3 participants