Return-Path: X-Original-To: apmail-continuum-commits-archive@www.apache.org Delivered-To: apmail-continuum-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 677125873 for ; Tue, 10 May 2011 22:47:02 +0000 (UTC) Received: (qmail 85841 invoked by uid 500); 10 May 2011 22:47:02 -0000 Delivered-To: apmail-continuum-commits-archive@continuum.apache.org Received: (qmail 85813 invoked by uid 500); 10 May 2011 22:47:02 -0000 Mailing-List: contact commits-help@continuum.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@continuum.apache.org Delivered-To: mailing list commits@continuum.apache.org Received: (qmail 85806 invoked by uid 99); 10 May 2011 22:47:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 May 2011 22:47:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 May 2011 22:46:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6548B2388A66; Tue, 10 May 2011 22:46:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1101669 [4/4] - in /continuum/branches/continuum-1.3.x: ./ continuum-webapp-test/src/test/resources/ continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/p... Date: Tue, 10 May 2011 22:46:25 -0000 To: commits@continuum.apache.org From: ctan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110510224627.6548B2388A66@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp Tue May 10 22:46:21 2011 @@ -30,11 +30,11 @@ @@ -70,9 +70,9 @@ - ${project.id} + - ${pageScope.project.name} + @@ -80,19 +80,19 @@ - ${project.projectGroupId} - ${project.id} - ${project.name} - ${project.buildInSuccessId} + + + + - ${project.buildNumber} + - ${project.buildNumber} + - ${project.buildNumber} +   @@ -110,8 +110,8 @@ - ${project.id} - ${project.projectGroupId} + + @@ -120,8 +120,8 @@ - ${project.id} - ${project.projectGroupId} + + @@ -154,8 +154,8 @@ - ${project.id} - ${project.name} + + " alt="" title="" border="0"> @@ -173,7 +173,7 @@ - ${project.id} + " alt="" title="" border="0"> @@ -191,7 +191,7 @@ - ${project.id} + " alt="" title="" border="0"/> @@ -213,7 +213,7 @@ test="${projectIdle}"> - ${project.id} + struts.token Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/groupSummary.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/groupSummary.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/groupSummary.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/groupSummary.jsp Tue May 10 22:46:21 2011 @@ -33,7 +33,7 @@
-

${infoMessage}

+

@@ -63,13 +63,18 @@ filterable="false"> - ${group.id}">${group.name} + + + + + + - ${group.id} + @@ -84,7 +89,7 @@ - ${group.id} + <s:text name=" title="" border="0"> @@ -98,7 +103,7 @@ - ${group.id} + <s:text name=" title="" border="0"> Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/navigations/ProjectMenu.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/navigations/ProjectMenu.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/navigations/ProjectMenu.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/navigations/ProjectMenu.jsp Tue May 10 22:46:21 2011 @@ -20,6 +20,7 @@ <%@ taglib uri="/struts-tags" prefix="s" %> <%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%> <%@ taglib uri="continuum" prefix="c1" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

@@ -43,13 +44,13 @@ - + - + @@ -58,7 +59,7 @@ - + @@ -67,7 +68,7 @@ - + Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupAdd.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupAdd.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupAdd.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupAdd.jsp Tue May 10 22:46:21 2011 @@ -30,8 +30,7 @@

- - +
Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupBuildDefinition.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupBuildDefinition.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupBuildDefinition.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupBuildDefinition.jsp Tue May 10 22:46:21 2011 @@ -35,8 +35,8 @@ - ${projectGroupId} - ${projectGroup.name} + +
Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupEdit.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupEdit.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupEdit.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupEdit.jsp Tue May 10 22:46:21 2011 @@ -32,18 +32,18 @@
- -
-

-
-
- + +
+

+
+
+

-
+
- : ${groupSummary.numSuccesses} + :  " alt=""> -   : ${groupSummary.numErrors} +   :  " alt=""> -   : ${groupSummary.numFailures} +   :  " alt="">
Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp Tue May 10 22:46:21 2011 @@ -41,7 +41,7 @@ --> -

${projectGroup.name}

+

- ${pageScope.project.id} + - ${pageScope.project.name} +
@@ -65,8 +65,8 @@ - ${pageScope.project.id} - ${project.name} + + " alt="" title="" border="0"> @@ -90,8 +90,8 @@ test="${pageScope.project.state == 1 || pageScope.project.state == 10 || pageScope.project.state == 2 || pageScope.project.state == 3 || pageScope.project.state == 4}"> - ${pageScope.project.id} - ${pageScope.project.name} + + struts.token Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupNotifier.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupNotifier.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupNotifier.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupNotifier.jsp Tue May 10 22:46:21 2011 @@ -35,7 +35,7 @@ - ${projectGroupId} + Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupReleaseResults.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupReleaseResults.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupReleaseResults.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupReleaseResults.jsp Tue May 10 22:46:21 2011 @@ -37,7 +37,7 @@ -

${projectGroup.name}

+

@@ -72,8 +72,8 @@ - ${pageScope.result.id} - ${projectGroupId} + + Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp Tue May 10 22:46:21 2011 @@ -82,7 +82,7 @@ -

${projectGroup.name}

+

@@ -190,8 +190,8 @@ - ${projectGroupId} - ${projectGroup.name} + + Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectView.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectView.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectView.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectView.jsp Tue May 10 22:46:21 2011 @@ -35,7 +35,7 @@ -

${project.name}

+

@@ -45,7 +45,7 @@ - ${project.projectGroup.id} + @@ -79,8 +79,8 @@

- ${project.id} - ${project.projectGroup.id} + +
@@ -114,10 +114,10 @@ - ${notifier.id} - - ${project.projectGroup.id} - ${notifier.type} + + + + " alt="" title="" border="0"> @@ -137,10 +137,10 @@ - - ${project.projectGroup.id} - ${notifier.type} - ${notifier.id} + + + + " alt="" title="" border="0"> Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/releases.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/releases.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/releases.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/releases.jsp Tue May 10 22:46:21 2011 @@ -48,11 +48,11 @@ - ${pageScope.releaseSummary.releaseId} - ${pageScope.releaseSummary.projectId} - ${pageScope.releaseSummary.releaseGoal} + + + - ${pageScope.releaseSummary.releaseId} + Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/schedules.jsp URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/schedules.jsp?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/schedules.jsp (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/schedules.jsp Tue May 10 22:46:21 2011 @@ -46,15 +46,15 @@ - ${pageScope.schedule.id} + " alt="" title="" border="0" /> - ${pageScope.schedule.id} - ${pageScope.schedule.name} + + struts.token Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/AddProjectActionTest.java URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/AddProjectActionTest.java?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/AddProjectActionTest.java (original) +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/AddProjectActionTest.java Tue May 10 22:46:21 2011 @@ -42,6 +42,16 @@ public class AddProjectActionTest private final Mock continuumMock; + private static final String VALID_NAME_CHARACTER = "abcABC123whitespaces_.:-"; + + private static final String VALID_VERSION_CHARACTER = "abcABC123.-"; + + private static final String VALID_SCM_URL_CHARACTER = "abcABC123_.:-#~=@\\/|[]"; + + private static final String VALID_SCM_TAG_CHARACTER = "abcABC123_.:-#~=@\\/|[]"; + + private static final String VALID_DESCRIPTION_CHARACTER = "abcABC123whitespaces_.-"; + public AddProjectActionTest() { action = new AddProjectActionStub(); @@ -90,6 +100,35 @@ public class AddProjectActionTest action.add(); continuumMock.verify(); } + + public void testAddAntProjectWithValidValues() + throws Exception + { + List projects = createProjectList(); + continuumMock.expects( once() ).method( "getProjects" ).will( returnValue( projects ) ); + continuumMock.expects( once() ).method( "addProject" ).will( returnValue( 3 ) ); + + action.setProjectName( VALID_NAME_CHARACTER ); + action.setProjectDescription( VALID_DESCRIPTION_CHARACTER ); + action.setProjectVersion( VALID_VERSION_CHARACTER ); + action.setProjectScmUrl( VALID_SCM_URL_CHARACTER ); + action.setProjectScmTag( VALID_SCM_TAG_CHARACTER ); + action.setProjectType( "ant" ); + action.setSelectedProjectGroup( 1 ); + action.setBuildDefintionTemplateId( 1 ); + + // validate + action.validate(); + + // verify + assertFalse( action.hasActionErrors() ); + assertEquals( 0, action.getActionErrors().size() ); + + // add + action.add(); + + continuumMock.verify(); + } /** * Test add of Shell project @@ -116,7 +155,36 @@ public class AddProjectActionTest action.add(); continuumMock.verify(); } - + + public void testAddShellProjectWithValidValues() + throws Exception + { + List projects = createProjectList(); + continuumMock.expects( once() ).method( "getProjects" ).will( returnValue( projects ) ); + continuumMock.expects( once() ).method( "addProject" ).will( returnValue( 3 ) ); + + action.setProjectName( VALID_NAME_CHARACTER ); + action.setProjectDescription( VALID_DESCRIPTION_CHARACTER ); + action.setProjectVersion( VALID_VERSION_CHARACTER ); + action.setProjectScmUrl( VALID_SCM_URL_CHARACTER ); + action.setProjectScmTag( VALID_SCM_TAG_CHARACTER ); + action.setProjectType( "shell" ); + action.setSelectedProjectGroup( 1 ); + action.setBuildDefintionTemplateId( 1 ); + + // validate + action.validate(); + + // verify + assertFalse( action.hasActionErrors() ); + assertEquals( 0, action.getActionErrors().size() ); + + // add + action.add(); + + continuumMock.verify(); + } + private List createProjectList() { List projects = new ArrayList(); Modified: continuum/branches/continuum-1.3.x/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java (original) +++ continuum/branches/continuum-1.3.x/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java Tue May 10 22:46:21 2011 @@ -29,6 +29,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang.StringUtils; import org.apache.continuum.buildmanager.BuildManagerException; import org.apache.continuum.buildmanager.BuildsManager; import org.apache.continuum.dao.SystemConfigurationDao; @@ -66,7 +68,6 @@ import org.apache.maven.continuum.xmlrpc import org.codehaus.plexus.redback.authorization.AuthorizationException; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.redback.role.RoleManagerException; -import org.codehaus.plexus.util.StringUtils; import net.sf.dozer.util.mapping.DozerBeanMapperSingletonWrapper; import net.sf.dozer.util.mapping.MapperIF; @@ -79,6 +80,46 @@ import net.sf.dozer.util.mapping.MapperI public class ContinuumServiceImpl extends AbstractContinuumSecureService { + private static final String NAME_VALID_EXPRESSION = "[a-zA-Z0-9_.\\s\\-]*"; + + private static final String DIRECTORY_VALID_EXPRESSION = "[A-Za-z0-9_/\\s:.\\\\-]*"; + + private static final String URL_VALID_EXPRESSION = "[A-Za-z0-9_.@:/-]*"; + + private static final String PROJECT_VERSION_VALID_EXPRESSION = "[a-zA-Z0-9.-]*"; + + private static final String PROJECT_SCM_URL_VALID_EXPRESSION = "[a-zA-Z0-9_.:${}#~=@\\/|\\[\\]-]*"; + + private static final String PROJECT_SCM_TAG_VALID_EXPRESSION = "[a-zA-Z0-9_.:@\\/|#~=\\[\\]-]*"; + + private static final String PROJECT_GROUP_ID_VALID_EXPRESSION = "[A-Za-z0-9.]*"; + + private static final String PROJECT_ARTIFACT_ID_VALID_EXPRESSION = "[A-Za-z0-9\\-]*"; + + private static final String PROJECT_EXECUTOR_OR_BUILDDEF_TYPE_VALID_EXPRESSION = "maven2|maven-1|ant|shell"; + + private static final String SCHEDULE_CRON_VALID_EXPRESSION = "[A-Z0-9\\s*/,-?#]*"; + + private static final String PROJECTGROUP_ID_VALID_EXPRESSION = "[a-zA-Z0-9.\\s]*"; + + private static final String REPOSITORY_LAYOUT_VALID_EXPRESSION = "default|legacy"; + + private static final String BUILD_DEFINITION_ARGUMENTS_VALID_EXPRESSION = "[A-Za-z0-9_./=,\":\\s\\\\-]*"; + + private static final String BUILD_DEFINITION_GOALS_VALID_EXPRESSION = "[A-Za-z0-9_:\\s\\-]*"; + + private static final String BUILD_DEFINITION_BUILD_FILE_VALID_EXPRESSION = "[A-Za-z0-9_.\\-]*"; + + private static final String INSTALLATION_VARNAME_VALID_EXPRESSION = "[A-Za-z][A-Za-z0-9_]*"; + + private static final String INSTALLATION_VARVALUE_VALID_EXPRESSION = "[A-Za-z0-9_.:=${}/\\s\\\\-]*"; + + private static final String INSTALLATION_TYPE_VALID_EXPRESSION = "jdk|maven2|maven1|ant|envvar"; + + private static final String DIRECTORY_TYPE_VALID_EXPRESSION = "releases|buildOutput"; + + private static final String NOTIFIER_TYPE_VALID_EXPRESSION = "irc|jabber|msn|mail|wagon"; + private static final MapperIF mapper = DozerBeanMapperSingletonWrapper.getInstance(); /** @@ -167,6 +208,31 @@ public class ContinuumServiceImpl public ProjectSummary updateProject( ProjectSummary project ) throws ContinuumException { + if ( StringUtils.isNotBlank( project.getName() ) && + !project.getName().matches( NAME_VALID_EXPRESSION ) ) + //!GenericValidator.matchRegexp( project.getName(), NAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Name contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( project.getScmTag() ) && + !project.getScmTag().matches( PROJECT_SCM_TAG_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Scm Tag contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( project.getScmUrl() ) && + !project.getScmUrl().matches( PROJECT_SCM_URL_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Scm Url contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( project.getVersion() ) && + !project.getVersion().matches( PROJECT_VERSION_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Version contains invalid characters" ); + } + ProjectSummary ps = getProjectSummary( project.getId() ); checkRemoveProjectFromGroupAuthorization( ps.getProjectGroup().getName() ); @@ -326,6 +392,11 @@ public class ContinuumServiceImpl throw new ContinuumException( "project group name can't be spaces" ); } + if ( !projectGroup.getName().matches( NAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "ProjectGroup Name contains invalid characters" ); + } + org.apache.maven.continuum.model.project.ProjectGroup pg = continuum.getProjectGroupWithProjects( projectGroup.getId() ); @@ -347,7 +418,7 @@ public class ContinuumServiceImpl } } - pg.setDescription( projectGroup.getDescription() ); + pg.setDescription( StringEscapeUtils.escapeXml( projectGroup.getDescription() ) ); org.apache.continuum.model.repository.LocalRepository repo = new org.apache.continuum.model.repository.LocalRepository(); @@ -360,11 +431,23 @@ public class ContinuumServiceImpl public ProjectGroupSummary addProjectGroup( String groupName, String groupId, String description ) throws Exception { + if ( StringUtils.isNotBlank( groupId ) && + !groupId.matches( PROJECTGROUP_ID_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "ProjectGroup Id contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( groupName ) && + !groupName.matches( NAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "ProjectGroup Name contains invalid characters" ); + } + org.apache.maven.continuum.model.project.ProjectGroup pg = new org.apache.maven.continuum.model.project.ProjectGroup(); pg.setName( groupName ); pg.setGroupId( groupId ); - pg.setDescription( description ); + pg.setDescription( StringEscapeUtils.escapeXml( description ) ); continuum.addProjectGroup( pg ); return populateProjectGroupSummary( continuum.getProjectGroupByGroupId( groupId ) ); } @@ -378,6 +461,11 @@ public class ContinuumServiceImpl public ProjectNotifier updateNotifier( int projectid, ProjectNotifier newNotifier ) throws ContinuumException { + if ( StringUtils.isNotBlank( newNotifier.getType() ) && + !newNotifier.getType().matches( NOTIFIER_TYPE_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Notifier Type can only be 'irc, jabber, msn, mail or wagon" ); + } org.apache.maven.continuum.model.project.ProjectNotifier notifier = continuum.getNotifier( projectid, newNotifier.getId() ); @@ -396,6 +484,11 @@ public class ContinuumServiceImpl public ProjectNotifier addNotifier( int projectid, ProjectNotifier newNotifier ) throws ContinuumException { + if ( StringUtils.isNotBlank( newNotifier.getType() ) && + !newNotifier.getType().matches( NOTIFIER_TYPE_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Notifier Type can only be 'irc, jabber, msn, mail or wagon'" ); + } org.apache.maven.continuum.model.project.ProjectNotifier notifier = new org.apache.maven.continuum.model.project.ProjectNotifier(); @@ -427,6 +520,11 @@ public class ContinuumServiceImpl public ProjectNotifier updateGroupNotifier( int projectgroupid, ProjectNotifier newNotifier ) throws ContinuumException { + if ( StringUtils.isNotBlank( newNotifier.getType() ) && + !newNotifier.getType().matches( NOTIFIER_TYPE_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Notifier Type can only be 'irc, jabber, msn, mail, or wagon" ); + } org.apache.maven.continuum.model.project.ProjectNotifier notifier = continuum.getGroupNotifier( projectgroupid, newNotifier.getId() ); @@ -447,6 +545,13 @@ public class ContinuumServiceImpl { org.apache.maven.continuum.model.project.ProjectNotifier notifier = new org.apache.maven.continuum.model.project.ProjectNotifier(); + + if ( StringUtils.isNotBlank( newNotifier.getType() ) && + !newNotifier.getType().matches( NOTIFIER_TYPE_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Notifier Type can only be 'irc, jabber, msn, mail or wagon" ); + } + notifier.setConfiguration( newNotifier.getConfiguration() ); notifier.setFrom( newNotifier.getFrom() ); notifier.setRecipientType( newNotifier.getRecipientType() ); @@ -813,7 +918,7 @@ public class ContinuumServiceImpl org.apache.maven.continuum.model.project.Schedule storedSchedule = continuum.getSchedule( schedule.getId() ); storedSchedule.setActive( newSchedule.isActive() ); storedSchedule.setName( newSchedule.getName() ); - storedSchedule.setDescription( newSchedule.getDescription() ); + storedSchedule.setDescription( StringEscapeUtils.escapeXml( newSchedule.getDescription() ) ); storedSchedule.setDelay( newSchedule.getDelay() ); storedSchedule.setCronExpression( newSchedule.getCronExpression() ); storedSchedule.setMaxJobExecutionTime( newSchedule.getMaxJobExecutionTime() ); @@ -1475,9 +1580,65 @@ public class ContinuumServiceImpl { return null; } + + // validate + if ( StringUtils.isNotBlank( projectSummary.getArtifactId() ) && + !projectSummary.getArtifactId().matches( PROJECT_ARTIFACT_ID_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Artifact Id contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( projectSummary.getExecutorId() ) && + !projectSummary.getExecutorId().matches( PROJECT_EXECUTOR_OR_BUILDDEF_TYPE_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Executor Id can only be 'maven2, maven-1, ant or shell'" ); + } + + if ( StringUtils.isNotBlank( projectSummary.getGroupId() ) && + !projectSummary.getGroupId().matches( PROJECT_GROUP_ID_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Group Id contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( projectSummary.getName() ) && + !projectSummary.getName().matches( NAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Name contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( projectSummary.getScmTag() ) && + !projectSummary.getScmTag().matches( PROJECT_SCM_TAG_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Scm Tag contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( projectSummary.getScmUrl() ) && + !projectSummary.getScmUrl().matches( PROJECT_SCM_URL_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Scm Url contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( projectSummary.getUrl() ) && + !projectSummary.getUrl().matches( URL_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Url contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( projectSummary.getVersion() ) && + !projectSummary.getVersion().matches( PROJECT_VERSION_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Version contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( projectSummary.getWorkingDirectory() ) && + !projectSummary.getWorkingDirectory().matches( DIRECTORY_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Project Working Directory contains invalid characters" ); + } + project.setArtifactId( projectSummary.getArtifactId() ); project.setBuildNumber( projectSummary.getBuildNumber() ); - project.setDescription( projectSummary.getDescription() ); + project.setDescription( StringEscapeUtils.escapeXml( projectSummary.getDescription() ) ); project.setExecutorId( projectSummary.getExecutorId() ); project.setGroupId( projectSummary.getGroupId() ); project.setId( projectSummary.getId() ); @@ -1517,13 +1678,26 @@ public class ContinuumServiceImpl private org.apache.maven.continuum.model.project.ProjectGroup populateProjectGroupSummary( ProjectGroupSummary group, org.apache.maven.continuum.model.project.ProjectGroup g ) + throws ContinuumException { if ( group == null ) { return null; } - g.setDescription( group.getDescription() ); + if ( StringUtils.isNotBlank( group.getGroupId() ) && + !group.getGroupId().matches( PROJECTGROUP_ID_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "ProjectGroup Id contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( group.getName() ) && + !group.getName().matches( NAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "ProjectGroup Name contains invalid characters" ); + } + + g.setDescription( StringEscapeUtils.escapeXml( group.getDescription() ) ); g.setGroupId( group.getGroupId() ); g.setId( group.getId() ); g.setName( group.getName() ); @@ -1600,6 +1774,30 @@ public class ContinuumServiceImpl return null; } + if ( StringUtils.isNotBlank( buildDef.getArguments() ) && + !buildDef.getArguments().matches( BUILD_DEFINITION_ARGUMENTS_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Build Definition Arguments contain invalid characters" ); + } + + if ( StringUtils.isNotBlank( buildDef.getBuildFile() ) && + !buildDef.getBuildFile().matches( BUILD_DEFINITION_BUILD_FILE_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Build Definition Build File contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( buildDef.getGoals() ) && + !buildDef.getGoals().matches( BUILD_DEFINITION_GOALS_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Build Definition Goals contain invalid characters" ); + } + + if ( StringUtils.isNotBlank( buildDef.getType() ) && + !buildDef.getType().matches( PROJECT_EXECUTOR_OR_BUILDDEF_TYPE_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Build Definition Type can only be 'maven2, maven-1, ant, or shell'" ); + } + bd.setArguments( buildDef.getArguments() ); bd.setBuildFile( buildDef.getBuildFile() ); bd.setType( buildDef.getType() ); @@ -1638,16 +1836,29 @@ public class ContinuumServiceImpl private org.apache.maven.continuum.model.project.Schedule populateSchedule( Schedule schedule, org.apache.maven.continuum.model.project.Schedule s ) + throws ContinuumException { if ( schedule == null ) { return null; } + if ( StringUtils.isNotBlank( schedule.getCronExpression() ) && + !schedule.getCronExpression().matches( SCHEDULE_CRON_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Schedule Cron Expression contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( schedule.getName() ) && + !schedule.getName().matches( NAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Schedule Name contains invalid characters" ); + } + s.setActive( schedule.isActive() ); s.setCronExpression( schedule.getCronExpression() ); s.setDelay( schedule.getDelay() ); - s.setDescription( schedule.getDescription() ); + s.setDescription( StringEscapeUtils.escapeXml( schedule.getDescription() ) ); s.setId( schedule.getId() ); s.setMaxJobExecutionTime( schedule.getMaxJobExecutionTime() ); s.setName( schedule.getName() ); @@ -1668,11 +1879,17 @@ public class ContinuumServiceImpl return null; } + if ( StringUtils.isNotBlank( profile.getName() ) + && !profile.getName().matches( NAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Build Environment Name contains invalid characters" ); + } + try { newProfile.setActive( profile.isActive() ); newProfile.setBuildWithoutChanges( profile.isBuildWithoutChanges() ); - newProfile.setDescription( profile.getDescription() ); + newProfile.setDescription( StringEscapeUtils.escapeXml( profile.getDescription() ) ); newProfile.setName( profile.getName() ); newProfile.setScmMode( profile.getScmMode() ); if ( profile.getBuilder() != null ) @@ -1725,12 +1942,37 @@ public class ContinuumServiceImpl private org.apache.maven.continuum.model.system.Installation populateInstallation( Installation install, org.apache.maven.continuum.model.system.Installation inst ) + throws ContinuumException { if ( install == null ) { return null; } + if ( StringUtils.isNotBlank( install.getName() ) && + !install.getName().matches( NAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Installation Name contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( install.getType() ) && + !install.getType().matches( INSTALLATION_TYPE_VALID_EXPRESSION )) + { + throw new ContinuumException( "Installation Type contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( install.getVarName() ) && + !install.getVarName().matches( INSTALLATION_VARNAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Installation VarName contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( install.getVarValue() ) && + !install.getVarValue().matches( INSTALLATION_VARVALUE_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Installation VarValue contains invalid characters" ); + } + inst.setName( install.getName() ); inst.setType( install.getType() ); inst.setVarName( install.getVarName() ); @@ -1775,7 +2017,7 @@ public class ContinuumServiceImpl repoPurge.setDefaultPurge( repoPurgeConfig.isDefaultPurge() ); repoPurge.setDeleteAll( repoPurgeConfig.isDeleteAll() ); repoPurge.setDeleteReleasedSnapshots( repoPurgeConfig.isDeleteReleasedSnapshots() ); - repoPurge.setDescription( repoPurgeConfig.getDescription() ); + repoPurge.setDescription( StringEscapeUtils.escapeXml( repoPurgeConfig.getDescription() ) ); repoPurge.setEnabled( repoPurgeConfig.isEnabled() ); repoPurge.setRetentionCount( repoPurgeConfig.getRetentionCount() ); if ( repoPurgeConfig.getRepository() != null ) @@ -1817,10 +2059,22 @@ public class ContinuumServiceImpl return null; } + if ( StringUtils.isNotBlank( dirPurgeConfig.getDirectoryType() ) && + !dirPurgeConfig.getDirectoryType().matches( DIRECTORY_TYPE_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Directory Purge Configuration Type can only be 'releases or buildOutput'" ); + } + + if ( StringUtils.isNotBlank( dirPurgeConfig.getLocation() ) && + !dirPurgeConfig.getLocation().matches( DIRECTORY_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Directory Purge Configuration Location contains invalid characters" ); + } + dirPurge.setDaysOlder( dirPurgeConfig.getDaysOlder() ); dirPurge.setDefaultPurge( dirPurgeConfig.isDefaultPurge() ); dirPurge.setDeleteAll( dirPurgeConfig.isDeleteAll() ); - dirPurge.setDescription( dirPurgeConfig.getDescription() ); + dirPurge.setDescription( StringEscapeUtils.escapeXml( dirPurgeConfig.getDescription() ) ); dirPurge.setDirectoryType( dirPurgeConfig.getDirectoryType() ); dirPurge.setEnabled( dirPurgeConfig.isEnabled() ); @@ -1858,12 +2112,31 @@ public class ContinuumServiceImpl private org.apache.continuum.model.repository.LocalRepository populateLocalRepository( LocalRepository repository, org.apache.continuum.model.repository.LocalRepository repo ) + throws ContinuumException { if ( repository == null ) { return null; } + if ( StringUtils.isNotBlank( repository.getLayout() ) && + !repository.getLayout().matches( REPOSITORY_LAYOUT_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Repository Layout can only be 'default or legacy'" ); + } + + if ( StringUtils.isNotBlank( repository.getLocation() ) && + !repository.getLocation().matches( DIRECTORY_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Repository Location contains invalid characters" ); + } + + if ( StringUtils.isNotBlank( repository.getName() ) && + !repository.getName().matches( NAME_VALID_EXPRESSION ) ) + { + throw new ContinuumException( "Repository Name contains invalid characters" ); + } + repo.setLayout( repository.getLayout() ); repo.setLocation( repository.getLocation() ); repo.setName( repository.getName() ); Modified: continuum/branches/continuum-1.3.x/pom.xml URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/pom.xml?rev=1101669&r1=1101668&r2=1101669&view=diff ============================================================================== --- continuum/branches/continuum-1.3.x/pom.xml (original) +++ continuum/branches/continuum-1.3.x/pom.xml Tue May 10 22:46:21 2011 @@ -1596,6 +1596,11 @@ under the License. commons-logging-api 1.1 + + org.jsoup + jsoup + 1.5.2 +