Skip to content

Commit 5275ac1

Browse files
author
Steve Salas
committed
Warn if endpoint does not match surface method
1 parent b96162a commit 5275ac1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

codepulse/src/main/scala/com/secdec/codepulse/input/surface/SurfaceDetectorPostProcessor.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ class SurfaceDetectorPostProcessor(eventBus: GeneralEventBus, treeBuilderManager
6868
logger.debug(" line {} - {}", x.startingLineNumber, x.endingLineNumber)
6969
val sourceFilePath = if (x.filePath.length > 1 && x.filePath.startsWith("/")) x.filePath.substring(1) else x.filePath
7070
val isJsp = sourceFilePath.toLowerCase().endsWith(".jsp")
71-
if (isJsp) {
72-
treeNodeData.findMethods(sourceFilePath).headOption.map(x => markSurfaceMethod(sourceFilePath, x))
71+
val foundMethod = if (isJsp) treeNodeData.findMethods(sourceFilePath).headOption else treeNodeData.findMethods(sourceFilePath, x.startingLineNumber, x.endingLineNumber).headOption
72+
if (foundMethod.isEmpty) {
73+
val missingMethodDescription = s"Unable to find method for discovered endpoint in ${x.filePath} at line number range ${x.startingLineNumber}-${x.endingLineNumber}."
74+
logger.warn(missingMethodDescription)
7375
} else {
74-
treeNodeData.findMethods(sourceFilePath, x.startingLineNumber, x.endingLineNumber).headOption.map(x => markSurfaceMethod(sourceFilePath, x))
76+
markSurfaceMethod(sourceFilePath, foundMethod.get)
7577
}
7678
})
7779

0 commit comments

Comments
 (0)