-
Notifications
You must be signed in to change notification settings - Fork 293
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: risk acceptance permission overrides #1417
fix: risk acceptance permission overrides #1417
Conversation
WalkthroughThe pull request introduces enhanced permission handling in the risk acceptance workflow. The changes modify the Changes
Sequence DiagramsequenceDiagram
participant User
participant RiskAcceptanceViewSet
participant RBACPermissions
User->>RiskAcceptanceViewSet: Attempt action (accept/reject/revoke)
RiskAcceptanceViewSet->>RBACPermissions: Check permissions
RBACPermissions-->>RiskAcceptanceViewSet: Verify action-specific permission
alt Permission Granted
RiskAcceptanceViewSet->>User: Allow action
else Permission Denied
RiskAcceptanceViewSet->>User: Raise PermissionDenied
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (10)
🔇 Additional comments (4)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
backend/core/views.py (2)
1720-1729
: Consider a unified permissions strategy.The check for
request.user != self.get_object().approver
ensures that only the designated approver can accept the risk acceptance. However, this duplicates the permission checking logic in RBAC. It might be more cohesive to rely solely on RBAC for verifying user eligibility and use the object’s designated approver field only as supporting data if the user passes the RBAC checks.
1734-1743
: Retain consistency in naming log messages.The error message logs “risk rejectance” which differs from “risk acceptance” used in other logs. Consider a uniform naming convention such as “reject risk acceptance” for consistency and clarity in logs.
- "Only the approver can reject the risk rejectance", + "Only the approver can reject the risk acceptance",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/core/permissions.py
(1 hunks)backend/core/views.py
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: startup-docker-compose-test
- GitHub Check: startup-functional-test (3.12)
- GitHub Check: enterprise-startup-functional-test (3.12)
- GitHub Check: functional-tests (3.12, chromium)
- GitHub Check: enterprise-startup-docker-compose-test
- GitHub Check: enterprise-functional-tests (3.12, chromium)
- GitHub Check: build (3.12)
- GitHub Check: test (3.12)
- GitHub Check: ruff (3.12)
- GitHub Check: Analyze (python)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
backend/core/views.py (2)
1679-1684
: Enforce consistent permission checks for risk acceptance actions.This new
permission_overrides
dictionary correctly aligns with the PR objective by ensuring that theapprove_riskacceptance
codename is required for theaccept
,reject
, andrevoke
actions. This design makes permissions more explicit and more straightforward to maintain.
1748-1757
: Verify intention for revoke action checks.This block follows the same pattern of verifying
approver
identity before revoking. Ensure that workflow states and transitions allow for revocation by the same user who is the designated approver and confirm alignment with the updatedapprove_riskacceptance
requirement. If additional states or concurrency checks are planned, consider adding those here.backend/core/permissions.py (1)
40-47
: Excellent approach to dynamic permission overrides.This logic correctly retrieves custom permission codes from
view.permission_overrides
if the view’saction
matches an overridden permission. This design keeps your permission checks flexible and aligns with standard DRF patterns. Good job!
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.
LGTM
Summary by CodeRabbit
Security Enhancements
Bug Fixes