Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Enforce explicitly setting SHA in API requests #5146

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion server/controllers/api_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type APIRequest struct {
Repository string `validate:"required"`
Ref string `validate:"required"`
Type string `validate:"required"`
Sha string `validate:"required"`
PR int
Projects []string
Paths []struct {
Expand Down Expand Up @@ -239,7 +240,7 @@ func (a *APIController) apiParseAndValidate(r *http.Request) (*APIRequest, *comm
Num: request.PR,
BaseBranch: request.Ref,
HeadBranch: request.Ref,
HeadCommit: request.Ref,
HeadCommit: request.Sha,
BaseRepo: baseRepo,
},
Scope: a.Scope,
Expand Down
2 changes: 2 additions & 0 deletions server/controllers/api_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestAPIController_Plan(t *testing.T) {
body, _ := json.Marshal(controllers.APIRequest{
Repository: "Repo",
Ref: "main",
Sha: "abc123",
Type: "Gitlab",
Projects: []string{"default"},
})
Expand All @@ -45,6 +46,7 @@ func TestAPIController_Apply(t *testing.T) {
body, _ := json.Marshal(controllers.APIRequest{
Repository: "Repo",
Ref: "main",
Sha: "abc123",
Type: "Gitlab",
Projects: []string{"default"},
})
Expand Down
Loading