diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-11-06 12:13:22 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-11-06 12:37:27 +0300 |
commit | a15efb05bcd8b8d8d7e7aa8f4b4936093bd952ea (patch) | |
tree | b7cbb09746d0ee19da9ba3bcbe0ecc5b8aa10f3f /internal/gitaly/service | |
parent | 18d45ceae79eac82623ef69bf2367fa1bb398390 (diff) |
operations: Always set GL_PROTOCOL in hooks
When updating references via `updateReferenceWithHooks`, then we need to
assemble the envvars to post to the service. But one envvar actually got
lost in the conversion from Ruby to Go, which is the `GL_PROTOCOL`
variable. Not setting this variable may cause GitLab to misinterpret a
change's source and thus fail to correctly apply access control rules.
Add the missing variable. As the function will only ever be called from
other RPCs in the OperationsService, its safe to assume that it'll
always we "web".
Diffstat (limited to 'internal/gitaly/service')
-rw-r--r-- | internal/gitaly/service/operations/merge.go | 1 | ||||
-rw-r--r-- | internal/gitaly/service/operations/merge_test.go | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go index 6d2f2b3e5..9b432a2ed 100644 --- a/internal/gitaly/service/operations/merge.go +++ b/internal/gitaly/service/operations/merge.go @@ -117,6 +117,7 @@ func (s *server) updateReferenceWithHooks(ctx context.Context, repo *gitalypb.Re } env := append([]string{ + "GL_PROTOCOL=web", fmt.Sprintf("GL_ID=%s", user.GetGlId()), fmt.Sprintf("GL_USERNAME=%s", user.GetGlUsername()), fmt.Sprintf("GL_REPOSITORY=%s", repo.GetGlRepository()), diff --git a/internal/gitaly/service/operations/merge_test.go b/internal/gitaly/service/operations/merge_test.go index e9844e83f..3ae4da5cf 100644 --- a/internal/gitaly/service/operations/merge_test.go +++ b/internal/gitaly/service/operations/merge_test.go @@ -119,6 +119,7 @@ func testSuccessfulMerge(t *testing.T, ctx context.Context) { lines := strings.Split(string(hookEnv), "\n") require.Contains(t, lines, expectedGlID, "expected env of hook %q to contain %q", h, expectedGlID) + require.Contains(t, lines, "GL_PROTOCOL=web", "expected env of hook %q to contain GL_PROTOCOL") if h == "pre-receive" || h == "post-receive" { require.Regexp(t, mergeBranchHeadBefore+" .* refs/heads/"+mergeBranchName, lines[0], "expected env of hook %q to contain reference change", h) |