forked from WebGoat/WebGoat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added testcases for bypassing frontend validation.
- Improved layout of the lesson - Fixed JavaScript issues with 'let'
- Loading branch information
Showing
5 changed files
with
105 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ns/src/main/resources/lessonPlans/en/BypassRestrictions_FrontendValidation.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ss-restrictions/src/main/resources/lessonPlans/en/BypassRestrictions_Intro.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
|
||
== Concept | ||
|
||
Users have a great degree of control over the front-end of the web application. | ||
They can alter HTML code, sometimes also scripts. This is why | ||
apps that require certain format of input should also validate on server-side. | ||
|
||
== Goals | ||
|
||
* The user should have a basic knowledge of HTML | ||
* The user should be able to tamper a request before sending (with proxy or other tool) | ||
* The user will be able to tamper with field restrictions and bypass client-side validation |
76 changes: 76 additions & 0 deletions
76
...ions/src/test/java/org/owasp/webgoat/plugin/BypassRestrictionsFrontendValidationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.owasp.webgoat.plugin; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.owasp.webgoat.plugins.LessonTest; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
import org.springframework.test.web.servlet.result.MockMvcResultHandlers; | ||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.mockito.Mockito.when; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
/** | ||
* @author nbaars | ||
* @since 6/16/17. | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
public class BypassRestrictionsFrontendValidationTest extends LessonTest { | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
when(webSession.getCurrentLesson()).thenReturn(new BypassRestrictions()); | ||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); | ||
} | ||
|
||
@Test | ||
public void noChangesShouldNotPassTheLesson() throws Exception { | ||
mockMvc.perform(MockMvcRequestBuilders.post("/BypassRestrictions/frontendValidation") | ||
.param("field1", "abc") | ||
.param("field2", "123") | ||
.param("field3", "abc ABC 123") | ||
.param("field4", "seven") | ||
.param("field5", "01101") | ||
.param("field6", "90201 1111") | ||
.param("field7", "301-604-4882") | ||
.param("error", "2")) | ||
.andDo(MockMvcResultHandlers.print()) | ||
.andExpect(status().isOk()).andExpect(jsonPath("$.lessonCompleted", is(false))); | ||
} | ||
|
||
@Test | ||
public void bypassAllFieldShouldPass() throws Exception { | ||
mockMvc.perform(MockMvcRequestBuilders.post("/BypassRestrictions/frontendValidation") | ||
.param("field1", "abcd") | ||
.param("field2", "1234") | ||
.param("field3", "abc $ABC 123") | ||
.param("field4", "ten") | ||
.param("field5", "01101AA") | ||
.param("field6", "90201 1111AA") | ||
.param("field7", "301-604-4882$$") | ||
.param("error", "0")) | ||
.andDo(MockMvcResultHandlers.print()) | ||
.andExpect(status().isOk()).andExpect(jsonPath("$.lessonCompleted", is(true))); | ||
} | ||
|
||
@Test | ||
public void notBypassingAllFieldShouldNotPass() throws Exception { | ||
mockMvc.perform(MockMvcRequestBuilders.post("/BypassRestrictions/frontendValidation") | ||
.param("field1", "abc") | ||
.param("field2", "1234") | ||
.param("field3", "abc $ABC 123") | ||
.param("field4", "ten") | ||
.param("field5", "01101AA") | ||
.param("field6", "90201 1111AA") | ||
.param("field7", "301-604-4882AA") | ||
.param("error", "0")) | ||
.andDo(MockMvcResultHandlers.print()) | ||
.andExpect(status().isOk()).andExpect(jsonPath("$.lessonCompleted", is(false))); | ||
} | ||
|
||
|
||
} |