From 2cf5a80da0dd40ba1aaecd1c0fb71a38bfa131d4 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Thu, 16 Sep 2021 08:43:11 -0700 Subject: [PATCH] [JENKINS-66470] Register view-related permission groups and permissions prior to the execution of JCasC (#5723) * [JENKINS-66470] Register view-related permission groups and permissions prior to the execution of JCasC * Update core/src/main/java/hudson/model/View.java Co-authored-by: Daniel Beck <1831569+daniel-beck@users.noreply.github.com> Co-authored-by: Daniel Beck <1831569+daniel-beck@users.noreply.github.com> --- core/src/main/java/hudson/model/View.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index 25c80b5089..b6b21bbeca 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -32,6 +32,8 @@ import hudson.ExtensionPoint; import hudson.Functions; import hudson.Indenter; import hudson.Util; +import hudson.init.InitMilestone; +import hudson.init.Initializer; import hudson.model.Descriptor.FormException; import hudson.model.listeners.ItemListener; import hudson.scm.ChangeLogSet; @@ -1318,6 +1320,16 @@ public abstract class View extends AbstractModelObject implements AccessControll public static final Permission CONFIGURE = new Permission(PERMISSIONS,"Configure", Messages._View_ConfigurePermission_Description(), Permission.CONFIGURE, PermissionScope.ITEM_GROUP); public static final Permission READ = new Permission(PERMISSIONS,"Read", Messages._View_ReadPermission_Description(), Permission.READ, PermissionScope.ITEM_GROUP); + @Initializer(before = InitMilestone.SYSTEM_CONFIG_LOADED) + @Restricted(DoNotUse.class) + public static void registerPermissions() { + // Pending JENKINS-17200, ensure that the above permissions have been registered prior to + // allowing plugins to adapt the system configuration, which may depend on these permissions + // having been registered. Since this method is static and since it follows the above + // construction of static permission objects (and therefore their calls to + // PermissionGroup#register), there is nothing further to do in this method. + } + // to simplify access from Jelly public static Permission getItemCreatePermission() { return Item.CREATE;