Only allow simple names when creating workers, VMs, etc. and escape paths in API client (#129)

* Controller: only allow simple names when creating workers, VMs, etc.

* Client: escape paths

* simplename: allow ':' character
This commit is contained in:
Nikolay Edigaryev
2023-09-22 14:51:43 -04:00
committed by GitHub
parent 2adb17c3c4
commit 8c62df0eba
8 changed files with 80 additions and 13 deletions
+4
View File
@@ -4,6 +4,7 @@ import (
"errors"
storepkg "github.com/cirruslabs/orchard/internal/controller/store"
"github.com/cirruslabs/orchard/internal/responder"
"github.com/cirruslabs/orchard/internal/simplename"
v1 "github.com/cirruslabs/orchard/pkg/resource/v1"
"github.com/gin-gonic/gin"
"net/http"
@@ -23,6 +24,9 @@ func (controller *Controller) createWorker(ctx *gin.Context) responder.Responder
if worker.Name == "" {
return responder.JSON(http.StatusPreconditionFailed, NewErrorResponse("worker name is empty"))
} else if err := simplename.Validate(worker.Name); err != nil {
return responder.JSON(http.StatusPreconditionFailed,
NewErrorResponse("worker name %v", err))
}
currentTime := time.Now()