mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix: Forgejo Security Patches, 2026-03-09 (#11513)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11513 Reviewed-by: 0ko <0ko@noreply.codeberg.org>
This commit is contained in:
commit
6dbf72975d
34 changed files with 1088 additions and 278 deletions
|
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
"forgejo.org/models"
|
||||
activities_model "forgejo.org/models/activities"
|
||||
"forgejo.org/models/db"
|
||||
git_model "forgejo.org/models/git"
|
||||
issues_model "forgejo.org/models/issues"
|
||||
access_model "forgejo.org/models/perm/access"
|
||||
|
|
@ -1373,33 +1374,18 @@ func CancelScheduledAutoMerge(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
exist, autoMerge, err := pull_model.GetScheduledMergeByPullID(ctx, pull.ID)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
}
|
||||
if !exist {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Doer.ID != autoMerge.DoerID {
|
||||
allowed, err := access_model.IsUserRepoAdmin(ctx, ctx.Repo.Repository, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
}
|
||||
if !allowed {
|
||||
if err := automerge.RemoveScheduledAutoMerge(ctx, ctx.Doer, pull, ctx.Repo.Permission); err != nil {
|
||||
switch {
|
||||
case errors.Is(err, util.ErrPermissionDenied):
|
||||
ctx.Error(http.StatusForbidden, "No permission to cancel", "user has no permission to cancel the scheduled auto merge")
|
||||
return
|
||||
case db.IsErrNotExist(err):
|
||||
ctx.NotFound()
|
||||
default:
|
||||
ctx.InternalServerError(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err := automerge.RemoveScheduledAutoMerge(ctx, ctx.Doer, pull); err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
} else {
|
||||
ctx.Status(http.StatusNoContent)
|
||||
}
|
||||
ctx.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// GetPullRequestCommits gets all commits associated with a given PR
|
||||
|
|
|
|||
|
|
@ -480,8 +480,7 @@ func AuthorizeOAuth(ctx *context.Context) {
|
|||
|
||||
// pkce support
|
||||
switch form.CodeChallengeMethod {
|
||||
case "S256":
|
||||
case "plain":
|
||||
case "S256", "plain":
|
||||
if err := ctx.Session.Set("CodeChallengeMethod", form.CodeChallengeMethod); err != nil {
|
||||
handleAuthorizeError(ctx, AuthorizeError{
|
||||
ErrorCode: ErrorCodeServerError,
|
||||
|
|
|
|||
|
|
@ -218,8 +218,13 @@ func ChangeProjectStatus(ctx *context.Context) {
|
|||
}
|
||||
id := ctx.ParamsInt64(":id")
|
||||
|
||||
if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, 0, id, toClose); err != nil {
|
||||
ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err)
|
||||
project, err := project_model.GetProjectForUserByID(ctx, ctx.ContextUser.ID, id)
|
||||
if err != nil {
|
||||
ctx.NotFoundOrServerError("GetProjectForUserByID", project_model.IsErrProjectNotExist, err)
|
||||
return
|
||||
}
|
||||
if err := project_model.ChangeProjectStatus(ctx, project, toClose); err != nil {
|
||||
ctx.ServerError("ChangeProjectStatus", err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect(project_model.ProjectLinkForOrg(ctx.ContextUser, id))
|
||||
|
|
|
|||
|
|
@ -3682,7 +3682,7 @@ func updateAttachments(ctx *context.Context, item any, files []string) error {
|
|||
if len(files) > 0 {
|
||||
switch content := item.(type) {
|
||||
case *issues_model.Issue:
|
||||
err = issues_model.UpdateIssueAttachments(ctx, content.ID, files)
|
||||
err = issues_model.UpdateIssueAttachments(ctx, content, files)
|
||||
case *issues_model.Comment:
|
||||
err = content.UpdateAttachments(ctx, files)
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -192,8 +192,13 @@ func ChangeProjectStatus(ctx *context.Context) {
|
|||
}
|
||||
id := ctx.ParamsInt64(":id")
|
||||
|
||||
if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
|
||||
ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err)
|
||||
project, err := project_model.GetProjectForRepoByID(ctx, ctx.Repo.Repository.ID, id)
|
||||
if err != nil {
|
||||
ctx.NotFoundOrServerError("GetProjectForRepoByID", project_model.IsErrProjectNotExist, err)
|
||||
return
|
||||
}
|
||||
if err := project_model.ChangeProjectStatus(ctx, project, toClose); err != nil {
|
||||
ctx.ServerError("ChangeProjectStatus", err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect(project_model.ProjectLinkForRepo(ctx.Repo.Repository, id))
|
||||
|
|
|
|||
|
|
@ -1538,17 +1538,22 @@ func CancelAutoMergePullRequest(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if err := automerge.RemoveScheduledAutoMerge(ctx, ctx.Doer, issue.PullRequest); err != nil {
|
||||
if db.IsErrNotExist(err) {
|
||||
if err := automerge.RemoveScheduledAutoMerge(ctx, ctx.Doer, issue.PullRequest, ctx.Repo.Permission); err != nil {
|
||||
switch {
|
||||
case errors.Is(err, util.ErrPermissionDenied):
|
||||
ctx.Flash.Error(ctx.Tr("repo.pulls.auto_merge.no_permission"))
|
||||
ctx.Redirect(issue.HTMLURL())
|
||||
case db.IsErrNotExist(err):
|
||||
ctx.Flash.Error(ctx.Tr("repo.pulls.auto_merge_not_scheduled"))
|
||||
ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index))
|
||||
return
|
||||
ctx.Redirect(issue.HTMLURL())
|
||||
default:
|
||||
ctx.ServerError("RemoveScheduledAutoMerge", err)
|
||||
}
|
||||
ctx.ServerError("RemoveScheduledAutoMerge", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("repo.pulls.auto_merge_canceled_schedule"))
|
||||
ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index))
|
||||
ctx.Redirect(issue.HTMLURL())
|
||||
}
|
||||
|
||||
func stopTimerIfAvailable(ctx *context.Context, user *user_model.User, issue *issues_model.Issue) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue