fix: add missing access checks and size limits (#39942)

Several handlers and parsers skipped checks that their siblings already
perform.

- Reject issue, comment, label, milestone and release mutations in
archived repositories via the API with one guard per route group,
matching the web UI
- Hide timeline references and dependencies pointing at issues the doer
cannot read, in the web UI and the API, including pull requests of the
same repository without pull request access
- Reject workflow runs with more than `MaxJobNumPerRun` jobs, including
inline reusable workflow jobs, and show rejected pushes as invalid
workflow runs
- Bound how much of a Helm chart archive is inflated while looking for
`Chart.yaml`

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-27 21:40:42 +01:00
1 parent f35c67bd79
commit 178d33ed4d
16 files changed
+229 -103

No files matched your search

+21
View File
@@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
"sync"
"testing"
"time"
@@ -705,3 +706,23 @@ func testAPIIssueProjects(t *testing.T) {
req = NewRequestWithJSON(t, "POST", urlStr, &api.CreateIssueOption{Title: "issue by a reader", Projects: []int64{1}}).AddTokenAuth(readerToken)
assert.Empty(t, DecodeJSON(t, MakeRequest(t, req, http.StatusCreated), &api.Issue{}).Projects)
}
func TestAPIArchivedRepoMutations(t *testing.T) {
defer tests.PrepareTestEnv(t)()
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
assert.NoError(t, repo_model.SetArchiveRepoState(t.Context(), repo, true))
token := getUserToken(t, "user2", auth_model.AccessTokenScopeWriteIssue, auth_model.AccessTokenScopeWriteRepository)
for route, status := range map[string]int{
"GET /issues/1/reactions": http.StatusOK,
"POST /issues/1/reactions": http.StatusLocked,
"DELETE /issues/comments/1": http.StatusLocked,
"DELETE /labels/1": http.StatusLocked,
"GET /releases/1": http.StatusOK,
"DELETE /releases/1": http.StatusLocked,
} {
t.Run(route, func(t *testing.T) {
method, path, _ := strings.Cut(route, " ")
MakeRequest(t, NewRequest(t, method, "/api/v1/repos/user2/repo1"+path).AddTokenAuth(token), status)
})
}
}