Make it possible to return per-stage hints

git-svn-id: http://webgoat.googlecode.com/svn/trunk@144 4033779f-a91e-0410-96ef-6bf7bf53c507
This commit is contained in:
rogan.dawes 2007-07-10 11:53:34 +00:00
parent d39975c299
commit e6fcd4176c
48 changed files with 65 additions and 61 deletions

View File

@ -353,27 +353,29 @@ public abstract class AbstractLesson extends Screen implements Comparable
/** /**
* Gets the hintCount attribute of the Lesson object * Gets the hintCount attribute of the Lesson object
* @param s The user's WebSession
* *
* @return The hintCount value * @return The hintCount value
*/ */
public int getHintCount() public int getHintCount(WebSession s)
{ {
return getHints().size(); return getHints(s).size();
} }
protected abstract List getHints(); protected abstract List<String> getHints(WebSession s);
/** /**
* Fill in a minor hint that will help people who basically get it, but * Fill in a minor hint that will help people who basically get it, but
* are stuck on somthing silly. * are stuck on somthing silly.
* @param s The users WebSession
* *
* @return The hint1 value * @return The hint1 value
*/ */
public String getHint(int hintNumber) public String getHint(WebSession s, int hintNumber)
{ {
return (String) getHints().get(hintNumber); return getHints(s).get(hintNumber);
} }
@ -409,7 +411,7 @@ public abstract class AbstractLesson extends Screen implements Comparable
* Gets the content of lessonPlanURL * Gets the content of lessonPlanURL
* *
* @param s * @param s
* TODO * The user's WebSession
* *
* @return The HTML content of the current lesson plan * @return The HTML content of the current lesson plan
*/ */

View File

@ -135,7 +135,7 @@ public class AccessControlMatrix extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("Many sites attempt to restrict access to resources by role."); hints.add("Many sites attempt to restrict access to resources by role.");

View File

@ -264,7 +264,7 @@ public class BackDoors extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("Your user id is 101. Use it to see your information"); hints.add("Your user id is 101. Use it to see your information");

View File

@ -272,7 +272,7 @@ public class BasicAuthentication extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
public List getHints() public List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
// int stage = getLessonTracker(session, BASIC).getStage(); // int stage = getLessonTracker(session, BASIC).getStage();

View File

@ -198,7 +198,7 @@ public class BlindSqlInjection extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
if (runningOnWindows()) if (runningOnWindows())

View File

@ -73,7 +73,7 @@ public class BufferOverflow extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
public List getHints() public List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("Lesson Hint 1"); hints.add("Lesson Hint 1");

View File

@ -292,7 +292,7 @@ public class CSRF extends LessonAdapter {
} }
@Override @Override
protected List getHints() { protected List<String> getHints(WebSession s) {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add( "Enter some text and try to include an image in there." ); hints.add( "Enter some text and try to include an image in there." );
hints.add( "In order to make the picture almost invisible try to add width=\"1\" and height=\"1\"." ); hints.add( "In order to make the picture almost invisible try to add width=\"1\" and height=\"1\"." );

View File

@ -504,7 +504,7 @@ public class Challenge2Screen extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints(WebSession s) protected List<String> getHints(WebSession s)
{ {
//<START_OMIT_SOURCE> //<START_OMIT_SOURCE>

View File

@ -333,7 +333,7 @@ public class CommandInjection extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -207,7 +207,7 @@ public class CrossSiteScripting extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();

View File

@ -173,7 +173,7 @@ public class DOMInjection extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();

View File

@ -199,7 +199,7 @@ public class DOS_Login extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("Use a SQL Injection to obtain the user names. "); hints.add("Use a SQL Injection to obtain the user names. ");

View File

@ -575,7 +575,7 @@ public class Encoding extends LessonAdapter
* @return The hints value * @return The hints value
*/ */
public List getHints() public List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();

View File

@ -142,7 +142,7 @@ public class FailOpenAuthentication extends WeakAuthenticationCookie
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("You can force errors during the authentication process."); hints.add("You can force errors during the authentication process.");

View File

@ -116,7 +116,7 @@ public class ForcedBrowsing extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
public List getHints() public List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("Try to guess the URL for the config page"); hints.add("Try to guess the URL for the config page");

View File

@ -299,7 +299,7 @@ public class ForgotPassword extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
public List getHints() public List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();

View File

@ -185,7 +185,7 @@ public class HiddenFieldTampering extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -198,7 +198,7 @@ public class HtmlClues extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -93,7 +93,7 @@ public class HttpBasics extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
public List getHints() public List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("Type in your name and press 'go'"); hints.add("Type in your name and press 'go'");

View File

@ -158,7 +158,7 @@ public class HttpOnly extends LessonAdapter {
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add( "Read the directions and try out the buttons." ); hints.add( "Read the directions and try out the buttons." );

View File

@ -246,7 +246,7 @@ public class HttpSplitting extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();

View File

@ -284,7 +284,7 @@ public class JSONInjection extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("JSON stands for JavaScript Object Notation."); hints.add("JSON stands for JavaScript Object Notation.");

View File

@ -279,7 +279,7 @@ public class JavaScriptValidation extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();

View File

@ -223,9 +223,9 @@ public abstract class LessonAdapter extends AbstractLesson
* *
* @return The hintCount value * @return The hintCount value
*/ */
public int getHintCount() public int getHintCount(WebSession s)
{ {
return getHints().size(); return getHints(s).size();
} }
@ -236,7 +236,7 @@ public abstract class LessonAdapter extends AbstractLesson
* *
* @return The hint1 value * @return The hint1 value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("There are no hints defined."); hints.add("There are no hints defined.");
@ -245,9 +245,9 @@ public abstract class LessonAdapter extends AbstractLesson
} }
public String getHint(int hintNumber) public String getHint(WebSession s, int hintNumber)
{ {
return (String) getHints().get(hintNumber); return (String) getHints(s).get(hintNumber);
} }

View File

@ -140,7 +140,7 @@ public class LogSpoofing extends LessonAdapter
@Override @Override
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("Try to fool the humane eye by using new lines."); hints.add("Try to fool the humane eye by using new lines.");

View File

@ -250,7 +250,7 @@ public class PathBasedAccessControl extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -171,7 +171,7 @@ public class Phishing extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -241,7 +241,7 @@ public class ReflectedXSS extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -82,7 +82,7 @@ public class RemoteAdminFlaw extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
public List getHints() public List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("WebGoat has 2 admin interfaces."); hints.add("WebGoat has 2 admin interfaces.");

View File

@ -200,7 +200,7 @@ public class RoleBasedAccessControl extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -210,7 +210,7 @@ public class SQLInjection extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -272,7 +272,7 @@ public class SilentTransactions extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("Check the javascript in the HTML source."); hints.add("Check the javascript in the HTML source.");

View File

@ -97,7 +97,7 @@ public class SoapRequest extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -343,7 +343,7 @@ public class SqlNumericInjection extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -259,7 +259,7 @@ public class SqlStringInjection extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -157,7 +157,7 @@ public class StoredXss extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("You can put HTML tags in your message."); hints.add("You can put HTML tags in your message.");

View File

@ -137,7 +137,7 @@ public class ThreadSafetyProblem extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -242,7 +242,7 @@ public class TraceXSS extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -215,7 +215,7 @@ public class UncheckedEmail extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("Try sending an anonymous message to yourself."); hints.add("Try sending an anonymous message to yourself.");

View File

@ -99,7 +99,7 @@ public class WSDLScanning extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -260,7 +260,7 @@ public class WeakAuthenticationCookie extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -158,7 +158,7 @@ public class WeakSessionID extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -94,7 +94,7 @@ public class WsSAXInjection extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();

View File

@ -87,7 +87,7 @@ public class WsSqlInjection extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints hints

View File

@ -338,7 +338,7 @@ public class XMLInjection extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();

View File

@ -242,7 +242,7 @@ public class XPATHInjection extends LessonAdapter
} }
protected List getHints() protected List<String> getHints(WebSession s)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();

View File

@ -133,7 +133,7 @@ public class ViewDatabase extends LessonAdapter
* *
* @return The hints value * @return The hints value
*/ */
protected List getHints() protected List<String> getHints(WebSession s)
{ {
List<String> hints = new ArrayList<String>(); List<String> hints = new ArrayList<String>();
hints.add("There are no hints defined"); hints.add("There are no hints defined");

View File

@ -447,10 +447,12 @@ public class WebSession
public String getHint() public String getHint()
{ {
String hint = null; String hint = null;
int hints = getCurrentLesson().getHintCount(this);
if (getHintNum() > hints)
hintNum = -1;
if ( getHintNum() >= 0 ) if ( getHintNum() >= 0 )
// FIXME // FIXME
hint = getCurrentLesson().getHint( getHintNum() ); hint = getCurrentLesson().getHint( this, getHintNum() );
return hint; return hint;
} }
@ -1015,7 +1017,7 @@ public class WebSession
String hint = null; String hint = null;
// FIXME // FIXME
int maxHints = getCurrentLesson().getHintCount(); int maxHints = getCurrentLesson().getHintCount(this);
if ( hintNum < maxHints - 1 ) if ( hintNum < maxHints - 1 )
{ {
hintNum++; hintNum++;
@ -1023,7 +1025,7 @@ public class WebSession
// Hints are indexed from 0 // Hints are indexed from 0
getCurrentLesson().getLessonTracker( this ).setMaxHintLevel( getHintNum() + 1 ); getCurrentLesson().getLessonTracker( this ).setMaxHintLevel( getHintNum() + 1 );
hint = (String) getCurrentLesson().getHint( getHintNum() ); hint = (String) getCurrentLesson().getHint( this, getHintNum() );
} }
return hint; return hint;
@ -1040,7 +1042,7 @@ public class WebSession
// Hints are indexed from 0 // Hints are indexed from 0
getCurrentLesson().getLessonTracker( this ).setMaxHintLevel( getHintNum() + 1 ); getCurrentLesson().getLessonTracker( this ).setMaxHintLevel( getHintNum() + 1 );
hint = (String) getCurrentLesson().getHint( getHintNum() ); hint = (String) getCurrentLesson().getHint( this, getHintNum() );
} }
return hint; return hint;