fix(projects): hide linked pull requests the viewer cannot read (#40016)

Project board cards list the pull requests that reference their issue,
but loaded them without checking the viewer's access. A private pull
request mentioning a public issue showed its title, number and state on
that issue's board to anyone who can view the board, anonymous visitors
included.

Repository and organization boards now skip linked pull requests in
repositories where the viewer cannot read pull requests, matching how
the issue page already hides such references.

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: bircni <bircni@icloud.com>
Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
authored and GitHub committed 2026-10-31 17:31:34 +01:00
1 parent 4144d4ed5b
commit 36ea65a1df
4 files changed
+68 -38

No files matched your search

+17
View File
@@ -377,6 +377,23 @@ func TestOrgProjectFilterByMilestone(t *testing.T) {
func TestProjects(t *testing.T) {
defer tests.PrepareTestEnv(t)()
t.Run("PrivateLinkedPullRequest", func(t *testing.T) {
require.NoError(t, db.Insert(t.Context(), &issues_model.Comment{
Type: issues_model.CommentTypePullRef,
PosterID: 2,
IssueID: 1,
RefRepoID: 3,
RefIssueID: 12,
RefIsPull: true,
}))
const linkedPR = `href="/org3/repo3/pulls/2"`
resp := MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/projects/1"), http.StatusOK)
assert.NotContains(t, resp.Body.String(), linkedPR)
resp = loginUser(t, "user2").MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/projects/1"), http.StatusOK)
assert.Contains(t, resp.Body.String(), linkedPR)
})
t.Run("LoadIssuesAssigneesForProject", func(t *testing.T) {
_ = db.TruncateBeans(t.Context(), "project_issue", "issue_assignees")
_ = db.Insert(t.Context(),