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.
feat: show directly requested file in requests overview
When a call directly hits a file it is now show up in the requests overview. This helps the user whether an attack from WebGoat actually requested the uploaded file. Closes: WebGoatgh-1551
- Loading branch information
Showing
3 changed files
with
81 additions
and
20 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
41 changes: 41 additions & 0 deletions
41
src/test/java/org/owasp/webgoat/webwolf/requests/WebWolfTraceRepositoryTest.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,41 @@ | ||
package org.owasp.webgoat.webwolf.requests; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.net.URI; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.actuate.web.exchanges.HttpExchange; | ||
|
||
class WebWolfTraceRepositoryTest { | ||
|
||
@Test | ||
@DisplayName("When a user hits a file upload it should be recorded") | ||
void shouldAddFilesRequest() { | ||
HttpExchange httpExchange = mock(); | ||
HttpExchange.Request request = mock(); | ||
when(httpExchange.getRequest()).thenReturn(request); | ||
when(request.getUri()).thenReturn(URI.create("http://localhost:9090/files/test1234/test.jpg")); | ||
WebWolfTraceRepository repository = new WebWolfTraceRepository(); | ||
|
||
repository.add(httpExchange); | ||
|
||
Assertions.assertThat(repository.findAll()).hasSize(1); | ||
} | ||
|
||
@Test | ||
@DisplayName("When a user hits file upload page ('/files') it should be recorded") | ||
void shouldAddNotAddFilesRequestOverview() { | ||
HttpExchange httpExchange = mock(); | ||
HttpExchange.Request request = mock(); | ||
when(httpExchange.getRequest()).thenReturn(request); | ||
when(request.getUri()).thenReturn(URI.create("http://localhost:9090/files")); | ||
WebWolfTraceRepository repository = new WebWolfTraceRepository(); | ||
|
||
repository.add(httpExchange); | ||
|
||
Assertions.assertThat(repository.findAll()).hasSize(0); | ||
} | ||
} |