Skip to content

fix: workspace model scope permission error - #7787

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_workspace_model_scope_permission_error
Nov 10, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_workspace_model_scope_permission_error

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: workspace model scope permission error

scope=[PermissionScopeConstants.WORKSPACE, PermissionScopeConstants.WORKSPACE_RESOURCE],
resource_permission_group_list=[ResourcePermissionConst.MODEL_MANAGE],
),
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here is an analysis of the provided code diff:

1. Irregularities & Issues

  • Redundant Scope Addition: In three out of the four hunks, PermissionScopeConstants.WORKSPACE is added to a list that already contained PermissionScopeConstants.WORKSPACE_RESOURCE. Depending on the permission logic, having both WORKSPACE and WORKSPACE_RESOURCE might be semantically redundant or overly broad. If WORKSPACE implies all resources within it, adding WORKSPACE_RESOURCE explicitly may be unnecessary. Verify if this double-scoping causes unintended permission grants.
  • Inconsistency in First Hunk: The first hunk previously had only WORKSCOPE, while the others had WORKSPACE_RESOURCE. The new state makes them identical ([WORKSPACE, WORKSPACE_RESOURCE]). Ensure this is intentional and not a copy-paste error obscuring a need for distinct scopes across these four permissions.

2. Optimization Suggestions

  • Reduce Duplication (DRY Principle): Four separate PermissionMeta entries appear to have nearly identical configurations:
    • Same roles: [WORKSPACE_MANAGE, USER]
    • Same category: WORKSPACE
    • Same scope: [WORKSPACE, WORKSPACE_RESOURCE]
    • Same resource group: [MODEL_MANAGE]
    • Suggestion: If these entries differ only by their Enum name/key, consider refactoring to avoid repeating the PermissionMeta block four times. You could iterate over a list of keys or use a helper function/method to reduce boilerplate.
  • Data Structure Efficiency: If multiple permissions share identical scope/role/category/resource settings, consider grouping them under a single permission definition with multiple aliases or a combined resource group, rather than duplicating the entire meta object.

3. Potential Logic Risks

  • Permission Escalation: Adding WORKSPACE scope to entries that previously only had WORKSPACE_RESOURCE likely broadens the permission. USER roles now potentially get broader workspace-wide access where they previously had more restricted resource-specific access. Confirm this is the desired security outcome.

Summary

The change is syntactically correct but raises security concerns due to broadened permissions and maintenance concerns due to repetitive code blocks. Review whether the expanded scope is necessary for all four permissions.

@peslyn
peslyn merged commit d0f487e into v3 Nov 10, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_workspace_model_scope_permission_error branch November 10, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants