Skip to content

Commit 0da280c

Browse files
committed
Merge branch 'next' into WEB-139
2 parents a3bf6d0 + 9bb1cb8 commit 0da280c

File tree

11 files changed

+1725
-266
lines changed

11 files changed

+1725
-266
lines changed

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<name>WebGoat</name>
34
<modelVersion>4.0.0</modelVersion>
45
<groupId>WebGoat</groupId>
56
<artifactId>WebGoat</artifactId>
@@ -19,6 +20,8 @@
1920
<org.springframework.version>3.2.4.RELEASE</org.springframework.version>
2021
<spring.security.version>3.2.4.RELEASE</spring.security.version>
2122
<tiles.version>2.2.2</tiles.version>
23+
<!-- If run from Bamboo this will be replaced with the bamboo build number -->
24+
<build.number>local</build.number>
2225
</properties>
2326

2427
<build>
@@ -40,6 +43,22 @@
4043
<encoding>ISO-8859-1</encoding>
4144
</configuration>
4245
</plugin>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-war-plugin</artifactId>
49+
<configuration>
50+
<manifest>
51+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
52+
</manifest>
53+
<archive>
54+
<manifestEntries>
55+
<Specification-Title>${project.name}</Specification-Title>
56+
<Specification-Version>${project.version}</Specification-Version>
57+
<Implementation-Version>${build.number}</Implementation-Version>
58+
</manifestEntries>
59+
</archive>
60+
</configuration>
61+
</plugin>
4362
<plugin>
4463
<groupId>org.apache.tomcat.maven</groupId>
4564
<artifactId>tomcat7-maven-plugin</artifactId>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package org.owasp.webgoat.application;
7+
8+
import org.apache.commons.lang3.StringUtils;
9+
import org.apache.commons.lang3.builder.ToStringBuilder;
10+
11+
/**
12+
* Singleton which is created on context startup
13+
*
14+
* @author rlawson
15+
*/
16+
public class Application {
17+
18+
private static final Application INSTANCE = new Application();
19+
20+
private Application() {
21+
22+
}
23+
24+
public static final Application getInstance() {
25+
return INSTANCE;
26+
}
27+
28+
private String version = "SNAPSHOT";
29+
private String build = "local";
30+
private String name = "WebGoat";
31+
32+
/**
33+
* @return the version
34+
*/
35+
public String getVersion() {
36+
return version;
37+
}
38+
39+
/**
40+
* @param version the version to set
41+
*/
42+
public void setVersion(String version) {
43+
if (StringUtils.isNotBlank(version)) {
44+
this.version = version;
45+
}
46+
}
47+
48+
/**
49+
* @return the build
50+
*/
51+
public String getBuild() {
52+
return build;
53+
}
54+
55+
/**
56+
* @param build the build to set
57+
*/
58+
public void setBuild(String build) {
59+
if (StringUtils.isNotBlank(build)) {
60+
this.build = build;
61+
}
62+
}
63+
64+
/**
65+
* @return the name
66+
*/
67+
public String getName() {
68+
return name;
69+
}
70+
71+
/**
72+
* @param name the name to set
73+
*/
74+
public void setName(String name) {
75+
if (StringUtils.isNotBlank(name)) {
76+
this.name = name;
77+
}
78+
}
79+
80+
@Override
81+
public String toString() {
82+
return new ToStringBuilder(this).
83+
append("name", name).
84+
append("version", version).
85+
append("build", build).
86+
toString();
87+
}
88+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package org.owasp.webgoat.application;
7+
8+
import java.io.IOException;
9+
import java.io.InputStream;
10+
import java.util.jar.Attributes;
11+
import java.util.jar.Manifest;
12+
import javax.servlet.ServletContext;
13+
import javax.servlet.ServletContextEvent;
14+
import javax.servlet.ServletContextListener;
15+
16+
/**
17+
* Web application lifecycle listener.
18+
*
19+
* @author rlawson
20+
*/
21+
public class WebGoatServletListener implements ServletContextListener {
22+
23+
@Override
24+
public void contextInitialized(ServletContextEvent sce) {
25+
ServletContext context = sce.getServletContext();
26+
context.log("WebGoat is starting");
27+
setApplicationVariables(context);
28+
}
29+
30+
@Override
31+
public void contextDestroyed(ServletContextEvent sce) {
32+
ServletContext context = sce.getServletContext();
33+
context.log("WebGoat is stopping");
34+
}
35+
36+
private void setApplicationVariables(ServletContext context) {
37+
Application app = Application.getInstance();
38+
try {
39+
InputStream inputStream = context.getResourceAsStream("/META-INF/MANIFEST.MF");
40+
Manifest manifest = new Manifest(inputStream);
41+
Attributes attr = manifest.getMainAttributes();
42+
String name = attr.getValue("Specification-Title");
43+
String version = attr.getValue("Specification-Version");
44+
String build = attr.getValue("Implementation-Version");
45+
app.setName(name);
46+
app.setVersion(version);
47+
app.setBuild(build);
48+
} catch (IOException ioe) {
49+
context.log("Error setting application variables", ioe);
50+
}
51+
}
52+
}

src/main/java/org/owasp/webgoat/controller/Start.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import javax.servlet.http.HttpServletRequest;
1111
import javax.servlet.http.HttpSession;
1212
import org.apache.commons.lang3.StringUtils;
13+
import org.owasp.webgoat.application.Application;
1314
import org.owasp.webgoat.session.WebSession;
1415
import org.slf4j.Logger;
1516
import org.slf4j.LoggerFactory;
@@ -55,6 +56,13 @@ public ModelAndView start(HttpServletRequest request,
5556

5657
String contactEmail = servletContext.getInitParameter("email");
5758
model.addObject("contactEmail", contactEmail);
59+
String emailList = servletContext.getInitParameter("emaillist");
60+
model.addObject("emailList", emailList);
61+
62+
Application app = Application.getInstance();
63+
logger.info("Setting application properties: " + app);
64+
model.addObject("version", app.getVersion());
65+
model.addObject("build", app.getBuild());
5866

5967
// if everything ok then go to webgoat UI
6068
model.setViewName("main_new");
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* *************************************************************************************************
3+
*
4+
*
5+
* This file is part of WebGoat, an Open Web Application Security Project
6+
* utility. For details, please see http://www.owasp.org/
7+
*
8+
* Copyright (c) 2002 - 20014 Bruce Mayhew
9+
*
10+
* This program is free software; you can redistribute it and/or modify it under
11+
* the terms of the GNU General Public License as published by the Free Software
12+
* Foundation; either version 2 of the License, or (at your option) any later
13+
* version.
14+
*
15+
* This program is distributed in the hope that it will be useful, but WITHOUT
16+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18+
* details.
19+
*
20+
* You should have received a copy of the GNU General Public License along with
21+
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22+
* Place - Suite 330, Boston, MA 02111-1307, USA.
23+
*
24+
* Getting Source ==============
25+
*
26+
* Source for this application is maintained at
27+
* https://github.com/WebGoat/WebGoat, a repository for free software projects.
28+
*
29+
* For details, please see http://webgoat.github.io
30+
*/
31+
package org.owasp.webgoat.service;
32+
33+
import javax.servlet.http.HttpSession;
34+
import org.owasp.webgoat.application.Application;
35+
import org.springframework.stereotype.Controller;
36+
import org.springframework.web.bind.annotation.RequestMapping;
37+
import org.springframework.web.bind.annotation.ResponseBody;
38+
39+
/**
40+
*
41+
* @author rlawson
42+
*/
43+
@Controller
44+
public class ApplicationService extends BaseService {
45+
46+
/**
47+
* Returns global application info
48+
*
49+
* @param session
50+
* @return
51+
*/
52+
@RequestMapping(value = "/application.mvc", produces = "application/json")
53+
public @ResponseBody
54+
Application showApplication(HttpSession session) {
55+
Application app = Application.getInstance();
56+
return app;
57+
}
58+
59+
}

src/main/webapp/WEB-INF/pages/about.jsp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,27 @@
1010
</div>
1111
<div class="modal-body modal-scroll">
1212
<p>Thanks for hacking The Goat!</p>
13-
<p>WebGoat is a demonstration of common web application flaws. The
14-
associated exercises are intended to provide hands-on experience with
15-
techniques aimed at demonstrating and testing application penetration.
13+
<p>WebGoat is a demonstration of common web application flaws. The
14+
associated exercises are intended to provide hands-on experience with
15+
techniques aimed at demonstrating and testing application penetration.
1616
</p>
17-
<p>From the entire WebGoat team, we appreciate your interest and efforts
18-
in making applications not just better, but safer and more secure for
19-
everyone. We, as well as our sacrificial goat, thank you.</p>
20-
<p>Version: 6.0</p>
17+
<p>From the entire WebGoat team, we appreciate your interest and efforts
18+
in making applications not just better, but safer and more secure for
19+
everyone. We, as well as our sacrificial goat, thank you.</p>
20+
<p>
21+
Version: ${version},&nbsp;Build: ${build}
22+
</p>
23+
2124
<div class="row">
22-
<div class="col-md-6">
23-
<p>Contact us:
24-
<ul>
25-
<li>WebGoat mailing list: [email protected]</li>
26-
<li>Bruce Mayhew: [email protected]</li>
27-
</ul>
28-
</p>
29-
</div>
30-
</div>
25+
<div class="col-md-6">
26+
<p>Contact us:
27+
<ul>
28+
<li>WebGoat mailing list: ${emailList}</li>
29+
<li>Bruce Mayhew: ${contactEmail}</li>
30+
</ul>
31+
</p>
32+
</div>
33+
</div>
3134
<div class="row">
3235
<div class="col-md-6">
3336
<p>WebGoat Authors
@@ -86,9 +89,9 @@
8689
</ul>
8790
</p>
8891
<p>Did we miss you? Our sincere apologies, as we know there have
89-
been many contributors over the years. If your name does not
90-
appear in any of the lists above, please send us a note. We'll
91-
get you added with no further sacrifices required.</p>
92+
been many contributors over the years. If your name does not
93+
appear in any of the lists above, please send us a note. We'll
94+
get you added with no further sacrifices required.</p>
9295
</div>
9396
</div>
9497
</div>

0 commit comments

Comments
 (0)