]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10040 add length validation to ce ws
authorGuillaume Jambet <guillaume.jambet@sonarsource.com>
Thu, 2 Nov 2017 14:38:41 +0000 (15:38 +0100)
committerGuillaume Jambet <guillaume.jambet@gmail.com>
Wed, 8 Nov 2017 12:51:31 +0000 (13:51 +0100)
server/sonar-server/src/main/java/org/sonar/server/ce/ws/SubmitAction.java

index 8fbcdc69a6c7c52cd60f5eece463f5c3d4b66409..f00b66f0dd73201e14b0c08ca25d23284d68b4f2 100644 (file)
@@ -33,6 +33,8 @@ import org.sonar.server.organization.DefaultOrganizationProvider;
 import org.sonar.server.ws.WsUtils;
 import org.sonarqube.ws.WsCe;
 
+import static org.sonar.core.component.ComponentKeys.MAX_COMPONENT_KEY_LENGTH;
+import static org.sonar.db.component.ComponentValidator.MAX_COMPONENT_NAME_LENGTH;
 import static org.sonar.server.ws.WsUtils.checkRequest;
 
 public class SubmitAction implements CeWsAction {
@@ -72,6 +74,7 @@ public class SubmitAction implements CeWsAction {
     action
       .createParam(PARAM_PROJECT_KEY)
       .setRequired(true)
+      .setMaximumLength(MAX_COMPONENT_KEY_LENGTH)
       .setDescription("Key of project")
       .setExampleValue("my_project");
 
@@ -83,6 +86,7 @@ public class SubmitAction implements CeWsAction {
     action
       .createParam(PARAM_PROJECT_NAME)
       .setRequired(false)
+      .setMaximumLength(MAX_COMPONENT_NAME_LENGTH)
       .setDescription("Optional name of the project, used only if the project does not exist yet.")
       .setExampleValue("My Project");