You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
flowchart LR
A["Controller API调用"]
B["GetInstanceAuditPlanIfCurrentUserCanView"]
C["遍历多权限校验"]
D["返回审核计划详情"]
A -- "调用权限检查" --> B
B -- "检查多种权限" --> C
C -- "验证并返回结果" --> D
Why: The suggestion accurately identifies a critical issue in which the undeclared user variable is passed to GetCanOperationInstances, potentially causing a nil pointer dereference. The improved code properly retrieves user from the context via c.Get("user"), making the fix both relevant and effective.
saveAuditPlanInstanceIds := up.GetInstancesByOP(dmsCommonV1.OpPermissionTypeSaveAuditPlan)
-accessibleInstanceId = append(accessibleInstanceId, saveAuditPlanInstanceIds...)+combinedInstances := append(accessibleInstanceId, saveAuditPlanInstanceIds...)+instanceSet := make(map[string]struct{})+for _, id := range combinedInstances {+ instanceSet[id] = struct{}{}+}+uniqueInstances := make([]string, 0, len(instanceSet))+for id := range instanceSet {+ uniqueInstances = append(uniqueInstances, id)+}+accessibleInstanceId = uniqueInstances
Suggestion importance[1-10]: 7
__
Why: The suggestion adds deduplication after merging instance IDs, addressing potential duplicate entries that could affect subsequent operations, thereby enhancing overall data integrity.
Why: The suggestion replaces the dynamic error message with a hard-coded one, which may improve message clarity slightly but reduces flexibility in reflecting actual permission issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
assign in @LordofAvernus
关联的 issue
https://github.com/actiontech/sqle-ee/issues/2387#issuecomment-3032010540
描述你的变更
如果之前其他人在数据源上开启了扫描任务,该用户看不到,尝试开启时报错
确认项(pr提交后操作)
Tip
请在指定复审人之前,确认并完成以下事项,完成后✅
not_compatibleneed_update_docDescription
修改权限检查接口调用参数,删除多余opType
重构权限检查函数,实现多权限遍历校验
更新v1和v2接口中的权限校验调用逻辑
优化代码防止空指针异常
Changes diagram
Changes walkthrough 📝
instance_audit_plan.go
调整实例审核计划权限校验接口调用sqle/api/controller/v1/instance_audit_plan.go
opType参数project_permission.go
重构实例审核计划权限检查逻辑sqle/api/controller/v1/project_permission.go
GetInstanceAuditPlanIfCurrentUserCanView签名opTypes数组替代单一权限参数instance_audit_plan.go
更新实例审核计划接口权限逻辑sqle/api/controller/v2/instance_audit_plan.go