Repository navigation
[INFRA-1174] fix(security): scope project stats and grouping keys - #10065
Conversation
Project stats follow the project list visibility rules, the advance analytics overview counts members only of the caller's projects in the workspace, and workspace-level issue grouping builds project/state/cycle/module/label keys from the caller's projects. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Linked to Plane Work Item(s) References
This comment was auto-generated by Plane |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
lovelace3
left a comment
There was a problem hiding this comment.
No blocking findings.
Verified
test_workspace_stats_grouping_project_scope_app.py: 8 passed at the head. Withadvance.py,analytic/base.py,workspace/user.pyandgrouper.pyreset to the merge-base, 6 fail and the 2 positive controls pass, which matches the description. Worktree restored and clean. Neighbouring suites (unit/utils/test_paginator.py,test_order_queryset.py,test_avatar_url_annotation.py): 18 passed.project-statsnow uses the same visibility asProjectViewSet.list(guest: member projects only; member: member projects ornetwork=2; admin: all).- Every other
issue_group_valuescaller passesproject_id: the project, cycle, module and archived issue lists, and space has its own copy. Their keys are unchanged, apart fromgroup_by=project_idnow returning only that project.user-issuesis the only workspace-wide caller, and its issue queryset is already limited to the caller's active project memberships, so no issue loses its group. - The overview
total_userswithproject_idsis now limited byproject_filters(URL workspace, active membership, not archived or deleted). The other overview counts already were.
Minor (non-blocking): inline note on the helper default.
| project_ids = ( | ||
| [project_id] | ||
| if project_id | ||
| else ProjectMember.objects.filter(workspace__slug=slug, member=user, is_active=True).values("project_id") |
There was a problem hiding this comment.
Minor: with neither project_id nor user, this becomes ProjectMember.filter(member=None), which is member_id IS NULL, so every key list comes back empty. GroupedOffsetPaginator.__query_grouper only keeps results whose key is in group_by_fields, so for a non-m2m group_by such a caller would return 200 with every issue silently dropped. No current caller hits this: user-issues passes user, and the others pass project_id. The shared helper does make it easy to hit later, though. Consider raising (or asserting) when both are missing, instead of defaulting user=None.
There was a problem hiding this comment.
Addressed in faaa2a0 (raises when neither project_id nor user is given).
- issue_group_values raises ValueError when called with neither project_id nor user - Add a unit test for it Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Public board grouping (space issue_group_values) takes project, state, label, cycle and module keys only from the board's project. - Test: public issues endpoint grouped by project/state/cycle returns only keys from the board's project. Co-Authored-By: Claude Opus 5.5 <[email protected]>
lovelace3
left a comment
There was a problem hiding this comment.
Follow-up on fe59389.
All earlier findings resolved; no new findings.
- Minor,
issue_group_valuessilently returned empty keys when given neitherproject_idnoruser: resolved. It now raisesValueError. I checked every caller for the case where the new raise would turn a legitimate request into a 500, and none hits it:- The issue, cycle, module and archived-issue lists, where
group_byandsub_group_byboth passproject_idfrom a<uuid:project_id>URL kwarg, so it is never empty. user-issues, which passesuser=request.user.- Space has its own copy of the helper. That copy always receives
deploy_board.entity_identifier. - A throwaway probe hit all five endpoints with group/sub-group combinations: all 200.
- The issue, cycle, module and archived-issue lists, where
- New in fe59389, space grouper:
group_by=project_idon a public board used to return every project id in the workspace as group keys. It now returns only the board's project. For state, label, module and cycle the change is behaviour-neutral, because space always passedproject_idand the old code already filtered on it. No issue loses its group, since the public queryset is already limited to the board's project.
Tests: test_workspace_stats_grouping_project_scope_app.py + unit/utils/test_grouper.py, 12 passed. With both grouper.py files reverted to f931003, 2 fail: the public-board project_id case and the unit test. The state_id / cycle_id public-board cases pass on the old code as well, which is expected given the note above, so they are guards rather than regression tests.
…0065) * [INFRA-1174] fix(security): scope project stats and grouping keys Project stats follow the project list visibility rules, the advance analytics overview counts members only of the caller's projects in the workspace, and workspace-level issue grouping builds project/state/cycle/module/label keys from the caller's projects. * [INFRA-1174] fix(security): address review feedback - issue_group_values raises ValueError when called with neither project_id nor user - Add a unit test for it * [INFRA-1174] fix(security): address review feedback - Public board grouping (space issue_group_values) takes project, state, label, cycle and module keys only from the board's project. - Test: public issues endpoint grouped by project/state/cycle returns only keys from the board's project.
fix(security): scope project stats and grouping keys (upstream makeplane#10065)
Description
Three workspace-level endpoints built project-derived values from every project in the workspace instead of the projects the caller can see.
ProjectStatsEndpoint(project-stats) now applies the project list visibility rules fromProjectViewSet.list: workspace admins see every project, members see projects they belong to plus public ones, guests only projects they belong to. The analytics overview "Active projects" widget is unchanged for admins.AdvanceAnalyticsEndpointoverview: whenproject_idsis passed, member counts are taken only from those projects that passget_analytics_filters'project_filters(URL workspace, caller is an active member, not deleted/archived), like the other overview counts.issue_group_valuestakes an optionaluser. Group keys come from the given project or, workspace-wide, from the projects the user is an active member of. This covers project, state, cycle, module and label keys.WorkspaceUserProfileIssuesEndpoint(user-issues) passesrequest.user. With aproject_id,group_by=project_idnow returns only that project.plane/space/utils/grouper.py) takes project, state, label, cycle and module keys only from the board's project.Behaviour change: members and guests get fewer rows from
project-stats. Workspace-level groupeduser-issuesresponses no longer include empty groups for projects, states, cycles, modules or labels outside the caller's projects. Public board issues grouped by project return only the board's project.Type of Change
Screenshots and Media (if applicable)
Test Scenarios
project-statsas a workspace member → own and public projects only; as a guest → own projects only; as an admin → every project.advance-analytics/?tab=overview&project_ids=<project the caller is not in>,<project in another workspace>→total_users.count == 0; with the caller's own project → that project's member count.user-issues/<id>/?group_by=project_id|state_id|cycle_id→ keys include the caller's project, state and cycle, and exclude ones from a project the caller is not in.issues/?group_by=project_id|state_id|cycle_id→ keys from the board's project only;project_idreturns exactly that project.issue_group_valuescalled with neitherproject_idnoruser→ValueError(plane/tests/unit/utils/test_grouper.py).plane/tests/contract/app/test_workspace_stats_grouping_project_scope_app.py: 11 passed; 6 fail without the fix (the 2 positive controls pass either way), and the publicproject_idcase fails without the space grouper change. Together with the paginator, order_queryset, project, workspace, cycle-issue, module-issue and issue-list guest suites: 52 passed.References
🤖 Generated with Claude Code
Summary by CodeRabbit