Click here to Skip to main content
15,896,606 members
Articles / Programming Languages / Java

XSS vulnarability detection tool for JSP

Rate me:
Please Sign up or sign in to vote.
4.94/5 (11 votes)
30 Jul 2013CPOL7 min read 48.3K   536   8  
A tool to detect unsafe use of EL which leads to XSS vulnarability.
<project basedir="." name="JspValidator">
	<property file="${basedir}/build.properties"/>

	<property name="src.home" value="${basedir}/src"/>
	<property name="cfg.home" value="${basedir}/meta"/>
	<property name="build.home" value="${basedir}/build"/>
	<property name="dist.home" value="${build.home}/dist"/>
	<property name="compile.home" value="${build.home}/compile"/>
	<property name="meta.home" value="${build.home}/meta"/>

	<path id="compile.path">
		<fileset dir="${basedir}/lib" includes="*.jar"/>
	</path>

	<target name="init" description="initialize the build environment!">
		<mkdir dir="${build.home}"/>
		<delete dir="${compile.home}"/>
		<delete dir="${meta.home}"/>
		<tstamp>
			<format property="TS_TODAY" pattern="MMMM dd, yyyy hh:mm:ss"/>
		</tstamp>
	</target>

	<target name="genBuildNo">
		<propertyfile file="${basedir}/buildno.properties">
			<entry key="build.number" operation="+" type="int" default="0"/>
		</propertyfile>
	</target>
	<target name="readBuildNo">
		<property file="${basedir}/buildno.properties"/>
	</target>

	<target name="genManifest" depends="readBuildNo" description="Generate MANIFEST.MF file.">
		<mkdir dir="${meta.home}"/>
		<manifest file="${meta.home}/MANIFEST.MF">
			<attribute name="Built-By" value="${user.name}"/>
			<attribute name="Built-On" value="${TS_TODAY}"/>
			<section name="common">
				<attribute name="Specification-Title" value="${app.name}"/>
				<attribute name="Specification-Version" value="${app.version}.${build.number}"/>
			    <attribute name="Specification-Vendor" value="Prasad P. Khandekar"/>
			</section>
		</manifest>
	</target>

	<target name="compile" depends="init" description="Compile source code">
		<mkdir dir="${compile.home}"/>
		<javac srcdir="${src.home}" destdir="${compile.home}" debug="${compile.debug}"  
			optimize="${compile.optimize}" target="${compile.target}"
			source="${compile.source}">
			<classpath refid="compile.path"/>
		</javac>
	</target>

	<target name="dist" depends="compile, genBuildNo,  genManifest" description="Create a distributable jar">
		<mkdir dir="${dist.home}"/>
		<jar destfile="${dist.home}/${app.name}-${app.version}.${build.number}.jar" 
			basedir="${compile.home}" manifest="${meta.home}/MANIFEST.MF">
		</jar>
		<jar destfile="${dist.home}/${app.name}-${app.version}.${build.number}-source.jar" 
			basedir="${src.home}" manifest="${meta.home}/MANIFEST.MF">
		</jar>
		<echo message="${dist.home}/${app.name}-${app.version}.${build.number}.jar"/>
	</target>

	<target name="jar" depends="compile, genManifest" description="Create a distributable jar">
		<mkdir dir="${dist.home}"/>
		<jar destfile="${dist.home}/${app.name}-test-${app.version}.${build.number}.jar" 
			basedir="${compile.home}" manifest="${meta.home}/MANIFEST.MF">
		</jar>
		<echo message="Created ${dist.home}/${app.name}-test-${app.version}.${build.number}.jar"/>
	</target>
</project>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Freelancer
India India
I am a software professional with over 20 years of commercial business applications design and development experience.

My programming experience includes Java, Spring, .NET, Classic VB & ASP, Scripting, Power Builder, PHP, Magic & far far ago FoxPro, C, Assembly and COBOL.

From last 11 years I am mostly working with Java Technology. I am currently available to take up new assignments.

Comments and Discussions