File tree Expand file tree Collapse file tree 3 files changed +659
-1
lines changed
main/kotlin/org/evomaster/core/problem/security/service
kotlin/org/evomaster/core/problem/security Expand file tree Collapse file tree 3 files changed +659
-1
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments