Skip to content

Commit 1cfbe2b

Browse files
committed
Merge branch 'next' of https://github.com/WebGoat/WebGoat into next
Conflicts: .gitignore
2 parents 624e8a4 + 8eac6ef commit 1cfbe2b

File tree

313 files changed

+563
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+563
-218
lines changed

.gitignore

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
/nb-configuration.xml
22
/nbactions.xml
3+
/target/
4+
/.classpath
5+
/.project
6+
/.settings/.jsdtscope
7+
/.settings/org.eclipse.jdt.core.prefs
8+
/.settings/org.eclipse.m2e.core.prefs
9+
/.settings/org.eclipse.wst.common.component
10+
/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
11+
/.settings/org.eclipse.wst.common.project.facet.core.xml
12+
/.settings/org.eclipse.wst.jsdt.ui.superType.container
13+
/.settings/org.eclipse.wst.jsdt.ui.superType.name
14+
/.settings/org.eclipse.wst.validation.prefs
15+
/.externalToolBuilders/
316
.project
417
/target
518
.classpath
@@ -11,5 +24,3 @@ src/main/main.iml
1124
*.LOCAL.*.jsp
1225
*.REMOTE.*.jsp
1326

14-
15-

src/main/java/org/owasp/webgoat/HammerHead.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
134134
logger.debug("Response already committed, exiting");
135135
return;
136136
}
137-
138-
if ("true".equals(request.getParameter("start"))) {
137+
138+
if ("true".equals(request.getParameter("start")) || request.getQueryString() == null) {
139139
logger.warn("Redirecting to start controller");
140140
response.sendRedirect("start.mvc");
141141
return;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.controller;
7+
8+
import javax.servlet.http.HttpServletRequest;
9+
import javax.servlet.http.HttpSession;
10+
import org.slf4j.Logger;
11+
import org.slf4j.LoggerFactory;
12+
import org.springframework.stereotype.Controller;
13+
import org.springframework.web.bind.annotation.RequestMapping;
14+
import org.springframework.web.bind.annotation.RequestMethod;
15+
import org.springframework.web.bind.annotation.RequestParam;
16+
import org.springframework.web.servlet.ModelAndView;
17+
18+
/**
19+
*
20+
* @author rlawson
21+
*/
22+
@Controller
23+
public class About {
24+
25+
final Logger logger = LoggerFactory.getLogger(About.class);
26+
private static final String WELCOMED = "welcomed";
27+
28+
@RequestMapping(value = "about.mvc", method = RequestMethod.GET)
29+
public ModelAndView welcome(HttpServletRequest request,
30+
@RequestParam(value = "error", required = false) String error,
31+
@RequestParam(value = "logout", required = false) String logout) {
32+
33+
// set the welcome attribute
34+
// this is so the attack servlet does not also
35+
// send them to the welcome page
36+
HttpSession session = request.getSession();
37+
if (session.getAttribute(WELCOMED) == null) {
38+
session.setAttribute(WELCOMED, "true");
39+
}
40+
41+
//go ahead and send them to webgoat (skip the welcome page)
42+
ModelAndView model = new ModelAndView();
43+
//model.setViewName("welcome");
44+
//model.setViewName("main_new");
45+
model.setViewName("about");
46+
return model;
47+
}
48+
49+
}

src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import org.apache.ecs.ElementContainer;
2020
import org.apache.ecs.StringElement;
2121
import org.apache.ecs.html.Body;
22+
import org.apache.ecs.html.Center;
2223
import org.apache.ecs.html.Form;
24+
import org.apache.ecs.html.H1;
2325
import org.apache.ecs.html.Head;
2426
import org.apache.ecs.html.Html;
2527
import org.apache.ecs.html.IMG;
@@ -729,11 +731,8 @@ public static Element readMethodFromFile(BufferedReader reader, String methodNam
729731
*/
730732
public void handleRequest(WebSession s) {
731733
// call createContent first so messages will go somewhere
732-
733734
Form form = new Form(getFormAction(), Form.POST).setName("form").setEncType("");
734-
735735
form.addElement(createContent(s));
736-
737736
setContent(form);
738737
}
739738

src/main/java/org/owasp/webgoat/lessons/CrossSiteScripting/CrossSiteScripting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public String getLessonSolutionFileName(WebSession s)
103103
{
104104
String solutionFileName = null;
105105
String stage = getStage(s);
106-
solutionFileName = "/lesson_solutions/Lab XSS/Lab " + stage + ".html";
106+
solutionFileName = "/lesson_solutions_1/Lab XSS/Lab " + stage + ".html";
107107
return solutionFileName;
108108
}
109109

src/main/java/org/owasp/webgoat/lessons/HttpBasics.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5+
56
import org.apache.ecs.Element;
67
import org.apache.ecs.ElementContainer;
78
import org.apache.ecs.StringElement;
9+
import org.apache.ecs.html.BR;
810
import org.apache.ecs.html.Input;
911
import org.owasp.webgoat.session.ECSFactory;
1012
import org.owasp.webgoat.session.WebSession;
@@ -58,6 +60,7 @@ protected Element createContent(WebSession s) {
5860

5961
StringBuffer person = null;
6062
try {
63+
ec.addElement(new BR());
6164
ec.addElement(new StringElement(WebGoatI18N.get("EnterYourName") + ": "));
6265

6366
person = new StringBuffer(s.getParser().getStringParameter(PERSON, ""));

src/main/java/org/owasp/webgoat/lessons/HttpSplitting.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
package org.owasp.webgoat.lessons;
33

4-
import java.io.PrintWriter;
54
import java.net.URLDecoder;
65
import java.text.DateFormat;
76
import java.text.SimpleDateFormat;
@@ -54,7 +53,8 @@ public class HttpSplitting extends SequentialLessonAdapter
5453
private static String STAGE = "stage";
5554

5655
public final static A MAC_LOGO = new A().setHref("http://www.softwaresecured.com").addElement(new IMG("images/logos/softwaresecured.gif").setAlt("Software Secured").setBorder(0).setHspace(0).setVspace(0));
57-
/**
56+
57+
/**
5858
* Description of the Method
5959
*
6060
* @param s

src/main/java/org/owasp/webgoat/lessons/RoleBasedAccessControl/RoleBasedAccessControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public String getLessonSolutionFileName(WebSession s)
176176
{
177177
String solutionFileName = null;
178178
String stage = getStage(s);
179-
solutionFileName = "/lesson_solutions/Lab Access Control/Lab " + stage + ".html";
179+
solutionFileName = "/lesson_solutions_1/Lab Access Control/Lab " + stage + ".html";
180180
return solutionFileName;
181181
}
182182

src/main/java/org/owasp/webgoat/lessons/SQLInjection/SQLInjection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public String getLessonSolutionFileName(WebSession s)
272272
{
273273
String solutionFileName = null;
274274
String stage = getStage(s);
275-
solutionFileName = "/lesson_solutions/Lab SQL Injection/Lab " + stage + ".html";
275+
solutionFileName = "/lesson_solutions_1/Lab SQL Injection/Lab " + stage + ".html";
276276
return solutionFileName;
277277
}
278278
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.owasp.webgoat.service;
2+
3+
import javax.servlet.http.HttpSession;
4+
5+
import org.owasp.webgoat.lessons.AbstractLesson;
6+
import org.owasp.webgoat.session.Course;
7+
import org.owasp.webgoat.session.WebSession;
8+
import org.springframework.stereotype.Controller;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.ResponseBody;
11+
12+
@Controller
13+
public class LessonTitleService extends BaseService {
14+
15+
/**
16+
* Returns the title for the current attack
17+
*
18+
* @param session
19+
* @return
20+
*/
21+
@RequestMapping(value = "/lessontitle.mvc", produces = "application/html")
22+
public @ResponseBody
23+
String showPlan(HttpSession session) {
24+
WebSession ws = getWebSession(session);
25+
return getLessonTitle(ws);
26+
}
27+
28+
private String getLessonTitle(WebSession s) {
29+
String title = "";
30+
int scr = s.getCurrentScreen();
31+
Course course = s.getCourse();
32+
33+
if (s.isUser() || s.isChallenge()) {
34+
AbstractLesson lesson = course.getLesson(s, scr, AbstractLesson.USER_ROLE);
35+
title = lesson != null ? lesson.getTitle() : "";
36+
}
37+
return title;
38+
}
39+
40+
}

0 commit comments

Comments
 (0)