diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java index 391edbeab7..d358fbba42 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java @@ -233,6 +233,12 @@ public Category getCategory() { */ protected abstract boolean getDefaultHidden(); + /** + *

getSubmitMethod

+ */ + public abstract String getSubmitMethod(); + + /** * Gets the fileMethod attribute of the Lesson class * @@ -643,7 +649,7 @@ public String getLink() { .append("/").append(getCategory().getRanking()).toString(); } - /** + /** * Get the link to the target servlet. * * Unlike getLink() this method does not require rendering the output of diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/LessonAdapter.java b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/LessonAdapter.java index 69a1c8d468..419e8a5258 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/LessonAdapter.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/LessonAdapter.java @@ -153,6 +153,13 @@ protected List getHints(WebSession s) { return hints; } + /** + * provide a default submitMethod of lesson does not implement + */ + public String getSubmitMethod() { + return "GET"; + } + /** * {@inheritDoc} * diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/model/LessonInfoModel.java b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/model/LessonInfoModel.java index d49ea6bd3c..9f3ef5162f 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/lessons/model/LessonInfoModel.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/lessons/model/LessonInfoModel.java @@ -4,9 +4,6 @@ import org.owasp.webgoat.lessons.Category; import org.owasp.webgoat.session.WebSession; -/** - * Created by jason on 9/18/15. - */ public class LessonInfoModel { private String lessonTitle; @@ -14,9 +11,7 @@ public class LessonInfoModel { private boolean hasSource; private boolean hasSolution; private boolean hasPlan; - private String source; - private String solution; - private String plan; + private String submitMethod; public LessonInfoModel(WebSession webSession) { AbstractLesson lesson = webSession.getCurrentLesson(); @@ -26,6 +21,7 @@ public LessonInfoModel(WebSession webSession) { this.hasSolution = !lesson.getSolution(webSession).contains("Could not find the solution file or solution file does not exist"); this.lessonTitle = lesson.getTitle(); this.numberHints = lesson.getHintCount(webSession); + this.submitMethod = lesson.getSubmitMethod(); if ( this.numberHints < 1 || lesson.getHint(webSession,0).equals("Hint: There are no hints defined.")) { this.numberHints = 0; @@ -60,16 +56,8 @@ public boolean isHasPlan() { return hasPlan; } - public String getSource() { - return source; - } - - public String getSolution() { - return solution; - } - - public String getPlan() { - return plan; + public String getSubmitMethod() { + return submitMethod; } } diff --git a/webgoat-container/src/test/java/org/owasp/webgoat/lessons/AbstractLessonTest.java b/webgoat-container/src/test/java/org/owasp/webgoat/lessons/AbstractLessonTest.java index 82b74e34b0..37f5206f58 100644 --- a/webgoat-container/src/test/java/org/owasp/webgoat/lessons/AbstractLessonTest.java +++ b/webgoat-container/src/test/java/org/owasp/webgoat/lessons/AbstractLessonTest.java @@ -9,6 +9,7 @@ import java.util.Arrays; import java.util.List; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; public class AbstractLessonTest { @@ -41,6 +42,7 @@ public String getTitle() { public String getCurrentAction(WebSession s) { return "an action"; } + public String getSubmitMethod() { return "GET";} public void restartLesson() { } public void setCurrentAction(WebSession s, String lessonScreen) { @@ -56,6 +58,7 @@ public void testLinks() { String srvLink = lesson.getServletLink(); assertThat(srvLink, CoreMatchers.startsWith("attack?Screen=")); assertThat(srvLink, CoreMatchers.endsWith("&menu=900")); + assertEquals(lesson.getSubmitMethod(),"GET"); } }