fix(sec): permission check for project issue

- Do an access check when loading issues for a project board, currently
this is not done and exposes the title, labels and existence of a
private issue that the viewer of the project board may not have access
to.
- The number of issues cannot be calculated in a efficient manner
and stored in the database because their number may vary depending on
the visibility of the repositories participating in the project. The
previous implementation used the pre-calculated numbers stored in each
project, which did not reflect that potential variation.
- The code is derived from https://github.com/go-gitea/gitea/pull/22865

(cherry picked from commit 2193afaeb9954a5778f5a47aafd0e6fbbf48d000)
This commit is contained in:
Earl Warren 2025-02-05 22:05:22 +00:00
parent 0f1cf6dade
commit 913e3b536e
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
7 changed files with 83 additions and 44 deletions

View file

@ -125,6 +125,19 @@ func Projects(ctx *context.Context) {
ctx.Data["IsProjectsPage"] = true
ctx.Data["SortType"] = sortType
numOpenIssues, err := issues_model.NumIssuesInProjects(ctx, projects, ctx.Doer, ctx.Org.Organization, optional.Some(false))
if err != nil {
ctx.ServerError("NumIssuesInProjects", err)
return
}
numClosedIssues, err := issues_model.NumIssuesInProjects(ctx, projects, ctx.Doer, ctx.Org.Organization, optional.Some(true))
if err != nil {
ctx.ServerError("NumIssuesInProjects", err)
return
}
ctx.Data["NumOpenIssuesInProject"] = numOpenIssues
ctx.Data["NumClosedIssuesInProject"] = numClosedIssues
ctx.HTML(http.StatusOK, tplProjects)
}
@ -310,7 +323,7 @@ func ViewProject(ctx *context.Context) {
return
}
issuesMap, err := issues_model.LoadIssuesFromBoardList(ctx, boards)
issuesMap, err := issues_model.LoadIssuesFromBoardList(ctx, boards, ctx.Doer, nil, optional.None[bool]())
if err != nil {
ctx.ServerError("LoadIssuesOfBoards", err)
return