LessonAdapter did not read the 'New Lesson Instructions.txt' (IOException)
This commit is contained in:
parent
112386b43e
commit
18204c62c6
@ -1,5 +1,7 @@
|
|||||||
package org.owasp.webgoat.lessons;
|
package org.owasp.webgoat.lessons;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.ecs.Element;
|
import org.apache.ecs.Element;
|
||||||
import org.apache.ecs.ElementContainer;
|
import org.apache.ecs.ElementContainer;
|
||||||
import org.apache.ecs.StringElement;
|
import org.apache.ecs.StringElement;
|
||||||
@ -14,37 +16,39 @@ import org.owasp.webgoat.session.WebSession;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* *************************************************************************************************
|
* *************************************************************************************************
|
||||||
*
|
* <p>
|
||||||
*
|
* <p>
|
||||||
* This file is part of WebGoat, an Open Web Application Security Project
|
* This file is part of WebGoat, an Open Web Application Security Project
|
||||||
* utility. For details, please see http://www.owasp.org/
|
* utility. For details, please see http://www.owasp.org/
|
||||||
*
|
* <p>
|
||||||
* Copyright (c) 2002 - 20014 Bruce Mayhew
|
* Copyright (c) 2002 - 20014 Bruce Mayhew
|
||||||
*
|
* <p>
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* 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
|
* 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
|
* Foundation; either version 2 of the License, or (at your option) any later
|
||||||
* version.
|
* version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* 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
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
* details.
|
* details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License along with
|
* 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
|
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
* Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
* <p>
|
||||||
* Getting Source ==============
|
* Getting Source ==============
|
||||||
*
|
* <p>
|
||||||
* Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository
|
* Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository
|
||||||
* for free software projects.
|
* for free software projects.
|
||||||
*
|
* <p>
|
||||||
* For details, please see http://webgoat.github.io
|
* For details, please see http://webgoat.github.io
|
||||||
*
|
*
|
||||||
* @author Bruce Mayhew <a href="http://code.google.com/p/webgoat">WebGoat</a>
|
* @author Bruce Mayhew <a href="http://code.google.com/p/webgoat">WebGoat</a>
|
||||||
@ -69,25 +73,21 @@ public abstract class LessonAdapter extends AbstractLesson {
|
|||||||
ec.addElement(new P());
|
ec.addElement(new P());
|
||||||
ec
|
ec
|
||||||
.addElement(new StringElement(
|
.addElement(new StringElement(
|
||||||
"Lesson are simple to create and very little coding is required. "
|
"Lesson are simple to create and very little coding is required. "
|
||||||
+ "In fact, most lessons can be created by following the easy to use instructions in the "
|
+ "In fact, most lessons can be created by following the easy to use instructions in the "
|
||||||
+ "<A HREF=http://www.owasp.org/index.php/WebGoat_User_and_Install_Guide_Table_of_Contents>WebGoat User Guide.</A> "
|
+ "<A HREF=http://www.owasp.org/index.php/WebGoat_User_and_Install_Guide_Table_of_Contents>WebGoat User Guide.</A> "
|
||||||
+ "If you would prefer, send your lesson ideas to "
|
+ "If you would prefer, send your lesson ideas to "
|
||||||
+ getWebgoatContext().getFeedbackAddressHTML()));
|
+ getWebgoatContext().getFeedbackAddressHTML()));
|
||||||
|
|
||||||
String fileName = s.getContext().getRealPath("WEB-INF/classes/New Lesson Instructions.txt");
|
try (InputStream is = Thread.currentThread().getContextClassLoader()
|
||||||
if (fileName != null) {
|
.getResourceAsStream("New Lesson Instructions.txt")) {
|
||||||
try {
|
if (is != null) {
|
||||||
PRE pre = new PRE();
|
PRE pre = new PRE();
|
||||||
BufferedReader in = new BufferedReader(new FileReader(fileName));
|
pre.addElement(Joiner.on("\n").join(IOUtils.readLines(is)));
|
||||||
String line = null;
|
|
||||||
while ((line = in.readLine()) != null) {
|
|
||||||
pre.addElement(line + "\n");
|
|
||||||
}
|
|
||||||
ec.addElement(pre);
|
ec.addElement(pre);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return (ec);
|
return (ec);
|
||||||
}
|
}
|
||||||
@ -140,9 +140,9 @@ public abstract class LessonAdapter extends AbstractLesson {
|
|||||||
/**
|
/**
|
||||||
* Gets the credits attribute of the AbstractLesson object
|
* Gets the credits attribute of the AbstractLesson object
|
||||||
*
|
*
|
||||||
* @deprecated Credits are in the about page. This method s no
|
|
||||||
* longer called from WebGoat
|
|
||||||
* @return The credits value
|
* @return The credits value
|
||||||
|
* @deprecated Credits are in the about page. This method s no
|
||||||
|
* longer called from WebGoat
|
||||||
*/
|
*/
|
||||||
public Element getCredits() {
|
public Element getCredits() {
|
||||||
return new StringElement();
|
return new StringElement();
|
||||||
|
@ -16,9 +16,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static java.nio.file.StandardOpenOption.APPEND;
|
|
||||||
import static java.nio.file.StandardOpenOption.CREATE;
|
|
||||||
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
|
|
||||||
import static org.owasp.webgoat.plugins.PluginFileUtils.fileEndsWith;
|
import static org.owasp.webgoat.plugins.PluginFileUtils.fileEndsWith;
|
||||||
import static org.owasp.webgoat.plugins.PluginFileUtils.hasParentDirectoryWithName;
|
import static org.owasp.webgoat.plugins.PluginFileUtils.hasParentDirectoryWithName;
|
||||||
import static org.owasp.webgoat.plugins.PluginFileUtils.replaceInFiles;
|
import static org.owasp.webgoat.plugins.PluginFileUtils.replaceInFiles;
|
||||||
@ -94,7 +91,7 @@ public class Plugin {
|
|||||||
Path propertiesPath = createPropertiesDirectory();
|
Path propertiesPath = createPropertiesDirectory();
|
||||||
LabelProvider.updatePluginResources(propertiesPath);
|
LabelProvider.updatePluginResources(propertiesPath);
|
||||||
PluginFileUtils.createDirsIfNotExists(file.getParent());
|
PluginFileUtils.createDirsIfNotExists(file.getParent());
|
||||||
Files.write(propertiesPath.resolve(file.getFileName()), lines, CREATE, (reload ? APPEND : TRUNCATE_EXISTING));
|
Files.write(propertiesPath.resolve(file.getFileName()), lines);
|
||||||
} catch (IOException io) {
|
} catch (IOException io) {
|
||||||
throw new PluginLoadingFailure("Property file detected, but unable to copy the properties", io);
|
throw new PluginLoadingFailure("Property file detected, but unable to copy the properties", io);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user