mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-04 08:27:31 +00:00
fix(security): harden access checks and migration validation (#38324)
Harden access checks for issue dependencies, team repository membership, notifications, stars, tracked times and repository migrations.
This commit is contained in:
@@ -224,3 +224,23 @@ func TestAPIStarPublicOnly(t *testing.T) {
|
||||
require.Len(t, repos, 1)
|
||||
assert.Equal(t, "user5/repo4", repos[0].FullName)
|
||||
}
|
||||
|
||||
func TestAPIStarredReposOmitsInaccessiblePrivateRepos(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 40})
|
||||
privateRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 3})
|
||||
assert.True(t, privateRepo.IsPrivate)
|
||||
assert.NoError(t, repo_service.AddOrUpdateCollaborator(t.Context(), privateRepo, user, perm.AccessModeRead))
|
||||
assert.NoError(t, repo_model.StarRepo(t.Context(), user, privateRepo, true))
|
||||
assert.NoError(t, repo_service.DeleteCollaboration(t.Context(), privateRepo, user))
|
||||
|
||||
token := getUserToken(t, user.Name, auth_model.AccessTokenScopeReadUser, auth_model.AccessTokenScopeReadRepository)
|
||||
req := NewRequest(t, "GET", "/api/v1/user/starred").AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
repos := DecodeJSON(t, resp, []api.Repository{})
|
||||
for _, repo := range repos {
|
||||
assert.NotEqual(t, privateRepo.FullName(), repo.FullName)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user