Skip to content

Commit c5aa437

Browse files
authored
Remove irrelevant vulnerabilities from ifds output (#145)
1 parent 3030af2 commit c5aa437

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

jacodb-analysis/src/main/kotlin/org/jacodb/analysis/engine/IfdsResult.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ class IfdsResult(
8080
}
8181
is PredecessorKind.Unknown -> {
8282
addEdge(pred.predEdge.v, lastVertex)
83-
if (pred.predEdge.u == pred.predEdge.v && !stopAtMethodStart) {
84-
sources.add(pred.predEdge.v)
85-
} else { // Turning point
83+
if (pred.predEdge.u != pred.predEdge.v) {
8684
// TODO: ideally, we should analyze the place from which the edge was given to ifds,
8785
// for now we just go to method start
8886
dfs(IfdsEdge(pred.predEdge.u, pred.predEdge.u), pred.predEdge.v, stopAtMethodStart)

jacodb-analysis/src/main/kotlin/org/jacodb/analysis/graph/ApplicationGraphFactory.kt

+1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ val defaultBannedPackagePrefixes: List<String> = listOf(
4949
"java.",
5050
"jdk.internal.",
5151
"sun.",
52+
"javax.",
5253
)

jacodb-analysis/src/main/kotlin/org/jacodb/analysis/library/analyzers/NpeAnalyzer.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ private class NpeForwardFunctions(
222222

223223
val thisInstance = method.thisInstance
224224

225-
// Possibly null fields
225+
// Possibly null public non-final fields
226226
result += method.enclosingClass.fields
227-
.filter { it.isNullable != false && !it.isStatic }
227+
.filter { it.isNullable != false && !it.isStatic && it.isPublic && !it.isFinal }
228228
.map {
229229
NpeTaintNode(
230230
AccessPath.fromOther(AccessPath.fromLocal(thisInstance), listOf(FieldAccessor(it)))

jacodb-cli/src/main/kotlin/org/jacodb/cli/main.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.jacodb.api.JcClassOrInterface
3939
import org.jacodb.api.JcClassProcessingTask
4040
import org.jacodb.api.JcMethod
4141
import org.jacodb.api.analysis.JcApplicationGraph
42+
import org.jacodb.api.ext.methods
4243
import org.jacodb.impl.features.InMemoryHierarchy
4344
import org.jacodb.impl.features.Usages
4445
import org.jacodb.impl.jacodb
@@ -144,8 +145,7 @@ fun main(args: Array<String>) {
144145
}
145146
}
146147
}).get()
147-
val startJcMethods = startJcClasses.flatMap { it.declaredMethods }
148-
148+
val startJcMethods = startJcClasses.flatMap { it.methods }.filter { it.isPublic }
149149

150150
val graph = runBlocking {
151151
cp.newApplicationGraphForAnalysis()

0 commit comments

Comments
 (0)