Skip to content

Commit

Permalink
fix(pipeline): validate expected commit before passing to git-checkou…
Browse files Browse the repository at this point in the history
…t pipeline (#1667)

* fix(pipeline): validate expected commit before passing to git-checkout pipeline

Signed-off-by: Luca Di Maio <[email protected]>

* fix linting

Signed-off-by: Luca Di Maio <[email protected]>

---------

Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 authored Nov 23, 2024
1 parent b47ef6c commit 2fff904
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/build/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ func validateWith(data map[string]string, inputs map[string]config.Input) (map[s
return data, fmt.Errorf("checksum input %q for pipeline, invalid length", k)
}
}
if k == "expected-commit" && data[k] != "" {
if !matchValidShaChars(data[k]) {
return data, fmt.Errorf("expectec commit %q for pipeline contains invalid characters", k)
}
if len(data[k]) != 40 {
return data, fmt.Errorf("expected commit %q for pipeline, invalid length", k)
}
}

if v.Required && data[k] == "" {
return data, fmt.Errorf("required input %q for pipeline is missing", k)
Expand Down

0 comments on commit 2fff904

Please sign in to comment.