diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/controller/StartLesson.java b/webgoat-container/src/main/java/org/owasp/webgoat/controller/StartLesson.java index 0200e3e10..491e781c8 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/controller/StartLesson.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/controller/StartLesson.java @@ -33,8 +33,9 @@ package org.owasp.webgoat.controller; import org.owasp.webgoat.lessons.AbstractLesson; import org.owasp.webgoat.lessons.RandomLessonAdapter; import org.owasp.webgoat.plugins.YmlBasedLesson; +import org.owasp.webgoat.session.LessonTracker; +import org.owasp.webgoat.session.UserTracker; import org.owasp.webgoat.session.WebSession; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; @@ -51,10 +52,6 @@ import java.util.Optional; @Controller public class StartLesson { - //simple filter can be removed after ECS removal - private static final String refactored = "ClientSideFiltering AccessControlMatrix"; - - /** *
start.
* @@ -95,4 +92,33 @@ public class StartLesson { model.addObject("lesson", lesson.get()); return model; } + +//// FIXME: 8/8/2016 duplicate code + @RequestMapping(value = {"*.attack"}, produces = "text/html") + public ModelAndView attack(HttpServletRequest request) { + // I will set here the thymeleaf fragment location based on the resource requested. + ModelAndView model = new ModelAndView(); + SecurityContext context = SecurityContextHolder.getContext(); //TODO this should work with the security roles of Spring + GrantedAuthority authority = context.getAuthentication().getAuthorities().iterator().next(); + String path = request.getServletPath(); // we now got /a/b/c/AccessControlMatrix.lesson + String lessonName = path.substring(path.lastIndexOf('/') + 1, path.indexOf(".attack")); + WebSession ws = (WebSession) request.getSession().getAttribute(WebSession.SESSION); + List+ * Copyright (c) 2002 - 20014 Bruce Mayhew + *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + *
+ * You should have received a copy of the GNU General Public License along with this program; if + * not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + *
+ * Getting Source ============== + *
+ * Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository for free software + * projects. + *
+ * + * @author WebGoat + * @version $Id: $Id + * @since August 08, 2016 + */ +public interface Attack { + + boolean attack(); +} diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/LessonAdapter.java b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/LessonAdapter.java index 15d83cc09..993c18694 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/LessonAdapter.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/LessonAdapter.java @@ -220,6 +220,11 @@ public abstract class LessonAdapter extends AbstractLesson { s.getLessonSession(this).setCurrentLessonScreen(lessonScreen); } + @Override + protected Element makeMessages(WebSession s) { + return super.makeMessages(s); + } + /** *
getSessionAttribute.
* diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/plugins/Plugin.java b/webgoat-container/src/main/java/org/owasp/webgoat/plugins/Plugin.java index 7016bf4bf..9c41d2933 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/plugins/Plugin.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/plugins/Plugin.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.google.common.base.Optional; import com.google.common.collect.Lists; +import com.google.common.reflect.ClassPath; import org.apache.commons.io.FileUtils; import org.owasp.webgoat.lessons.AbstractLesson; import org.springframework.util.StringUtils; @@ -84,7 +85,8 @@ public class Plugin { final ListloadFiles.
* @@ -152,6 +167,7 @@ public class Plugin { /** * Lesson is optional, it is also possible that the supplied jar contains only helper classes. + * Lesson could be a new lesson (adoc based) or still ECS based. * * @return a {@link com.google.common.base.Optional} object. */ diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/plugins/YmlBasedLesson.java b/webgoat-container/src/main/java/org/owasp/webgoat/plugins/YmlBasedLesson.java index e1498e484..f1d53228d 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/plugins/YmlBasedLesson.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/plugins/YmlBasedLesson.java @@ -1,5 +1,6 @@ package org.owasp.webgoat.plugins; +import org.owasp.webgoat.lessons.Attack; import org.owasp.webgoat.lessons.Category; import org.owasp.webgoat.lessons.LessonAdapter; import org.owasp.webgoat.session.WebSession; @@ -42,12 +43,15 @@ public class YmlBasedLesson extends LessonAdapter { private final List