1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2026-06-03 16:35:37 +02:00

fix(cli,server): fix trusted flags copy-paste bug and server nil pointer panic (#6501)

Co-authored-by: Bruno Clermont <bruno.clermont@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
Bruno Clermont
2026-04-25 16:12:55 -04:00
committed by GitHub
parent 4dd3be7f96
commit 19190cf1ab
2 changed files with 9 additions and 3 deletions
+2 -2
View File
@@ -118,11 +118,11 @@ func repoUpdate(ctx context.Context, c *cli.Command) error {
}
if c.IsSet("trusted-network") {
t := c.Bool("trusted-network")
patch.Trusted.Security = &t
patch.Trusted.Network = &t
}
if c.IsSet("trusted-volumes") {
t := c.Bool("trusted-volumes")
patch.Trusted.Security = &t
patch.Trusted.Volumes = &t
}
}
+7 -1
View File
@@ -234,8 +234,14 @@ func PatchRepo(c *gin.Context) {
}
if in.Trusted != nil {
if (*in.Trusted.Network != repo.Trusted.Network || *in.Trusted.Volumes != repo.Trusted.Volumes || *in.Trusted.Security != repo.Trusted.Security) && !user.Admin {
// if user is not admin
if !user.Admin &&
// and some trusted settings got changed
((in.Trusted.Network != nil && *in.Trusted.Network != repo.Trusted.Network) ||
(in.Trusted.Volumes != nil && *in.Trusted.Volumes != repo.Trusted.Volumes) ||
(in.Trusted.Security != nil && *in.Trusted.Security != repo.Trusted.Security)) {
log.Trace().Msgf("user '%s' wants to change trusted without being an instance admin", user.Login)
// return error
c.String(http.StatusForbidden, "Insufficient privileges")
return
}