No more yml(3)

This commit is contained in:
Nanne Baars 2016-10-13 06:35:46 -04:00
parent 5ac9a3b69d
commit 660f8bc660
3 changed files with 3 additions and 90 deletions

View File

@ -30,11 +30,9 @@
*/ */
package org.owasp.webgoat.controller; 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.AbstractLesson;
import org.owasp.webgoat.lessons.NewLesson;
import org.owasp.webgoat.lessons.RandomLessonAdapter; import org.owasp.webgoat.lessons.RandomLessonAdapter;
import org.owasp.webgoat.plugins.YmlBasedLesson;
import org.owasp.webgoat.session.WebSession; import org.owasp.webgoat.session.WebSession;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContext;
@ -46,7 +44,6 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
@ -69,7 +66,7 @@ public class StartLesson {
model.addObject("lesson", ws.getCurrentLesson()); model.addObject("lesson", ws.getCurrentLesson());
model.addObject("message", ws.getMessage()); model.addObject("message", ws.getMessage());
model.addObject("instructions", ws.getInstructions()); 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.addObject("migrated", isMigrated); //remove after ECS removal otherwise you will see the lesson twice
model.setViewName("lesson_content"); model.setViewName("lesson_content");
return model; return model;

View File

@ -29,7 +29,6 @@ public class Plugin {
private PluginClassLoader classLoader; private PluginClassLoader classLoader;
private Class<AbstractLesson> lesson; private Class<AbstractLesson> lesson;
private YmlBasedLesson ymlBasedLesson; //TODO REMOVE!
private Class<NewLesson> newLesson; private Class<NewLesson> newLesson;
private List<Class<LessonEndpoint>> lessonEndpoints = Lists.newArrayList(); private List<Class<LessonEndpoint>> lessonEndpoints = Lists.newArrayList();
private Map<String, File> solutionLanguageFiles = new HashMap<>(); private Map<String, File> solutionLanguageFiles = new HashMap<>();
@ -106,7 +105,7 @@ public class Plugin {
lessonSourceFile = file.toFile(); lessonSourceFile = file.toFile();
} }
if (fileEndsWith(file, ".css", ".jsp", ".js", ".yml")) { if (fileEndsWith(file, ".css", ".jsp", ".js")) {
pluginFiles.add(file.toFile()); pluginFiles.add(file.toFile());
} }
} }
@ -119,16 +118,12 @@ public class Plugin {
*/ */
public Optional<AbstractLesson> getLesson() { public Optional<AbstractLesson> getLesson() {
try { try {
if (ymlBasedLesson != null) {
return Optional.of(ymlBasedLesson);
}
if (lesson != null) { if (lesson != null) {
return Optional.of(lesson.newInstance()); return Optional.of(lesson.newInstance());
} }
if (newLesson != null) { if (newLesson != null) {
return Optional.of(newLesson.newInstance()); return Optional.of(newLesson.newInstance());
} }
} catch (IllegalAccessException | InstantiationException e) { } catch (IllegalAccessException | InstantiationException e) {
throw new PluginLoadingFailure("Unable to instantiate the lesson " + lesson.getName(), e); throw new PluginLoadingFailure("Unable to instantiate the lesson " + lesson.getName(), e);
} }

View File

@ -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/
* <p>
* Copyright (c) 2002 - 20014 Bruce Mayhew
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* Getting Source ==============
* <p>
* Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository for free software
* projects.
* <p>
*
* @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<String> hints;
private final String title;
private final String id;
private List<LessonEndpoint> lessonEndpoints;
public YmlBasedLesson(String category, List<String> 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<String> getHints(WebSession s) {
return hints;
}
@Override
protected Integer getDefaultRanking() {
return DEFAULT_RANKING;
}
@Override
public String getTitle() {
return title;
}
public String getId() {
return id;
}
}