mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-16 05:45:21 +01:00
lock out info/refs from calling upload-archive
This commit is contained in:
parent
e4a3f34e8e
commit
be3f7790d1
@ -13,7 +13,7 @@ func addOwnerRepoGitHTTPRouters(m *web.Router) {
|
||||
m.Group("/{username}/{reponame}", func() {
|
||||
m.Methods("POST,OPTIONS", "/git-upload-pack", repo.ServiceUploadPack)
|
||||
m.Methods("POST,OPTIONS", "/git-receive-pack", repo.ServiceReceivePack)
|
||||
m.Post("/git-upload-archive", repo.ServiceUploadArchive)
|
||||
m.Methods("POST,OPTIONS", "/git-upload-archive", repo.ServiceUploadArchive)
|
||||
m.Methods("GET,OPTIONS", "/info/refs", repo.GetInfoRefs)
|
||||
m.Methods("GET,OPTIONS", "/HEAD", repo.GetTextFile("HEAD"))
|
||||
m.Methods("GET,OPTIONS", "/objects/info/alternates", repo.GetTextFile("objects/info/alternates"))
|
||||
|
||||
@ -438,7 +438,8 @@ func serviceRPC(ctx *context.Context, h *serviceHandler, service string) {
|
||||
}
|
||||
|
||||
var stderr bytes.Buffer
|
||||
if service != ServiceTypeUploadArchive {
|
||||
// git upload-archive does not have a -- stateless-rpc option
|
||||
if service == ServiceTypeUploadArchive || service == ServiceTypeReceivePack {
|
||||
cmd.AddArguments("--stateless-rpc")
|
||||
}
|
||||
if err := gitrepo.RunCmd(ctx, h.getStorageRepo(), cmd.AddArguments(".").
|
||||
@ -510,6 +511,10 @@ func GetInfoRefs(ctx *context.Context) {
|
||||
}
|
||||
setHeaderNoCache(ctx)
|
||||
service := getServiceType(ctx)
|
||||
if !(service == ServiceTypeUploadPack || service == ServiceTypeReceivePack) {
|
||||
ctx.Resp.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
cmd, err := prepareGitCmdWithAllowedService(service)
|
||||
if err == nil {
|
||||
if protocol := ctx.Req.Header.Get("Git-Protocol"); protocol != "" && safeGitProtocolHeader.MatchString(protocol) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user