From 79814fba21824b5589c0bb2602cb7f44a6507391 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 21 Apr 2023 13:47:18 +0200 Subject: [PATCH] Ensure other repositories are given as ssh URL --- repositories.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/repositories.go b/repositories.go index f6eb53f..cff6ca3 100644 --- a/repositories.go +++ b/repositories.go @@ -115,6 +115,11 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) { } } + if uri.Scheme != "ssh" && uri.Scheme != "git+ssh" { + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "Unrecognized URL scheme. You need to provide a SSH repository URL."}) + return + } + if strings.Contains(uri.Host, "epita.fr") { if !strings.HasPrefix(uri.Path, fmt.Sprintf("/%s/", u.Login)) { c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "repository URL forbidden"})