From e6d8010ef27cdd8805f65e78c67b035cffc9b231 Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Wed, 25 Sep 2019 17:58:52 +0200 Subject: [PATCH 1/2] Add logging for when user requested attachment doesn't belong to the specified release. --- routers/api/v1/repo/release_attachment.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go index aa2cc14cf920b..8c8bcc89e1103 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" @@ -57,6 +58,7 @@ func GetReleaseAttachment(ctx *context.APIContext) { return } if attach.ReleaseID != releaseID { + log.Info("User requested attachment is not in release, release_id %v, attachment_id: %v", releaseID, attachID) ctx.NotFound() return } @@ -263,6 +265,7 @@ func EditReleaseAttachment(ctx *context.APIContext, form api.EditAttachmentOptio return } if attach.ReleaseID != releaseID { + log.Info("User requested attachment is not in release, release_id %v, attachment_id: %v", releaseID, attachID) ctx.NotFound() return } @@ -320,6 +323,7 @@ func DeleteReleaseAttachment(ctx *context.APIContext) { return } if attach.ReleaseID != releaseID { + log.Info("User requested attachment is not in release, release_id %v, attachment_id: %v", releaseID, attachID) ctx.NotFound() return } From 068422f1a6712d421b02a57296d76eea0d169098 Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Wed, 25 Sep 2019 18:13:40 +0200 Subject: [PATCH 2/2] Fix API to use correct variable for release asset (attachment) --- routers/api/v1/repo/release_attachment.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go index 8c8bcc89e1103..d0d02139d9299 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -258,7 +258,7 @@ func EditReleaseAttachment(ctx *context.APIContext, form api.EditAttachmentOptio // Check if release exists an load release releaseID := ctx.ParamsInt64(":id") - attachID := ctx.ParamsInt64(":attachment") + attachID := ctx.ParamsInt64(":asset") attach, err := models.GetAttachmentByID(attachID) if err != nil { ctx.Error(500, "GetAttachmentByID", err) @@ -316,7 +316,7 @@ func DeleteReleaseAttachment(ctx *context.APIContext) { // Check if release exists an load release releaseID := ctx.ParamsInt64(":id") - attachID := ctx.ParamsInt64(":attachment") + attachID := ctx.ParamsInt64(":asset") attach, err := models.GetAttachmentByID(attachID) if err != nil { ctx.Error(500, "GetAttachmentByID", err)