Skip to content

Commit

Permalink
api: Explicit checks
Browse files Browse the repository at this point in the history
Signed-off-by: Max Asnaashari <[email protected]>
  • Loading branch information
masnax committed Sep 4, 2024
1 parent 3f6fed5 commit af2bc7d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/services_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ func serviceTokensPost(s *state.State, r *http.Request) response.Response {
return response.SmartError(err)
}

if strings.Contains(req.JoinerName, "/") || strings.Contains(req.JoinerName, "\\") || strings.Contains(req.JoinerName, "..") {
return response.SmartError(err)
}

_, err = filepath.Abs(req.JoinerName)
if err != nil {
return response.SmartError(err)
}

_ = os.MkdirAll(req.JoinerName, 0700)

sh, err := service.NewHandler(s.Name(), req.ClusterAddress, s.OS.StateDir, false, false, types.ServiceType(serviceType))
Expand Down

0 comments on commit af2bc7d

Please sign in to comment.