Skip to content

Commit d696a78

Browse files
committed
reset state
1 parent 18ea250 commit d696a78

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/security/xss/stored/json/XSSStoredJSONApplication.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,15 @@ open class XSSStoredJSONApplication {
7272
private val guestbookEntries = mutableListOf<Pair<String, String>>() // Query parameter
7373
}
7474

75+
open fun resetDB() {
76+
comments.clear()
77+
userBios.clear()
78+
guestbookEntries.clear()
79+
}
80+
7581
// ==== BODY PARAMETER - Comment System ====
7682

77-
@PostMapping(path = ["/comment"], produces = [MediaType.APPLICATION_JSON_VALUE])
83+
@PostMapping(path = ["/comments"], produces = [MediaType.APPLICATION_JSON_VALUE])
7884
open fun storeComment(@RequestBody commentDto: CommentDto): ResponseEntity<CommentResponseDto> {
7985
// VULNERABLE: Stores user input without sanitization
8086
val comment = commentDto.comment ?: "No comment"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package com.foo.rest.examples.spring.openapi.v3.security.xss.stored.html
22

33
import com.foo.rest.examples.spring.openapi.v3.SpringController
4+
import com.foo.rest.examples.spring.openapi.v3.security.xss.stored.json.XSSStoredJSONApplication
45

5-
class XSSStoredController: SpringController(XSSStoredApplication::class.java)
6+
class XSSStoredController: SpringController(XSSStoredApplication::class.java){
7+
override fun resetStateOfSUT() {
8+
val app = ctx!!.getBean(XSSStoredJSONApplication::class.java)
9+
app.resetDB()
10+
}
11+
}

core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/test/kotlin/com/foo/rest/examples/spring/openapi/v3/security/xss/stored/json/XSSStoredJSONController.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ package com.foo.rest.examples.spring.openapi.v3.security.xss.stored.json
22

33
import com.foo.rest.examples.spring.openapi.v3.SpringController
44

5-
class XSSStoredJSONController: SpringController(XSSStoredJSONApplication::class.java)
5+
class XSSStoredJSONController: SpringController(XSSStoredJSONApplication::class.java){
6+
override fun resetStateOfSUT() {
7+
val app = ctx!!.getBean(XSSStoredJSONApplication::class.java)
8+
app.resetDB()
9+
}
10+
}

core/src/main/kotlin/org/evomaster/core/problem/rest/oracle/RestSecurityOracle.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,6 @@ object RestSecurityOracle {
228228
"<img src=x onerror=alert('XSS')>",
229229
"<svg onload=alert('XSS')>",
230230
"<details open ontoggle=alert('XSS')>",
231-
//TODO if payload contains "/" it causes StackOverflow:
232-
//java.lang.StackOverflowError
233-
// at org.evomaster.core.search.StructuralElement.<init>(StructuralElement.kt:107)
234-
// at org.evomaster.core.search.StructuralElement.<init>(StructuralElement.kt:19)
235-
// at org.evomaster.core.search.gene.Gene.<init>(Gene.kt:58)
236-
// at org.evomaster.core.search.gene.root.SimpleGene.<init>(SimpleGene.kt:13)
237-
// at org.evomaster.core.search.gene.collection.EnumGene.<init>(EnumGene.kt:25)
238-
// at org.evomaster.core.search.gene.collection.EnumGene.copyContent(EnumGene.kt:111)
239231
"<script>alert('XSS')</script>",
240232
"<iframe src='javascript:alert(\"XSS\")'></iframe>"
241233
)

0 commit comments

Comments
 (0)