From 660f8bc660b9aecd463cbcaf9649d47c2908b3e8 Mon Sep 17 00:00:00 2001 From: Nanne Baars Date: Thu, 13 Oct 2016 06:35:46 -0400 Subject: [PATCH] No more yml(3) --- .../owasp/webgoat/controller/StartLesson.java | 7 +- .../org/owasp/webgoat/plugins/Plugin.java | 7 +- .../owasp/webgoat/plugins/YmlBasedLesson.java | 79 ------------------- 3 files changed, 3 insertions(+), 90 deletions(-) delete mode 100644 webgoat-container/src/main/java/org/owasp/webgoat/plugins/YmlBasedLesson.java 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 a983cb1b3..94e00fb9d 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 @@ -30,11 +30,9 @@ */ package org.owasp.webgoat.controller; -import com.google.gson.JsonObject; -import org.json.JSONObject; import org.owasp.webgoat.lessons.AbstractLesson; +import org.owasp.webgoat.lessons.NewLesson; import org.owasp.webgoat.lessons.RandomLessonAdapter; -import org.owasp.webgoat.plugins.YmlBasedLesson; import org.owasp.webgoat.session.WebSession; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContext; @@ -46,7 +44,6 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import java.util.List; -import java.util.Map; import java.util.Optional; @@ -69,7 +66,7 @@ public class StartLesson { model.addObject("lesson", ws.getCurrentLesson()); model.addObject("message", ws.getMessage()); model.addObject("instructions", ws.getInstructions()); - boolean isMigrated = ws.getCurrentLesson() instanceof YmlBasedLesson; + boolean isMigrated = ws.getCurrentLesson() instanceof NewLesson; model.addObject("migrated", isMigrated); //remove after ECS removal otherwise you will see the lesson twice model.setViewName("lesson_content"); return model; 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 59fb67201..f1bdf8cb0 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 @@ -29,7 +29,6 @@ public class Plugin { private PluginClassLoader classLoader; private Class lesson; - private YmlBasedLesson ymlBasedLesson; //TODO REMOVE! private Class newLesson; private List> lessonEndpoints = Lists.newArrayList(); private Map solutionLanguageFiles = new HashMap<>(); @@ -106,7 +105,7 @@ public class Plugin { lessonSourceFile = file.toFile(); } - if (fileEndsWith(file, ".css", ".jsp", ".js", ".yml")) { + if (fileEndsWith(file, ".css", ".jsp", ".js")) { pluginFiles.add(file.toFile()); } } @@ -119,16 +118,12 @@ public class Plugin { */ public Optional getLesson() { try { - if (ymlBasedLesson != null) { - return Optional.of(ymlBasedLesson); - } if (lesson != null) { return Optional.of(lesson.newInstance()); } if (newLesson != null) { return Optional.of(newLesson.newInstance()); } - } catch (IllegalAccessException | InstantiationException e) { throw new PluginLoadingFailure("Unable to instantiate the lesson " + lesson.getName(), e); } 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 deleted file mode 100644 index 877433eea..000000000 --- a/webgoat-container/src/main/java/org/owasp/webgoat/plugins/YmlBasedLesson.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.owasp.webgoat.plugins; - -import org.owasp.webgoat.lessons.Category; -import org.owasp.webgoat.lessons.LessonAdapter; -import org.owasp.webgoat.lessons.LessonEndpoint; -import org.owasp.webgoat.session.WebSession; - -import java.util.List; - -/** - * ************************************************************************************************ - * This file is part of WebGoat, an Open Web Application Security Project utility. For details, - * please see http://www.owasp.org/ - *

- * 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 June 28, 2016 - */ -public class YmlBasedLesson extends LessonAdapter { - - private final static Integer DEFAULT_RANKING = new Integer(10); - private final String category; - private final List hints; - private final String title; - private final String id; - private List lessonEndpoints; - - public YmlBasedLesson(String category, List hints, String title, String id) { - this.category = category; - this.hints = hints; - this.title = title; - this.id = id; - } - - @Override - protected Category getDefaultCategory() { - return Category.getCategory(category); - } - - @Override - protected List getHints(WebSession s) { - return hints; - } - - @Override - protected Integer getDefaultRanking() { - return DEFAULT_RANKING; - } - - @Override - public String getTitle() { - return title; - } - - public String getId() { - return id; - } - -}