From af04ff1dc9e684412f8be462969da747e9809119 Mon Sep 17 00:00:00 2001 From: Roman Zipp Date: Sun, 23 Jan 2022 18:24:34 +0100 Subject: [PATCH] Update upload pipeline validation --- main.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 5a01895..704652b 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,6 @@ import ( "github.com/spf13/afero" "io" "net/http" - "strings" ) const Name string = "Lithium" @@ -56,12 +55,25 @@ func UploadHandler(w http.ResponseWriter, r *http.Request, pipes []pipelines.IPi defer formFile.Close() // check pipelines form param - formPipelines := strings.Split(r.FormValue("pipelines"), ",") - if len(formPipelines) == 0 { + formPipeline := r.FormValue("pipeline") + if formPipeline == "" { writeError(w, http.StatusUnprocessableEntity, "pipeline parameter missing") return } + var execPipe pipelines.IPipeline + for _, pipe := range pipes { + if formPipeline == pipe.GetSlug() { + execPipe = pipe + break + } + } + + if execPipe == nil { + writeError(w, http.StatusUnprocessableEntity, "pipeline not found") + return + } + bucket := r.FormValue("bucket") if bucket == "" { writeError(w, http.StatusUnprocessableEntity, "bucket parameter missing")