처음에 나오는 단락은 WebGoat-Lessons/lesson-template-legacy/src/main/resources/plugin/NewLegacyLesson/lessonPlans/en/NewLegacyLesson.html 여기에 있네요.
내용 업데이트가 필요… (lesson-template-legacy에 있는 건 말 그대로 template 이걸 복사해서 쓰면 될 듯 합니다.)
이 파일에 lesson에 대한 소개가 포함될 겁니다. NewLegacyLesson.java 파일 안에 getInstructions()를 사용할 수도 있어요. 맘대로 수정이 가능하고, 번역할 때 사용하면 좋을 거라고…
Detailed Lesson Creation Instructions.
Lesson을 만들려면 WebGoat User Guide를 따라서 하면 된데요. webgoat@owasp.org 에 아이디어를 보내도 좋다고…ㅋㅋ
아래는 lesson 생성에 대한 좀더 자세한 설명
Lesson 생성을 위해 하는 모든 건 LessonAdapter 안에 있는 추상적인 methods이 실행되는 겁니다.(implement 오타인가;;)
Follow the outline below.
WebGoat은 Jakarta Project의 Element Construction Set을 사용합니다.(ECS)
http://jakarta.apache.org/site/downloads/downloads_ecs.cgi
에서 ECS에 대한 API를 많이 공부해야 합니다.
다른 lessons 에서 어떻게 ECS를 사용하는 지에 대한 예시를 볼 수 있습니다.
Step 1: Set up the framework
import java.util.*;
import org.apache.ecs.*;
import org.apache.ecs.html.*;
// Add copyright text - use text from another lesson
//(이거 복붙해서 쓰래요.)
public class NewLesson extends LessonAdapter{
protected Element createContent(WebSession s){
return( new StringElement( "Hello World" ) );
}
public String getCategory(){
}
protected List getHints(){
}
protected String getInstructions(){
}
protected Element getMenuItem(){
}
protected Integer getRanking(){
}
public String getTitle(){
}
}
Step 2: Implement createContent
Content를 만드는 건 진짜 쉽습니다. 2가지로 나뉩니다.
- 사용자의 마지막 request로부터의 input을 다루는 것,
- 사용자를 위해 다음 화면을 만드는 것.
이 모든 건 createContent method에서 발생합니다. 각 lesson마다 하나의 page로 다루어 진다는 것을 기억하세요. 그래서 lesson을 그런 식으로 설계를 할 필요가 있습니다.
createContent의 일반적인 좋은 patten은 다음과 같습니다.
// define a constant for the field name
// field name을 위한 하나의 상수를 정의
private static final String INPUT = "input";
protected Element createContent(WebSession s)
{
ElementContainer ec = new ElementContainer();
try
{
// get some input from the user -- see ParameterParser for details
// (사용자로부터 어떤 입력을 받음)
String userInput = s.getParser().getStringParameter(INPUT, "");
// do something with the input
// (입력에 대해 무언 가를 함.)
// -- SQL query?
// -- Runtime.exec?
// -- Some other dangerous thing
// generate some output -- a string and an input field
// (출력을 만듦니다. -- string이랑 input field)
ec.addElement(new StringElement("Enter a string: "));
ec.addElement( new Input(Input.TEXT, INPUT, userInput) );
// Tell the lesson tracker the lesson has completed.
// (lesson tracker에게 끝났음을 알리고.)
// This should occur when the user has 'hacked' the lesson.
// (사용자가 lesson을 hack했을 때 발생해야 합니다.)
makeSuccess(s);
}
catch (Exception e)
{
s.setMessage("Error generating " + this.getClass().getName());
e.printStackTrace();
}
return (ec);
}
ECS is quite powerful -- see the Encoding lesson for an example of how
to use it to create a table with rows and rows of output.
테이블을 생성해서 출력하기 위해 Encoding lesson에 대한 예제를 참고하세요.
Step 3: Implement the other methods
LessonAdapter의 다른 methods는 lesson이 WebGoat framework에 전반적으로 연결되도록 돕습니다. 쉽고 얼마 안걸려요.
public String getCategory()
{
// The default category is "General" Only override this
// method if you wish to create a new category or if you
// wish this lesson to reside within a category other the
// "General"
// (기본 category는 "General" 입니다. 새 category를 만들거나
// 다른 category에 포함시키려면 이 method를 override 하면 됩니다.)
return( "NewCategory" ); // or use an existing category
}
protected List getHints()
{
// Hints will be returned to the user in the order they
// appear below. The user must click on the "next hint"
// button before the hint will be displayed.
// (next hint 버튼을 눌러야 합니다.)
List hints = new ArrayList();
hints.add("A general hint to put users on the right track");
hints.add("A hint that gives away a little piece of the problem");
hints.add("A hint that basically gives the answer");
return hints;
}
protected String getInstructions()
{
// Instructions will rendered as html and will appear below
// the area and above the actual lesson area.
// (설명은 html로 만들어 지며 실제 lesson 위에 나타나게 됩니다.)
// Instructions should provide the user with the general setup
// and goal of the lesson.
return("The text that goes at the top of the page");
}
protected Element getMenuItem()
{
// This is the text of the link that will appear on
// the left hand menus under the appropriate category.
// (왼쪽의 menu에서 적절한 category 아래에 표시할 link에 대한 text 입니다.)
// Their is a limited amount of horizontal space in
// this area before wrapping will occur.
return( "MyLesson" );
}
protected Integer getRanking()
{
// The ranking denotes the order in which the menu item
// will appear in menu list for each category. The lowest
// number will appear as the first lesson.
// (category menu에 표시될 순서를 나타냅니다. 숫자가 작을수록 위에 표시됩니다.)
return new Integer(10);
}
public String getTitle()
{
// The title of the lesson. This will appear above the
// control area at the top of the page. This field will
// be rendered as html.
return ("My Lesson's Short Title");
}
Step 4: Build and test
Eclipse 안에서 Tomcat Server를 구동시켜 lesson을 test 할 수 있습니다.
WebGoat root의 "readme.txt"를 참고하세요.
Step 5: Create the lesson plan
All WebGoat lessons have a lesson plan that describes the goals of the lesson.
WebGoat의 모든 lesson은 lesson의 목표가 적힌 lesson plan을 가집니다.
Lesson plan을 만들고 lesson_plans 폴더에 넣으세요.
Step 6: Give back to the community
If you've come up with a lesson that you think helps to teach people about
web application security, please contribute it by sending it to the people
who maintain the WebGoat application.
Thanks!
The WebGoat Team.