Skip to content

fix(events): omit GitLab webhook tokens from errors - #6851

Open
chenrui333 wants to merge 1 commit into
mainfrom
fix/gitlab-webhook-token-errors
Open

fix(events): omit GitLab webhook tokens from errors#6851
chenrui333 wants to merge 1 commit into
mainfrom
fix/gitlab-webhook-token-errors

Conversation

@chenrui333

Copy link
Copy Markdown
Member

What

Omit the supplied GitLab webhook token from authentication errors.

Why

These errors are written to logs and returned in HTTP responses.

Testing

Rejection regression fails before the fix; validator and events-controller package tests pass.

Copilot AI lite review requested due to automatic review settings September 7, 2026 06:45
@github-actions github-actions Bot added go Pull requests that update Go code provider/gitlab size/s labels Sep 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped to removing sensitive token data from error strings and includes regression tests that verify the non-leak behavior.

Pull request overview

This PR updates the GitLab webhook request validator to avoid leaking webhook token values in authentication error messages, preventing accidental disclosure via logs and HTTP responses.

Changes:

  • Removed the supplied X-Gitlab-Token value from the “did not match expected secret” error message.
  • Updated the invalid-secret regression test to assert that neither the configured secret nor the client-supplied token appears in the error text (and that rejection happens before body parsing).
File summaries
File Description
server/controllers/events/gitlab_request_parser_validator.go Sanitizes the secret-mismatch error message to omit webhook token values.
server/controllers/events/gitlab_request_parser_validator_test.go Strengthens tests to ensure token values are not present in errors and auth fails before parsing.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-code-quality

github-code-quality Bot commented Sep 7, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Go

Go / code-coverage/go

The overall line coverage in commit 86919fb in the fix/gitlab-webhook-t... branch is 73%. Line coverage data for the main branch is not yet available.

Show a line coverage summary of the most covered files.
File main fix/gitlab-webhook-t... 86919fb +/-
server/events/v...ithub/client.go 88%
server/core/ter...aform_client.go 88%
server/controll...i_controller.go 83%
server/events/p...mand_builder.go 83%
server/events/v...itlab/client.go 80%
server/events/p...mmand_runner.go 76%
server/events/event_parser.go 76%
server/events/working_dir.go 73%
server/server.go 70%
server/controll...s_controller.go 64%

Updated September 07, 2026 23:51 UTC

@chenrui333
chenrui333 force-pushed the fix/gitlab-webhook-token-errors branch from 18e1453 to c4726e8 Compare September 7, 2026 09:16
Keep the authentication failure diagnostic without including the supplied token, which is forwarded to logs and the HTTP response. Cover missing, mismatched, and suffixed tokens before malformed payload parsing.

Assisted-by: OpenAI
Signed-off-by: Rui Chen <rui@chenrui.dev>
@chenrui333
chenrui333 force-pushed the fix/gitlab-webhook-token-errors branch from c4726e8 to 86919fb Compare September 7, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code provider/gitlab size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants