Skip to content
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: 修复客户端密钥使用一个星号作为关联规则时,没有权限拉取文件 --bug=132594799 #3588

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bcs-services/bcs-bscp/cmd/feed-server/service/rpc_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ func (s *Service) GetDownloadURL(ctx context.Context, req *pbfs.GetDownloadURLRe
return nil, status.Errorf(codes.Aborted, "get app meta failed, %s", err.Error())
}

req.FileMeta.ConfigItemSpec.Path = tools.ConvertBackslashes(req.FileMeta.ConfigItemSpec.Path)

// validate can file be downloaded by credential.
match, err := s.bll.Auth().CanMatchCI(
im.Kit, req.BizId, app.Name, req.Token, req.FileMeta.ConfigItemSpec.Path, req.FileMeta.ConfigItemSpec.Name)
Expand Down Expand Up @@ -698,6 +700,8 @@ func (s *Service) AsyncDownload(ctx context.Context, req *pbfs.AsyncDownloadReq)
return nil, status.Errorf(codes.PermissionDenied, "not have app %s permission", app.Name)
}

req.FileMeta.ConfigItemSpec.Path = tools.ConvertBackslashes(req.FileMeta.ConfigItemSpec.Path)

if !credential.MatchConfigItem(app.Name, req.FileMeta.ConfigItemSpec.Path, req.FileMeta.ConfigItemSpec.Name) {
return nil, status.Error(codes.PermissionDenied, "no permission download file")
}
Expand Down
5 changes: 5 additions & 0 deletions bcs-services/bcs-bscp/pkg/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,8 @@ func SplitPathAndName(remainingPath string) (string, string) {
}
return remainingPath, ""
}

// ConvertBackslashes 用于将字符串中的反斜杠转换为正斜杠
func ConvertBackslashes(input string) string {
return strings.ReplaceAll(input, `\`, "/")
}
Loading