Skip to content

Commit ae2abed

Browse files
authored
Merge pull request #1388 from WebFuzzing/ssrf-url-name-test
Extracted URL names from ApiGuru as test SSRF input detection
2 parents 507783e + 8764396 commit ae2abed

File tree

3 files changed

+659
-1
lines changed

3 files changed

+659
-1
lines changed

core/src/main/kotlin/org/evomaster/core/problem/security/service/SSRFAnalyser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class SSRFAnalyser {
203203
* A private method to identify parameter is a potentially holds URL value
204204
* using a Regex based approach.
205205
*/
206-
private fun manualClassifier(name: String, description: String? = null): Boolean {
206+
fun manualClassifier(name: String, description: String? = null): Boolean {
207207
if (potentialUrlParamNames.contains(name.lowercase())) {
208208
return true
209209
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.evomaster.core.problem.security
2+
3+
import org.evomaster.core.problem.security.service.SSRFAnalyser
4+
import org.junit.jupiter.api.Assertions.assertEquals
5+
import org.junit.jupiter.api.Test
6+
import java.io.File
7+
8+
class URLNameTest {
9+
10+
private val fileName = "src/test/resources/security/names.csv"
11+
12+
private fun loadURLNames(): List<Triple<String, String, Boolean>> {
13+
val output = mutableListOf<Triple<String, String, Boolean>>()
14+
val file = File(fileName)
15+
if (!file.exists()) {
16+
throw Exception("File does not exist")
17+
}
18+
19+
try {
20+
file.bufferedReader().use { reader ->
21+
// We ignore the handling of CSV header since it's a custom file
22+
reader.readLines().forEach { line ->
23+
val values = line.split(",")
24+
if (values.size != 3) {
25+
throw Exception("Wrong number of values")
26+
}
27+
output.add(Triple(values[0], values[1], values[2].toInt() == 1))
28+
}
29+
}
30+
} catch (e: Exception) {
31+
throw Exception("Error reading CSV file: ${e.message}")
32+
}
33+
34+
return output
35+
}
36+
37+
38+
@Test
39+
fun testURLNames() {
40+
val sa = SSRFAnalyser()
41+
val urlNames = loadURLNames()
42+
43+
urlNames.forEach { v->
44+
assertEquals(v.third, sa.manualClassifier(v.first, v.second))
45+
}
46+
}
47+
48+
}

0 commit comments

Comments
 (0)