From 855cdedae823d7352c995081da35649f3da80d72 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 67802fd9e7cc..493eab89422c 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -9,6 +9,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" "code.gitea.io/gitea/modules/upload" @@ -55,6 +56,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 } @@ -249,6 +251,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 } @@ -306,6 +309,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 501127a0a08a8790a89a5476ebb7e49172b71ff6 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 493eab89422c..c49e4d3e346e 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -244,7 +244,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) @@ -302,7 +302,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)