Skip to content

Commit 3e43bae

Browse files
authored
Merge branch 'main' into novet
2 parents dce15b2 + dbed39d commit 3e43bae

File tree

28 files changed

+792
-659
lines changed

28 files changed

+792
-659
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ go 1.24
88
godebug x509negativeserial=1
99

1010
require (
11-
code.gitea.io/actions-proto-go v0.4.0
11+
code.gitea.io/actions-proto-go v0.4.1
1212
code.gitea.io/gitea-vet v0.2.3
1313
code.gitea.io/sdk/gitea v0.20.0
1414
codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570
@@ -318,7 +318,7 @@ replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1
318318

319319
replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142115-2c99e1ffdfa0
320320

321-
replace github.com/nektos/act => gitea.com/gitea/act v0.261.3
321+
replace github.com/nektos/act => gitea.com/gitea/act v0.261.4
322322

323323
// TODO: the only difference is in `PutObject`: the fork doesn't use `NewVerifyingReader(r, sha256.New(), oid, expectedSize)`, need to figure out why
324324
replace github.com/charmbracelet/git-lfs-transfer => gitea.com/gitea/git-lfs-transfer v0.2.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I=
22
cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
3-
code.gitea.io/actions-proto-go v0.4.0 h1:OsPBPhodXuQnsspG1sQ4eRE1PeoZyofd7+i73zCwnsU=
4-
code.gitea.io/actions-proto-go v0.4.0/go.mod h1:mn7Wkqz6JbnTOHQpot3yDeHx+O5C9EGhMEE+htvHBas=
3+
code.gitea.io/actions-proto-go v0.4.1 h1:l0EYhjsgpUe/1VABo2eK7zcoNX2W44WOnb0MSLrKfls=
4+
code.gitea.io/actions-proto-go v0.4.1/go.mod h1:mn7Wkqz6JbnTOHQpot3yDeHx+O5C9EGhMEE+htvHBas=
55
code.gitea.io/gitea-vet v0.2.3 h1:gdFmm6WOTM65rE8FUBTRzeQZYzXePKSSB1+r574hWwI=
66
code.gitea.io/gitea-vet v0.2.3/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
77
code.gitea.io/sdk/gitea v0.20.0 h1:Zm/QDwwZK1awoM4AxdjeAQbxolzx2rIP8dDfmKu+KoU=
@@ -16,8 +16,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
1616
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
1717
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
1818
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
19-
gitea.com/gitea/act v0.261.3 h1:BhiYpGJQKGq0XMYYICCYAN4KnsEWHyLbA6dxhZwFcV4=
20-
gitea.com/gitea/act v0.261.3/go.mod h1:Pg5C9kQY1CEA3QjthjhlrqOC/QOT5NyWNjOjRHw23Ok=
19+
gitea.com/gitea/act v0.261.4 h1:Tf9eLlvsYFtKcpuxlMvf9yT3g4Hshb2Beqw6C1STuH8=
20+
gitea.com/gitea/act v0.261.4/go.mod h1:Pg5C9kQY1CEA3QjthjhlrqOC/QOT5NyWNjOjRHw23Ok=
2121
gitea.com/gitea/git-lfs-transfer v0.2.0 h1:baHaNoBSRaeq/xKayEXwiDQtlIjps4Ac/Ll4KqLMB40=
2222
gitea.com/gitea/git-lfs-transfer v0.2.0/go.mod h1:UrXUCm3xLQkq15fu7qlXHUMlrhdlXHoi13KH2Dfiits=
2323
gitea.com/go-chi/binding v0.0.0-20240430071103-39a851e106ed h1:EZZBtilMLSZNWtHHcgq2mt6NSGhJSZBuduAlinMEmso=

models/actions/runner.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,17 @@ func FixRunnersWithoutBelongingRepo(ctx context.Context) (int64, error) {
337337
}
338338
return res.RowsAffected()
339339
}
340+
341+
func CountWrongRepoLevelRunners(ctx context.Context) (int64, error) {
342+
var result int64
343+
_, err := db.GetEngine(ctx).SQL("SELECT count(`id`) FROM `action_runner` WHERE `repo_id` > 0 AND `owner_id` > 0").Get(&result)
344+
return result, err
345+
}
346+
347+
func UpdateWrongRepoLevelRunners(ctx context.Context) (int64, error) {
348+
result, err := db.GetEngine(ctx).Exec("UPDATE `action_runner` SET `owner_id` = 0 WHERE `repo_id` > 0 AND `owner_id` > 0")
349+
if err != nil {
350+
return 0, err
351+
}
352+
return result.RowsAffected()
353+
}

models/actions/variable.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,17 @@ func GetVariablesOfRun(ctx context.Context, run *ActionRun) (map[string]string,
147147

148148
return variables, nil
149149
}
150+
151+
func CountWrongRepoLevelVariables(ctx context.Context) (int64, error) {
152+
var result int64
153+
_, err := db.GetEngine(ctx).SQL("SELECT count(`id`) FROM `action_variable` WHERE `repo_id` > 0 AND `owner_id` > 0").Get(&result)
154+
return result, err
155+
}
156+
157+
func UpdateWrongRepoLevelVariables(ctx context.Context) (int64, error) {
158+
result, err := db.GetEngine(ctx).Exec("UPDATE `action_variable` SET `owner_id` = 0 WHERE `repo_id` > 0 AND `owner_id` > 0")
159+
if err != nil {
160+
return 0, err
161+
}
162+
return result.RowsAffected()
163+
}

models/issues/pull_list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullR
6161
}
6262

6363
// GetUnmergedPullRequestsByHeadInfo returns all pull requests that are open and has not been merged
64-
func GetUnmergedPullRequestsByHeadInfo(ctx context.Context, repoID int64, branch string) ([]*PullRequest, error) {
64+
func GetUnmergedPullRequestsByHeadInfo(ctx context.Context, repoID int64, branch string) (PullRequestList, error) {
6565
prs := make([]*PullRequest, 0, 2)
6666
sess := db.GetEngine(ctx).
6767
Join("INNER", "issue", "issue.id = pull_request.issue_id").
@@ -116,7 +116,7 @@ func HasUnmergedPullRequestsByHeadInfo(ctx context.Context, repoID int64, branch
116116

117117
// GetUnmergedPullRequestsByBaseInfo returns all pull requests that are open and has not been merged
118118
// by given base information (repo and branch).
119-
func GetUnmergedPullRequestsByBaseInfo(ctx context.Context, repoID int64, branch string) ([]*PullRequest, error) {
119+
func GetUnmergedPullRequestsByBaseInfo(ctx context.Context, repoID int64, branch string) (PullRequestList, error) {
120120
prs := make([]*PullRequest, 0, 2)
121121
return prs, db.GetEngine(ctx).
122122
Where("base_repo_id=? AND base_branch=? AND has_merged=? AND issue.is_closed=?",

models/issues/pull_list_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import (
1616
func TestPullRequestList_LoadAttributes(t *testing.T) {
1717
assert.NoError(t, unittest.PrepareTestDatabase())
1818

19-
prs := []*issues_model.PullRequest{
19+
prs := issues_model.PullRequestList{
2020
unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 1}),
2121
unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2}),
2222
}
23-
assert.NoError(t, issues_model.PullRequestList(prs).LoadAttributes(db.DefaultContext))
23+
assert.NoError(t, prs.LoadAttributes(db.DefaultContext))
2424
for _, pr := range prs {
2525
assert.NotNil(t, pr.Issue)
2626
assert.Equal(t, pr.IssueID, pr.Issue.ID)
@@ -32,11 +32,11 @@ func TestPullRequestList_LoadAttributes(t *testing.T) {
3232
func TestPullRequestList_LoadReviewCommentsCounts(t *testing.T) {
3333
assert.NoError(t, unittest.PrepareTestDatabase())
3434

35-
prs := []*issues_model.PullRequest{
35+
prs := issues_model.PullRequestList{
3636
unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 1}),
3737
unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2}),
3838
}
39-
reviewComments, err := issues_model.PullRequestList(prs).LoadReviewCommentsCounts(db.DefaultContext)
39+
reviewComments, err := prs.LoadReviewCommentsCounts(db.DefaultContext)
4040
assert.NoError(t, err)
4141
assert.Len(t, reviewComments, 2)
4242
for _, pr := range prs {
@@ -47,11 +47,11 @@ func TestPullRequestList_LoadReviewCommentsCounts(t *testing.T) {
4747
func TestPullRequestList_LoadReviews(t *testing.T) {
4848
assert.NoError(t, unittest.PrepareTestDatabase())
4949

50-
prs := []*issues_model.PullRequest{
50+
prs := issues_model.PullRequestList{
5151
unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 1}),
5252
unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2}),
5353
}
54-
reviewList, err := issues_model.PullRequestList(prs).LoadReviews(db.DefaultContext)
54+
reviewList, err := prs.LoadReviews(db.DefaultContext)
5555
assert.NoError(t, err)
5656
// 1, 7, 8, 9, 10, 22
5757
assert.Len(t, reviewList, 6)

models/migrations/migrations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ func prepareMigrationTasks() []*migration {
374374
// Gitea 1.23.0-rc0 ends at migration ID number 311 (database version 312)
375375
newMigration(312, "Add DeleteBranchAfterMerge to AutoMerge", v1_24.AddDeleteBranchAfterMergeForAutoMerge),
376376
newMigration(313, "Move PinOrder from issue table to a new table issue_pin", v1_24.MovePinOrderToTableIssuePin),
377+
newMigration(314, "Update OwnerID as zero for repository level action tables", v1_24.UpdateOwnerIDOfRepoLevelActionsTables),
377378
}
378379
return preparedMigrations
379380
}

models/migrations/v1_24/v314.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_24 //nolint
5+
6+
import (
7+
"xorm.io/xorm"
8+
)
9+
10+
func UpdateOwnerIDOfRepoLevelActionsTables(x *xorm.Engine) error {
11+
if _, err := x.Exec("UPDATE `action_runner` SET `owner_id` = 0 WHERE `repo_id` > 0 AND `owner_id` > 0"); err != nil {
12+
return err
13+
}
14+
if _, err := x.Exec("UPDATE `action_variable` SET `owner_id` = 0 WHERE `repo_id` > 0 AND `owner_id` > 0"); err != nil {
15+
return err
16+
}
17+
_, err := x.Exec("UPDATE `secret` SET `owner_id` = 0 WHERE `repo_id` > 0 AND `owner_id` > 0")
18+
return err
19+
}

models/secret/secret.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,17 @@ func GetSecretsOfTask(ctx context.Context, task *actions_model.ActionTask) (map[
165165

166166
return secrets, nil
167167
}
168+
169+
func CountWrongRepoLevelSecrets(ctx context.Context) (int64, error) {
170+
var result int64
171+
_, err := db.GetEngine(ctx).SQL("SELECT count(`id`) FROM `secret` WHERE `repo_id` > 0 AND `owner_id` > 0").Get(&result)
172+
return result, err
173+
}
174+
175+
func UpdateWrongRepoLevelSecrets(ctx context.Context) (int64, error) {
176+
result, err := db.GetEngine(ctx).Exec("UPDATE `secret` SET `owner_id` = 0 WHERE `repo_id` > 0 AND `owner_id` > 0")
177+
if err != nil {
178+
return 0, err
179+
}
180+
return result.RowsAffected()
181+
}

modules/markup/sanitizer_default_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func TestSanitizer(t *testing.T) {
6262
`<a href="javascript:alert('xss')">bad</a>`, `bad`,
6363
`<a href="vbscript:no">bad</a>`, `bad`,
6464
`<a href="data:1234">bad</a>`, `bad`,
65+
66+
// Some classes and attributes are used by the frontend framework and will execute JS code, so make sure they are removed
67+
`<div class="link-action" data-attr-class="foo" data-url="xxx">txt</div>`, `<div data-attr-class="foo">txt</div>`,
68+
`<div class="form-fetch-action" data-markdown-generated-content="bar" data-global-init="a" data-global-click="b">txt</div>`, `<div data-markdown-generated-content="bar">txt</div>`,
6569
}
6670

6771
for i := 0; i < len(testCases); i += 2 {

0 commit comments

Comments
 (0)