]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9448 Sanitize api/qualityprofiles/compare
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 22 Jun 2017 08:19:14 +0000 (10:19 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Mon, 26 Jun 2017 07:09:42 +0000 (09:09 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CompareAction.java
server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/compare-example.json [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-compare.json [deleted file]

index 6bd6685c4d022100d7f7bdb2be6f51e9f564bc81..2afadf8c4a3a76afea850205180bd35a720a12d2 100644 (file)
@@ -35,7 +35,6 @@ import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService.NewAction;
 import org.sonar.api.server.ws.WebService.NewController;
 import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.core.util.Uuids;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.qualityprofile.ActiveRuleDto;
@@ -47,6 +46,8 @@ import org.sonar.server.qualityprofile.QProfileComparison.ActiveRuleDiff;
 import org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
+import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02;
 
 public class CompareAction implements QProfileWsAction {
 
@@ -84,17 +85,17 @@ public class CompareAction implements QProfileWsAction {
       .setDescription("Compare two quality profiles.")
       .setHandler(this)
       .setInternal(true)
-      .setResponseExample(getClass().getResource("example-compare.json"))
+      .setResponseExample(getClass().getResource("compare-example.json"))
       .setSince("5.2");
 
     compare.createParam(PARAM_LEFT_KEY)
-      .setDescription("A profile key.")
-      .setExampleValue(Uuids.UUID_EXAMPLE_01)
+      .setDescription("Profile key.")
+      .setExampleValue(UUID_EXAMPLE_01)
       .setRequired(true);
 
     compare.createParam(PARAM_RIGHT_KEY)
       .setDescription("Another profile key.")
-      .setExampleValue(Uuids.UUID_EXAMPLE_02)
+      .setExampleValue(UUID_EXAMPLE_02)
       .setRequired(true);
   }
 
@@ -148,7 +149,7 @@ public class CompareAction implements QProfileWsAction {
     json.endObject().close();
   }
 
-  private void writeProfile(JsonWriter json, QProfileDto profile) {
+  private static void writeProfile(JsonWriter json, QProfileDto profile) {
     json.prop(ATTRIBUTE_KEY, profile.getKee())
       .prop(ATTRIBUTE_NAME, profile.getName());
   }
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/compare-example.json b/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/compare-example.json
new file mode 100644 (file)
index 0000000..82f84ee
--- /dev/null
@@ -0,0 +1,65 @@
+{
+   "left" : {
+      "key" : "AU-TpxcA-iU5OvuD2FL1",
+      "name" : "My Profile"
+   },
+   "right" : {
+      "key" : "AU-TpxcA-iU5OvuD2FL5",
+      "name" : "My Other Profile"
+   },
+   "same" : [
+      {
+         "key" : "javascript:EqEqEq",
+         "pluginKey" : "javascript",
+         "pluginName" : "SonarQube",
+         "languageKey": "js",
+         "languageName": "JavaScript",
+         "name" : "\"===\" and \"!==\" should be used instead of \"==\" and \"!=\"",
+         "severity" : "MAJOR"
+      }
+   ],
+   "inLeft" : [
+      {
+         "key" : "javascript:TrailingWhitespace",
+         "pluginKey" : "javascript",
+         "pluginName" : "SonarQube",
+         "languageKey": "js",
+         "languageName": "JavaScript",
+         "name" : "Avoid trailing whitespaces",
+         "severity" : "MAJOR"
+      }
+   ],
+   "inRight" : [
+      {
+         "key" : "javascript:TabCharacter",
+         "pluginKey" : "javascript",
+         "pluginName" : "SonarQube",
+         "languageKey": "js",
+         "languageName": "JavaScript",
+         "name" : "Avoid use of tabulation character",
+         "severity" : "MINOR"
+      }
+   ],
+   "modified" : [
+      {
+         "key" : "javascript:ExcessiveParameterList",
+         "pluginKey" : "javascript",
+         "pluginName" : "SonarQube",
+         "languageKey": "js",
+         "languageName": "JavaScript",
+         "name" : "Avoid function with too many parameters",
+         "right" : {
+            "severity" : "MAJOR",
+            "params" : {
+               "maximumFunctionParameters" : "7"
+            }
+         },
+         "left" : {
+            "severity" : "MAJOR",
+            "params" : {
+               "maximumFunctionParameters" : "10"
+            }
+         }
+      }
+   ]
+}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-compare.json b/server/sonar-server/src/main/resources/org/sonar/server/qualityprofile/ws/example-compare.json
deleted file mode 100644 (file)
index 82f84ee..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-{
-   "left" : {
-      "key" : "AU-TpxcA-iU5OvuD2FL1",
-      "name" : "My Profile"
-   },
-   "right" : {
-      "key" : "AU-TpxcA-iU5OvuD2FL5",
-      "name" : "My Other Profile"
-   },
-   "same" : [
-      {
-         "key" : "javascript:EqEqEq",
-         "pluginKey" : "javascript",
-         "pluginName" : "SonarQube",
-         "languageKey": "js",
-         "languageName": "JavaScript",
-         "name" : "\"===\" and \"!==\" should be used instead of \"==\" and \"!=\"",
-         "severity" : "MAJOR"
-      }
-   ],
-   "inLeft" : [
-      {
-         "key" : "javascript:TrailingWhitespace",
-         "pluginKey" : "javascript",
-         "pluginName" : "SonarQube",
-         "languageKey": "js",
-         "languageName": "JavaScript",
-         "name" : "Avoid trailing whitespaces",
-         "severity" : "MAJOR"
-      }
-   ],
-   "inRight" : [
-      {
-         "key" : "javascript:TabCharacter",
-         "pluginKey" : "javascript",
-         "pluginName" : "SonarQube",
-         "languageKey": "js",
-         "languageName": "JavaScript",
-         "name" : "Avoid use of tabulation character",
-         "severity" : "MINOR"
-      }
-   ],
-   "modified" : [
-      {
-         "key" : "javascript:ExcessiveParameterList",
-         "pluginKey" : "javascript",
-         "pluginName" : "SonarQube",
-         "languageKey": "js",
-         "languageName": "JavaScript",
-         "name" : "Avoid function with too many parameters",
-         "right" : {
-            "severity" : "MAJOR",
-            "params" : {
-               "maximumFunctionParameters" : "7"
-            }
-         },
-         "left" : {
-            "severity" : "MAJOR",
-            "params" : {
-               "maximumFunctionParameters" : "10"
-            }
-         }
-      }
-   ]
-}