]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14606 Add 'sonar.plugins.risk.consent' property
authorJacek <jacek.poreda@sonarsource.com>
Mon, 22 Mar 2021 09:09:08 +0000 (10:09 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 15 Apr 2021 20:03:44 +0000 (20:03 +0000)
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
sonar-core/src/main/java/org/sonar/core/extension/PluginRiskConsent.java [new file with mode: 0644]

index 77e216a3fd01098673b3fa7b4d0ec9574e7cfc14..26532c6bc5d781470c68f19afe04434cf36cc5a3 100644 (file)
 package org.sonar.core.config;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.PropertyType;
 import org.sonar.api.config.EmailSettings;
 import org.sonar.api.config.PropertyDefinition;
 import org.sonar.api.resources.Qualifiers;
+import org.sonar.core.extension.PluginRiskConsent;
 
 import static java.util.Arrays.asList;
 import static org.sonar.api.PropertyType.BOOLEAN;
+import static org.sonar.api.PropertyType.SINGLE_SELECT_LIST;
 import static org.sonar.api.PropertyType.STRING;
+import static org.sonar.core.extension.PluginRiskConsent.NOT_ACCEPTED;
 
 public class CorePropertyDefinitions {
 
@@ -39,15 +44,17 @@ public class CorePropertyDefinitions {
 
   private static final String CATEGORY_ORGANIZATIONS = "organizations";
 
-  //TODO remove
+  // TODO remove
   @Deprecated
   public static final String ORGANIZATIONS_ANYONE_CAN_CREATE = "sonar.organizations.anyoneCanCreate";
 
-  //TODO remove
+  // TODO remove
   @Deprecated
   public static final String ORGANIZATIONS_CREATE_PERSONAL_ORG = "sonar.organizations.createPersonalOrg";
   public static final String DISABLE_NOTIFICATION_ON_BUILT_IN_QPROFILES = "sonar.builtInQualityProfiles.disableNotificationOnUpdate";
 
+  public static final String PLUGINS_RISK_CONSENT = "sonar.plugins.risk.consent";
+
   private CorePropertyDefinitions() {
     // only static stuff
   }
@@ -100,6 +107,14 @@ public class CorePropertyDefinitions {
         .category(CoreProperties.CATEGORY_GENERAL)
         .type(BOOLEAN)
         .build(),
+      PropertyDefinition.builder(PLUGINS_RISK_CONSENT)
+        .name("State of user plugins risk consent")
+        .description("Determine whether user is required to accept plugins risk consent")
+        .defaultValue(NOT_ACCEPTED.name())
+        .options(Arrays.stream(PluginRiskConsent.values()).map(Enum::name).collect(Collectors.toList()))
+        .hidden()
+        .type(SINGLE_SELECT_LIST)
+        .build(),
 
       // WEB LOOK&FEEL
       PropertyDefinition.builder(WebConstants.SONAR_LF_LOGO_URL)
diff --git a/sonar-core/src/main/java/org/sonar/core/extension/PluginRiskConsent.java b/sonar-core/src/main/java/org/sonar/core/extension/PluginRiskConsent.java
new file mode 100644 (file)
index 0000000..80d976b
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.core.extension;
+
+public enum PluginRiskConsent {
+  NOT_ACCEPTED,
+  REQUIRED,
+  ACCEPTED
+}