fix(sec): permission check for project issue

- Do an access check when loading issues for a project column, 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
This commit is contained in:
Gusted 2025-01-29 09:47:37 +01:00 committed by Earl Warren
parent 94845020e8
commit b1b635c1d9
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
7 changed files with 83 additions and 43 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.LoadIssuesFromColumnList(ctx, columns)
issuesMap, err := issues_model.LoadIssuesFromColumnList(ctx, columns, ctx.Doer, nil, optional.None[bool]())
if err != nil {
ctx.ServerError("LoadIssuesOfColumns", err)
return