continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r190355 - in /maven/continuum/trunk/continuum-web/src/main: java/org/apache/maven/continuum/web/validation/SafePathValidator.java resources/META-INF/plexus/components.xml resources/forms/shellProject.xml resources/localization/Continuum.properties resources/templates/screens/Add.vm
Date Mon, 13 Jun 2005 05:39:56 GMT
Author: jvanzyl
Date: Sun Jun 12 22:39:56 2005
New Revision: 190355

URL: http://svn.apache.org/viewcvs?rev=190355&view=rev
Log:
o adding a validator that makes sure a wandering path isn't entered for an
  executable, for shell and ant projects the executables have to be in the
  path or in the working directory.

Added:
    maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/SafePathValidator.java
Modified:
    maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/trunk/continuum-web/src/main/resources/forms/shellProject.xml
    maven/continuum/trunk/continuum-web/src/main/resources/localization/Continuum.properties
    maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Add.vm

Added: maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/SafePathValidator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/SafePathValidator.java?rev=190355&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/SafePathValidator.java
(added)
+++ maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/SafePathValidator.java
Sun Jun 12 22:39:56 2005
@@ -0,0 +1,42 @@
+package org.apache.maven.continuum.web.validation;
+
+import java.util.List;
+
+import org.apache.maven.scm.manager.ScmManager;
+
+import org.codehaus.plexus.formica.FormicaException;
+import org.codehaus.plexus.formica.validation.AbstractValidator;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id: ScmUrlValidator.java 170819 2005-05-18 20:34:26Z trygvis $
+ */
+public class SafePathValidator
+    extends AbstractValidator
+{
+    public static final String FILE_SEPARATOR = "file.separator";
+
+    public boolean validate( String path )
+        throws FormicaException
+    {
+        // ----------------------------------------------------------------------
+        // Normalize what we have to start ...
+        // ----------------------------------------------------------------------
+
+        String normalizedPath = FileUtils.normalize( path );
+
+        if ( normalizedPath.startsWith( System.getProperty( FILE_SEPARATOR ) ) )
+        {
+            return false;
+        }
+
+        if ( normalizedPath.startsWith( ".." ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+}

Modified: maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml?rev=190355&r1=190354&r2=190355&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml
Sun Jun 12 22:39:56 2005
@@ -266,6 +266,12 @@
       </requirements>
     </component>
 
+    <component>
+      <role>org.codehaus.plexus.formica.validation.Validator</role>
+      <role-hint>safe-path</role-hint>
+      <implementation>org.apache.maven.continuum.web.validation.SafePathValidator</implementation>
+    </component>
+
     <!--
      |
      | Content Generators

Modified: maven/continuum/trunk/continuum-web/src/main/resources/forms/shellProject.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/forms/shellProject.xml?rev=190355&r1=190354&r2=190355&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/forms/shellProject.xml (original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/forms/shellProject.xml Sun Jun
12 22:39:56 2005
@@ -11,6 +11,10 @@
           <id>required</id>
           <error-message-key>project.executable.error</error-message-key>
         </validator>
+        <validator>
+          <id>safe-path</id>
+          <error-message-key>project.executable.safepath.error</error-message-key>
+        </validator>
       </validators>
       <expression>executable</expression>
       <type>text</type>

Modified: maven/continuum/trunk/continuum-web/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/localization/Continuum.properties?rev=190355&r1=190354&r2=190355&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/localization/Continuum.properties
(original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/localization/Continuum.properties
Sun Jun 12 22:39:56 2005
@@ -72,6 +72,16 @@
 project.phase.message = Enter the phase or goals to execute (default: install)
 
 // ----------------------------------------------------------------------
+// Shell project
+// ----------------------------------------------------------------------
+
+project.arguments.label = Arguments
+project.arguments.message = Enter shell script arguments, if any
+project.arguments.error =
+
+project.executable.safepath.error = Executable must be in the path, or must be in the working
directory
+
+// ----------------------------------------------------------------------
 // Ant Project
 // ----------------------------------------------------------------------
 
@@ -90,14 +100,6 @@
 project.version.label = Version
 project.version.error = You must provide a version
 project.version.message = Enter the version of the project
-
-// ----------------------------------------------------------------------
-// Shell project
-// ----------------------------------------------------------------------
-
-project.arguments.label = Arguments
-project.arguments.message = Enter shell script arguments, if any
-project.arguments.error =
 
 // ----------------------------------------------------------------------
 // General errors

Modified: maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Add.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Add.vm?rev=190355&r1=190354&r2=190355&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Add.vm (original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/Add.vm Sun Jun
12 22:39:56 2005
@@ -1,3 +1,4 @@
+$page.setTitle( "Add Project" )
 #if ( !$fid )
   #set ( $fid = $data.getParameters().getString( "fid" ) )
 #end



Mime
View raw message