From c55d56291485f05d8be29e4854bf7a4605fe9bae Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Wed, 25 Nov 2015 21:21:12 +0000 Subject: [PATCH 1/4] [JENKINS-31596] The kill switch is never relevant if you do not have RUN_SCRIPTS --- .../jenkins/security/s2m/MasterKillSwitchConfiguration.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java index c5b23e529025..032c8fa0018b 100644 --- a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java +++ b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java @@ -48,6 +48,9 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti * Unless this option is relevant, we don't let users choose this. */ public boolean isRelevant() { + if (!jenkins.hasPermission(Jenkins.RUN_SCRIPTS))) { + return false; + } if (rule.getMasterKillSwitch()) { return true; // always relevant if it is enabled. } From 39ef6157fa41b5e9df92fec03f0fc65c95e07c57 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Wed, 25 Nov 2015 22:28:31 +0000 Subject: [PATCH 2/4] Revert "[JENKINS-31596] The kill switch is never relevant if you do not have RUN_SCRIPTS" This reverts commit c55d56291485f05d8be29e4854bf7a4605fe9bae. --- .../jenkins/security/s2m/MasterKillSwitchConfiguration.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java index 032c8fa0018b..c5b23e529025 100644 --- a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java +++ b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java @@ -48,9 +48,6 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti * Unless this option is relevant, we don't let users choose this. */ public boolean isRelevant() { - if (!jenkins.hasPermission(Jenkins.RUN_SCRIPTS))) { - return false; - } if (rule.getMasterKillSwitch()) { return true; // always relevant if it is enabled. } From 208320f8e121dd151286f457d2f0fa3099b8047f Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Wed, 25 Nov 2015 22:29:08 +0000 Subject: [PATCH 3/4] Revert "Merge pull request #1917 from stephenc/jenkins-31596" This reverts commit d00dc71b24dbfff8c5e6944c7776c9279bd6b5b0, reversing changes made to 7ffefe190dff2d530f1fe5c3e207cc461335af6a. --- .../s2m/MasterKillSwitchConfiguration.java | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java index c5b23e529025..cfec0ab96ece 100644 --- a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java +++ b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java @@ -1,8 +1,6 @@ package jenkins.security.s2m; import hudson.Extension; -import hudson.ExtensionList; -import hudson.ExtensionPoint; import javax.inject.Inject; import jenkins.model.GlobalConfiguration; import jenkins.model.GlobalConfigurationCategory; @@ -54,39 +52,8 @@ public boolean isRelevant() { return jenkins.isUseSecurity() // if security is off, there's no point && (jenkins.getComputers().length>1 // if there's no slave, || !jenkins.clouds.isEmpty() // and no clouds, likewise this is pointless - || Relevance.fromExtension() // unless a plugin thinks otherwise ) ; } - - /** - * Some plugins may cause the {@link MasterKillSwitchConfiguration} to be relevant for additional reasons, - * by implementing this extension point they can indicate such additional conditions. - * - * @since FIXME - */ - public static abstract class Relevance implements ExtensionPoint { - - /** - * Is the {@link MasterKillSwitchConfiguration} relevant. - * - * @return {@code true} if the {@link MasterKillSwitchConfiguration} relevant. - */ - public abstract boolean isRelevant(); - - /** - * Is the {@link MasterKillSwitchConfiguration} relevant for any of the {@link Relevance} extensions. - * - * @return {@code true} if and only if {@link Relevance#isRelevant()} for at least one extension. - */ - public static boolean fromExtension() { - for (Relevance r : ExtensionList.lookup(Relevance.class)) { - if (r.isRelevant()) { - return true; - } - } - return false; - } - } } From 3c94a7cb60c39286945d5a9c1ccee505c01d16b8 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Wed, 25 Nov 2015 22:32:29 +0000 Subject: [PATCH 4/4] [JENKINS-31596] No excuses, have security => relevant --- .../security/s2m/MasterKillSwitchConfiguration.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java index cfec0ab96ece..69bb8e34bc1f 100644 --- a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java +++ b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java @@ -46,14 +46,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti * Unless this option is relevant, we don't let users choose this. */ public boolean isRelevant() { - if (rule.getMasterKillSwitch()) { - return true; // always relevant if it is enabled. - } - return jenkins.isUseSecurity() // if security is off, there's no point - && (jenkins.getComputers().length>1 // if there's no slave, - || !jenkins.clouds.isEmpty() // and no clouds, likewise this is pointless - ) - ; + return jenkins.hasPermission(Jenkins.RUN_SCRIPTS) && jenkins.isUseSecurity(); } }