Skip to content

Fix release draft access check logic#36720

Merged
lunny merged 5 commits intogo-gitea:mainfrom
wxiaoguang:fix-release-draft
Feb 25, 2026
Merged

Fix release draft access check logic#36720
lunny merged 5 commits intogo-gitea:mainfrom
wxiaoguang:fix-release-draft

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

  1. remove hasRepoWriteScope to avoid abuse
  2. clarify "ctx.Written" behavior
  3. merge "read-only" tests to slightly improve performance

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 23, 2026
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Feb 23, 2026
@wxiaoguang wxiaoguang added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Feb 23, 2026
@wxiaoguang wxiaoguang added this to the 1.26.0 milestone Feb 23, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 23, 2026
@silverwind silverwind requested a review from Copilot February 24, 2026 11:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts draft-release access checks in the API to avoid improper draft visibility via token scope handling, and refactors related integration tests to run under a shared test environment setup.

Changes:

  • Replace draft-access logic with a consolidated canAccessReleaseDraft helper and use it across release and release-attachment API endpoints.
  • Remove hasRepoWriteScope and simplify draft handling to consistently return 404 when drafts aren’t accessible.
  • Merge several “read” integration tests into a single grouped test to reduce repeated environment setup overhead.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/integration/api_releases_test.go Groups multiple release read-related API tests under a single PrepareTestEnv run.
tests/integration/api_releases_attachment_test.go Converts standalone tests into helper subtests invoked by the grouped release read test.
routers/api/v1/repo/release_attachment.go Uses the new draft-access helper to gate draft release attachment listing/getting.
routers/api/v1/repo/release.go Introduces canAccessReleaseDraft and uses it to control draft visibility and inclusion in listings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 25, 2026
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 25, 2026
@lunny lunny enabled auto-merge (squash) February 25, 2026 19:53
@lunny lunny merged commit 840cf68 into go-gitea:main Feb 25, 2026
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 25, 2026
zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 26, 2026
* giteaofficial/main:
  Fix release draft access check logic (go-gitea#36720)
  Change image transparency grid to CSS (go-gitea#36711)
  Avoid opening new tab when downloading actions logs (go-gitea#36740)
  Add validation constraints for repository creation fields (go-gitea#36671)
  Fix SVG height calculation in diff viewer (go-gitea#36748)
@wxiaoguang wxiaoguang deleted the fix-release-draft branch February 26, 2026 04:19
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 26, 2026
* main: (24 commits)
  Instance-wide (global) info banner and maintenance mode (go-gitea#36571)
  Add created_by filter to SearchIssues (go-gitea#36670)
  Inline and lazy-load EasyMDE CSS, fix border colors (go-gitea#36714)
  Fix release draft access check logic (go-gitea#36720)
  Change image transparency grid to CSS (go-gitea#36711)
  Avoid opening new tab when downloading actions logs (go-gitea#36740)
  Add validation constraints for repository creation fields (go-gitea#36671)
  Fix SVG height calculation in diff viewer (go-gitea#36748)
  Fix path resolving (go-gitea#36734)
  [skip ci] Updated translations via Crowdin
  Fix track time list permission check (go-gitea#36662)
  Fix incorrect setting loading order (go-gitea#36735)
  Use case-insensitive matching for Git error "Not a valid object name" (go-gitea#36728)
  feat: Add workflow dependencies visualization (go-gitea#36248)
  Add keyboard shortcuts for repository file and code search (go-gitea#36416)
  Refactor text utility classes to Tailwind CSS (go-gitea#36703)
  Prevent redirect bypasses via backslash-encoded paths (go-gitea#36660)
  Fix force push time-line commit comments of pull request (go-gitea#36653)
  Fix get release draft permission check (go-gitea#36659)
  Move `X_FRAME_OPTIONS` setting from `cors` to `security` section (go-gitea#30256)
  ...

# Conflicts:
#	web_src/css/base.css
#	web_src/css/index.css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants