Move definition of standard Categories to Category class

Also update all the referring classes


git-svn-id: http://webgoat.googlecode.com/svn/trunk@129 4033779f-a91e-0410-96ef-6bf7bf53c507
This commit is contained in:
rogan.dawes 2007-07-10 11:48:02 +00:00
parent 5f67544b24
commit 747319aab5
55 changed files with 118 additions and 155 deletions

View File

@ -73,87 +73,6 @@ import org.owasp.webgoat.session.WebgoatProperties;
public abstract class AbstractLesson extends Screen implements Comparable
{
/**
* Description of the Field
*/
public final static Category A1 = new Category("Unvalidated Parameters",
new Integer(110));
/**
* Description of the Field
*/
public final static Category A10 = new Category(
"Insecure Configuration Management", new Integer(1010));
/**
* Description of the Field
*/
public final static Category A2 = new Category("Broken Access Control",
new Integer(210));
/**
* Description of the Field
*/
public final static Category A3 = new Category(
"Broken Authentication and Session Management", new Integer(310));
/**
* Description of the Field
*/
public final static Category A4 = new Category(
"Cross-Site Scripting (XSS)", new Integer(410));
/**
* Description of the Field
*/
public final static Category A5 = new Category("Buffer Overflows",
new Integer(510));
/**
* Description of the Field
*/
public final static Category A6 = new Category("Injection Flaws",
new Integer(610));
/**
* Description of the Field
*/
public final static Category A7 = new Category("Improper Error Handling",
new Integer(710));
/**
* Description of the Field
*/
public final static Category A8 = new Category("Insecure Storage",
new Integer(810));
/**
* Description of the Field
*/
public final static Category A9 = new Category("Denial of Service",
new Integer(910));
/**
* Description of the Field
*/
public final static Category WEB_SERVICES = new Category("Web Services",
new Integer(1110));
public final static Category AJAX_SECURITY = new Category("AJAX Security",
new Integer(1150));
public final static Category ADMIN_FUNCTIONS = new Category(
"Admin Functions", new Integer(10));
public final static Category GENERAL = new Category("General", new Integer(
50));
public final static Category CODE_QUALITY = new Category("Code Quality",
new Integer(70));
public final static Category CHALLENGE = new Category("Challenge",
new Integer(2000));
/**
* Description of the Field
*/
@ -198,22 +117,22 @@ public abstract class AbstractLesson extends Screen implements Comparable
*/
public AbstractLesson()
{
categories.add(A1);
categories.add(A2);
categories.add(A3);
categories.add(A4);
categories.add(A5);
categories.add(A6);
categories.add(A7);
categories.add(A8);
categories.add(A9);
categories.add(A10);
categories.add(WEB_SERVICES);
categories.add(AJAX_SECURITY);
categories.add(ADMIN_FUNCTIONS);
categories.add(GENERAL);
categories.add(CODE_QUALITY);
categories.add(CHALLENGE);
categories.add(Category.A1);
categories.add(Category.A2);
categories.add(Category.A3);
categories.add(Category.A4);
categories.add(Category.A5);
categories.add(Category.A6);
categories.add(Category.A7);
categories.add(Category.A8);
categories.add(Category.A9);
categories.add(Category.A10);
categories.add(Category.WEB_SERVICES);
categories.add(Category.AJAX_SECURITY);
categories.add(Category.ADMIN_FUNCTIONS);
categories.add(Category.GENERAL);
categories.add(Category.CODE_QUALITY);
categories.add(Category.CHALLENGE);
id = new Integer(++count);
}

View File

@ -126,7 +126,7 @@ public class AccessControlMatrix extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.A2;
return Category.A2;
}

View File

@ -279,7 +279,7 @@ public class BackDoors extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.A6;
return Category.A6;
}

View File

@ -263,7 +263,7 @@ public class BasicAuthentication extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.A3;
return Category.A3;
}

View File

@ -156,7 +156,7 @@ public class BlindSqlInjection extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A6;
return Category.A6;
}

View File

@ -64,7 +64,7 @@ public class BufferOverflow extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.A5;
return Category.A5;
}

View File

@ -280,7 +280,7 @@ public class CSRF extends LessonAdapter {
@Override
protected Category getDefaultCategory() {
return AbstractLesson.A2;
return Category.A2;
}
private final static Integer DEFAULT_RANKING = new Integer(120);

View File

@ -35,6 +35,54 @@ package org.owasp.webgoat.lessons;
public class Category implements Comparable
{
public final static Category A1 = new Category("Unvalidated Parameters",
new Integer(110));
public final static Category A2 = new Category("Broken Access Control",
new Integer(210));
public final static Category A3 = new Category(
"Broken Authentication and Session Management", new Integer(310));
public final static Category A4 = new Category(
"Cross-Site Scripting (XSS)", new Integer(410));
public final static Category A5 = new Category("Buffer Overflows",
new Integer(510));
public final static Category A6 = new Category("Injection Flaws",
new Integer(610));
public final static Category A7 = new Category("Improper Error Handling",
new Integer(710));
public final static Category A8 = new Category("Insecure Storage",
new Integer(810));
public final static Category A9 = new Category("Denial of Service",
new Integer(910));
public final static Category A10 = new Category(
"Insecure Configuration Management", new Integer(1010));
public final static Category WEB_SERVICES = new Category("Web Services",
new Integer(1110));
public final static Category AJAX_SECURITY = new Category("AJAX Security",
new Integer(1150));
public final static Category ADMIN_FUNCTIONS = new Category(
"Admin Functions", new Integer(10));
public final static Category GENERAL = new Category("General", new Integer(
50));
public final static Category CODE_QUALITY = new Category("Code Quality",
new Integer(70));
public final static Category CHALLENGE = new Category("Challenge",
new Integer(2000));
private String category;
private Integer ranking;
@ -46,7 +94,6 @@ public class Category implements Comparable
this.ranking = ranking;
}
public int compareTo(Object obj)
{
int value = 1;
@ -80,7 +127,7 @@ public class Category implements Comparable
public boolean equals(Object obj)
{
return getName().equals(((Category) obj).getName());
return (obj instanceof Category) && getName().equals(((Category) obj).getName());
}

View File

@ -445,7 +445,7 @@ public class Challenge2Screen extends LessonAdapter
protected Category getDefaultCategory()
{
return CHALLENGE;
return Category.CHALLENGE;
}

View File

@ -324,7 +324,7 @@ public class CommandInjection extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A6;
return Category.A6;
}

View File

@ -11,7 +11,6 @@ import org.apache.ecs.Element;
import org.apache.ecs.ElementContainer;
import org.apache.ecs.html.IMG;
import org.apache.ecs.html.A;
import org.owasp.webgoat.lessons.AbstractLesson;
import org.owasp.webgoat.lessons.Category;
import org.owasp.webgoat.lessons.LessonAdapter;
import org.owasp.webgoat.lessons.LessonAction;
@ -199,7 +198,7 @@ public class CrossSiteScripting extends LessonAdapter
*/
public Category getDefaultCategory()
{
return AbstractLesson.A4;
return Category.A4;
}

View File

@ -162,7 +162,7 @@ public class DOMInjection extends LessonAdapter
protected Category getDefaultCategory()
{
return AJAX_SECURITY;
return Category.AJAX_SECURITY;
}

View File

@ -190,7 +190,7 @@ public class DOS_Login extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A9;
return Category.A9;
}

View File

@ -565,7 +565,7 @@ public class Encoding extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.A8;
return Category.A8;
}

View File

@ -133,7 +133,7 @@ public class FailOpenAuthentication extends WeakAuthenticationCookie
*/
public Category getDefaultCategory()
{
return AbstractLesson.A7;
return Category.A7;
}

View File

@ -107,7 +107,7 @@ public class ForcedBrowsing extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A10;
return Category.A10;
}

View File

@ -290,7 +290,7 @@ public class ForgotPassword extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.A3;
return Category.A3;
}

View File

@ -176,7 +176,7 @@ public class HiddenFieldTampering extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A1;
return Category.A1;
}

View File

@ -239,7 +239,7 @@ public class HtmlClues extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.CODE_QUALITY;
return Category.CODE_QUALITY;
}

View File

@ -119,7 +119,7 @@ public class HttpBasics extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.GENERAL;
return Category.GENERAL;
}

View File

@ -149,7 +149,7 @@ public class HttpOnly extends LessonAdapter {
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A4;
return Category.A4;
}

View File

@ -242,7 +242,7 @@ public class HttpSplitting extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.GENERAL;
return Category.GENERAL;
}

View File

@ -280,7 +280,7 @@ public class JSONInjection extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.AJAX_SECURITY;
return Category.AJAX_SECURITY;
}

View File

@ -270,7 +270,7 @@ public class JavaScriptValidation extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A1;
return Category.A1;
}

View File

@ -200,7 +200,7 @@ public abstract class LessonAdapter extends AbstractLesson
*/
protected Category getDefaultCategory()
{
return GENERAL;
return Category.GENERAL;
}

View File

@ -163,7 +163,7 @@ public class LogSpoofing extends LessonAdapter
@Override
protected Category getDefaultCategory()
{
return AbstractLesson.A6;
return Category.A6;
}

View File

@ -60,7 +60,7 @@ public class NewLesson extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return GENERAL;
return Category.GENERAL;
}
private final static Integer DEFAULT_RANKING = new Integer(85);

View File

@ -241,7 +241,7 @@ public class PathBasedAccessControl extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A2;
return Category.A2;
}

View File

@ -265,7 +265,7 @@ public class Phishing extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A4;
return Category.A4;
}

View File

@ -232,7 +232,7 @@ public class ReflectedXSS extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A4;
return Category.A4;
}

View File

@ -73,7 +73,7 @@ public class RemoteAdminFlaw extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A2;
return Category.A2;
}

View File

@ -11,7 +11,6 @@ import org.apache.ecs.Element;
import org.apache.ecs.ElementContainer;
import org.apache.ecs.html.A;
import org.apache.ecs.html.IMG;
import org.owasp.webgoat.lessons.AbstractLesson;
import org.owasp.webgoat.lessons.Category;
import org.owasp.webgoat.lessons.LessonAction;
import org.owasp.webgoat.lessons.LessonAdapter;
@ -192,7 +191,7 @@ public class RoleBasedAccessControl extends LessonAdapter
*/
public Category getDefaultCategory()
{
return AbstractLesson.A2;
return Category.A2;
}

View File

@ -11,7 +11,6 @@ import org.apache.ecs.Element;
import org.apache.ecs.ElementContainer;
import org.apache.ecs.html.A;
import org.apache.ecs.html.IMG;
import org.owasp.webgoat.lessons.AbstractLesson;
import org.owasp.webgoat.lessons.Category;
import org.owasp.webgoat.lessons.LessonAction;
import org.owasp.webgoat.lessons.LessonAdapter;
@ -202,7 +201,7 @@ public class SQLInjection extends LessonAdapter
*/
public Category getDefaultCategory()
{
return AbstractLesson.A6;
return Category.A6;
}

View File

@ -268,7 +268,7 @@ public class SilentTransactions extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.AJAX_SECURITY;
return Category.AJAX_SECURITY;
}

View File

@ -93,7 +93,7 @@ public class SoapRequest extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.WEB_SERVICES;
return Category.WEB_SERVICES;
}

View File

@ -334,7 +334,7 @@ public class SqlNumericInjection extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A6;
return Category.A6;
}

View File

@ -250,7 +250,7 @@ public class SqlStringInjection extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A6;
return Category.A6;
}

View File

@ -148,7 +148,7 @@ public class StoredXss extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A4;
return Category.A4;
}

View File

@ -180,7 +180,7 @@ public class ThreadSafetyProblem extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.GENERAL;
return Category.GENERAL;
}

View File

@ -233,7 +233,7 @@ public class TraceXSS extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A4;
return Category.A4;
}

View File

@ -206,7 +206,7 @@ public class UncheckedEmail extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A1;
return Category.A1;
}

View File

@ -95,7 +95,7 @@ public class WSDLScanning extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.WEB_SERVICES;
return Category.WEB_SERVICES;
}

View File

@ -229,7 +229,7 @@ public class WeakAuthenticationCookie extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A3;
return Category.A3;
}

View File

@ -149,7 +149,7 @@ public class WeakSessionID extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return AbstractLesson.A3;
return Category.A3;
}

View File

@ -90,7 +90,7 @@ public class WsSAXInjection extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.WEB_SERVICES;
return Category.WEB_SERVICES;
}

View File

@ -83,7 +83,7 @@ public class WsSqlInjection extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.WEB_SERVICES;
return Category.WEB_SERVICES;
}

View File

@ -327,7 +327,7 @@ public class XMLInjection extends LessonAdapter
protected Category getDefaultCategory()
{
return AJAX_SECURITY;
return Category.AJAX_SECURITY;
}

View File

@ -224,7 +224,7 @@ public class XPATHInjection extends LessonAdapter
protected Category getDefaultCategory()
{
return AbstractLesson.A6;
return Category.A6;
}

View File

@ -99,7 +99,7 @@ public class ProductsAdminScreen extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return ADMIN_FUNCTIONS;
return Category.ADMIN_FUNCTIONS;
}

View File

@ -110,7 +110,7 @@ public class RefreshDBScreen extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return ADMIN_FUNCTIONS;
return Category.ADMIN_FUNCTIONS;
}
private final static Integer DEFAULT_RANKING = new Integer(1000);

View File

@ -117,7 +117,7 @@ public class ReportCardScreen extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return ADMIN_FUNCTIONS;
return Category.ADMIN_FUNCTIONS;
}
private final static Integer DEFAULT_RANKING = new Integer(1000);

View File

@ -177,7 +177,7 @@ public class SummaryReportCardScreen extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return ADMIN_FUNCTIONS;
return Category.ADMIN_FUNCTIONS;
}
private final static Integer DEFAULT_RANKING = new Integer(1000);

View File

@ -99,7 +99,7 @@ public class UserAdminScreen extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return ADMIN_FUNCTIONS;
return Category.ADMIN_FUNCTIONS;
}
private final static Integer DEFAULT_RANKING = new Integer(1000);

View File

@ -116,7 +116,7 @@ public class ViewDatabase extends LessonAdapter
*/
protected Category getDefaultCategory()
{
return ADMIN_FUNCTIONS;
return Category.ADMIN_FUNCTIONS;
}
private final static Integer DEFAULT_RANKING = new Integer(1000);

View File

@ -863,7 +863,7 @@ public class WebSession
{
if ( getCurrentLesson() != null )
{
return ( AbstractLesson.CHALLENGE.equals(getCurrentLesson().getCategory()));
return ( Category.CHALLENGE.equals(getCurrentLesson().getCategory()));
}
return false;
}