Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Verify that the webhook event we receive is the push event

天舟37dc263a6a29
diff --git a/backend/server/webhook.go b/backend/server/webhook.go
index 4b5dfeb720..11dd6df801 100644
--- a/backend/server/webhook.go
+++ b/backend/server/webhook.go
@@ -38,6 +38,11 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
}
s.l.Info((fmt.Sprintf("Push event: %+v", *pushEvent)))
+ // This shouldn't happen as we only setup webhook to receive push event, just in case.
+ if pushEvent.ObjectKind != gitlab.WebhookPush {
+ return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid webhook event type. Expect push, got %s", pushEvent.ObjectKind))
+ }
+
webhookEndpointId := c.Param("id")
repositoryFind := &api.RepositoryFind{
WebhookEndpointId: &webhookEndpointId,