mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(sdk): fix Uncontrolled data used in network request
Signed-off-by: baihailong <baihailong@oppo.com>
This commit is contained in:
parent
dd741df686
commit
4a87988bf7
@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -23,6 +24,8 @@ import (
|
|||||||
"github.com/samsarahq/thunder/graphql/schemabuilder"
|
"github.com/samsarahq/thunder/graphql/schemabuilder"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var volNameRegexp = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]{1,61}[a-zA-Z0-9]$")
|
||||||
|
|
||||||
type FileService struct {
|
type FileService struct {
|
||||||
userClient *user.UserClient
|
userClient *user.UserClient
|
||||||
manager *VolumeManager
|
manager *VolumeManager
|
||||||
@ -307,6 +310,11 @@ func (fs *FileService) DownFile(writer http.ResponseWriter, request *http.Reques
|
|||||||
return fmt.Errorf("not found path in get param ?vol_name=[your path]")
|
return fmt.Errorf("not found path in get param ?vol_name=[your path]")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check volName
|
||||||
|
if !volNameRegexp.MatchString(volName) {
|
||||||
|
return fmt.Errorf("name can only be number and letters")
|
||||||
|
}
|
||||||
|
|
||||||
// author validate
|
// author validate
|
||||||
if err := fs.userVolPerm(ctx, info.User_id, volName).read(); err != nil {
|
if err := fs.userVolPerm(ctx, info.User_id, volName).read(); err != nil {
|
||||||
return fmt.Errorf("the user does not have permission to access this volume")
|
return fmt.Errorf("the user does not have permission to access this volume")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user