-
Notifications
You must be signed in to change notification settings - Fork 429
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: prevent unauthorised remove-users access #3791
fix: prevent unauthorised remove-users access #3791
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Uffizzi Preview |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3791 +/- ##
=======================================
Coverage 95.91% 95.92%
=======================================
Files 1102 1103 +1
Lines 34789 34822 +33
=======================================
+ Hits 33369 33403 +34
+ Misses 1420 1419 -1 ☔ View full report in Codecov by Sentry. |
|
||
organisation_id = view.kwargs.get("pk") | ||
if organisation_id and not organisation_id.isnumeric(): | ||
raise APIException("Invalid organisation ID") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes the 500 status code. Why not use ValidationError
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops yep good catch, I wanted 400.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -1797,3 +1797,49 @@ def test_doesnt_retrieve_stale_api_usage_notifications( | |||
# Then | |||
assert response.status_code == status.HTTP_200_OK | |||
assert len(response.data["results"]) == 0 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test for non-numeric org id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Thanks for submitting a PR! Please check the boxes below:
pre-commit
to check lintingdocs/
if required so people know about the feature!Changes
Prevents unauthorised users from removing users from a given organisation.
How did you test this code?
Added unit tests.