Skip to content

Commit

Permalink
fix: Delete improper path manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsuki3939 committed Sep 27, 2023
1 parent 56d6935 commit fb0a89a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/core/serve_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"net"
"net/http"
"os"
"path/filepath"

"cuelang.org/go/cue"
"cuelang.org/go/cue/cuecontext"
Expand Down Expand Up @@ -116,7 +117,8 @@ func HttpGet(c echo.Context, rootpath string) error {

res := make([]interface{}, 0)
for _, v := range req.Paths {
buf, err := os.ReadFile(rootpath + v + "/input.cue")
path := filepath.Join(rootpath, v, "input.cue")
buf, err := os.ReadFile(path)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
if err != nil {
return errors.New(fmt.Sprintf("HttpGet error: Read file: %v", err))
}
Expand Down Expand Up @@ -166,7 +168,7 @@ func HttpSet(c echo.Context, ctx context.Context, gogit *gogit.Git, scfg *ServeC

reqBody.Path = req["path"].(string)
reqBody.Value = req["value"].(map[string]interface{})
inputPath := scfg.ConfigRootPath + reqBody.Path + "/input.cue"
inputPath := filepath.Join(scfg.ConfigRootPath, reqBody.Path, "input.cue")
buf, err := os.ReadFile(inputPath)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("HttpSet error: read: %v", err))
Expand Down

0 comments on commit fb0a89a

Please sign in to comment.