From c9382301dcb625b06fffe4b2bf1c90aed396e38a Mon Sep 17 00:00:00 2001 From: ecrupper Date: Thu, 11 Jan 2024 13:53:52 -0600 Subject: [PATCH 1/2] fix(compiler): validate yaml.Build post-expansion and fully validate step image --- compiler/native/compile.go | 6 ------ compiler/native/validate.go | 8 ++++---- scm/github/webhook.go | 5 ++++- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/compiler/native/compile.go b/compiler/native/compile.go index b0648ded0..206124519 100644 --- a/compiler/native/compile.go +++ b/compiler/native/compile.go @@ -50,12 +50,6 @@ func (c *client) Compile(v interface{}) (*pipeline.Build, *library.Pipeline, err _pipeline.SetData(data) _pipeline.SetType(c.repo.GetPipelineType()) - // validate the yaml configuration - err = c.Validate(p) - if err != nil { - return nil, _pipeline, err - } - // create map of templates for easy lookup templates := mapFromTemplates(p.Templates) diff --git a/compiler/native/validate.go b/compiler/native/validate.go index 1d5b0440b..e3c79d862 100644 --- a/compiler/native/validate.go +++ b/compiler/native/validate.go @@ -101,8 +101,8 @@ func validateStages(s yaml.StageSlice) error { return fmt.Errorf("no name provided for step for stage %s", stage.Name) } - if len(step.Image) == 0 && len(step.Template.Name) == 0 { - return fmt.Errorf("no image or template provided for step %s for stage %s", step.Name, stage.Name) + if len(step.Image) == 0 { + return fmt.Errorf("no image provided for step %s for stage %s", step.Name, stage.Name) } if step.Name == "clone" || step.Name == "init" { @@ -128,8 +128,8 @@ func validateSteps(s yaml.StepSlice) error { return fmt.Errorf("no name provided for step") } - if len(step.Image) == 0 && len(step.Template.Name) == 0 { - return fmt.Errorf("no image or template provided for step %s", step.Name) + if len(step.Image) == 0 { + return fmt.Errorf("no image provided for step %s", step.Name) } if step.Name == "clone" || step.Name == "init" { diff --git a/scm/github/webhook.go b/scm/github/webhook.go index 8dcda751d..275d9ae3d 100644 --- a/scm/github/webhook.go +++ b/scm/github/webhook.go @@ -152,7 +152,10 @@ func (c *client) processPushEvent(h *library.Hook, payload *github.PushEvent) (* b.SetClone(repo.GetCloneURL()) b.SetSource(payload.GetHeadCommit().GetURL()) b.SetTitle(fmt.Sprintf("%s received from %s", constants.EventPush, repo.GetHTMLURL())) - b.SetMessage(payload.GetHeadCommit().GetMessage()) + + sanitizedMessage := strings.Replace(payload.GetHeadCommit().GetMessage(), `\`, `\\`, -1) + + b.SetMessage(sanitizedMessage) b.SetCommit(payload.GetHeadCommit().GetID()) b.SetSender(payload.GetSender().GetLogin()) b.SetAuthor(payload.GetHeadCommit().GetAuthor().GetLogin()) From 99b65f85e1553b307b76f5c8c0c7f9b07f23406b Mon Sep 17 00:00:00 2001 From: ecrupper Date: Thu, 11 Jan 2024 13:57:51 -0600 Subject: [PATCH 2/2] remove errant other file update --- scm/github/webhook.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scm/github/webhook.go b/scm/github/webhook.go index 275d9ae3d..8dcda751d 100644 --- a/scm/github/webhook.go +++ b/scm/github/webhook.go @@ -152,10 +152,7 @@ func (c *client) processPushEvent(h *library.Hook, payload *github.PushEvent) (* b.SetClone(repo.GetCloneURL()) b.SetSource(payload.GetHeadCommit().GetURL()) b.SetTitle(fmt.Sprintf("%s received from %s", constants.EventPush, repo.GetHTMLURL())) - - sanitizedMessage := strings.Replace(payload.GetHeadCommit().GetMessage(), `\`, `\\`, -1) - - b.SetMessage(sanitizedMessage) + b.SetMessage(payload.GetHeadCommit().GetMessage()) b.SetCommit(payload.GetHeadCommit().GetID()) b.SetSender(payload.GetSender().GetLogin()) b.SetAuthor(payload.GetHeadCommit().GetAuthor().GetLogin())