diff options
259 files changed, 6282 insertions, 86 deletions
diff --git a/example-jetty-embedded/pom.xml b/example-jetty-embedded/pom.xml index 82d1dacbc7..5a7822d306 100644 --- a/example-jetty-embedded/pom.xml +++ b/example-jetty-embedded/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>example-jetty-embedded</artifactId> diff --git a/jetty-aggregate/jetty-all-server/pom.xml b/jetty-aggregate/jetty-all-server/pom.xml index 77408e07cf..615ac85311 100644 --- a/jetty-aggregate/jetty-all-server/pom.xml +++ b/jetty-aggregate/jetty-all-server/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-aggregate-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty.aggregate</groupId> diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index 139b372af2..723f4f8e7d 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-aggregate-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty.aggregate</groupId> diff --git a/jetty-aggregate/jetty-client/pom.xml b/jetty-aggregate/jetty-client/pom.xml index 6a5b360590..2fed88be39 100644 --- a/jetty-aggregate/jetty-client/pom.xml +++ b/jetty-aggregate/jetty-client/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-aggregate-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty.aggregate</groupId> diff --git a/jetty-aggregate/jetty-plus/pom.xml b/jetty-aggregate/jetty-plus/pom.xml index be6d292562..c818785f2c 100644 --- a/jetty-aggregate/jetty-plus/pom.xml +++ b/jetty-aggregate/jetty-plus/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-aggregate-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty.aggregate</groupId> diff --git a/jetty-aggregate/jetty-server/pom.xml b/jetty-aggregate/jetty-server/pom.xml index 814319dce7..62a3ec7b9d 100644 --- a/jetty-aggregate/jetty-server/pom.xml +++ b/jetty-aggregate/jetty-server/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-aggregate-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty.aggregate</groupId> diff --git a/jetty-aggregate/jetty-servlet/pom.xml b/jetty-aggregate/jetty-servlet/pom.xml index 581dad5c19..c7d3712856 100644 --- a/jetty-aggregate/jetty-servlet/pom.xml +++ b/jetty-aggregate/jetty-servlet/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-aggregate-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty.aggregate</groupId> diff --git a/jetty-aggregate/jetty-webapp/pom.xml b/jetty-aggregate/jetty-webapp/pom.xml index af96431776..aea41b912d 100644 --- a/jetty-aggregate/jetty-webapp/pom.xml +++ b/jetty-aggregate/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-aggregate-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty.aggregate</groupId> diff --git a/jetty-aggregate/pom.xml b/jetty-aggregate/pom.xml index 462ae76b08..16b432b6dd 100644 --- a/jetty-aggregate/pom.xml +++ b/jetty-aggregate/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-aggregate-project</artifactId> diff --git a/jetty-ajp/pom.xml b/jetty-ajp/pom.xml index e1c5373311..f88269051c 100644 --- a/jetty-ajp/pom.xml +++ b/jetty-ajp/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-ajp</artifactId> diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index 2a7d4a4060..563d77e219 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-annotations</artifactId> diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index 85ad3f179f..feab2d4d74 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-client</artifactId> diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml index 552995a122..2b1cd03333 100644 --- a/jetty-continuation/pom.xml +++ b/jetty-continuation/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-continuation</artifactId> diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index 91039d72d5..2e42e687e9 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-deploy</artifactId> diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 42dd09e601..8f5c1e3e5a 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -3,7 +3,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <artifactId>jetty-distribution</artifactId> <name>Jetty :: Distribution Assemblies</name> @@ -142,6 +142,16 @@ </artifactItem> <artifactItem> <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp-verifier</artifactId> + <version>${project.version}</version> + <classifier>config</classifier> + <type>jar</type> + <overWrite>true</overWrite> + <includes>**</includes> + <outputDirectory>${assembly.directory}</outputDirectory> + </artifactItem> + <artifactItem> + <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-plus</artifactId> <version>${project.version}</version> <classifier>config</classifier> @@ -262,6 +272,15 @@ <includes>**</includes> <outputDirectory>${assembly.directory}/lib</outputDirectory> </artifactItem> + <artifactItem> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp-verifier</artifactId> + <version>${project.version}</version> + <type>jar</type> + <overWrite>true</overWrite> + <includes>**</includes> + <outputDirectory>${assembly.directory}/lib</outputDirectory> + </artifactItem> <artifactItem> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-deploy</artifactId> @@ -496,4 +515,4 @@ <version>${project.version}</version> </dependency> </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml index 912cc35c34..d1fa2afd27 100644 --- a/jetty-http/pom.xml +++ b/jetty-http/pom.xml @@ -2,7 +2,7 @@ <parent> <artifactId>jetty-project</artifactId> <groupId>org.eclipse.jetty</groupId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty</groupId> diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index 1226373759..46f1957b98 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -2,7 +2,7 @@ <parent> <artifactId>jetty-project</artifactId> <groupId>org.eclipse.jetty</groupId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty</groupId> diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml index 0721cb962b..e56dd6ef1a 100644 --- a/jetty-jaspi/pom.xml +++ b/jetty-jaspi/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-jaspi</artifactId> diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml index 18bad4a4ac..9456c3789a 100644 --- a/jetty-jmx/pom.xml +++ b/jetty-jmx/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-jmx</artifactId> diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index 574e1393a1..596600ee0a 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-jndi</artifactId> diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index 9396114f38..2195586e4c 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-plus</artifactId> diff --git a/jetty-policy/pom.xml b/jetty-policy/pom.xml index 9307e573c5..b87d7ea525 100644 --- a/jetty-policy/pom.xml +++ b/jetty-policy/pom.xml @@ -3,7 +3,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-policy</artifactId> diff --git a/jetty-policy/src/main/config/etc/jetty-policy.xml b/jetty-policy/src/main/config/etc/jetty-policy.xml new file mode 100644 index 0000000000..6d8848cc4b --- /dev/null +++ b/jetty-policy/src/main/config/etc/jetty-policy.xml @@ -0,0 +1,23 @@ +<?xml version="1.0"?> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> + +<!-- =============================================================== --> +<!-- mechanic for starting jetty policy --> +<!-- --> +<!-- =============================================================== --> + + + +<Configure id="Policy" class="org.eclipse.jetty.policy.JettyPolicyConfigurator"> + + <Call name="addPolicy"> + <Arg><SystemProperty name="jetty.home"/>/lib/policy/jetty.policy</Arg> + </Call> + + <Call name="addProperty"> + <Arg>jetty.home</Arg> + <Arg><SystemProperty name="jetty.home"/></Arg> + </Call> + + <Call name="initialize"/> +</Configure> diff --git a/jetty-policy/src/main/java/org/eclipse/jetty/policy/JettyPolicy.java b/jetty-policy/src/main/java/org/eclipse/jetty/policy/JettyPolicy.java index ac9b037964..04b105d82b 100644 --- a/jetty-policy/src/main/java/org/eclipse/jetty/policy/JettyPolicy.java +++ b/jetty-policy/src/main/java/org/eclipse/jetty/policy/JettyPolicy.java @@ -73,6 +73,8 @@ public class JettyPolicy extends Policy public JettyPolicy(Set<String> policies, Map<String, String> properties) { + System.out.println("Activating the JettyPolicy"); + try { __DEBUG = Boolean.getBoolean("org.eclipse.jetty.policy.DEBUG"); @@ -288,11 +290,13 @@ public class JettyPolicy extends Policy initialize(); } - for (Iterator<Object> i = _cache.keySet().iterator(); i.hasNext();) + synchronized (_cache) { - System.out.println(i.next().toString()); + for (Iterator<Object> i = _cache.keySet().iterator(); i.hasNext();) + { + System.out.println(i.next().toString()); + } } - if (__DEBUG) { diff --git a/jetty-policy/src/main/java/org/eclipse/jetty/policy/JettyPolicyConfigurator.java b/jetty-policy/src/main/java/org/eclipse/jetty/policy/JettyPolicyConfigurator.java new file mode 100644 index 0000000000..d397a1f5dd --- /dev/null +++ b/jetty-policy/src/main/java/org/eclipse/jetty/policy/JettyPolicyConfigurator.java @@ -0,0 +1,58 @@ +package org.eclipse.jetty.policy; + +//======================================================================== +//Copyright (c) Webtide LLC +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +// +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +// +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +// +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + +import java.security.Policy; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * + * + */ +public class JettyPolicyConfigurator +{ + Set<String> _policies= new HashSet<String>(); + Map<String, String> _properties = new HashMap<String,String>(); + + public JettyPolicyConfigurator() + { + + } + + public void addPolicy( String policy ) + { + _policies.add(policy); + } + + public void addProperty( String name, String value ) + { + _properties.put(name,value); + } + + public void initialize() + { + System.out.println("Initializing Jetty Policy"); + + JettyPolicy jpolicy = new JettyPolicy( _policies, _properties ); + Policy.setPolicy(jpolicy); + System.setSecurityManager(new SecurityManager()); + } + +} diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index af06f3668e..651e3226cd 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-rewrite</artifactId> diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml index 26b6d607ba..04e3856c31 100644 --- a/jetty-security/pom.xml +++ b/jetty-security/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-security</artifactId> diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index dd2dd1fb3a..7d6c692bf8 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-server</artifactId> diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml index 6280c65d32..a9d1938e86 100644 --- a/jetty-servlet/pom.xml +++ b/jetty-servlet/pom.xml @@ -3,7 +3,7 @@ <parent> <artifactId>jetty-project</artifactId> <groupId>org.eclipse.jetty</groupId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-servlet</artifactId> diff --git a/jetty-servlets/pom.xml b/jetty-servlets/pom.xml index 56e9a8a5e9..093c2cbe2e 100644 --- a/jetty-servlets/pom.xml +++ b/jetty-servlets/pom.xml @@ -3,7 +3,7 @@ <parent> <artifactId>jetty-project</artifactId> <groupId>org.eclipse.jetty</groupId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-servlets</artifactId> diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index 5edab24bfc..27b583c855 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-start</artifactId> diff --git a/jetty-util/pom.xml b/jetty-util/pom.xml index e17138337b..864d26de18 100644 --- a/jetty-util/pom.xml +++ b/jetty-util/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-util</artifactId> diff --git a/jetty-webapp-verifier/.gitignore b/jetty-webapp-verifier/.gitignore new file mode 100644 index 0000000000..9c65b190a8 --- /dev/null +++ b/jetty-webapp-verifier/.gitignore @@ -0,0 +1,9 @@ +target/ +.classpath +.project +.settings +*.swp +*.patch +*.diff +*.log +cobertura.ser diff --git a/jetty-webapp-verifier/pom.xml b/jetty-webapp-verifier/pom.xml new file mode 100644 index 0000000000..93caf63245 --- /dev/null +++ b/jetty-webapp-verifier/pom.xml @@ -0,0 +1,111 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-project</artifactId> + <version>7.0.1-SNAPSHOT</version> + </parent> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp-verifier</artifactId> + <name>Jetty :: Webapp Verifier Tool</name> + <packaging>jar</packaging> + <properties> + <war.file.repo>target/war-files</war.file.repo> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy</id> + <phase>generate-resources</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>test-webapp-logging-java</artifactId> + <version>${project.version}</version> + <type>war</type> + <outputDirectory>${war.file.repo}</outputDirectory> + <destFileName>test-webapp-logging-java.war</destFileName> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>config.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-xml</artifactId> + <version>${version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <!-- + * + * Dependencies that should be provided should their respected verifiers be used + * + *--> + <dependency> + <groupId>asm</groupId> + <artifactId>asm</artifactId> + <version>3.1</version> + <optional>true</optional> + </dependency> + <dependency> + <groupId>asm</groupId> + <artifactId>asm-tree</artifactId> + <version>3.1</version> + <optional>true</optional> + </dependency> + </dependencies> + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-project-info-reports-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>cobertura-maven-plugin</artifactId> + </plugin> + </plugins> + </reporting> +</project> diff --git a/jetty-webapp-verifier/src/main/config/etc/jetty-waver-default-ruleset.xml b/jetty-webapp-verifier/src/main/config/etc/jetty-waver-default-ruleset.xml new file mode 100644 index 0000000000..fe7e5ccfa3 --- /dev/null +++ b/jetty-webapp-verifier/src/main/config/etc/jetty-waver-default-ruleset.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.RequiredContentsVerifier"> + <Call name="addPath"> + <Arg>/WEB-INF/web.xml</Arg> + </Call> + </New> + </Item> + <!-- + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.SignedJarVerifier"> + <Call name="setType"> + <Arg>JKS</Arg> + </Call> + <Call name="setAlias"> + <Arg>verisignclass3ca</Arg> + </Call> + <Call name="setKeystoreLocation"> + <Arg><SystemProperty name="java.home" default="."/>/lib/security/cacerts</Arg> + </Call> + </New> + </Item> + --> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/AbstractArchiveScanningRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/AbstractArchiveScanningRule.java new file mode 100644 index 0000000000..4cbc570809 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/AbstractArchiveScanningRule.java @@ -0,0 +1,94 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.File; +import java.util.Enumeration; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +/** + * AbstractArchiveScanningRule for Rules that scan the archive contents. + */ +public abstract class AbstractArchiveScanningRule extends AbstractRule +{ + public abstract String getDescription(); + + public abstract String getName(); + + @Override + public void visitWebInfLibJar(String path, File archive, JarFile jar) + { + scanClassesInArchive(path,jar); + } + + @Override + public void visitWebInfLibZip(String path, File archive, ZipFile zip) + { + scanClassesInArchive(path,zip); + } + + private String asClassname(String path) + { + StringBuffer name = new StringBuffer(); + for (char c : path.toCharArray()) + { + if (c == '/') + { + name.append("."); + } + else + { + name.append(c); + } + } + if (name.toString().endsWith(".class")) + { + name.delete(name.length() - 6,name.length() - 1); + } + return name.toString(); + } + + private void scanClassesInArchive(String path, ZipFile zip) + { + String className; + Enumeration<? extends ZipEntry> entries = zip.entries(); + while (entries.hasMoreElements()) + { + ZipEntry entry = entries.nextElement(); + if (entry.getName().endsWith(".class")) + { + className = asClassname(entry.getName()); + visitArchiveClass(path + "!/" + entry.getName(),className,zip,entry); + } + else + { + visitArchiveResource(path + "!/" + entry.getName(),zip,entry); + } + } + } + + public void visitArchiveResource(String path, ZipFile zip, ZipEntry entry) + { + /* override to do something with */ + } + + public void visitArchiveClass(String path, String className, ZipFile archive, ZipEntry archiveEntry) + { + /* override to do something with */ + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/AbstractRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/AbstractRule.java new file mode 100644 index 0000000000..c8a52952e8 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/AbstractRule.java @@ -0,0 +1,215 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.File; +import java.util.jar.JarFile; +import java.util.zip.ZipFile; + +public abstract class AbstractRule implements Rule +{ + private ViolationListener violationListener; + private File rootDir; + + protected void error(String path, String detail) + { + Violation violation = new Violation(Severity.ERROR,path,detail); + violation.setVerifierInfo(this); + violationListener.reportViolation(violation); + } + + protected void exception(String path, String detail, Throwable t) + { + Violation violation = new Violation(Severity.ERROR,path,detail,t); + violation.setVerifierInfo(this); + violationListener.reportViolation(violation); + } + + protected String getWebappRelativePath(File dir) + { + if (rootDir == null) + { + throw new RuntimeException("rootDir is not initialized, can't get relative path. " + + "Did you overide .visitWebappStart() and not call super.visitWebappStart()?"); + } + return rootDir.toURI().relativize(dir.toURI()).toASCIIString(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#setViolationListener(ViolationListener) + */ + public void setViolationListener(ViolationListener listener) + { + this.violationListener = listener; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#initialize() + */ + public void initialize() throws Throwable + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitDirectoryEnd(java.lang.String, java.io.File) + */ + public void visitDirectoryEnd(String path, File dir) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitDirectoryStart(java.lang.String, java.io.File) + */ + public void visitDirectoryStart(String path, File dir) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitFile(java.lang.String, java.io.File, java.io.File) + */ + public void visitFile(String path, File dir, File file) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebappEnd(java.lang.String, java.io.File) + */ + public void visitWebappEnd(String path, File dir) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * NOTE: be sure to call super.{@link #visitWebappStart(String, File)} in your overriden method. + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebappStart(java.lang.String, java.io.File) + */ + public void visitWebappStart(String path, File dir) + { + if (path.equals(ROOT_PATH)) + { + rootDir = new File(path); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebInfClass(java.lang.String, java.lang.String, + * java.io.File) + */ + public void visitWebInfClass(String path, String className, File classFile) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebInfClassesEnd(java.lang.String, java.io.File) + */ + public void visitWebInfClassesEnd(String path, File dir) + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebInfClassesStart(java.lang.String, java.io.File) + */ + public void visitWebInfClassesStart(String path, File dir) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebInfClassResource(java.lang.String, java.lang.String, + * java.io.File) + */ + public void visitWebInfClassResource(String path, String resourcePath, File resourceFile) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebInfLibEnd(java.lang.String, java.io.File) + */ + public void visitWebInfLibEnd(String path, File dir) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebInfLibJar(String, File, JarFile) + */ + public void visitWebInfLibJar(String path, File archive, JarFile jar) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebInfLibStart(java.lang.String, java.io.File) + */ + public void visitWebInfLibStart(String path, File dir) + { + /* override to implement */ + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebInfLibZip(String, File, ZipFile) + */ + public void visitWebInfLibZip(String path, File archive, ZipFile zip) + { + /* override to implement */ + } + + protected void warning(String path, String detail) + { + Violation violation = new Violation(Severity.WARNING,path,detail); + violation.setVerifierInfo(this); + violationListener.reportViolation(violation); + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/Rule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/Rule.java new file mode 100644 index 0000000000..a21b9ad9b4 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/Rule.java @@ -0,0 +1,222 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.File; +import java.net.URLClassLoader; +import java.util.jar.JarFile; +import java.util.zip.ZipFile; + +/** + * <p> + * Rule is the interface that the {@link WebappVerifier} uses to notify Rule implementations of events in the Iteration + * of a Webapp contents. + * </p> + * + * <p> + * The visitor pattern used here has the following order .. + * </p> + * + * <pre> + * 1) [1] {@link #visitWebappStart(String, File)} + * Iterate Contents: + * 2) [1..n] {@link #visitDirectoryStart(String, File)} + * 3) [0..n] {@link #visitFile(String, File, File)} + * 4) [1..n] {@link #visitDirectoryEnd(String, File)} + * Iterate WEB-INF/classes: + * 5) [0..1] {@link #visitWebInfClassesStart(String, File)} + * 6) [0..n] {@link #visitWebInfClass(String, String, File)} + * 7) [0..n] {@link #visitWebInfClassResource(String, String, File)} + * 8) [0..1] {@link #visitWebInfClassesEnd(String, File)} + * Iterate WEB-INF/lib: + * 9) [0..1] {@link #visitWebInfLibStart(String, File)} + * 10) [0..n] {@link #visitWebInfLibJar(String, File, JarFile)} + * 11) [0..n] {@link #visitWebInfLibZip(String, File, ZipFile)} + * 12) [0..1] {@link #visitWebInfLibEnd(String, File)} + * 13) [1] {@link #visitWebappEnd(String, File)} + * </pre> + */ +public interface Rule +{ + public static final String ROOT_PATH = ""; + + /** + * A short name for the rule. + */ + public String getName(); + + /** + * A Description of the purpose of the rule. What does it check for? Why? + */ + public String getDescription(); + + /** + * Initialization logic for the rule, exceptions from initialization will be logged as a {@link Severity#ERROR} + * level {@link Violation} with the {@link Violation#getThrowable()} set. + * + * If you want more meaningful violation messages than default, be sure to capture your own initialization related + * failures and report them to the {@link ViolationListener} at a {@link Severity#ERROR} level. + */ + public void initialize() throws Throwable; + + /** + * Set the listener to report violations back to. + */ + public void setViolationListener(ViolationListener listener); + + /** + * The iteration of the webapp has begun. + * + * @param path + * the war relative path to this directory. + * @param dir + * the real File System directory to the webapp work directory + */ + public void visitWebappStart(String path, File dir); + + /** + * A visit of a directory has begun. + * + * @param path + * the war relative path to this directory. + * @param dir + * the real File System directory object for this directory. + */ + public void visitDirectoryStart(String path, File dir); + + /** + * A visit of a file. + * + * @param path + * the war relative path to this file. + * @param dir + * the real File System directory object for this file. This is the same directory as seen in + * {@link #visitDirectoryStart(String, File)} and {@link #visitDirectoryEnd(String, File)} + * @param file + * the real File System {@link File} object to this file + */ + public void visitFile(String path, File dir, File file); + + /** + * A visit of a directory has ended. + * + * @param path + * the war relative path to this directory. + * @param dir + * the real File System directory. + */ + public void visitDirectoryEnd(String path, File dir); + + /** + * The visit to WEB-INF/classes is starting + * + * @param path + * the war relative path to the WEB-INF/classes dir. (Note: Will always be "WEB-INF/classes") + * @param dir + * the real File System directory. + */ + public void visitWebInfClassesStart(String path, File dir); + + /** + * A visit of a Class found in WEB-INF/classes. + * + * @param path + * the war relative path to this directory. + * @param className + * the full classname of the class found. TODO: Base this off of class bytecode? + * @param classFile + * the real File System directory object for this directory. + */ + public void visitWebInfClass(String path, String className, File classFile); + + /** + * A visit of a Resource available in "WEB-INF/classes" which is not a Class (such as an XML file or a properties + * file) + * + * @param path + * the war relative path to this directory. + * @param resourcePath + * the full resourcePath to the file found. Returned in a format that is compatible to + * {@link URLClassLoader#findResource(String)} call. + * @param resourceFile + * the real File System directory object for this directory. + */ + public void visitWebInfClassResource(String path, String resourcePath, File resourceFile); + + /** + * The visit to WEB-INF/classes has ended + * + * @param path + * the war relative path to the WEB-INF/classes dir. (Note: Will always be "WEB-INF/classes") + * @param dir + * the real File System directory. + */ + public void visitWebInfClassesEnd(String path, File dir); + + /** + * The visit to WEB-INF/lib is starting. + * + * @param path + * the war relative path to the WEB-INF/lib dir. (Note: Will always be "WEB-INF/lib") + * @param dir + * the real File System directory. + */ + public void visitWebInfLibStart(String path, File dir); + + /** + * A visit to a JAR archive in the WEB-INF/lib directory. + * + * @param path + * the war relative path to the JAR archive in the WEB-INF/lib dir. + * @param archive + * the real File System file. + * @param jar + * the {@link JarFile} + */ + public void visitWebInfLibJar(String path, File archive, JarFile jar); + + /** + * A visit to an archive in the WEB-INF/lib directory has begun. + * + * @param path + * the war relative path to the archive in the WEB-INF/lib dir. + * @param archive + * the real File System file. + * @param zip + * the {@link ZipFile} + */ + public void visitWebInfLibZip(String path, File archive, ZipFile zip); + + /** + * The visit to WEB-INF/lib has ended. + * + * @param path + * the war relative path to the WEB-INF/lib dir. (Note: Will always be "WEB-INF/lib") + * @param dir + * the real File System directory. + */ + public void visitWebInfLibEnd(String path, File dir); + + /** + * The iteration of the webapp has ended. + * + * @param path + * the war relative path to this directory. + * @param dir + * the real File System directory to the webapp work directory + */ + public void visitWebappEnd(String path, File dir); +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/RuleSet.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/RuleSet.java new file mode 100644 index 0000000000..5dfd32e8d0 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/RuleSet.java @@ -0,0 +1,89 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.File; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jetty.xml.XmlConfiguration; + +/** + * RuleSet holds the set of configured {@link Rule}s that the WebappVerifier will use. + */ +public class RuleSet +{ + private String name; + private List<Rule> rules = new ArrayList<Rule>(); + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public List<Rule> getRules() + { + return rules; + } + + public void setRules(List<Rule> rules) + { + this.rules = rules; + } + + public void setRules(Rule[] ruleArray) + { + this.rules.clear(); + this.rules.addAll(Arrays.asList(ruleArray)); + } + + public void addRule(Rule rule) + { + this.rules.add(rule); + } + + public WebappVerifier createWebappVerifier(URI webappURI) + { + WebappVerifier webappVerifier = new WebappVerifier(webappURI); + webappVerifier.setRules(rules); + return webappVerifier; + } + + public static RuleSet load(URL configuration) throws Exception + { + XmlConfiguration xml; + xml = new XmlConfiguration(configuration); + return (RuleSet)xml.configure(); + } + + public static RuleSet load(URI configuration) throws Exception + { + return load(configuration.toURL()); + } + + public static RuleSet load(File configuration) throws Exception + { + return load(configuration.toURL()); + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/Severity.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/Severity.java new file mode 100644 index 0000000000..8435c5c05b --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/Severity.java @@ -0,0 +1,39 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +public enum Severity +{ + WARNING, ERROR; + + public static Severity parse(String value) + { + if (value == null) + { + return null; + } + + for (Severity sev : Severity.values()) + { + if (sev.name().equalsIgnoreCase(value)) + { + return sev; + } + } + + return null; + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/Violation.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/Violation.java new file mode 100644 index 0000000000..66be3fa299 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/Violation.java @@ -0,0 +1,186 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +public class Violation +{ + private String path; + + private Severity severity; + + private String detail; + + private Throwable throwable; + + private String ruleId; + + private Class<? extends Rule> ruleClass; + + public Violation(Severity severity, String path, String detail) + { + this.severity = severity; + this.path = path; + this.detail = detail; + } + + public Violation(Severity severity, String path, String detail, Rule verifier) + { + this.severity = severity; + this.path = path; + this.detail = detail; + setVerifierInfo(verifier); + } + + public Violation(Severity severity, String path, String detail, Throwable throwable) + { + this.severity = severity; + this.path = path; + this.detail = detail; + this.throwable = throwable; + } + + public void setVerifierInfo(Rule verifier) + { + this.ruleId = verifier.getName(); + this.ruleClass = verifier.getClass(); + } + + @Override + public String toString() + { + StringBuffer msg = new StringBuffer(); + msg.append("Violation["); + msg.append("severity=").append(severity.name()); + msg.append(",path=").append(path); + msg.append(",detail=").append(detail); + if (ruleId != null) + { + msg.append(",verifierId=").append(ruleId); + } + if (ruleClass != null) + { + msg.append(",verifierClass=").append(ruleClass.getName()); + } + if (throwable != null) + { + msg.append(",throwable=").append(throwable.getClass().getName()); + } + msg.append("]"); + return msg.toString(); + } + + public String toDelimString() + { + StringBuffer msg = new StringBuffer(); + msg.append(severity.name()); + msg.append("|").append(path); + msg.append("|").append(detail); + return msg.toString(); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((detail == null)?0:detail.hashCode()); + result = prime * result + ((path == null)?0:path.hashCode()); + result = prime * result + ((severity == null)?0:severity.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + Violation other = (Violation)obj; + if (detail == null) + { + if (other.detail != null) + { + return false; + } + } + else if (!detail.equals(other.detail)) + { + return false; + } + if (path == null) + { + if (other.path != null) + { + return false; + } + } + else if (!path.equals(other.path)) + { + return false; + } + if (severity == null) + { + if (other.severity != null) + { + return false; + } + } + else if (!severity.equals(other.severity)) + { + return false; + } + return true; + } + + public Class<? extends Rule> getRuleClass() + { + return ruleClass; + } + + public String getRuleId() + { + return ruleId; + } + + public String getDetail() + { + return detail; + } + + public String getPath() + { + return path; + } + + public Severity getSeverity() + { + return severity; + } + + public Throwable getThrowable() + { + return throwable; + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/ViolationComparator.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/ViolationComparator.java new file mode 100644 index 0000000000..24ea663f22 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/ViolationComparator.java @@ -0,0 +1,49 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.text.CollationKey; +import java.text.Collator; +import java.util.Comparator; + +public class ViolationComparator implements Comparator<Violation> +{ + private static ViolationComparator INSTANCE = new ViolationComparator(); + + public static ViolationComparator getInstance() + { + return INSTANCE; + } + + private Collator collator = Collator.getInstance(); + + public int compare(Violation o1, Violation o2) + { + CollationKey pathKey1 = collator.getCollationKey(o1.getPath()); + CollationKey pathKey2 = collator.getCollationKey(o2.getPath()); + + int diff = pathKey1.compareTo(pathKey2); + if (diff != 0) + { + // different paths. + return diff; + } + + CollationKey detailKey1 = collator.getCollationKey(o1.getDetail()); + CollationKey detailKey2 = collator.getCollationKey(o2.getDetail()); + return detailKey1.compareTo(detailKey2); + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/ViolationListener.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/ViolationListener.java new file mode 100644 index 0000000000..e2ab668eca --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/ViolationListener.java @@ -0,0 +1,21 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +public interface ViolationListener +{ + void reportViolation(Violation violation); +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/WebappVerifier.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/WebappVerifier.java new file mode 100644 index 0000000000..25044c1891 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/WebappVerifier.java @@ -0,0 +1,570 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.jar.JarFile; +import java.util.zip.ZipFile; + +import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.util.resource.JarResource; +import org.eclipse.jetty.util.resource.Resource; + +/** + * The Webapp Verifier is a component that can be configured to run and arbitrary number of {@link Rule}s that analyze + * the contents of a war file and report rule violations. + */ +public class WebappVerifier implements ViolationListener +{ + /** + * <p> + * Represents the source webappURI. + * </p> + * <p> + * Can be http, file, jar, etc ... + * </p> + * <p> + * Verification does not occur directly against this URI. + * </p> + */ + private URI _webappURI; + + /** + * Represents the local webapp file directory, often times points to the working (unpacked) webapp directory. + * + * NOTE: if _webappURI is a "file://" access URI, and points to a directory, then the _webappDir will point to the + * the same place, otherwise it will point to the webapp directory. + */ + private File _webappDir; + private File _workdir; + private List<Rule> _rules; + private Map<String, List<Violation>> _violations; + + /** + * Instantiate a WebappVerifier, against the specific webappURI, using the default workdir. + * + * @param webappURI + * the webappURI to verify + */ + public WebappVerifier(URI webappURI) + { + this._webappURI = webappURI; + this._workdir = new File(System.getProperty("java.io.tmpdir"),"jetty-waver"); + this._rules = new ArrayList<Rule>(); + this._violations = new HashMap<String, List<Violation>>(); + } + + public void addRule(Rule rule) + { + _rules.add(rule); + try + { + rule.setViolationListener(this); + rule.initialize(); + } + catch (Throwable t) + { + // Capture any errors out of initialize or setViolationListener() that might occur. + String msg = String.format("Unable to add rule [%s]: %s",rule.getName(),t.getMessage()); + reportException(Rule.ROOT_PATH,msg,rule,t); + } + } + + private String cleanFilename(URI uri) + { + // Need a filename to store this download to. + String destname = uri.getPath(); + int idx = destname.lastIndexOf('/'); + if (idx > 0) + { + destname = destname.substring(idx); + } + destname = destname.trim().toLowerCase(); + + if (destname.length() <= 0) + { + // whoops, there's nothing left. + // could be caused by urls that point to paths. + destname = new SimpleDateFormat("yyyy-MM-dd_hh-mm-ss").format(new Date()); + } + + // Neuter illegal characters + char cleaned[] = new char[destname.length()]; + for (int i = 0; i < destname.length(); i++) + { + char c = destname.charAt(i); + if (c == '|' || c == '/' || c == '\\' || c == '*' || c == '?' || c == ':' || c == '#') + { + cleaned[i] = '_'; + } + else + { + cleaned[i] = c; + } + } + + destname = new String(cleaned); + + if (!destname.endsWith(".war")) + { + destname += ".war"; + } + + return destname; + } + + private File download(URI uri) throws MalformedURLException, IOException + { + // Establish destfile + File destfile = new File(_workdir,cleanFilename(uri)); + + InputStream in = null; + FileOutputStream out = null; + try + { + in = uri.toURL().openStream(); + out = new FileOutputStream(destfile); + IO.copy(in,out); + } + finally + { + IO.close(in); + } + return destfile; + } + + private File establishLocalWebappDir() throws URISyntaxException, IOException + { + if ("file".equals(_webappURI.getScheme())) + { + File path = new File(_webappURI); + if (path.isDirectory()) + { + return path; + } + return unpack(path); + } + + File downloadedFile = download(_webappURI); + return unpack(downloadedFile); + } + + public List<Rule> getRules() + { + return _rules; + } + + public Collection<Violation> getViolations() + { + // TODO: Icky! I need a better way of getting the list of raw + // violations, complete, without path mapping in place. + // Yet, I need path mapping as well, right? + List<Violation> violations = new ArrayList<Violation>(); + for (List<Violation> pathviol : _violations.values()) + { + violations.addAll(pathviol); + } + return violations; + } + + public File getWebappDir() + { + return _webappDir; + } + + private String getWebappRelativePath(File dir) + { + return _webappDir.toURI().relativize(dir.toURI()).toASCIIString(); + } + + public File getWorkDir() + { + return _workdir; + } + + /** + * Tests a filesystem path for webapp expected files, like "WEB-INF/web.xml" + */ + private boolean isValidWebapp(File path) + { + File webXml = new File(path,"WEB-INF" + File.separator + "web.xml"); + if (!webXml.exists()) + { + reportViolation(Severity.ERROR,Rule.ROOT_PATH,"Missing WEB-INF/web.xml"); + return false; + } + + if (!webXml.isFile()) + { + reportViolation(Severity.ERROR,Rule.ROOT_PATH,"The WEB-INF/web.xml is not a File"); + return false; + } + + return true; + } + + private void reportException(String path, String detail, Rule rule, Throwable t) + { + Violation viol = new Violation(Severity.ERROR,path,detail,t); + viol.setVerifierInfo(rule); + reportViolation(viol); + } + + public void reportViolation(Severity error, String path, String detail) + { + reportViolation(new Violation(error,path,detail)); + } + + public void reportViolation(Violation violation) + { + List<Violation> pathviol = _violations.get(violation.getPath()); + if (pathviol == null) + { + pathviol = new ArrayList<Violation>(); + } + pathviol.add(violation); + _violations.put(violation.getPath(),pathviol); + } + + public void setRules(Collection<Rule> rules) + { + this._rules.clear(); + // Add each rule separately, to establish initialization & listeners + for (Rule verifier : rules) + { + addRule(verifier); + } + } + + public void setWorkDir(File workDir) + { + this._workdir = workDir; + } + + private File unpack(File path) throws URISyntaxException, IOException + { + String destname = path.getName().substring(0,path.getName().length() - 4); + File destDir = new File(_workdir,destname); + URI warURI = new URI("jar",path.toURI() + "!/",null); + JarResource warResource = (JarResource)Resource.newResource(warURI); + warResource.extract(destDir,false); + return destDir; + } + + public void visitAll() + { + try + { + _webappDir = establishLocalWebappDir(); + + // Issue start. + for (Rule rule : _rules) + { + rule.visitWebappStart(Rule.ROOT_PATH,_webappDir); + } + + if (isValidWebapp(_webappDir)) + { + // Iterate through content + visitContents(); + // Iterate through WEB-INF/classes + visitWebInfClasses(); + // Iterate through WEB-INF/lib + visitWebInfLib(); + } + + // Issue end. + for (Rule rule : _rules) + { + rule.visitWebappEnd(Rule.ROOT_PATH,_webappDir); + } + } + catch (IOException e) + { + reportViolation(new Violation(Severity.ERROR,Rule.ROOT_PATH,e.getMessage(),e)); + } + catch (URISyntaxException e) + { + reportViolation(new Violation(Severity.ERROR,Rule.ROOT_PATH,e.getMessage(),e)); + } + } + + private void visitWebInfClasses() + { + File classesDir = new File(_webappDir,"WEB-INF" + File.separator + "classes"); + if (!classesDir.exists()) + { + // skip this path. + return; + } + + String classesPath = getWebappRelativePath(classesDir); + + if (!classesDir.isDirectory()) + { + reportViolation(Severity.ERROR,classesPath,"WEB-INF/classes is not a Directory?"); + return; + } + + // Issue start. + for (Rule rule : _rules) + { + rule.visitWebInfClassesStart(classesPath,classesDir); + } + + visitClassesDir(classesDir,classesDir); + + // Issue end. + for (Rule rule : _rules) + { + rule.visitWebInfClassesEnd(classesPath,classesDir); + } + } + + private void visitClassesDir(File classesRoot, File classesDir) + { + File files[] = classesDir.listFiles(); + for (File file : files) + { + if (file.isFile()) + { + if (file.getName().endsWith(".class")) + { + visitClass(classesRoot,file); + } + else + { + visitClassResource(classesRoot,file); + } + } + else if (file.isDirectory()) + { + // recurse + visitClassesDir(classesRoot,file); + } + } + } + + private void visitClassResource(File classesRoot, File file) + { + String path = getWebappRelativePath(file); + String resourcePath = classesRoot.toURI().relativize(file.toURI()).toASCIIString(); + for (Rule rule : _rules) + { + rule.visitWebInfClassResource(path,resourcePath,file); + } + } + + private void visitClass(File classesRoot, File file) + { + String path = getWebappRelativePath(file); + String className = classesRoot.toURI().relativize(file.toURI()).toASCIIString(); + className = className.replace("/","."); + if (className.endsWith(".class")) + { + className = className.substring(0,className.length() - 6); + } + for (Rule rule : _rules) + { + rule.visitWebInfClass(path,className,file); + } + } + + private void visitWebInfLib() + { + File libDir = new File(_webappDir,"WEB-INF" + File.separator + "lib"); + if (!libDir.exists()) + { + // skip this path. + return; + } + + String libPath = getWebappRelativePath(libDir); + + if (!libDir.isDirectory()) + { + reportViolation(Severity.ERROR,libPath,"WEB-INF/lib is not a Directory?"); + return; + } + + // Issue start. + for (Rule rule : _rules) + { + rule.visitWebInfLibStart(libPath,libDir); + } + + // Iterator through contents of WEB-INF/lib + File archives[] = libDir.listFiles(); + for (File archive : archives) + { + if (!archive.isFile()) + { + reportViolation(Severity.WARNING,Rule.ROOT_PATH,"Found non-file in WEB-INF/lib. Remove it, " + + "as it cannot be accessed by the Servlet container or the Webapp: " + archive); + continue; + } + + if (archive.getName().toLowerCase().endsWith(".jar")) + { + visitWebInfLibJar(libPath,archive); + continue; + } + + if (archive.getName().toLowerCase().endsWith(".zip")) + { + visitWebInfLibZip(libPath,archive); + continue; + } + + reportViolation(Severity.WARNING,Rule.ROOT_PATH,"Found non-archive in WEB-INF/lib. Remove it, " + + "as it cannot be accessed by the Servlet container or the Webapp: " + archive); + } + + // Issue end. + for (Rule rule : _rules) + { + rule.visitWebInfLibEnd(libPath,libDir); + } + } + + private void visitWebInfLibJar(String libPath, File archive) + { + String jarPath = libPath + archive.getName(); + + // Issue visit on Jar + for (Rule rule : _rules) + { + JarFile jar = null; + try + { + jar = new JarFile(archive); + rule.visitWebInfLibJar(jarPath,archive,jar); + } + catch (Throwable t) + { + reportViolation(new Violation(Severity.ERROR,jarPath,t.getMessage(),t)); + } + finally + { + if (jar != null) + { + try + { + jar.close(); + } + catch (IOException ignore) + { + /* ignore */ + } + } + } + } + } + + private void visitWebInfLibZip(String libPath, File archive) + { + String zipPath = libPath + archive.getName(); + + // Issue visit on Zip + for (Rule rule : _rules) + { + ZipFile zip = null; + try + { + zip = new ZipFile(archive); + rule.visitWebInfLibZip(zipPath,archive,zip); + } + catch (Throwable t) + { + reportViolation(new Violation(Severity.ERROR,zipPath,t.getMessage(),t)); + } + finally + { + if (zip != null) + { + try + { + zip.close(); + } + catch (IOException ignore) + { + /* ignore */ + } + } + } + } + } + + private void visitContents() + { + visitDirectoryRecursively(_webappDir); + } + + private void visitDirectoryRecursively(File dir) + { + String path = getWebappRelativePath(dir); + + // Start Dir + for (Rule rule : this._rules) + { + rule.visitDirectoryStart(path,dir); + } + + File entries[] = dir.listFiles(); + + // Individual Files + for (File file : entries) + { + if (file.isFile()) + { + String filepath = path + file.getName(); + for (Rule rule : this._rules) + { + rule.visitFile(filepath,dir,file); + } + } + } + + // Sub dirs + for (File file : entries) + { + if (file.isDirectory()) + { + visitDirectoryRecursively(file); + } + } + + // End Dir + for (Rule rule : this._rules) + { + rule.visitDirectoryEnd(path,dir); + } + } + +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/ForbiddenClassesRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/ForbiddenClassesRule.java new file mode 100644 index 0000000000..6e845725c1 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/ForbiddenClassesRule.java @@ -0,0 +1,90 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.eclipse.jetty.webapp.verifier.AbstractArchiveScanningRule; + +/** + * ForbiddenClassesVerifier checks the various classes available to the Webapp to ensure that they do not contain and + * forbidden classes. + */ +public class ForbiddenClassesRule extends AbstractArchiveScanningRule +{ + private Map<String, Pattern> classPatterns = new HashMap<String, Pattern>(); + + public void addClassPattern(String classPattern) + { + StringBuffer regex = new StringBuffer(); + for (char c : classPattern.toCharArray()) + { + if (c == '.') + { + regex.append("\\."); + } + else if (c == '*') + { + regex.append(".*"); + } + else + { + regex.append(c); + } + } + classPatterns.put(classPattern,Pattern.compile(regex.toString())); + } + + @Override + public String getDescription() + { + return "Ensures that forbidden packages are not present in the war file"; + } + + @Override + public String getName() + { + return "forbidden-class"; + } + + private void validateClassname(String path, String className) + { + for (Map.Entry<String, Pattern> pattern : this.classPatterns.entrySet()) + { + if (pattern.getValue().matcher(className).matches()) + { + error(path,"Class forbidden by pattern: " + pattern.getKey()); + } + } + } + + @Override + public void visitWebInfClass(String path, String className, File classFile) + { + validateClassname(path,className); + } + + @Override + public void visitArchiveClass(String path, String className, ZipFile archive, ZipEntry archiveEntry) + { + validateClassname(path,className); + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/ForbiddenContentsRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/ForbiddenContentsRule.java new file mode 100644 index 0000000000..c3d2fdedb8 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/ForbiddenContentsRule.java @@ -0,0 +1,58 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jetty.webapp.verifier.AbstractRule; +import org.eclipse.jetty.webapp.verifier.support.PathGlob; + +/** + * ForbiddenContentsVerifier ensures that content matching a pattern does not exist in the webapp. + */ +public class ForbiddenContentsRule extends AbstractRule +{ + private List<String> _patterns = new ArrayList<String>(); + + public void addPattern(String pattern) + { + _patterns.add(pattern); + } + + public String getDescription() + { + return "Checks for forbidden content"; + } + + public String getName() + { + return "forbidden-content"; + } + + @Override + public void visitFile(String path, File dir, File file) + { + for (String pattern : _patterns) + { + if (PathGlob.match(pattern,path)) + { + error(path,"Forbidden content detected"); + } + } + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JarSignatureRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JarSignatureRule.java new file mode 100644 index 0000000000..91fc212208 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JarSignatureRule.java @@ -0,0 +1,231 @@ +// ======================================================================== +// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.security.KeyStore; +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.webapp.verifier.AbstractRule; + +/** + * Signed Jar Verifier + */ +public class JarSignatureRule extends AbstractRule +{ + private String _keystoreLocation = System.getProperty("java.home") + "/lib/security/cacerts"; + private String _type = "JKS"; // default + private String _alias = "verisignclass3ca"; // default + private KeyStore _keystore; + + private static X509Certificate[] _trustedCertificates; + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.webapp.verifier.AbstractRule#getDescription() + */ + public String getDescription() + { + return "verifies that the given keystore contains the certificates required for all jar files present"; + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.webapp.verifier.AbstractRule#getName() + */ + public String getName() + { + return "jar-signature"; + } + + /* ------------------------------------------------------------ */ + /** + * @param jar + * @return + */ + private List<JarEntry> resolveJar(JarFile jar) + { + List<JarEntry> entries = new ArrayList<JarEntry>(); + + Enumeration<JarEntry> e = jar.entries(); + + while (e.hasMoreElements()) + { + JarEntry jarEntry = e.nextElement(); + try + { + entries.add(jarEntry); // for further verification + IO.toString(jar.getInputStream(jar.getEntry(jarEntry.getName()))); + } + catch (IOException e1) + { + throw new SecurityException(e1); + } + } + + return entries; + } + + /* ------------------------------------------------------------ */ + /** + * Set the _keystore. + * + * @param keystore + * the _keystore to set + */ + public void setKeystoreLocation( String keyStoreLocation ) + { + _keystoreLocation = keyStoreLocation; + } + + @Override + public void initialize() + { + try + { + _keystore = KeyStore.getInstance(_type); + + InputStream istream = new File( _keystoreLocation ).toURL().openStream(); + + _keystore.load(istream,null); + + _trustedCertificates = new X509Certificate[] + { (X509Certificate)_keystore.getCertificate(_alias) }; + + } + catch (Throwable t) + { + exception(_keystoreLocation, t.getMessage(), t); + } + } + + public void setType(String type) + { + _type = type; + } + + /** + * @see org.eclipse.jetty.webapp.verifier.Rule#visitWebInfLibJar(java.lang.String, java.io.File, java.util.jar.JarFile) + */ + @Override + public void visitWebInfLibJar(String path, File archive, JarFile jar) + { + + try + { + if (jar.getManifest() == null) + { + error(jar.toString(),"missing manifest.mf, can not be signed"); + } + + List<JarEntry> entries = resolveJar(jar); + + for (JarEntry jarEntry : entries) + { + if (!jarEntry.isDirectory() && !jarEntry.getName().startsWith("META-INF")) + { + Certificate[] certs = jarEntry.getCertificates(); + + if (certs == null || certs.length == 0) + { + error(jarEntry.getName(),"entry has not been signed"); + } + else + { + X509Certificate[] chainRoots = getChainRoots(certs); + boolean signed = false; + + for (int i = 0; i < chainRoots.length; i++) + { + if (isTrusted(chainRoots[i])) + { + signed = true; + break; + } + } + if (!signed) + { + error(jarEntry.getName(),"Untrusted provider's JAR"); + } + } + } + } + } + catch (Exception e) + { + exception(jar.getName(), e.getMessage(), e); + } + } + + private boolean isTrusted(X509Certificate certificate) + { + for (int i = 0; i < _trustedCertificates.length; i++) + { + if (certificate.getSubjectDN().equals(_trustedCertificates[i].getSubjectDN())) + { + if (certificate.equals(_trustedCertificates[i])) + { + return true; + } + } + } + + for (int i = 0; i < _trustedCertificates.length; i++) + { + if (certificate.getIssuerDN().equals(_trustedCertificates[i].getSubjectDN())) + { + try + { + certificate.verify(_trustedCertificates[i].getPublicKey()); + return true; + } + catch (Exception e) + { + } + } + } + return false; + } + + /** + * Returns a array of certificates with the root certificate of each chain + * + * @param certificates an array of X509 certificate's + * @return an array of X509 certificate's with the root certificate of each chain + */ + private X509Certificate[] getChainRoots(Certificate[] certificates) + { + List<X509Certificate> chainRoots = new ArrayList<X509Certificate>(); + + for (int i = 0; i < certificates.length - 1; i++) + { + if (!((X509Certificate)certificates[i + 1]).getSubjectDN().equals(((X509Certificate)certificates[i]).getIssuerDN())) + { + chainRoots.add((X509Certificate)certificates[i]); + } + } + + chainRoots.add((X509Certificate)certificates[certificates.length - 1]); + + return chainRoots.toArray(new X509Certificate[chainRoots.size()]); + } + +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JavaSupportLevelRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JavaSupportLevelRule.java new file mode 100644 index 0000000000..cf93c40938 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JavaSupportLevelRule.java @@ -0,0 +1,166 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.io.IOException; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.eclipse.jetty.webapp.verifier.AbstractArchiveScanningRule; +import org.eclipse.jetty.webapp.verifier.rules.asm.ASMUtil; +import org.eclipse.jetty.webapp.verifier.rules.asm.AbstractClassVisitor; + +/** + * Ensure all compiled classes within webapp are within the supported JVM range. + */ +public class JavaSupportLevelRule extends AbstractArchiveScanningRule +{ + class ClassVersionVisitor extends AbstractClassVisitor + { + private double classVersion = -1; + + public double getClassVersion() + { + return classVersion; + } + + @Override + public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) + { + this.classVersion = getJavaClassVersion(version); + } + + private double getJavaClassVersion(int version) + { + int major = version & 0xFFFF; + int minor = version >>> 16; + + // Java Versions to Class Version (major.minor) + // Java 1.6 = 50.0 + // Java 1.5 = 49.0 + // Java 1.4 = 48.0 + // Java 1.3 = 47.0 + // Java 1.2 = 46.0 + // Java 1.1 = 45.3 + + // TODO: check these since they are > instead of >= + if (major >= 50) + { + return 1.6; + } + else if (major >= 49) + { + return 1.5; + } + else if (major >= 48) + { + return 1.4; + } + else if (major >= 47) + { + return 1.3; + } + else if (major >= 46) + { + return 1.2; + } + else if (major >= 45) + { + if (minor >= 3) + { + return 1.1; + } + return 1.0; + } + + return 0.0; + } + + public void reset() + { + this.classVersion = (-1); + } + } + + private double supportedVersion = 1.5; + private ClassVersionVisitor visitor; + + @Override + public String getDescription() + { + return "Ensure all compiled classes within webapp are within the supported JVM"; + } + + @Override + public String getName() + { + return "java-support-level"; + } + + public double getSupportedVersion() + { + return supportedVersion; + } + + public void setSupportedVersion(double supportedVersion) + { + this.supportedVersion = supportedVersion; + } + + @Override + public void visitWebappStart(String path, File dir) + { + visitor = new ClassVersionVisitor(); + } + + + @Override + public void visitWebInfClass(String path, String className, File classFile) + { + try + { + visitor.reset(); + ASMUtil.visitClassFile(classFile,visitor,0); + if (visitor.classVersion > supportedVersion) + { + error(path,"Class is compiled for java version [" + visitor.classVersion + "] which is over supported java version [" + supportedVersion + "]"); + } + } + catch (IOException e) + { + exception(path,"Unable to read class",e); + } + } + + @Override + public void visitArchiveClass(String path, String className, ZipFile archive, ZipEntry archiveEntry) + { + try + { + visitor.reset(); + ASMUtil.visitClass(archive.getInputStream(archiveEntry),visitor,0); + if (visitor.classVersion > supportedVersion) + { + error(path,"Class is compiled for java version [" + visitor.classVersion + "] which is over supported java version [" + supportedVersion + "]"); + } + } + catch (IOException e) + { + exception(path,"Unable to read class",e); + } + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JspPrecompileRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JspPrecompileRule.java new file mode 100644 index 0000000000..73bfb552a4 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JspPrecompileRule.java @@ -0,0 +1,43 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; + +import org.eclipse.jetty.webapp.verifier.AbstractRule; + +/** + * Perform a JSP pre-compile to ensure all JSPs are valid. + */ +public class JspPrecompileRule extends AbstractRule +{ + public String getDescription() + { + return "Perform JSP precompile to ensure all jsps are valid"; + } + + public String getName() + { + return "jsp-precompile"; + } + + @Override + public void visitWebappStart(String path, File dir) + { + // TODO: implement rule. + error(path,"Rule [" + getClass().getName() + "] not yet implemented"); + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JspSupportLevelRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JspSupportLevelRule.java new file mode 100644 index 0000000000..15181ade9b --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/JspSupportLevelRule.java @@ -0,0 +1,43 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; + +import org.eclipse.jetty.webapp.verifier.AbstractRule; + +/** + * Ensure any included JSPs are supported by the Container. + */ +public class JspSupportLevelRule extends AbstractRule +{ + public String getDescription() + { + return "Ensure include JSP are supported by the Container"; + } + + public String getName() + { + return "jsp-support-level"; + } + + @Override + public void visitWebappStart(String path, File dir) + { + // TODO: implement rule. + error(path,"Rule [" + getClass().getName() + "] not yet implemented"); + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoJspRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoJspRule.java new file mode 100644 index 0000000000..d296f39a91 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoJspRule.java @@ -0,0 +1,46 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; + +import org.eclipse.jetty.webapp.verifier.AbstractRule; + +/** + * Prevent inclusion of *.jsp in webapp. + */ +public class NoJspRule extends AbstractRule +{ + public String getDescription() + { + return "Prevent inclusion of JSPs in webapp"; + } + + public String getName() + { + return "no-jsp"; + } + + @Override + public void visitFile(String path, File dir, File file) + { + String name = file.getName().toLowerCase(); + if (name.endsWith(".jsp") || name.endsWith(".jspf")) + { + error(path,"No JSP's are allowed"); + } + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoNativeRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoNativeRule.java new file mode 100644 index 0000000000..ee6f1176f8 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoNativeRule.java @@ -0,0 +1,68 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.eclipse.jetty.webapp.verifier.AbstractArchiveScanningRule; +import org.eclipse.jetty.webapp.verifier.support.PathGlob; + +/** + * Prevent use of native code in webapp. + */ +public class NoNativeRule extends AbstractArchiveScanningRule +{ + private String[] nativePatterns = + { "*.so", "*.so.*", "*.o", "*.dll", "*.com", "*.exe" }; + + @Override + public String getDescription() + { + return "Prevent use of native code in webapp"; + } + + @Override + public String getName() + { + return "no-native"; + } + + @Override + public void visitFile(String path, File dir, File file) + { + for (String pattern : nativePatterns) + { + if (PathGlob.match(pattern,path)) + { + error(path,"Native code is forbidden"); + } + } + } + + @Override + public void visitArchiveResource(String path, ZipFile zip, ZipEntry entry) + { + for (String pattern : nativePatterns) + { + if (PathGlob.match(pattern,entry.getName())) + { + error(path,"Native code is forbidden"); + } + } + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoScriptingRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoScriptingRule.java new file mode 100644 index 0000000000..2cbfd45efa --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoScriptingRule.java @@ -0,0 +1,235 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.eclipse.jetty.webapp.verifier.AbstractRule; + +/** + * NoScriptingRule ensure that no scripting languages are used in the webapp. + * + * Checks for actual script files in webapp filesystem, and existance of popular scripting language libraries as well. + */ +public class NoScriptingRule extends AbstractRule +{ + class Forbidden + { + public String key; + public String msg; + + public Forbidden(String key, String msg) + { + super(); + this.key = key; + this.msg = msg; + } + } + + private boolean allowJRuby = false; + private boolean allowBeanshell = false; + private boolean allowGroovy = false; + private boolean allowJython = false; + private boolean allowShell = false; + private List<Forbidden> forbiddenFileExtensions = new ArrayList<Forbidden>(); + private List<Forbidden> forbiddenClassIds = new ArrayList<Forbidden>(); + + public boolean isAllowShell() + { + return allowShell; + } + + public void setAllowShell(boolean allowShell) + { + this.allowShell = allowShell; + } + + public boolean isAllowJRuby() + { + return allowJRuby; + } + + public void setAllowJRuby(boolean allowJruby) + { + this.allowJRuby = allowJruby; + } + + public boolean isAllowBeanshell() + { + return allowBeanshell; + } + + public void setAllowBeanshell(boolean allowBeanshell) + { + this.allowBeanshell = allowBeanshell; + } + + public boolean isAllowGroovy() + { + return allowGroovy; + } + + public void setAllowGroovy(boolean allowGroovy) + { + this.allowGroovy = allowGroovy; + } + + public boolean isAllowJython() + { + return allowJython; + } + + public void setAllowJython(boolean allowJython) + { + this.allowJython = allowJython; + } + + public String getDescription() + { + return "Do not allow scripting languages in webapp"; + } + + public String getName() + { + return "forbidden-scripting"; + } + + @Override + public void initialize() throws Throwable + { + forbiddenFileExtensions.clear(); + forbiddenClassIds.clear(); + if (!allowJRuby) + { + String msg = "JRuby scripting not allowed"; + forbiddenFileExtensions.add(new Forbidden(".rb",msg)); + forbiddenFileExtensions.add(new Forbidden(".rhtml",msg)); + msg = "JRuby dependencies are not allowed"; + forbiddenClassIds.add(new Forbidden(".jruby.",msg)); + } + + if (!allowJython) + { + String msg = "Jython and Python scripting not allowed"; + forbiddenFileExtensions.add(new Forbidden(".py",msg)); + forbiddenFileExtensions.add(new Forbidden(".pyc",msg)); + msg = "Jython dependencies are not allowed"; + forbiddenClassIds.add(new Forbidden("org.python.",msg)); + } + + if (!allowGroovy) + { + String msg = "Groovy scripting not allowed"; + forbiddenFileExtensions.add(new Forbidden(".groovy",msg)); + msg = "Groovy dependencies are not allowed"; + forbiddenClassIds.add(new Forbidden(".groovy.",msg)); + } + + if (!allowShell) + { + String msg = "Shell scripting not allowed"; + forbiddenFileExtensions.add(new Forbidden(".sh",msg)); + forbiddenFileExtensions.add(new Forbidden(".bat",msg)); + forbiddenFileExtensions.add(new Forbidden(".cmd",msg)); + forbiddenFileExtensions.add(new Forbidden(".vbs",msg)); + } + } + + @Override + public void visitFile(String path, File dir, File file) + { + String name = file.getName().toLowerCase(); + for (Forbidden forbidden : forbiddenFileExtensions) + { + if (name.endsWith(forbidden.key)) + { + error(path,forbidden.msg); + } + } + } + + @Override + public void visitWebInfClass(String path, String className, File classFile) + { + validateClassname(path,className); + } + + private void validateClassname(String path, String className) + { + for (Forbidden forbidden : forbiddenClassIds) + { + if (className.contains(forbidden.key)) + { + error(path,forbidden.msg); + } + } + } + + @Override + public void visitWebInfClassResource(String path, String resourcePath, File resourceFile) + { + super.visitWebInfClassResource(path,resourcePath,resourceFile); + } + + @Override + public void visitWebInfLibJar(String path, File archive, JarFile jar) + { + iterateArchive(path,archive,jar); + } + + private void iterateArchive(String path, File archive, ZipFile zip) + { + try + { + Enumeration<? extends ZipEntry> entries = zip.entries(); + while (entries.hasMoreElements()) + { + ZipEntry entry = entries.nextElement(); + if (entry.getName().endsWith(".class")) + { + checkArchiveClassname(path,archive,entry.getName()); + } + } + } + catch (Throwable t) + { + exception(path,"Unable to iterate archive: Contents invalid?: " + t.getMessage(),t); + } + } + + private void checkArchiveClassname(String path, File archive, String name) + { + String className = name.replace("/","."); + if (className.endsWith(".class")) + { + className = className.substring(0,className.length() - 6); + } + + validateClassname(path + "!/" + name,className); + } + + @Override + public void visitWebInfLibZip(String path, File archive, ZipFile zip) + { + iterateArchive(path,archive,zip); + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoSourceControlRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoSourceControlRule.java new file mode 100644 index 0000000000..2b07684f3c --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoSourceControlRule.java @@ -0,0 +1,151 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.eclipse.jetty.webapp.verifier.AbstractArchiveScanningRule; + +/** + * Prevent inclusion of Source Control files & directories that might reveal hostnames, userids, and passwords to the + * source control. (CVS, .svn/, .git/) + */ +public class NoSourceControlRule extends AbstractArchiveScanningRule +{ + class ScmName + { + String scm; + String name; + + public ScmName(String scm, String name) + { + this.scm = scm; + this.name = name; + } + } + + private static List<ScmName> scmDirNames = new ArrayList<ScmName>(); + private static List<ScmName> scmFileNames = new ArrayList<ScmName>(); + + public NoSourceControlRule() + { + super(); + + // The order of patterns is most likely to least likely + + scmDirNames.add(new ScmName("Subversion",".svn")); // Standard Unix format + scmDirNames.add(new ScmName("Subversion","_svn")); // Alternate Windows format + scmDirNames.add(new ScmName("CVS","CVS")); + scmFileNames.add(new ScmName("CVS",".cvsignore")); + scmDirNames.add(new ScmName("Git",".git")); + scmFileNames.add(new ScmName("Git",".gitignore")); + scmDirNames.add(new ScmName("RCS","RCS")); + scmDirNames.add(new ScmName("SCCS","SCCS")); + scmFileNames.add(new ScmName("Visual SourceSafe","vssver.scc")); + scmDirNames.add(new ScmName("Arch",".arch-ids")); + scmDirNames.add(new ScmName("Bazaar",".bzr")); + scmFileNames.add(new ScmName("SurroundSCM",".MySCMServerInfo")); + scmDirNames.add(new ScmName("Mercurial",".hg")); + scmDirNames.add(new ScmName("BitKeeper","BitKeeper")); + scmDirNames.add(new ScmName("BitKeeper","ChangeSet")); + scmDirNames.add(new ScmName("Darcs","_darcs")); + scmDirNames.add(new ScmName("Darcs",".darcsrepo")); + scmFileNames.add(new ScmName("Darcs",".darcs-temp-mail")); + } + + @Override + public String getDescription() + { + return "Prevent inclusion of source control files in webapp"; + } + + @Override + public String getName() + { + return "no-source-control"; + } + + @Override + public void visitDirectoryStart(String path, File dir) + { + for (ScmName scmName : scmDirNames) + { + if (dir.getName().equalsIgnoreCase(scmName.name)) + { + error(path,scmName.scm + " Source Control directories are not allowed"); + } + } + } + + @Override + public void visitFile(String path, File dir, File file) + { + for (ScmName scmName : scmFileNames) + { + if (file.getName().equalsIgnoreCase(scmName.name)) + { + error(path,scmName.scm + " Source Control file are not allowed"); + } + } + } + + @Override + public void visitArchiveResource(String path, ZipFile zip, ZipEntry entry) + { + String basename = toBaseName(entry); + + if (entry.isDirectory()) + { + for (ScmName scmName : scmDirNames) + { + if (basename.equalsIgnoreCase(scmName.name)) + { + error(path,scmName.scm + " Source Control directories are not allowed"); + } + } + } + else + { + for (ScmName scmName : scmFileNames) + { + if (basename.equalsIgnoreCase(scmName.name)) + { + error(path,scmName.scm + " Source Control file are not allowed"); + } + } + } + } + + private String toBaseName(ZipEntry entry) + { + String name =entry.getName(); + if (name.endsWith("/")) + { + name = name.substring(0,name.length() - 1); + } + + int idx = name.lastIndexOf('/'); + if (idx >= 0) + { + return name.substring(idx + 1); + } + return name; + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoSourceRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoSourceRule.java new file mode 100644 index 0000000000..48f2f0c5e0 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/NoSourceRule.java @@ -0,0 +1,70 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.eclipse.jetty.webapp.verifier.AbstractArchiveScanningRule; +import org.eclipse.jetty.webapp.verifier.support.PathGlob; + +/** + * <p> + * Prevent inclusion of source files in webapp. (*.java) + * </p> + */ +public class NoSourceRule extends AbstractArchiveScanningRule +{ + private String[] sourcePatterns = + { "*.java" }; + + @Override + public String getDescription() + { + return "Prevent inclusion of source files in webapp"; + } + + @Override + public String getName() + { + return "no-source"; + } + + @Override + public void visitFile(String path, File dir, File file) + { + for (String pattern : sourcePatterns) + { + if (PathGlob.match(pattern,path)) + { + error(path,"Source code is forbidden"); + } + } + } + + @Override + public void visitArchiveResource(String path, ZipFile zip, ZipEntry entry) + { + for (String pattern : sourcePatterns) + { + if (PathGlob.match(pattern,entry.getName())) + { + error(path,"Source code is forbidden"); + } + } + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/RequiredContentsRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/RequiredContentsRule.java new file mode 100644 index 0000000000..75efa42adc --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/RequiredContentsRule.java @@ -0,0 +1,64 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jetty.webapp.verifier.AbstractRule; + +/** + * ForbiddenContentsVerifier ensures that content matching a pattern does not exist in the webapp. + */ +public class RequiredContentsRule extends AbstractRule +{ + private List<String> _paths = new ArrayList<String>(); + + public void addPath(String path) + { + _paths.add(path); + } + + public String getDescription() + { + return "Ensures that requred content is present"; + } + + public String getName() + { + return "required-content"; + } + + @Override + public void visitDirectoryEnd(String path, File dir) + { + if (path.equals(ROOT_PATH)) + { + File root = new File(path); + + for (String expectedPath : _paths) + { + File file = new File(root,expectedPath); + if (!file.exists()) + { + error(getWebappRelativePath(file),"Required content not found"); + } + } + } + } + +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/SaneArchiveRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/SaneArchiveRule.java new file mode 100644 index 0000000000..56a0ce22cb --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/SaneArchiveRule.java @@ -0,0 +1,59 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; + +import org.eclipse.jetty.webapp.verifier.AbstractRule; + +/** + * <p> + * Sanity check of archive (both war itself, as well as libs) to ensure that various entries within are sane. + * </p> + * + * <p> + * Example checks: + * </p> + * + * <ol> + * <li>Entries cannot contain references to parent "../../my_file.txt"</li> + * <li>Cannot contain multiple entries of the same name with different case. + * <ul> + * <li>/index.jsp</li> + * <li>/Index.jsp</li> + * </ul> + * <li> + * </ol> + */ +public class SaneArchiveRule extends AbstractRule +{ + public String getDescription() + { + return "Basic archive (jar & war) sanity checks"; + } + + public String getName() + { + return "sane-archive"; + } + + @Override + public void visitWebappStart(String path, File dir) + { + // TODO: implement rule. + error(path,"Rule [" + getClass().getName() + "] not yet implemented"); + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/ServletSupportLevelRule.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/ServletSupportLevelRule.java new file mode 100644 index 0000000000..29c95312b3 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/ServletSupportLevelRule.java @@ -0,0 +1,374 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.eclipse.jetty.webapp.verifier.AbstractRule; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +/** + * Ensure declared servlet level (servlet spec version) in webapp conforms to supported level. + */ +public class ServletSupportLevelRule extends AbstractRule +{ + private static final String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance"; + + class ServletId + { + String version; + String name; + String type; + + public ServletId(String version, String type, String name) + { + super(); + this.version = version; + this.type = type; + this.name = name; + } + } + + private String supportedVersion = "2.5"; + private String fileSep = System.getProperty("file.separator","/"); + private List<ServletId> dtdPublicIds = new ArrayList<ServletId>(); + private List<ServletId> dtdSystemIds = new ArrayList<ServletId>(); + private List<ServletId> nsIds = new ArrayList<ServletId>(); + private List<ServletId> schemaIds = new ArrayList<ServletId>(); + private String validVersions[] = + { "2.5", "2.4", "2.3", "2.2" }; + + public ServletSupportLevelRule() + { + // Servlet 2.5 + schemaIds.add(new ServletId("2.5","Schema","http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd")); + nsIds.add(new ServletId("2.5","XML Namespace","http://java.sun.com/xml/ns/javaee")); + + // Servlet 2.4 + schemaIds.add(new ServletId("2.4","Schema","http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd")); + nsIds.add(new ServletId("2.4","XML Namespace","http://java.sun.com/xml/ns/j2ee")); + + // Servlet 2.3 + dtdPublicIds.add(new ServletId("2.3","DOCTYPE Public ID","-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN")); + dtdSystemIds.add(new ServletId("2.3","DOCTYPE System ID","http://java.sun.com/dtd/web-app_2_3.dtd")); + + // Servlet 2.2 + dtdPublicIds.add(new ServletId("2.2","DOCTYPE Public ID","-//Sun Microsystems, Inc.//DTD WebApplication 2.2//EN")); + dtdSystemIds.add(new ServletId("2.2","DOCTYPE System ID","http://java.sun.com/j2ee/dtds/web-app_2.2.dtd")); + } + + public String getDescription() + { + return "Ensure webapp works within supported servlet spec"; + } + + public String getName() + { + return "servlet-support-level"; + } + + public String getSupportedVersion() + { + return supportedVersion; + } + + public void setSupportedVersion(String supportedLevel) + { + this.supportedVersion = supportedLevel; + } + + @Override + public void visitWebappStart(String path, File dir) + { + super.visitWebappStart(path,dir); + + File webXmlFile = new File(dir,"WEB-INF/web.xml".replaceAll("/",fileSep)); + String webxmlpath = getWebappRelativePath(webXmlFile); + + if (!webXmlFile.exists()) + { + error(webxmlpath,"web.xml does not exist"); + return; + } + + // Using JAXP to parse the web.xml (SAX pls) + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setValidating(false); + factory.setNamespaceAware(true); + + try + { + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(webXmlFile); + + List<ServletId> detectedIds = collectServletIds(webxmlpath,doc); + Set<String> versions = new TreeSet<String>(); + for (ServletId id : detectedIds) + { + versions.add(id.version); + } + + if (versions.size() > 1) + { + String msg = String.format("Found %d versions defined [%s], expected 1",versions.size(),join(versions,", ")); + error(webxmlpath,msg); + for (ServletId id : detectedIds) + { + reportConflicting(webxmlpath,id,detectedIds); + } + } + + reportOverVersion(webxmlpath,detectedIds); + } + catch (ParserConfigurationException e) + { + exception(webxmlpath,"[internal] Unable to establish XML parser",e); + } + catch (SAXException e) + { + exception(webxmlpath,"Unable to parse web.xml",e); + } + catch (IOException e) + { + exception(webxmlpath,"Unable to parse web.xml",e); + } + } + + private void reportOverVersion(String webxmlpath, List<ServletId> detectedIds) + { + double supportedVer = Double.parseDouble(this.supportedVersion); + + for (ServletId id : detectedIds) + { + try + { + double detectedVersion = Double.parseDouble(id.version); + if (detectedVersion > supportedVer) + { + String msg = String.format("Specified servlet version %s of %s is over the configured supported servlet version %s",id.version,id.type, + supportedVersion); + error(webxmlpath,msg); + } + } + catch (NumberFormatException e) + { + error(webxmlpath,String.format("Unable to parse version [%s] of %s, not a double",id.version,id.type)); + } + } + + } + + private void reportConflicting(String webxmlpath, ServletId mainId, List<ServletId> otherIds) + { + for (ServletId id : otherIds) + { + if (id.version.equals(mainId.version) == false) + { + String msg = String.format("version %s of %s conflicts with version %s of %s",mainId.version,mainId.type,id.version,id.type); + error(webxmlpath,msg); + } + } + } + + private String join(Collection<?> coll, String delim) + { + StringBuffer msg = new StringBuffer(); + + Iterator<?> it = coll.iterator(); + while (it.hasNext()) + { + msg.append(String.valueOf(it.next())); + if (it.hasNext()) + { + msg.append(delim); + } + } + + return msg.toString(); + } + + private List<ServletId> collectServletIds(String webxmlpath, Document doc) + { + List<ServletId> ids = new ArrayList<ServletId>(); + + // Check for DOCTYPE defined ids. + DocumentType doctype = doc.getDoctype(); + if (doctype != null) + { + if ("web-app".equals(doctype.getName())) + { + boolean valid = false; + for (ServletId id : dtdPublicIds) + { + if (id.name.equals(doctype.getPublicId())) + { + ids.add(id); + valid = true; + } + } + + if (!valid) + { + error(webxmlpath,"Invalid DOCTYPE public ID: " + doctype.getPublicId()); + } + + valid = false; + for (ServletId id : dtdSystemIds) + { + if (id.name.equals(doctype.getSystemId())) + { + ids.add(id); + valid = true; + } + } + + if (!valid) + { + error(webxmlpath,"Invalid DOCTYPE system ID: " + doctype.getSystemId()); + } + } + else + { + error(webxmlpath,"Invalid DOCTYPE detected, expected 'web-app', but found '" + doctype.getName() + "' instaed."); + } + } + + // Check for Root Element Namespace ids. + Element root = doc.getDocumentElement(); + + if ("web-app".equals(root.getTagName())) + { + String actualXmlNs = root.getAttribute("xmlns"); + String actualXsi = root.getAttribute("xmlns:xsi"); + String actualSchema = root.getAttribute("xsi:schemaLocation"); + String actualVersion = root.getAttribute("version"); + + if (hasAnyValue(actualXmlNs,actualXsi,actualSchema,actualVersion)) + { + if ((actualXmlNs == null) || (actualXmlNs == "")) + { + error(webxmlpath,"Attribute <web-app xmlns=\"\"> must exist with a valid value"); + } + else + { + boolean valid = false; + for (ServletId id : nsIds) + { + if (id.name.equals(actualXmlNs)) + { + ids.add(id); + valid = true; + } + } + + if (!valid) + { + String msg = String.format("Invalid xmlns value for <web-app xmlns=\"%s\">",actualXmlNs); + error(webxmlpath,msg); + } + } + + if ((actualXsi == null) || (actualXsi == "")) + { + error(webxmlpath,"Attribute <web-app xmlns:xsi=\"\"> must exist with a valid value"); + } + else if (!XSI_NS.equals(actualXsi)) + { + String msg = String.format("Attribute mismatch expecting <web-app xmlns:xsi=\"%s\"> but found <web-app xmlns:xsi=\"%s\">",XSI_NS,actualXsi); + error(webxmlpath,msg); + } + + if ((actualSchema == null) || (actualSchema == "")) + { + error(webxmlpath,"Attribute <web-app xsi:schemaLocation=\"\"> must exist with a valid value"); + } + else + { + boolean valid = false; + for (ServletId id : schemaIds) + { + if (id.name.equals(actualSchema)) + { + ids.add(id); + valid = true; + } + } + + if (!valid) + { + String msg = String.format("Invalid schemaLocation value <web-app xsi:schemaLocation=\"%s\">",actualSchema); + error(webxmlpath,msg); + } + } + + if ((actualVersion == null) || (actualVersion == "")) + { + error(webxmlpath,"Attribute <web-app version=\"\"> must exist with a valid value"); + } + else + { + boolean valid = false; + for (String version : validVersions) + { + if (version.equals(actualVersion)) + { + ids.add(new ServletId(version,"version attribute",null)); + valid = true; + } + } + + if (!valid) + { + String msg = String.format("Invalid version value <web-app version=\"%s\">",actualVersion); + error(webxmlpath,msg); + } + } + } + } + else + { + error(webxmlpath,"Invalid web.xml, root element expectd to be <web-app>, but was <" + root.getTagName() + ">"); + } + + return ids; + } + + private boolean hasAnyValue(String... values) + { + for (String value : values) + { + if ((value != null) && (value.length() > 0)) + { + return true; + } + } + return false; + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/asm/ASMUtil.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/asm/ASMUtil.java new file mode 100644 index 0000000000..9267c57ea7 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/asm/ASMUtil.java @@ -0,0 +1,54 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules.asm; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.eclipse.jetty.util.IO; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; + +/** + * Some simple utility methods for working with ASM in a common way. + */ +public class ASMUtil +{ + public static void visitClassFile(File classFile, ClassVisitor visitor, int flags) throws IOException + { + FileInputStream fin = null; + ClassReader creader = null; + + try + { + fin = new FileInputStream(classFile); + creader = new ClassReader(fin); + creader.accept(visitor,flags); + } + finally + { + IO.close(fin); + } + } + + public static void visitClass(InputStream stream, ClassVisitor visitor, int flags) throws IOException + { + ClassReader creader = new ClassReader(stream); + creader.accept(visitor,flags); + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/asm/AbstractClassVisitor.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/asm/AbstractClassVisitor.java new file mode 100644 index 0000000000..1ec62be77d --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/rules/asm/AbstractClassVisitor.java @@ -0,0 +1,77 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules.asm; + +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Attribute; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.MethodVisitor; + +/** + * Abstact implementation of {@link ClassVisitor} to make asm use within Rules easier. + */ +public abstract class AbstractClassVisitor implements ClassVisitor +{ + + public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) + { + /* Override Ready */ + } + + public AnnotationVisitor visitAnnotation(String desc, boolean visible) + { + /* Override Ready */ + return null; + } + + public void visitAttribute(Attribute attr) + { + /* Override Ready */ + } + + public void visitEnd() + { + /* Override Ready */ + } + + public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) + { + /* Override Ready */ + return null; + } + + public void visitInnerClass(String name, String outerName, String innerName, int access) + { + /* Override Ready */ + } + + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) + { + /* Override Ready */ + return null; + } + + public void visitOuterClass(String owner, String name, String desc) + { + /* Override Ready */ + } + + public void visitSource(String source, String debug) + { + /* Override Ready */ + } +} diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/support/PathGlob.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/support/PathGlob.java new file mode 100644 index 0000000000..12dd2e1636 --- /dev/null +++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/support/PathGlob.java @@ -0,0 +1,58 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.support; + +public class PathGlob +{ + /** + * @return true if match. + */ + public static boolean match(String pathSpec, String path) throws IllegalArgumentException + { + return match(pathSpec,path,false); + } + + /** + * @return true if match. + */ + public static boolean match(String pathSpec, String path, boolean noDefault) throws IllegalArgumentException + { + char c = pathSpec.charAt(0); + if (c == '/') + { + if (!noDefault && pathSpec.length() == 1 || pathSpec.equals(path)) + return true; + + if (isPathWildcardMatch(pathSpec,path)) + return true; + } + else if (c == '*') + return path.regionMatches(path.length() - pathSpec.length() + 1,pathSpec,1,pathSpec.length() - 1); + return false; + } + + private static boolean isPathWildcardMatch(String pathSpec, String path) + { + // For a spec of "/foo/*" match "/foo" , "/foo/..." but not "/foobar" + int cpl = pathSpec.length() - 2; + if (pathSpec.endsWith("/*") && path.regionMatches(0,pathSpec,0,cpl)) + { + if (path.length() == cpl || '/' == path.charAt(cpl)) + return true; + } + return false; + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/.gitignore b/jetty-webapp-verifier/src/test/artifacts/.gitignore new file mode 100644 index 0000000000..bf5aabfefa --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/.gitignore @@ -0,0 +1,11 @@ +target/ +.classpath +.project +.settings/ +*.tar.gz +*.zip +bsh* +jruby* +jython* +groovy* +*.swp diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/pom.xml new file mode 100644 index 0000000000..3d7601f2e1 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/pom.xml @@ -0,0 +1,9 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-groovy-lib</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Groovy Lib</name> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory new file mode 100644 index 0000000000..8af8bb9660 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory @@ -0,0 +1 @@ +org.codehaus.groovy.jsr223.GroovyScriptEngineFactory
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..906d0a4f50 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-lib/src/main/resources/README.txt @@ -0,0 +1,4 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid JAR file, nor contains valid Groovy implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/pom.xml new file mode 100644 index 0000000000..82ecbe4dad --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/pom.xml @@ -0,0 +1,22 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-groovy-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Groovy Webapp</name> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-groovy-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/README.txt new file mode 100644 index 0000000000..f27b3191d9 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/README.txt @@ -0,0 +1,4 @@ +This is a webapp is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid WAR file, nor contains valid Groovy implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9f88c1f963 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>Archetype Created Web Application</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/dummy.groovy b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/dummy.groovy new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/dummy.groovy diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/other/lib.groovy b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/other/lib.groovy new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-groovy-webapp/src/main/webapp/other/lib.groovy diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/pom.xml new file mode 100644 index 0000000000..302fcaf410 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/pom.xml @@ -0,0 +1,20 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java11-lib</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Java1.1 Lib</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <target>1.1</target> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyLib.java b/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyLib.java new file mode 100644 index 0000000000..d9a8203d14 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyLib.java @@ -0,0 +1,27 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.testcase.verifier; + +/** + * Dummy class for testcase purposes. + */ +public class DummyLib +{ + public void dummyTestClassNotIntendedForUse() + { + /* not intended for use - only used for test case purposes */ + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..62c883903b --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java11-lib/src/main/resources/README.txt @@ -0,0 +1,3 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +This JAR file is not for use outside of the /jetty-webapp-verifier/ test cases. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/pom.xml new file mode 100644 index 0000000000..c2b6cc3872 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/pom.xml @@ -0,0 +1,20 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java12-lib</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Java1.2 Lib</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <target>1.2</target> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyUpdatedLib.java b/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyUpdatedLib.java new file mode 100644 index 0000000000..30e35fa1e6 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyUpdatedLib.java @@ -0,0 +1,27 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.testcase.verifier; + +/** + * Dummy class for testcase purposes. + */ +public class DummyUpdatedLib +{ + public void dummyTestClassNotIntendedForUse() + { + /* not intended for use - only used for test case purposes */ + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..62c883903b --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java12-lib/src/main/resources/README.txt @@ -0,0 +1,3 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +This JAR file is not for use outside of the /jetty-webapp-verifier/ test cases. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/pom.xml new file mode 100644 index 0000000000..29683ed739 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/pom.xml @@ -0,0 +1,20 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java13-lib</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Java1.3 Lib</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <target>1.3</target> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyCurrentLib.java b/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyCurrentLib.java new file mode 100644 index 0000000000..25f060c490 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyCurrentLib.java @@ -0,0 +1,27 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.testcase.verifier; + +/** + * Dummy class for testcase purposes. + */ +public class DummyCurrentLib +{ + public void dummyTestClassNotIntendedForUse() + { + /* not intended for use - only used for test case purposes */ + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..62c883903b --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java13-lib/src/main/resources/README.txt @@ -0,0 +1,3 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +This JAR file is not for use outside of the /jetty-webapp-verifier/ test cases. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/pom.xml new file mode 100644 index 0000000000..f469224ddb --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/pom.xml @@ -0,0 +1,20 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java14-lib</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Java1.4 Lib</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <target>1.4</target> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyFreshLib.java b/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyFreshLib.java new file mode 100644 index 0000000000..b93f2cfd98 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyFreshLib.java @@ -0,0 +1,27 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.testcase.verifier; + +/** + * Dummy class for testcase purposes. + */ +public class DummyFreshLib +{ + public void dummyTestClassNotIntendedForUse() + { + /* not intended for use - only used for test case purposes */ + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..62c883903b --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java14-lib/src/main/resources/README.txt @@ -0,0 +1,3 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +This JAR file is not for use outside of the /jetty-webapp-verifier/ test cases. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/pom.xml new file mode 100644 index 0000000000..e12af4a27c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/pom.xml @@ -0,0 +1,20 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java15-lib</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Java1.5 Lib</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyLatestLib.java b/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyLatestLib.java new file mode 100644 index 0000000000..be05acc114 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyLatestLib.java @@ -0,0 +1,27 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.testcase.verifier; + +/** + * Dummy class for testcase purposes. + */ +public class DummyLatestLib +{ + public void dummyTestClassNotIntendedForUse() + { + /* not intended for use - only used for test case purposes */ + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..62c883903b --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java15-lib/src/main/resources/README.txt @@ -0,0 +1,3 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +This JAR file is not for use outside of the /jetty-webapp-verifier/ test cases. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/pom.xml new file mode 100644 index 0000000000..6ff141d750 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/pom.xml @@ -0,0 +1,20 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java16-lib</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Java1.6 Lib</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <target>1.6</target> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyModernLib.java b/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyModernLib.java new file mode 100644 index 0000000000..1e4c0352dc --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/src/main/java/org/eclipse/jetty/testcase/verifier/DummyModernLib.java @@ -0,0 +1,27 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.testcase.verifier; + +/** + * Dummy class for testcase purposes. + */ +public class DummyModernLib +{ + public void dummyTestClassNotIntendedForUse() + { + /* not intended for use - only used for test case purposes */ + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..62c883903b --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-java16-lib/src/main/resources/README.txt @@ -0,0 +1,3 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +This JAR file is not for use outside of the /jetty-webapp-verifier/ test cases. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/pom.xml new file mode 100644 index 0000000000..c38b9b4035 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/pom.xml @@ -0,0 +1,84 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-javaversions-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Java Versions Webapp</name> + <dependencies> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java11-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java12-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java13-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java14-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java15-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-java16-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>explode-jars-to-classes</id> + <phase>process-resources</phase> + <goals> + <goal>unpack-dependencies</goal> + </goals> + <configuration> + <includes>**/*.class</includes> + <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <!-- + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-unpacked</id> + <phase>process-resources</phase> + <goals> + <goal>add-resource</goal> + </goals> + <configuration> + <resources> + <resource> + <directory>${project.build.directory}/dependencies</directory> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + --> + </plugins> + </build> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/src/main/webapp/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/src/main/webapp/README.txt new file mode 100644 index 0000000000..ba2e223322 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/src/main/webapp/README.txt @@ -0,0 +1,4 @@ +This is a webapp is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid WAR file, nor contains valid JRuby implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9f88c1f963 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-javaversions-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>Archetype Created Web Application</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/pom.xml new file mode 100644 index 0000000000..6fec6b3db3 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/pom.xml @@ -0,0 +1,9 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-jruby-lib</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy JRuby Lib</name> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..73178116f2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/src/main/resources/README.txt @@ -0,0 +1,4 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid JAR file, nor contains valid JRuby implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/src/main/resources/builtin/javasupport.rb b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/src/main/resources/builtin/javasupport.rb new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-lib/src/main/resources/builtin/javasupport.rb diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/pom.xml new file mode 100644 index 0000000000..1f04225a00 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/pom.xml @@ -0,0 +1,22 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-jruby-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy JRuby Webapp</name> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-jruby-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/README.txt new file mode 100644 index 0000000000..ba2e223322 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/README.txt @@ -0,0 +1,4 @@ +This is a webapp is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid WAR file, nor contains valid JRuby implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9f88c1f963 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>Archetype Created Web Application</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/example.rb b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/example.rb new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/example.rb diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/other/lib.rb b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/other/lib.rb new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/other/lib.rb diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/output.rhtml b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/output.rhtml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jruby-webapp/src/main/webapp/output.rhtml diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/pom.xml new file mode 100644 index 0000000000..28076c9057 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/pom.xml @@ -0,0 +1,9 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-jython-lib</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Jython Lib</name> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/java/org/python/Version.java b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/java/org/python/Version.java new file mode 100644 index 0000000000..bf6af0b796 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/java/org/python/Version.java @@ -0,0 +1,28 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + +package org.python; + +/** + * Dummy class for testcase purposes. + */ +public class Version +{ + public void dummyTestClassNotIntendedForUse() + { + /* not intended for use - only used for test case purposes */ + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/java/org/python/core/JythonInitializer.java b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/java/org/python/core/JythonInitializer.java new file mode 100644 index 0000000000..c9f720aa1d --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/java/org/python/core/JythonInitializer.java @@ -0,0 +1,28 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + +package org.python.core; + +/** + * Dummy class for testcase purposes. + */ +public class JythonInitializer +{ + public void dummyTestClassNotIntendedForUse() + { + /* not intended for use - only used for test case purposes */ + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/java/org/python/util/Generic.java b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/java/org/python/util/Generic.java new file mode 100644 index 0000000000..b692781f8e --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/java/org/python/util/Generic.java @@ -0,0 +1,28 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + +package org.python.util; + +/** + * Dummy class for testcase purposes. + */ +public class Generic +{ + public void dummyTestClassNotIntendedForUse() + { + /* not intended for use - only used for test case purposes */ + } +} diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..bc6accef09 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-lib/src/main/resources/README.txt @@ -0,0 +1,4 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid JAR file, nor contains valid Jython implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/pom.xml new file mode 100644 index 0000000000..c37cae0b53 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/pom.xml @@ -0,0 +1,22 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-jython-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Jython Webapp</name> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-jython-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/README.txt new file mode 100644 index 0000000000..ba2e223322 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/README.txt @@ -0,0 +1,4 @@ +This is a webapp is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid WAR file, nor contains valid JRuby implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9f88c1f963 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>Archetype Created Web Application</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/dummy.py b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/dummy.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/dummy.py diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/dummy.pyc b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/dummy.pyc new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/dummy.pyc diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/other/lib.py b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/other/lib.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-jython-webapp/src/main/webapp/other/lib.py diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/pom.xml new file mode 100644 index 0000000000..af7f08ef7c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/pom.xml @@ -0,0 +1,17 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-nativeaccess-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Native Access Webapp</name> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/README.txt new file mode 100644 index 0000000000..ba2e223322 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/README.txt @@ -0,0 +1,4 @@ +This is a webapp is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid WAR file, nor contains valid JRuby implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9f88c1f963 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>Archetype Created Web Application</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/dummy.exe b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/dummy.exe new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/dummy.exe diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/dummy.o b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/dummy.o new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/dummy.o diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/dummy.so b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/dummy.so new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/dummy.so diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/executable b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/executable new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/executable diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.dll b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.dll new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.dll diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.o b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.o new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.o diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so.0.5.7 b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so.0.5.7 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so.0.5.7 diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so.1 b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so.1 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so.1 diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so.5 b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so.5 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-nativeaccess-webapp/src/main/webapp/other/lib.so.5 diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-scm-lib/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-lib/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-lib/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-scm-lib/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-lib/pom.xml new file mode 100644 index 0000000000..992cccb5e2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-lib/pom.xml @@ -0,0 +1,84 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-scm-lib</artifactId> + <packaging>pom</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy SCM Lib</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>create-scm-files</id> + <phase>generate-resources</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <!-- Generating these resources, as they cannot be checked + in reliably. duh. ;-) --> + <tasks> + <property name="outdir" value="${project.build.directory}/generated-scm-resources" /> + <mkdir dir="${outdir}/CVS" /> + <touch file="${outdir}/.cvsignore" /> + <mkdir dir="${outdir}/.svn" /> + <mkdir dir="${outdir}/_svn" /> + <mkdir dir="${outdir}/.git" /> + <touch file="${outdir}/.gitignore" /> + <mkdir dir="${outdir}/RCS" /> + <mkdir dir="${outdir}/SCCS" /> + <touch file="${outdir}/vssver.scc" /> + <mkdir dir="${outdir}/.arch-ids" /> + <mkdir dir="${outdir}/.bzr" /> + <touch file="${outdir}/.MySCMServerInfo" /> + <mkdir dir="${outdir}/.hg" /> + <mkdir dir="${outdir}/BitKeeper" /> + <mkdir dir="${outdir}/ChangeSet" /> + <mkdir dir="${outdir}/_darcs" /> + <mkdir dir="${outdir}/.darcs" /> + <mkdir dir="${outdir}/.darcsrepo" /> + <touch file="${outdir}/.darcs-temp-mail" /> + <copy file="${basedir}/src/main/resources/README.txt" + todir="${outdir}" /> + + <!-- Generating JAR file here as Maven is too smart and + won't allow you to create JAR files with SCM content in it. + --> + <jar destfile="${project.build.directory}/${project.artifactId}-${project.version}.jar" + basedir="${outdir}" + includes="**/*" + defaultexcludes="false" + /> + </tasks> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-scm-lib</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file> + <type>jar</type> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-scm-lib/src/main/resources/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-lib/src/main/resources/README.txt new file mode 100644 index 0000000000..62c883903b --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-lib/src/main/resources/README.txt @@ -0,0 +1,3 @@ +This dummy lib is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +This JAR file is not for use outside of the /jetty-webapp-verifier/ test cases. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/pom.xml new file mode 100644 index 0000000000..f2a20367d6 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/pom.xml @@ -0,0 +1,116 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-scm-webapp</artifactId> + <packaging>pom</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy SCM Webapp</name> + <dependencies> + <dependency> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-scm-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + <properties> + <war_work_dir>${project.build.directory}/generated-webapp</war_work_dir> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>create-scm-files</id> + <phase>generate-resources</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <mkdir dir="${war_work_dir}/CVS" /> + <touch file="${war_work_dir}/.cvsignore" /> + <mkdir dir="${war_work_dir}/.svn" /> + <mkdir dir="${war_work_dir}/_svn" /> + <mkdir dir="${war_work_dir}/.git" /> + <touch file="${war_work_dir}/.gitignore" /> + <mkdir dir="${war_work_dir}/RCS" /> + <mkdir dir="${war_work_dir}/SCCS" /> + <touch file="${war_work_dir}/vssver.scc" /> + <mkdir dir="${war_work_dir}/.arch-ids" /> + <mkdir dir="${war_work_dir}/.bzr" /> + <touch file="${war_work_dir}/.MySCMServerInfo" /> + <mkdir dir="${war_work_dir}/.hg" /> + <mkdir dir="${war_work_dir}/BitKeeper" /> + <mkdir dir="${war_work_dir}/ChangeSet" /> + <mkdir dir="${war_work_dir}/_darcs" /> + <mkdir dir="${war_work_dir}/.darcs" /> + <mkdir dir="${war_work_dir}/.darcsrepo" /> + <touch file="${war_work_dir}/.darcs-temp-mail" /> + <copy todir="${war_work_dir}"> + <fileset dir="${basedir}/src/main/webapp" /> + </copy> + <mkdir dir="${war_work_dir}/WEB-INF/lib" /> + </tasks> + </configuration> + </execution> + <execution> + <id>create-war</id> + <phase>package</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <jar destfile="${project.build.directory}/${project.artifactId}-${project.version}.war" + basedir="${war_work_dir}" + includes="**/*" + defaultexcludes="false" + /> + </tasks> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-deps</id> + <phase>process-resources</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${war_work_dir}/WEB-INF/lib</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-scm-lib</id> + <phase>process-resources</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file>${project.build.directory}/${project.artifactId}-${project.version}.war</file> + <type>war</type> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/src/main/webapp/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/src/main/webapp/README.txt new file mode 100644 index 0000000000..ba2e223322 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/src/main/webapp/README.txt @@ -0,0 +1,4 @@ +This is a webapp is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid WAR file, nor contains valid JRuby implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9f88c1f963 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-scm-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>Archetype Created Web Application</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servlet23-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet23-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet23-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servlet23-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet23-webapp/pom.xml new file mode 100644 index 0000000000..fb11c34596 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet23-webapp/pom.xml @@ -0,0 +1,9 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-servlet23-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Servlet 2.3 Webapp</name> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servlet23-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet23-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..8e33e5df0f --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet23-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>Web Application with Servlet 2.3</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servlet24-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet24-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet24-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servlet24-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet24-webapp/pom.xml new file mode 100644 index 0000000000..124277c062 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet24-webapp/pom.xml @@ -0,0 +1,9 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-servlet24-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Servlet 2.4 Webapp</name> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servlet24-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet24-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..84d45f9032 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet24-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> + +<web-app xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" + version="2.4"> + + <display-name>Web Application for Servlet 2.4</display-name> + +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servlet25-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet25-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet25-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servlet25-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet25-webapp/pom.xml new file mode 100644 index 0000000000..53f45ba3b9 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet25-webapp/pom.xml @@ -0,0 +1,9 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-servlet25-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Servlet 2.5 Webapp</name> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servlet25-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet25-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..d06d132c1c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servlet25-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<web-app xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd" + version="2.5"> + + <display-name>Web Application for Servlet 2.5</display-name> + +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed1-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed1-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed1-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed1-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed1-webapp/pom.xml new file mode 100644 index 0000000000..60dd7e54cf --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed1-webapp/pom.xml @@ -0,0 +1,9 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-servletmixed1-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Servlet Mixed 2.3+2.4 Webapp</name> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed1-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed1-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..7380f0f453 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed1-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> + +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> +<web-app id="dummymixed1" xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" + version="2.4"> + <display-name>Web Application with Mixed Servlet 2.3+2.4</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed2-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed2-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed2-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed2-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed2-webapp/pom.xml new file mode 100644 index 0000000000..28905a1b9f --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed2-webapp/pom.xml @@ -0,0 +1,9 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-servletmixed2-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Servlet Mixed 2.3+2.5 Webapp</name> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed2-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed2-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..655af0b40d --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-servletmixed2-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd"> + +<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> + <display-name>Web Application with Mixed Servlet 2.3+2.5</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/.gitignore b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/.gitignore new file mode 100644 index 0000000000..8baee4f43c --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/.gitignore @@ -0,0 +1,8 @@ +target/ +.classpath +.project +.settings +*.swp +*.log +*.patch +*.diff diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/pom.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/pom.xml new file mode 100644 index 0000000000..419a4ce698 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/pom.xml @@ -0,0 +1,17 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>dummy-shellscripts-webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>Jetty :: Webapp Verifier :: Dummy Shellscripts Webapp</name> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/README.txt b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/README.txt new file mode 100644 index 0000000000..f9b06ce72d --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/README.txt @@ -0,0 +1,4 @@ +This is a webapp is a TEST RESOURCE, used by the jetty project at http://www.eclipse.org/jetty/ + +It is neither a valid WAR file, nor contains valid Shell Script implementations, +in either scripting, source or binary form. diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9f88c1f963 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>Archetype Created Web Application</display-name> +</web-app> diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.bat b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.bat new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.bat diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.cmd b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.cmd new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.cmd diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.sh b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.sh new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.sh diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.vbs b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.vbs new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/dummy.vbs diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.bat b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.bat new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.bat diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.cmd b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.cmd new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.cmd diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.sh b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.sh new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.sh diff --git a/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.vbs b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.vbs new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/dummy-shellscripts-webapp/src/main/webapp/other/lib.vbs diff --git a/jetty-webapp-verifier/src/test/artifacts/pom.xml b/jetty-webapp-verifier/src/test/artifacts/pom.xml new file mode 100644 index 0000000000..2378b4f5d1 --- /dev/null +++ b/jetty-webapp-verifier/src/test/artifacts/pom.xml @@ -0,0 +1,36 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-project</artifactId> + <version>7.0.0.RC3-SNAPSHOT</version> + </parent> + <groupId>org.eclipse.jetty.tests</groupId> + <artifactId>jetty-webapp-verifier-artifacts</artifactId> + <name>Jetty :: Webapp Verifier :: Artifacts Parent</name> + <packaging>pom</packaging> + <modules> + <module>dummy-jruby-lib</module> + <module>dummy-jython-lib</module> + <module>dummy-groovy-lib</module> + <module>dummy-jruby-webapp</module> + <module>dummy-jython-webapp</module> + <module>dummy-groovy-webapp</module> + <module>dummy-shellscripts-webapp</module> + <module>dummy-nativeaccess-webapp</module> + <module>dummy-java11-lib</module> + <module>dummy-java12-lib</module> + <module>dummy-java13-lib</module> + <module>dummy-java14-lib</module> + <module>dummy-java15-lib</module> + <module>dummy-java16-lib</module> + <module>dummy-javaversions-webapp</module> + <module>dummy-scm-lib</module> + <module>dummy-scm-webapp</module> + <module>dummy-servlet23-webapp</module> + <module>dummy-servlet24-webapp</module> + <module>dummy-servlet25-webapp</module> + <module>dummy-servletmixed1-webapp</module> + <module>dummy-servletmixed2-webapp</module> + </modules> +</project> diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/AbstractTestWebappVerifier.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/AbstractTestWebappVerifier.java new file mode 100644 index 0000000000..a3dec9785d --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/AbstractTestWebappVerifier.java @@ -0,0 +1,46 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.File; +import junit.framework.TestCase; + +import org.eclipse.jetty.util.IO; + +public class AbstractTestWebappVerifier extends TestCase +{ + protected File getTestWorkDir() + { + File workDir = MavenTestingUtils.toTargetFile("test-work-dir"); + if (!workDir.exists()) + { + workDir.mkdirs(); + } + File testSpecificDir = new File(workDir,this.getClass().getSimpleName() + "_" + getName()); + if (testSpecificDir.exists()) + { + IO.delete(testSpecificDir); + } + testSpecificDir.mkdirs(); + return testSpecificDir; + } + + protected RuleSet loadRuleSet(String name) throws Exception + { + File xmlFile = MavenTestingUtils.getTestResourceFile(name); + return RuleSet.load(xmlFile.toURL()); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/CountingRule.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/CountingRule.java new file mode 100644 index 0000000000..a9f055a691 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/CountingRule.java @@ -0,0 +1,126 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.File; +import java.util.jar.JarFile; +import java.util.zip.ZipFile; + +public class CountingRule extends AbstractRule +{ + public int countWebappStart = 0; + public int countDirStart = 0; + public int countFile = 0; + public int countDirEnd = 0; + public int countWebInfClassesStart = 0; + public int countWebInfClass = 0; + public int countWebInfClassResource = 0; + public int countWebInfClassesEnd = 0; + public int countWebInfLibStart = 0; + public int countWebInfLibJar = 0; + public int countWebInfLibZip = 0; + public int countWebInfLibEnd = 0; + public int countWebappEnd = 0; + + public String getDescription() + { + return "TestCase only rule, that counts hits to visitors"; + } + + public String getName() + { + return "test-counting"; + } + + @Override + public void visitDirectoryEnd(String path, File dir) + { + countDirEnd++; + } + + @Override + public void visitDirectoryStart(String path, File dir) + { + countDirStart++; + } + + @Override + public void visitFile(String path, File dir, File file) + { + countFile++; + } + + @Override + public void visitWebappEnd(String path, File dir) + { + countWebappEnd++; + } + + @Override + public void visitWebappStart(String path, File dir) + { + super.visitWebappStart(path,dir); + countWebappStart++; + } + + @Override + public void visitWebInfClass(String path, String className, File classFile) + { + countWebInfClass++; + } + + @Override + public void visitWebInfClassesEnd(String path, File dir) + { + countWebInfClassesEnd++; + } + + @Override + public void visitWebInfClassesStart(String path, File dir) + { + countWebInfClassesStart++; + } + + @Override + public void visitWebInfClassResource(String path, String resourcePath, File resourceFile) + { + countWebInfClassResource++; + } + + @Override + public void visitWebInfLibEnd(String path, File dir) + { + countWebInfLibEnd++; + } + + @Override + public void visitWebInfLibJar(String path, File archive, JarFile jar) + { + countWebInfLibJar++; + } + + @Override + public void visitWebInfLibStart(String path, File dir) + { + countWebInfLibStart++; + } + + @Override + public void visitWebInfLibZip(String path, File archive, ZipFile zip) + { + countWebInfLibZip++; + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/MavenTestingUtils.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/MavenTestingUtils.java new file mode 100644 index 0000000000..6691f717e4 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/MavenTestingUtils.java @@ -0,0 +1,166 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import org.eclipse.jetty.util.IO; + +/** + * Common utility methods for working with JUnit tests cases in a maven friendly way. + */ +public class MavenTestingUtils +{ + private static File basedir; + private static File testResourcesDir; + private static File targetDir; + + public static File getBasedir() + { + if (basedir == null) + { + String cwd = System.getProperty("basedir"); + + if (cwd == null) + { + cwd = System.getProperty("user.dir"); + } + + basedir = new File(cwd); + } + + return basedir; + } + + /** + * Get the directory to the /target directory for this project. + * + * @return the directory path to the target directory. + */ + public static File getTargetDir() + { + if (targetDir == null) + { + targetDir = new File(basedir,"target"); + PathAssert.assertDirExists("Target Dir",targetDir); + } + return targetDir; + } + + /** + * Get a file from the src/test/resource directory. + * + * @param name + * the name of the path to get (it must exist as a file) + * @return the file in src/test/resource + */ + public static File getTestResourceFile(String name) + { + File file = new File(getTestResourcesDir(),name); + PathAssert.assertFileExists("Test Resource File",file); + return file; + } + + /** + * Get a dir from the src/test/resource directory. + * + * @param name + * the name of the path to get (it must exist as a dir) + * @return the dir in src/test/resource + */ + public static File getTestResourceDir(String name) + { + File dir = new File(getTestResourcesDir(),name); + PathAssert.assertDirExists("Test Resource Dir",dir); + return dir; + } + + /** + * Get a path resource (File or Dir) from the src/test/resource directory. + * + * @param name + * the name of the path to get (it must exist) + * @return the path in src/test/resource + */ + public static File getTestResourcePath(String name) + { + File path = new File(getTestResourcesDir(),name); + PathAssert.assertExists("Test Resource Path",path); + return path; + } + + /** + * Get the directory to the src/test/resource directory + * + * @return the directory {@link File} to the src/test/resources directory + */ + public static File getTestResourcesDir() + { + if (testResourcesDir == null) + { + testResourcesDir = new File(basedir,"src/test/resources".replace("/",File.separator)); + PathAssert.assertDirExists("Test Resources Dir",testResourcesDir); + } + return testResourcesDir; + } + + /** + * Create a {@link File} object for a path in the /target directory. + * + * @param path + * the path desired, no validation of existence is performed. + * @return the File to the path. + */ + public static File toTargetFile(String path) + { + return new File(getTargetDir(),path.replace("/",File.separator)); + } + + /** + * Read the contents of a file into a String and return it. + * + * @param file + * the file to read. + * @return the contents of the file. + * @throws IOException + * if unable to read the file. + */ + public static String readToString(File file) throws IOException + { + FileReader reader = null; + try + { + reader = new FileReader(file); + return IO.toString(reader); + } + finally + { + IO.close(reader); + } + } + + public static File toTargetTestingDir() + { + File dir = new File(getTargetDir(),"testing"); + if (!dir.exists()) + { + dir.mkdirs(); + } + return dir; + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/PathAssert.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/PathAssert.java new file mode 100644 index 0000000000..ff3012bc93 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/PathAssert.java @@ -0,0 +1,40 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.File; + +import junit.framework.Assert; + +public class PathAssert +{ + public static void assertDirExists(String msg, File path) + { + assertExists(msg,path); + Assert.assertTrue(msg + " path should be a Dir : " + path.getAbsolutePath(),path.isDirectory()); + } + + public static void assertFileExists(String msg, File path) + { + assertExists(msg,path); + Assert.assertTrue(msg + " path should be a File : " + path.getAbsolutePath(),path.isFile()); + } + + public static void assertExists(String msg, File path) + { + Assert.assertTrue(msg + " path should exist: " + path.getAbsolutePath(),path.exists()); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/RuleAssert.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/RuleAssert.java new file mode 100644 index 0000000000..5b9f25ba33 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/RuleAssert.java @@ -0,0 +1,184 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import junit.framework.Assert; + +import org.eclipse.jetty.util.IO; + +/** + * Rule based assertions. + */ +public class RuleAssert +{ + private static Pattern expectedViolationPattern; + + /** + * <p> + * Perform a static Rule assertion. + * </p> + * + * <p> + * You will need the following files. + * </p> + * + * <ol> + * <li><code>src/test/resources/${prefix}.setup.txt</code> - contains 1 line, which is the src/test/resources + * relative path to the webapp you want to test, (it can be a WAR file, or an exploded webapp directory</li> + * + * <li><code>src/test/resources/${prefix}.config.xml</code> - contains an XMLConfiguration suitable XML file for + * loading into a RuleSet. Represents the configuration that will be used for this test.</li> + * + * <li><code>src/test/resources/${prefix}.expectations.txt</code> - contains a list of expected Violations (1 + * violation per line), with the expected values pipe <code>"|"</code> delimited. Example: pattern is + * <code>"${severity}|${path}|${detail}"</code>, where a representative line + * <code>"ERROR|/WEB-INF|Missing required web.xml"</code> would mean a violation of type {@link Severity#ERROR}, + * with path <code>"/WEB-INF"</code>, and detail <code>"Missing required web.xml"</code></li> + * </ol> + * + * @param prefix + * the prefix of the integration files in src/test/resources that you want to use. + * @throws Exception + */ + public static void assertIntegration(String prefix) throws Exception + { + // Load the 3 integration files. + File setupFile = MavenTestingUtils.getTestResourceFile(prefix + ".setup.txt"); + File configFile = MavenTestingUtils.getTestResourceFile(prefix + ".config.xml"); + File expectationFile = MavenTestingUtils.getTestResourceFile(prefix + ".expectations.txt"); + + // Establish Webapp to use + String webappName = MavenTestingUtils.readToString(setupFile).trim(); + File webappPath = MavenTestingUtils.getTestResourcePath(webappName); + URI webappURI = webappPath.toURI(); + + // Load RuleSet configuration + RuleSet ruleset = RuleSet.load(configFile); + + // Run Verification + WebappVerifier verifier = ruleset.createWebappVerifier(webappURI); + verifier.setWorkDir(MavenTestingUtils.toTargetTestingDir()); + verifier.visitAll(); + + // Compare violations + assertViolations(loadExpectedViolations(expectationFile),verifier.getViolations()); + } + + public static void assertViolations(Collection<Violation> expectedColl, Collection<Violation> actualColl) + { + List<Violation> actualViolations = new ArrayList<Violation>(actualColl); + List<Violation> expectedViolations = new ArrayList<Violation>(expectedColl); + + Collections.sort(actualViolations,ViolationComparator.getInstance()); + Collections.sort(expectedViolations,ViolationComparator.getInstance()); + + // Compare expected vs actual + if (expectedViolations.size() != actualViolations.size()) + { + dumpViolations("Expected",expectedViolations); + dumpViolations("Actual",actualViolations); + Assert.assertEquals("Violation count",expectedViolations.size(),actualViolations.size()); + } + + for (int i = 0, n = expectedViolations.size(); i < n; i++) + { + Violation expected = expectedViolations.get(i); + Violation actual = actualViolations.get(i); + + Assert.assertEquals("Violation[" + i + "].path",expected.getPath(),actual.getPath()); + Assert.assertEquals("Violation[" + i + "].detail",expected.getDetail(),actual.getDetail()); + Assert.assertEquals("Violation[" + i + "].severity",expected.getSeverity(),actual.getSeverity()); + // TODO: add check on Violation.throwable + // TODO: add check on Violation.verifierId + // TODO: add check on Violation.verifierClass + } + } + + public static void dumpViolations(String msg, Collection<Violation> violations) + { + System.out.println(); + System.out.printf("/* Violations Dump: %s */%n",msg); + for (Violation violation : violations) + { + System.out.println(violation.toDelimString()); + } + } + + public static Collection<Violation> loadExpectedViolations(File expectationFile) throws IOException + { + FileReader reader = null; + BufferedReader buf = null; + try + { + List<Violation> ret = new ArrayList<Violation>(); + reader = new FileReader(expectationFile); + buf = new BufferedReader(reader); + + String line; + + while ((line = buf.readLine()) != null) + { + if (line.charAt(0) == '#') + { + // a comment. + continue; + } + + // Parse line + Violation violation = parseViolation(line); + + Assert.assertNotNull("Unable to parse expected violation line: " + line,violation); + + // Add to list + ret.add(violation); + } + + return ret; + } + finally + { + IO.close(buf); + IO.close(reader); + } + } + + protected static Violation parseViolation(String line) + { + expectedViolationPattern = Pattern.compile("^([^|]*)\\|([^|]*)\\|(.*)$"); + Matcher mat = expectedViolationPattern.matcher(line); + if (mat.matches()) + { + Severity severity = Severity.parse(mat.group(1)); + String path = mat.group(2); + String detail = mat.group(3); + return new Violation(severity,path,detail); + } + else + return null; + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/RuleAssertTest.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/RuleAssertTest.java new file mode 100644 index 0000000000..cc3d837bb1 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/RuleAssertTest.java @@ -0,0 +1,33 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import junit.framework.TestCase; + +public class RuleAssertTest extends TestCase +{ + public void testParseLine() + { + Violation v; + + v = RuleAssert.parseViolation("ERROR|/WEB-INF|Missing web.xml"); + + assertNotNull("Verifier should not be null",v); + assertEquals("Verifier.severity",Severity.ERROR,v.getSeverity()); + assertEquals("Verifier.path","/WEB-INF",v.getPath()); + assertEquals("Verifier.detail","Missing web.xml",v.getDetail()); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/RuleSetTest.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/RuleSetTest.java new file mode 100644 index 0000000000..5c19012f12 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/RuleSetTest.java @@ -0,0 +1,36 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import org.eclipse.jetty.webapp.verifier.rules.ForbiddenContentsRule; +import org.eclipse.jetty.webapp.verifier.rules.RequiredContentsRule; + +public class RuleSetTest extends AbstractTestWebappVerifier +{ + public void testLoad() throws Exception + { + RuleSet suite = loadRuleSet("basic-ruleset.xml"); + assertNotNull("Should have a valid RuleSet.",suite); + + assertNotNull("verifier list should not be null",suite.getRules()); + assertEquals("Should have 2 verifier",2,suite.getRules().size()); + + Rule verifier = suite.getRules().get(0); + assertEquals("Verifier[0]",ForbiddenContentsRule.class.getName(),verifier.getClass().getName()); + verifier = suite.getRules().get(1); + assertEquals("Verifier[1]",RequiredContentsRule.class.getName(),verifier.getClass().getName()); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/WebappVerifierTest.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/WebappVerifierTest.java new file mode 100644 index 0000000000..a5301492a3 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/WebappVerifierTest.java @@ -0,0 +1,63 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier; + +import java.util.Collection; + +public class WebappVerifierTest extends AbstractTestWebappVerifier +{ + public void testVerifierVisitation() throws Exception + { + CountingRule counts = new CountingRule(); + + // Create Webapp Specific Verifier from Verifier Suite + WebappVerifier verifier = new WebappVerifier(MavenTestingUtils.toTargetFile("war-files/test-webapp-logging-java.war").toURI()); + verifier.addRule(counts); + verifier.setWorkDir(getTestWorkDir()); + + // Run the verification. + verifier.visitAll(); + + // Collect the violations + Collection<Violation> violations = verifier.getViolations(); + assertNotNull("Should never have a null set of Violations",violations); + assertEquals("No violations caused",0,violations.size()); + + // Ensure each visitor was visited according to real contents of WAR + assertEquals("Counts.webappStart",1,counts.countWebappStart); + assertEquals("Counts.countWebappEnd",1,counts.countWebappEnd); + + // Visits in Directory + assertEquals("Counts.countDirStart",12,counts.countDirStart); + assertEquals("Counts.countFile",6,counts.countFile); + assertEquals("Counts.countDirEnd",12,counts.countDirEnd); + assertEquals("Counts.countDir (Start == End)",counts.countDirStart,counts.countDirEnd); + + // Visits in WEB-INF/classes + assertEquals("Counts.countWebInfClassesStart",1,counts.countWebInfClassesStart); + assertEquals("Counts.countWebInfClass",1,counts.countWebInfClass); + assertEquals("Counts.countWebInfClassResource",1,counts.countWebInfClassResource); + assertEquals("Counts.countWebInfClassesEnd",1,counts.countWebInfClassesEnd); + assertEquals("Counts.countWebInfClasses (Start == End)",counts.countWebInfClassesStart,counts.countWebInfClassesEnd); + + // Visits in WEB-INF/lib + assertEquals("Counts.countWebInfLibStart",0,counts.countWebInfLibStart); + assertEquals("Counts.countWebInfLibJar",0,counts.countWebInfLibJar); + assertEquals("Counts.countWebInfLibZip",0,counts.countWebInfLibZip); + assertEquals("Counts.countWebInfLibEnd",0,counts.countWebInfLibEnd); + assertEquals("Counts.countWebInfLib (Start == End)",counts.countWebInfLibStart,counts.countWebInfLibEnd); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/JarSignatureRuleTest.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/JarSignatureRuleTest.java new file mode 100644 index 0000000000..10917769d9 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/JarSignatureRuleTest.java @@ -0,0 +1,39 @@ +// ======================================================================== +// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import org.eclipse.jetty.webapp.verifier.AbstractTestWebappVerifier; +import org.eclipse.jetty.webapp.verifier.MavenTestingUtils; +import org.eclipse.jetty.webapp.verifier.WebappVerifier; +import org.eclipse.jetty.webapp.verifier.rules.JarSignatureRule; + +/** + * Tests against {@link JarSignatureRule} + */ +public class JarSignatureRuleTest extends AbstractTestWebappVerifier +{ + public void testSimpleVerify() throws Exception + { + JarSignatureRule signed = new JarSignatureRule(); + + // Create Webapp Specific Verifier from Verifier Suite + WebappVerifier verifier = new WebappVerifier(MavenTestingUtils.toTargetFile("test-classes/webapps/signed-jar-test-webapp.war").toURI()); + verifier.addRule( signed ); + verifier.setWorkDir( getTestWorkDir() ); + + // Run the verification. + verifier.visitAll(); + + assertTrue( verifier.getViolations().size() == 0 ); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/JavaSupportLevelRuleTest.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/JavaSupportLevelRuleTest.java new file mode 100644 index 0000000000..bf1561b648 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/JavaSupportLevelRuleTest.java @@ -0,0 +1,18 @@ +package org.eclipse.jetty.webapp.verifier.rules; + +import org.eclipse.jetty.webapp.verifier.RuleAssert; + +import junit.framework.TestCase; + +public class JavaSupportLevelRuleTest extends TestCase +{ + public void testJava15() throws Exception + { + RuleAssert.assertIntegration("java_level_1.5"); + } + + public void testJava14() throws Exception + { + RuleAssert.assertIntegration("java_level_1.4"); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/NoNativeRuleTest.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/NoNativeRuleTest.java new file mode 100644 index 0000000000..f082411392 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/NoNativeRuleTest.java @@ -0,0 +1,13 @@ +package org.eclipse.jetty.webapp.verifier.rules; + +import org.eclipse.jetty.webapp.verifier.RuleAssert; + +import junit.framework.TestCase; + +public class NoNativeRuleTest extends TestCase +{ + public void testNoNative() throws Exception + { + RuleAssert.assertIntegration("no_native"); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/NoScriptingRuleTest.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/NoScriptingRuleTest.java new file mode 100644 index 0000000000..c6c8bf32ec --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/NoScriptingRuleTest.java @@ -0,0 +1,42 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import org.eclipse.jetty.webapp.verifier.AbstractTestWebappVerifier; +import org.eclipse.jetty.webapp.verifier.RuleAssert; + +public class NoScriptingRuleTest extends AbstractTestWebappVerifier +{ + public void testJRubyConfiguration() throws Exception + { + RuleAssert.assertIntegration("no_scripting_jruby"); + } + + public void testJythonConfiguration() throws Exception + { + RuleAssert.assertIntegration("no_scripting_jython"); + } + + public void testGroovyConfiguration() throws Exception + { + RuleAssert.assertIntegration("no_scripting_groovy"); + } + + public void testShellConfiguration() throws Exception + { + RuleAssert.assertIntegration("no_scripting_shell"); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/NoSourceControlRuleTest.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/NoSourceControlRuleTest.java new file mode 100644 index 0000000000..f1716cbf59 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/NoSourceControlRuleTest.java @@ -0,0 +1,31 @@ +// ======================================================================== +// Copyright (c) Webtide LLC +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.apache.org/licenses/LICENSE-2.0.txt +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp.verifier.rules; + +import org.eclipse.jetty.webapp.verifier.RuleAssert; + +import junit.framework.TestCase; + +/** + * NoSourceControlRuleTest + */ +public class NoSourceControlRuleTest extends TestCase +{ + public void testNoScm() throws Exception + { + RuleAssert.assertIntegration("no_scm"); + } +} diff --git a/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/ServletSupportLevelRuleTest.java b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/ServletSupportLevelRuleTest.java new file mode 100644 index 0000000000..756a45aac0 --- /dev/null +++ b/jetty-webapp-verifier/src/test/java/org/eclipse/jetty/webapp/verifier/rules/ServletSupportLevelRuleTest.java @@ -0,0 +1,33 @@ +package org.eclipse.jetty.webapp.verifier.rules; + +import org.eclipse.jetty.webapp.verifier.RuleAssert; + +import junit.framework.TestCase; + +public class ServletSupportLevelRuleTest extends TestCase +{ + public void testServlet23Rule() throws Exception + { + RuleAssert.assertIntegration("servlet_level_2.3"); + } + + public void testServlet24Rule() throws Exception + { + RuleAssert.assertIntegration("servlet_level_2.4"); + } + + public void testServlet25Rule() throws Exception + { + RuleAssert.assertIntegration("servlet_level_2.5"); + } + + public void testServletMixed23n24Rule() throws Exception + { + RuleAssert.assertIntegration("servlet_level_mixed_2.3_2.4"); + } + + public void testServletMixed23n25Rule() throws Exception + { + RuleAssert.assertIntegration("servlet_level_mixed_2.3_2.5"); + } +} diff --git a/jetty-webapp-verifier/src/test/resources/basic-ruleset.xml b/jetty-webapp-verifier/src/test/resources/basic-ruleset.xml new file mode 100644 index 0000000000..2ac16f95f3 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/basic-ruleset.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.ForbiddenContentsRule"> + <Call name="addPattern"> + <Arg>*.jsp</Arg> + </Call> + </New> + </Item> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.RequiredContentsRule"> + <Call name="addPath"> + <Arg>/copyright.jsp</Arg> + </Call> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/content-verifier/WEB-INF/web.xml b/jetty-webapp-verifier/src/test/resources/content-verifier/WEB-INF/web.xml new file mode 100644 index 0000000000..12bbf745ce --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/content-verifier/WEB-INF/web.xml @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?> diff --git a/jetty-webapp-verifier/src/test/resources/java_level_1.4.config.xml b/jetty-webapp-verifier/src/test/resources/java_level_1.4.config.xml new file mode 100644 index 0000000000..aa26dd24aa --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/java_level_1.4.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.JavaSupportLevelRule"> + <Set name="supportedVersion">1.4</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/java_level_1.4.expectations.txt b/jetty-webapp-verifier/src/test/resources/java_level_1.4.expectations.txt new file mode 100644 index 0000000000..432b244129 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/java_level_1.4.expectations.txt @@ -0,0 +1,4 @@ +ERROR|WEB-INF/classes/org/eclipse/jetty/testcase/verifier/DummyLatestLib.class|Class is compiled for java version [1.5] which is over supported java version [1.4] +ERROR|WEB-INF/classes/org/eclipse/jetty/testcase/verifier/DummyModernLib.class|Class is compiled for java version [1.6] which is over supported java version [1.4] +ERROR|WEB-INF/lib/dummy-java15-lib-1.0-SNAPSHOT.jar!/org/eclipse/jetty/testcase/verifier/DummyLatestLib.class|Class is compiled for java version [1.5] which is over supported java version [1.4] +ERROR|WEB-INF/lib/dummy-java16-lib-1.0-SNAPSHOT.jar!/org/eclipse/jetty/testcase/verifier/DummyModernLib.class|Class is compiled for java version [1.6] which is over supported java version [1.4] diff --git a/jetty-webapp-verifier/src/test/resources/java_level_1.4.setup.txt b/jetty-webapp-verifier/src/test/resources/java_level_1.4.setup.txt new file mode 100644 index 0000000000..db98daf3ec --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/java_level_1.4.setup.txt @@ -0,0 +1 @@ +webapps/dummy-javaversions-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/java_level_1.5.config.xml b/jetty-webapp-verifier/src/test/resources/java_level_1.5.config.xml new file mode 100644 index 0000000000..5f80d29608 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/java_level_1.5.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.JavaSupportLevelRule"> + <Set name="supportedVersion">1.5</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/java_level_1.5.expectations.txt b/jetty-webapp-verifier/src/test/resources/java_level_1.5.expectations.txt new file mode 100644 index 0000000000..c119c45715 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/java_level_1.5.expectations.txt @@ -0,0 +1,2 @@ +ERROR|WEB-INF/classes/org/eclipse/jetty/testcase/verifier/DummyModernLib.class|Class is compiled for java version [1.6] which is over supported java version [1.5] +ERROR|WEB-INF/lib/dummy-java16-lib-1.0-SNAPSHOT.jar!/org/eclipse/jetty/testcase/verifier/DummyModernLib.class|Class is compiled for java version [1.6] which is over supported java version [1.5] diff --git a/jetty-webapp-verifier/src/test/resources/java_level_1.5.setup.txt b/jetty-webapp-verifier/src/test/resources/java_level_1.5.setup.txt new file mode 100644 index 0000000000..db98daf3ec --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/java_level_1.5.setup.txt @@ -0,0 +1 @@ +webapps/dummy-javaversions-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_native.config.xml b/jetty-webapp-verifier/src/test/resources/no_native.config.xml new file mode 100644 index 0000000000..47d49fc9c7 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_native.config.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.NoNativeRule" /> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_native.expectations.txt b/jetty-webapp-verifier/src/test/resources/no_native.expectations.txt new file mode 100644 index 0000000000..b187c8eeab --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_native.expectations.txt @@ -0,0 +1,6 @@ +ERROR|dummy.exe|Native code is forbidden +ERROR|dummy.o|Native code is forbidden +ERROR|dummy.so|Native code is forbidden +ERROR|other/lib.dll|Native code is forbidden +ERROR|other/lib.o|Native code is forbidden +ERROR|other/lib.so|Native code is forbidden diff --git a/jetty-webapp-verifier/src/test/resources/no_native.setup.txt b/jetty-webapp-verifier/src/test/resources/no_native.setup.txt new file mode 100644 index 0000000000..543f1ae374 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_native.setup.txt @@ -0,0 +1 @@ +webapps/dummy-nativeaccess-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scm.config.xml b/jetty-webapp-verifier/src/test/resources/no_scm.config.xml new file mode 100644 index 0000000000..af006caf35 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scm.config.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.NoSourceControlRule" /> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scm.expectations.txt b/jetty-webapp-verifier/src/test/resources/no_scm.expectations.txt new file mode 100644 index 0000000000..0b0f2c893b --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scm.expectations.txt @@ -0,0 +1,36 @@ +ERROR|_darcs/|Darcs Source Control directories are not allowed +ERROR|_svn/|Subversion Source Control directories are not allowed +ERROR|.arch-ids/|Arch Source Control directories are not allowed +ERROR|.bzr/|Bazaar Source Control directories are not allowed +ERROR|.cvsignore|CVS Source Control file are not allowed +ERROR|.darcsrepo/|Darcs Source Control directories are not allowed +ERROR|.darcs-temp-mail|Darcs Source Control file are not allowed +ERROR|.git/|Git Source Control directories are not allowed +ERROR|.gitignore|Git Source Control file are not allowed +ERROR|.hg/|Mercurial Source Control directories are not allowed +ERROR|.MySCMServerInfo|SurroundSCM Source Control file are not allowed +ERROR|.svn/|Subversion Source Control directories are not allowed +ERROR|BitKeeper/|BitKeeper Source Control directories are not allowed +ERROR|ChangeSet/|BitKeeper Source Control directories are not allowed +ERROR|CVS/|CVS Source Control directories are not allowed +ERROR|RCS/|RCS Source Control directories are not allowed +ERROR|SCCS/|SCCS Source Control directories are not allowed +ERROR|vssver.scc|Visual SourceSafe Source Control file are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/_darcs/|Darcs Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/_svn/|Subversion Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.arch-ids/|Arch Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.bzr/|Bazaar Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.cvsignore|CVS Source Control file are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.darcsrepo/|Darcs Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.darcs-temp-mail|Darcs Source Control file are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.git/|Git Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.gitignore|Git Source Control file are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.hg/|Mercurial Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.MySCMServerInfo|SurroundSCM Source Control file are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/.svn/|Subversion Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/BitKeeper/|BitKeeper Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/ChangeSet/|BitKeeper Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/CVS/|CVS Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/RCS/|RCS Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/SCCS/|SCCS Source Control directories are not allowed +ERROR|WEB-INF/lib/dummy-scm-lib-1.0-SNAPSHOT.jar!/vssver.scc|Visual SourceSafe Source Control file are not allowed diff --git a/jetty-webapp-verifier/src/test/resources/no_scm.setup.txt b/jetty-webapp-verifier/src/test/resources/no_scm.setup.txt new file mode 100644 index 0000000000..bc01807d23 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scm.setup.txt @@ -0,0 +1 @@ +webapps/dummy-scm-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_groovy.config.xml b/jetty-webapp-verifier/src/test/resources/no_scripting_groovy.config.xml new file mode 100644 index 0000000000..4986faf70b --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_groovy.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.NoScriptingRule"> + <Set name="allowGroovy">false</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_groovy.expectations.txt b/jetty-webapp-verifier/src/test/resources/no_scripting_groovy.expectations.txt new file mode 100644 index 0000000000..5a86d668a6 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_groovy.expectations.txt @@ -0,0 +1,4 @@ +ERROR|dummy.groovy|Groovy scripting not allowed +ERROR|other/lib.groovy|Groovy scripting not allowed +ERROR|WEB-INF/lib/dummy-groovy-lib-1.0-SNAPSHOT.jar!/org/codehaus/groovy/GroovyException.class|Groovy dependencies are not allowed +ERROR|WEB-INF/lib/dummy-groovy-lib-1.0-SNAPSHOT.jar!/org/codehaus/groovy/jsr223/GroovyScriptEngineFactory.class|Groovy dependencies are not allowed diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_groovy.setup.txt b/jetty-webapp-verifier/src/test/resources/no_scripting_groovy.setup.txt new file mode 100644 index 0000000000..f631249a77 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_groovy.setup.txt @@ -0,0 +1 @@ +webapps/dummy-groovy-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_jruby.config.xml b/jetty-webapp-verifier/src/test/resources/no_scripting_jruby.config.xml new file mode 100644 index 0000000000..882f5c2a30 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_jruby.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.NoScriptingRule"> + <Set name="allowJRuby">false</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_jruby.expectations.txt b/jetty-webapp-verifier/src/test/resources/no_scripting_jruby.expectations.txt new file mode 100644 index 0000000000..92678886a3 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_jruby.expectations.txt @@ -0,0 +1,6 @@ +ERROR|example.rb|JRuby scripting not allowed +ERROR|other/lib.rb|JRuby scripting not allowed +ERROR|output.rhtml|JRuby scripting not allowed +ERROR|WEB-INF/lib/dummy-jruby-lib-1.0-SNAPSHOT.jar!/org/jruby/javasupport/JavaArray.class|JRuby dependencies are not allowed +ERROR|WEB-INF/lib/dummy-jruby-lib-1.0-SNAPSHOT.jar!/org/jruby/Ruby.class|JRuby dependencies are not allowed +ERROR|WEB-INF/lib/dummy-jruby-lib-1.0-SNAPSHOT.jar!/org/jruby/runtime/RubyEvent.class|JRuby dependencies are not allowed
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_jruby.setup.txt b/jetty-webapp-verifier/src/test/resources/no_scripting_jruby.setup.txt new file mode 100644 index 0000000000..793c6a4e9e --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_jruby.setup.txt @@ -0,0 +1 @@ +webapps/dummy-jruby-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_jython.config.xml b/jetty-webapp-verifier/src/test/resources/no_scripting_jython.config.xml new file mode 100644 index 0000000000..83d5aad8b6 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_jython.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.NoScriptingRule"> + <Set name="allowJython">false</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_jython.expectations.txt b/jetty-webapp-verifier/src/test/resources/no_scripting_jython.expectations.txt new file mode 100644 index 0000000000..c6823a168a --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_jython.expectations.txt @@ -0,0 +1,6 @@ +ERROR|dummy.py|Jython and Python scripting not allowed +ERROR|dummy.pyc|Jython and Python scripting not allowed +ERROR|other/lib.py|Jython and Python scripting not allowed +ERROR|WEB-INF/lib/dummy-jython-lib-1.0-SNAPSHOT.jar!/org/python/util/Generic.class|Jython dependencies are not allowed +ERROR|WEB-INF/lib/dummy-jython-lib-1.0-SNAPSHOT.jar!/org/python/Version.class|Jython dependencies are not allowed +ERROR|WEB-INF/lib/dummy-jython-lib-1.0-SNAPSHOT.jar!/org/python/core/JythonInitializer.class|Jython dependencies are not allowed diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_jython.setup.txt b/jetty-webapp-verifier/src/test/resources/no_scripting_jython.setup.txt new file mode 100644 index 0000000000..4b20b76b0d --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_jython.setup.txt @@ -0,0 +1 @@ +webapps/dummy-jython-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_shell.config.xml b/jetty-webapp-verifier/src/test/resources/no_scripting_shell.config.xml new file mode 100644 index 0000000000..f97ea8bcdf --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_shell.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.NoScriptingRule"> + <Set name="allowShell">false</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_shell.expectations.txt b/jetty-webapp-verifier/src/test/resources/no_scripting_shell.expectations.txt new file mode 100644 index 0000000000..462b265c08 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_shell.expectations.txt @@ -0,0 +1,8 @@ +ERROR|dummy.bat|Shell scripting not allowed +ERROR|dummy.cmd|Shell scripting not allowed +ERROR|dummy.sh|Shell scripting not allowed +ERROR|dummy.vbs|Shell scripting not allowed +ERROR|other/lib.bat|Shell scripting not allowed +ERROR|other/lib.cmd|Shell scripting not allowed +ERROR|other/lib.sh|Shell scripting not allowed +ERROR|other/lib.vbs|Shell scripting not allowed diff --git a/jetty-webapp-verifier/src/test/resources/no_scripting_shell.setup.txt b/jetty-webapp-verifier/src/test/resources/no_scripting_shell.setup.txt new file mode 100644 index 0000000000..e180fb91db --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/no_scripting_shell.setup.txt @@ -0,0 +1 @@ +webapps/dummy-shellscripts-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_2.3.config.xml b/jetty-webapp-verifier/src/test/resources/servlet_level_2.3.config.xml new file mode 100644 index 0000000000..91b35b2524 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_2.3.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.ServletSupportLevelRule"> + <Set name="supportedVersion">2.1</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_2.3.expectations.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_2.3.expectations.txt new file mode 100644 index 0000000000..20af16893f --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_2.3.expectations.txt @@ -0,0 +1,2 @@ +ERROR|target/testing/dummy-servlet23-webapp/WEB-INF/web.xml|Specified servlet version 2.3 of DOCTYPE Public ID is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servlet23-webapp/WEB-INF/web.xml|Specified servlet version 2.3 of DOCTYPE System ID is over the configured supported servlet version 2.1 diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_2.3.setup.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_2.3.setup.txt new file mode 100644 index 0000000000..97453d84b2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_2.3.setup.txt @@ -0,0 +1 @@ +webapps/dummy-servlet23-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_2.4.config.xml b/jetty-webapp-verifier/src/test/resources/servlet_level_2.4.config.xml new file mode 100644 index 0000000000..91b35b2524 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_2.4.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.ServletSupportLevelRule"> + <Set name="supportedVersion">2.1</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_2.4.expectations.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_2.4.expectations.txt new file mode 100644 index 0000000000..07a9e3f666 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_2.4.expectations.txt @@ -0,0 +1,3 @@ +ERROR|target/testing/dummy-servlet24-webapp/WEB-INF/web.xml|Specified servlet version 2.4 of Schema is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servlet24-webapp/WEB-INF/web.xml|Specified servlet version 2.4 of version attribute is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servlet24-webapp/WEB-INF/web.xml|Specified servlet version 2.4 of XML Namespace is over the configured supported servlet version 2.1 diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_2.4.setup.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_2.4.setup.txt new file mode 100644 index 0000000000..5996e9b7e2 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_2.4.setup.txt @@ -0,0 +1 @@ +webapps/dummy-servlet24-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_2.5.config.xml b/jetty-webapp-verifier/src/test/resources/servlet_level_2.5.config.xml new file mode 100644 index 0000000000..196f3e7233 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_2.5.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.ServletSupportLevelRule"> + <Set name="supportedVersion">2.4</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_2.5.expectations.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_2.5.expectations.txt new file mode 100644 index 0000000000..78fa619543 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_2.5.expectations.txt @@ -0,0 +1,3 @@ +ERROR|target/testing/dummy-servlet25-webapp/WEB-INF/web.xml|Specified servlet version 2.5 of Schema is over the configured supported servlet version 2.4 +ERROR|target/testing/dummy-servlet25-webapp/WEB-INF/web.xml|Specified servlet version 2.5 of version attribute is over the configured supported servlet version 2.4 +ERROR|target/testing/dummy-servlet25-webapp/WEB-INF/web.xml|Specified servlet version 2.5 of XML Namespace is over the configured supported servlet version 2.4 diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_2.5.setup.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_2.5.setup.txt new file mode 100644 index 0000000000..66caaf0dfe --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_2.5.setup.txt @@ -0,0 +1 @@ +webapps/dummy-servlet25-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.4.config.xml b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.4.config.xml new file mode 100644 index 0000000000..91b35b2524 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.4.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.ServletSupportLevelRule"> + <Set name="supportedVersion">2.1</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.4.expectations.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.4.expectations.txt new file mode 100644 index 0000000000..a9da5ebb15 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.4.expectations.txt @@ -0,0 +1,14 @@ +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|Found 2 versions defined [2.3, 2.4], expected 1 +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|Invalid schemaLocation value <web-app xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|Specified servlet version 2.3 of DOCTYPE Public ID is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|Specified servlet version 2.3 of DOCTYPE System ID is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|Specified servlet version 2.4 of version attribute is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|Specified servlet version 2.4 of XML Namespace is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|version 2.3 of DOCTYPE Public ID conflicts with version 2.4 of version attribute +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|version 2.3 of DOCTYPE Public ID conflicts with version 2.4 of XML Namespace +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|version 2.3 of DOCTYPE System ID conflicts with version 2.4 of version attribute +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|version 2.3 of DOCTYPE System ID conflicts with version 2.4 of XML Namespace +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|version 2.4 of version attribute conflicts with version 2.3 of DOCTYPE Public ID +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|version 2.4 of version attribute conflicts with version 2.3 of DOCTYPE System ID +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|version 2.4 of XML Namespace conflicts with version 2.3 of DOCTYPE Public ID +ERROR|target/testing/dummy-servletmixed1-webapp/WEB-INF/web.xml|version 2.4 of XML Namespace conflicts with version 2.3 of DOCTYPE System ID diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.4.setup.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.4.setup.txt new file mode 100644 index 0000000000..b473c59a4e --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.4.setup.txt @@ -0,0 +1 @@ +webapps/dummy-servletmixed1-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.5.config.xml b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.5.config.xml new file mode 100644 index 0000000000..91b35b2524 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.5.config.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<Configure id="basicRuleSet" + class="org.eclipse.jetty.webapp.verifier.RuleSet"> + <Set name="rules"> + <Array type="org.eclipse.jetty.webapp.verifier.Rule"> + <Item> + <New class="org.eclipse.jetty.webapp.verifier.rules.ServletSupportLevelRule"> + <Set name="supportedVersion">2.1</Set> + </New> + </Item> + </Array> + </Set> +</Configure>
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.5.expectations.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.5.expectations.txt new file mode 100644 index 0000000000..d2326c321c --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.5.expectations.txt @@ -0,0 +1,15 @@ +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|Attribute <web-app xmlns:xsi=""> must exist with a valid value +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|Attribute <web-app xsi:schemaLocation=""> must exist with a valid value +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|Found 2 versions defined [2.3, 2.5], expected 1 +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|Specified servlet version 2.3 of DOCTYPE Public ID is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|Specified servlet version 2.3 of DOCTYPE System ID is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|Specified servlet version 2.5 of version attribute is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|Specified servlet version 2.5 of XML Namespace is over the configured supported servlet version 2.1 +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|version 2.3 of DOCTYPE Public ID conflicts with version 2.5 of version attribute +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|version 2.3 of DOCTYPE Public ID conflicts with version 2.5 of XML Namespace +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|version 2.3 of DOCTYPE System ID conflicts with version 2.5 of version attribute +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|version 2.3 of DOCTYPE System ID conflicts with version 2.5 of XML Namespace +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|version 2.5 of version attribute conflicts with version 2.3 of DOCTYPE Public ID +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|version 2.5 of version attribute conflicts with version 2.3 of DOCTYPE System ID +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|version 2.5 of XML Namespace conflicts with version 2.3 of DOCTYPE Public ID +ERROR|target/testing/dummy-servletmixed2-webapp/WEB-INF/web.xml|version 2.5 of XML Namespace conflicts with version 2.3 of DOCTYPE System ID diff --git a/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.5.setup.txt b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.5.setup.txt new file mode 100644 index 0000000000..da6d2ca507 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/servlet_level_mixed_2.3_2.5.setup.txt @@ -0,0 +1 @@ +webapps/dummy-servletmixed2-webapp.war
\ No newline at end of file diff --git a/jetty-webapp-verifier/src/test/resources/webapps/README.txt b/jetty-webapp-verifier/src/test/resources/webapps/README.txt new file mode 100644 index 0000000000..a46c58ef03 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/README.txt @@ -0,0 +1,10 @@ +There are a number of Webapps in this directory. + +Not all of them are valid. +But all of them are created by the jetty project. + +The non-eclipse names present in the various webapps, for classes, packages, etc. +Are used for testcase reasons, and are all dummy implementations. + +See the /jetty-webapp-verifier-examples/ project tree in source control for the +projects that built these webapps, and their respective WEB-INF/lib jars. diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-groovy-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-groovy-webapp.war Binary files differnew file mode 100644 index 0000000000..96f1eaec36 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-groovy-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-javaversions-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-javaversions-webapp.war Binary files differnew file mode 100644 index 0000000000..967fd373ee --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-javaversions-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-jruby-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-jruby-webapp.war Binary files differnew file mode 100644 index 0000000000..6704458065 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-jruby-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-jython-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-jython-webapp.war Binary files differnew file mode 100644 index 0000000000..6492ba056a --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-jython-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-nativeaccess-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-nativeaccess-webapp.war Binary files differnew file mode 100644 index 0000000000..81fa93c36d --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-nativeaccess-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-scm-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-scm-webapp.war Binary files differnew file mode 100644 index 0000000000..f7622c4c78 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-scm-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-servlet23-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servlet23-webapp.war Binary files differnew file mode 100644 index 0000000000..ffd51fba64 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servlet23-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-servlet24-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servlet24-webapp.war Binary files differnew file mode 100644 index 0000000000..57cc88c85e --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servlet24-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-servlet25-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servlet25-webapp.war Binary files differnew file mode 100644 index 0000000000..ba56dfb49d --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servlet25-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-servletmixed1-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servletmixed1-webapp.war Binary files differnew file mode 100644 index 0000000000..5ce4a90ddb --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servletmixed1-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-servletmixed2-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servletmixed2-webapp.war Binary files differnew file mode 100644 index 0000000000..8ecd5cd918 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-servletmixed2-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/dummy-shellscripts-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/dummy-shellscripts-webapp.war Binary files differnew file mode 100644 index 0000000000..fa7ffa3a58 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/dummy-shellscripts-webapp.war diff --git a/jetty-webapp-verifier/src/test/resources/webapps/signed-jar-test-webapp.war b/jetty-webapp-verifier/src/test/resources/webapps/signed-jar-test-webapp.war Binary files differnew file mode 100644 index 0000000000..4cce7a8a20 --- /dev/null +++ b/jetty-webapp-verifier/src/test/resources/webapps/signed-jar-test-webapp.war diff --git a/jetty-webapp/pom.xml b/jetty-webapp/pom.xml index 1bb84de46c..ead8dfdccc 100644 --- a/jetty-webapp/pom.xml +++ b/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-webapp</artifactId> @@ -102,6 +102,11 @@ <version>${project.version}</version> </dependency> <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp-verifier</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java index f39bc648fd..8e897d257c 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java @@ -4,11 +4,11 @@ // All rights reserved. This program and the accompanying materials // are made available under the terms of the Eclipse Public License v1.0 // and Apache License v2.0 which accompanies this distribution. -// The Eclipse Public License is available at +// The Eclipse Public License is available at // http://www.eclipse.org/legal/epl-v10.html // The Apache License v2.0 is available at // http://www.opensource.org/licenses/apache2.0.php -// You may elect to redistribute this code under either of these licenses. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.webapp; @@ -19,6 +19,7 @@ import java.net.MalformedURLException; import java.security.PermissionCollection; import java.util.EventListener; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.servlet.http.HttpSessionActivationListener; @@ -49,28 +50,29 @@ import org.eclipse.jetty.util.resource.Resource; * {@link org.eclipse.jetty.security.ConstraintSecurityHandler}, {@link org.eclipse.jetty.server.session.SessionHandler} * and {@link org.eclipse.jetty.servlet.ServletHandler}. * The handlers are configured by pluggable configuration classes, with - * the default being {@link org.eclipse.jetty.server.server.webapp.WebXmlConfiguration} and + * the default being {@link org.eclipse.jetty.server.server.webapp.WebXmlConfiguration} and * {@link org.eclipse.jetty.server.server.webapp.JettyWebXmlConfiguration}. - * + * * @org.apache.xbean.XBean description="Creates a servlet web application at a given context from a resource base" * * * */ public class WebAppContext extends ServletContextHandler -{ +{ public static final String TEMPDIR = "javax.servlet.context.tempdir"; public final static String WEB_DEFAULTS_XML="org/eclipse/jetty/webapp/webdefault.xml"; public final static String ERROR_PAGE="org.eclipse.jetty.server.error_page"; + public final static String SERVER_CONFIG = "org.eclipse.jetty.webapp.configuration"; - private static String[] __dftConfigurationClasses = - { - "org.eclipse.jetty.webapp.WebInfConfiguration", - "org.eclipse.jetty.webapp.WebXmlConfiguration", + private static String[] __dftConfigurationClasses = + { + "org.eclipse.jetty.webapp.WebInfConfiguration", + "org.eclipse.jetty.webapp.WebXmlConfiguration", "org.eclipse.jetty.webapp.MetaInfConfiguration", "org.eclipse.jetty.webapp.FragmentConfiguration", "org.eclipse.jetty.webapp.JettyWebXmlConfiguration", - "org.eclipse.jetty.webapp.TagLibConfiguration" + "org.eclipse.jetty.webapp.TagLibConfiguration" } ; private String[] _configurationClasses=__dftConfigurationClasses; private Configuration[] _configurations; @@ -84,8 +86,8 @@ public class WebAppContext extends ServletContextHandler private boolean _parentLoaderPriority= Boolean.getBoolean("org.eclipse.jetty.server.webapp.parentLoaderPriority"); private PermissionCollection _permissions; private String[] _systemClasses = { - "java.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) - "javax.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) + "java.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) + "javax.", // Java SE classes (per servlet spec v2.5 / SRV.9.7.2) "org.xml.", // needed by javax.xml "org.w3c.", // needed by javax.xml "org.apache.commons.logging.", // special case. @@ -100,7 +102,7 @@ public class WebAppContext extends ServletContextHandler "-org.eclipse.jetty.plus.jaas.", // don't hide jaas modules "-org.eclipse.jetty.servlet.DefaultServlet", // webapp cannot change default servlets "org.eclipse.jetty." // hide rest of jetty classes - }; + }; private File _tmpDir; private String _war; private String _extraClasspath; @@ -117,9 +119,9 @@ public class WebAppContext extends ServletContextHandler { ContextHandler handler = context.getContextHandler(); if (handler instanceof WebAppContext) - return (ContextHandler)handler; + return handler; } - return null; + return null; } /* ------------------------------------------------------------ */ @@ -162,12 +164,13 @@ public class WebAppContext extends ServletContextHandler super(null,sessionHandler,securityHandler,servletHandler,errorHandler); setErrorHandler(errorHandler!=null?errorHandler:new ErrorPageErrorHandler()); - } + } /* ------------------------------------------------------------ */ /** * @param servletContextName The servletContextName to set. */ + @Override public void setDisplayName(String servletContextName) { super.setDisplayName(servletContextName); @@ -190,9 +193,9 @@ public class WebAppContext extends ServletContextHandler /** Set Resource Alias. * Resource aliases map resource uri's within a context. * They may optionally be used by a handler when looking for - * a resource. - * @param alias - * @param uri + * a resource. + * @param alias + * @param uri */ public void setResourceAlias(String alias, String uri) { @@ -235,6 +238,7 @@ public class WebAppContext extends ServletContextHandler /* (non-Javadoc) * @see org.eclipse.jetty.server.server.handler.ContextHandler#setClassLoader(java.lang.ClassLoader) */ + @Override public void setClassLoader(ClassLoader classLoader) { super.setClassLoader(classLoader); @@ -243,6 +247,7 @@ public class WebAppContext extends ServletContextHandler } /* ------------------------------------------------------------ */ + @Override public Resource getResource(String uriInContext) throws MalformedURLException { IOException ioe= null; @@ -299,14 +304,15 @@ public class WebAppContext extends ServletContextHandler } /* ------------------------------------------------------------ */ - /* + /* * @see org.eclipse.thread.AbstractLifeCycle#doStart() */ + @Override protected void doStart() throws Exception { try { - // Setup configurations + // Setup configurations loadConfigurations(); @@ -319,14 +325,14 @@ public class WebAppContext extends ServletContextHandler _ownClassLoader=true; } - if (Log.isDebugEnabled()) + if (Log.isDebugEnabled()) { ClassLoader loader = getClassLoader(); Log.debug("Thread Context class loader is: " + loader); loader=loader.getParent(); while(loader!=null) { - Log.debug("Parent class loader is: " + loader); + Log.debug("Parent class loader is: " + loader); loader=loader.getParent(); } } @@ -344,7 +350,7 @@ public class WebAppContext extends ServletContextHandler _configurations[i].postConfigure(this); - if (isLogUrlOnStart()) + if (isLogUrlOnStart()) dumpUrl(); } catch (Exception e) @@ -360,10 +366,10 @@ public class WebAppContext extends ServletContextHandler /* * Dumps the current web app name and URL to the log */ - public void dumpUrl() + public void dumpUrl() { Connector[] connectors = getServer().getConnectors(); - for (int i=0;i<connectors.length;i++) + for (int i=0;i<connectors.length;i++) { String connectorName = connectors[i].getName(); String displayName = getDisplayName(); @@ -375,9 +381,10 @@ public class WebAppContext extends ServletContextHandler } /* ------------------------------------------------------------ */ - /* + /* * @see org.eclipse.thread.AbstractLifeCycle#doStop() */ + @Override protected void doStop() throws Exception { super.doStop(); @@ -458,6 +465,23 @@ public class WebAppContext extends ServletContextHandler return _serverClasses; } + public void addServerClass(String classname) + { + for (int i = 0, n = _serverClasses.length; i < n; i++) + { + if (_serverClasses[i].equals(classname)) + { + // Already present. + return; + } + } + + int len = _serverClasses.length + 1; + String sysclass[] = new String[len]; + System.arraycopy(_serverClasses,0,sysclass,0,len - 1); + sysclass[len - 1] = classname; + _serverClasses = sysclass; + } /* ------------------------------------------------------------ */ /** @@ -469,7 +493,23 @@ public class WebAppContext extends ServletContextHandler return _systemClasses; } + public void addSystemClass(String classname) + { + for (int i = 0, n = _systemClasses.length; i < n; i++) + { + if (_systemClasses[i].equals(classname)) + { + // Already present. + return; + } + } + int len = _systemClasses.length + 1; + String sysclass[] = new String[len]; + System.arraycopy(_systemClasses,0,sysclass,0,len - 1); + sysclass[len - 1] = classname; + _systemClasses = sysclass; + } /* ------------------------------------------------------------ */ public boolean isServerClass(String name) @@ -602,7 +642,7 @@ public class WebAppContext extends ServletContextHandler } /* ------------------------------------------------------------ */ - protected void loadConfigurations() + protected void loadConfigurations() throws Exception { if (_configurations!=null) @@ -610,14 +650,33 @@ public class WebAppContext extends ServletContextHandler if (_configurationClasses==null) _configurationClasses=__dftConfigurationClasses; - _configurations = new Configuration[_configurationClasses.length]; - for (int i=0;i<_configurations.length;i++) + int configsLen = _configurationClasses.length; + + @SuppressWarnings("unchecked") + List<Configuration> serverConfigs = (List<Configuration>)getServer().getAttribute(SERVER_CONFIG); + if (serverConfigs != null) + { + configsLen += serverConfigs.size(); + } + + _configurations = new Configuration[configsLen]; + for (int i = 0; i < _configurationClasses.length; i++) { _configurations[i]=(Configuration)Loader.loadClass(this.getClass(), _configurationClasses[i]).newInstance(); } + + if (serverConfigs != null) + { + int offset = _configurationClasses.length; + for (int i = 0, n = serverConfigs.size(); i < n; i++) + { + _configurations[i + offset] = serverConfigs.get(i); + } + } } /* ------------------------------------------------------------ */ + @Override protected boolean isProtectedTarget(String target) { while (target.startsWith("//")) @@ -628,6 +687,7 @@ public class WebAppContext extends ServletContextHandler /* ------------------------------------------------------------ */ + @Override public String toString() { return super.toString()+(_war==null?"":(","+_war)); @@ -656,7 +716,7 @@ public class WebAppContext extends ServletContextHandler } /* ------------------------------------------------------------ */ - /** + /** * The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml * @param defaultsDescriptor The defaultsDescriptor to set. */ @@ -703,6 +763,7 @@ public class WebAppContext extends ServletContextHandler } /* ------------------------------------------------------------ */ + @Override public void setEventListeners(EventListener[] eventListeners) { if (_sessionHandler!=null) @@ -731,9 +792,10 @@ public class WebAppContext extends ServletContextHandler * Conveniance method that calls {@link #setEventListeners(EventListener[])} * @param listener */ + @Override public void addEventListener(EventListener listener) { - setEventListeners((EventListener[])LazyList.addToArray(getEventListeners(), listener, EventListener.class)); + setEventListeners((EventListener[])LazyList.addToArray(getEventListeners(), listener, EventListener.class)); } @@ -775,12 +837,12 @@ public class WebAppContext extends ServletContextHandler } /* ------------------------------------------------------------ */ - /** + /** * Set the server classes patterns. * <p> * Server classes/packages are classes used to implement the server and are hidden * from the context. If the context needs to load these classes, it must have its - * own copy of them in WEB-INF/lib or WEB-INF/classes. + * own copy of them in WEB-INF/lib or WEB-INF/classes. * A class pattern is a string of one of the forms:<dl> * <dt>org.package.Classname</dt><dd>Match a specific class</dd> * <dt>org.package.</dt><dd>Match a specific package hierarchy</dd> @@ -789,7 +851,7 @@ public class WebAppContext extends ServletContextHandler * </dl> * @param serverClasses The serverClasses to set. */ - public void setServerClasses(String[] serverClasses) + public void setServerClasses(String[] serverClasses) { _serverClasses = serverClasses==null?null:(String[])serverClasses.clone(); } @@ -882,7 +944,7 @@ public class WebAppContext extends ServletContextHandler } /* ------------------------------------------------------------ */ - public boolean isLogUrlOnStart() + public boolean isLogUrlOnStart() { return _logUrlOnStart; } @@ -893,12 +955,13 @@ public class WebAppContext extends ServletContextHandler * * @param logOnStart whether or not the log message is created */ - public void setLogUrlOnStart(boolean logOnStart) + public void setLogUrlOnStart(boolean logOnStart) { this._logUrlOnStart = logOnStart; } /* ------------------------------------------------------------ */ + @Override protected void startContext() throws Exception { @@ -911,5 +974,4 @@ public class WebAppContext extends ServletContextHandler super.startContext(); } - } diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebappVerifierConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebappVerifierConfiguration.java new file mode 100644 index 0000000000..a47e2a750b --- /dev/null +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebappVerifierConfiguration.java @@ -0,0 +1,97 @@ +// ======================================================================== +// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +package org.eclipse.jetty.webapp; + +import java.io.File; +import java.net.URI; +import java.util.Collection; + +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.webapp.verifier.RuleSet; +import org.eclipse.jetty.webapp.verifier.Severity; +import org.eclipse.jetty.webapp.verifier.Violation; +import org.eclipse.jetty.webapp.verifier.WebappVerifier; + +/** + * WebappVerifierConfiguration + */ +public class WebappVerifierConfiguration implements Configuration +{ + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.webapp.Configuration#configure(org.eclipse.jetty.webapp.WebAppContext) + */ + public void configure(WebAppContext context) throws Exception + { + + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.webapp.Configuration#deconfigure(org.eclipse.jetty.webapp.WebAppContext) + */ + public void deconfigure(WebAppContext context) throws Exception + { + + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.webapp.Configuration#postConfigure(org.eclipse.jetty.webapp.WebAppContext) + */ + public void postConfigure(WebAppContext context) throws Exception + { + + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.webapp.Configuration#preConfigure(org.eclipse.jetty.webapp.WebAppContext) + */ + public void preConfigure(WebAppContext context) throws Exception + { + if(Log.isDebugEnabled()) + { + Log.debug("Configuring webapp verifier"); + } + + URI configurationUri = new File( System.getProperty( "jetty.home" )).toURI().resolve( "etc/default-webapp-verifier.xml" ); + + RuleSet suite = RuleSet.load( configurationUri.toURL() ); + + WebappVerifier verifier = suite.createWebappVerifier( new URI( context.getWar() ) ); + + verifier.visitAll(); + + Collection<Violation> violations = verifier.getViolations(); + + boolean haltWebapp = false; + + Log.info( " Webapp Verifier Report: " + violations.size() + " violations" ); + + for (Violation violation : violations) + { + if ( violation.getSeverity() == Severity.ERROR ) + { + haltWebapp = true; + } + + Log.info( violation.toString() ); + } + + if ( haltWebapp ) + { + throw new InstantiationException( "Configuration exception: webapp failed webapp verification" ); + } + } +} diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index 5b085aa2db..d1e38a0c1b 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>jetty-xml</artifactId> @@ -8,7 +8,7 @@ </parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> <name>Jetty :: Project</name> <url>${jetty.url}</url> <packaging>pom</packaging> @@ -132,6 +132,7 @@ <module>jetty-jaspi</module> <module>jetty-servlet</module> <module>jetty-webapp</module> + <module>jetty-webapp-verifier</module> <module>jetty-servlets</module> <module>jetty-deploy</module> <module>jetty-ajp</module> diff --git a/test-continuation-jetty6/pom.xml b/test-continuation-jetty6/pom.xml index c75b5a97db..536d58dabd 100644 --- a/test-continuation-jetty6/pom.xml +++ b/test-continuation-jetty6/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>test-continuation-jetty6</artifactId> diff --git a/test-continuation/pom.xml b/test-continuation/pom.xml index 48aa192ef0..7a6c1199e6 100644 --- a/test-continuation/pom.xml +++ b/test-continuation/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>test-continuation</artifactId> diff --git a/test-jetty-servlet/pom.xml b/test-jetty-servlet/pom.xml index 0951696540..27ef6e12de 100644 --- a/test-jetty-servlet/pom.xml +++ b/test-jetty-servlet/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>test-jetty-servlet</artifactId> diff --git a/test-jetty-webapp/pom.xml b/test-jetty-webapp/pom.xml index 3aaa1e590f..43388db7b4 100644 --- a/test-jetty-webapp/pom.xml +++ b/test-jetty-webapp/pom.xml @@ -2,7 +2,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.jetty</groupId> diff --git a/tests/pom.xml b/tests/pom.xml index 8754868f45..ca02bef237 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-project</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <groupId>org.eclipse.jetty.tests</groupId> <artifactId>tests-parent</artifactId> diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml index 8e98e1775a..203a37497d 100644 --- a/tests/test-integration/pom.xml +++ b/tests/test-integration/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.eclipse.jetty.tests</groupId> <artifactId>tests-parent</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>test-integration</artifactId> diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index 5565e4224f..e8ee33cc0e 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.eclipse.jetty.tests</groupId> <artifactId>tests-parent</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <artifactId>test-webapps-parent</artifactId> <name>Jetty Tests :: WebApps :: Parent</name> diff --git a/tests/test-webapps/test-webapp-logging-commons/pom.xml b/tests/test-webapps/test-webapp-logging-commons/pom.xml index 2427b6a379..37178c84f5 100644 --- a/tests/test-webapps/test-webapp-logging-commons/pom.xml +++ b/tests/test-webapps/test-webapp-logging-commons/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.eclipse.jetty.tests</groupId> <artifactId>test-webapps-parent</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <artifactId>test-webapp-logging-commons</artifactId> <name>Jetty Tests :: WebApp :: Commons Logging</name> diff --git a/tests/test-webapps/test-webapp-logging-java/pom.xml b/tests/test-webapps/test-webapp-logging-java/pom.xml index 0547472867..f7b5163ec4 100644 --- a/tests/test-webapps/test-webapp-logging-java/pom.xml +++ b/tests/test-webapps/test-webapp-logging-java/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.eclipse.jetty.tests</groupId> <artifactId>test-webapps-parent</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <artifactId>test-webapp-logging-java</artifactId> <name>Jetty Tests :: WebApp :: JavaSE Logging</name> diff --git a/tests/test-webapps/test-webapp-logging-log4j/pom.xml b/tests/test-webapps/test-webapp-logging-log4j/pom.xml index cedbcc4deb..71bfcd0713 100644 --- a/tests/test-webapps/test-webapp-logging-log4j/pom.xml +++ b/tests/test-webapps/test-webapp-logging-log4j/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.eclipse.jetty.tests</groupId> <artifactId>test-webapps-parent</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <artifactId>test-webapp-logging-log4j</artifactId> <name>Jetty Tests :: WebApp :: Log4J Logging</name> diff --git a/tests/test-webapps/test-webapp-logging-slf4j/pom.xml b/tests/test-webapps/test-webapp-logging-slf4j/pom.xml index f8b1f1eaca..8a6ce46380 100644 --- a/tests/test-webapps/test-webapp-logging-slf4j/pom.xml +++ b/tests/test-webapps/test-webapp-logging-slf4j/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.eclipse.jetty.tests</groupId> <artifactId>test-webapps-parent</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <artifactId>test-webapp-logging-slf4j</artifactId> <name>Jetty Tests :: WebApp :: Slf4J Logging</name> diff --git a/tests/test-webapps/test-webapp-rfc2616/pom.xml b/tests/test-webapps/test-webapp-rfc2616/pom.xml index 39e0a79507..a94fe7667d 100644 --- a/tests/test-webapps/test-webapp-rfc2616/pom.xml +++ b/tests/test-webapps/test-webapp-rfc2616/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.eclipse.jetty.tests</groupId> <artifactId>test-webapps-parent</artifactId> - <version>7.0.0.RC6-SNAPSHOT</version> + <version>7.0.1-SNAPSHOT</version> </parent> <artifactId>test-webapp-rfc2616</artifactId> <name>Jetty Tests :: WebApp :: RFC2616</name> |