You've already forked woodpecker
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:
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user