Skip to content

Commit 3d515b1

Browse files
authored
Merge pull request github#13769 from atorralba/atorralba/java/avoid-inputstream-low-confidence-dispatch
Java: Avoid low-confidence dispatch to InputStream methods
2 parents b21580b + 238cb26 commit 3d515b1

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Improved the precision of virtual dispatch of `java.io.InputStream` methods. Now, calls to these methods will not dispatch to arbitrary implementations of `InputStream` if there is a high-confidence alternative (like a models-as-data summary).
5+

java/ql/lib/ext/java.io.model.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extensions:
8484
- ["java.io", "File", True, "toString", "", "", "Argument[this]", "ReturnValue", "taint", "manual"]
8585
- ["java.io", "File", True, "toURI", "", "", "Argument[this]", "ReturnValue", "taint", "manual"]
8686
- ["java.io", "FilterOutputStream", True, "FilterOutputStream", "(OutputStream)", "", "Argument[0]", "Argument[this]", "taint", "manual"]
87+
- ["java.io", "InputStream", True, "read", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]
8788
- ["java.io", "InputStream", True, "read", "(byte[])", "", "Argument[this]", "Argument[0]", "taint", "manual"]
8889
- ["java.io", "InputStream", True, "read", "(byte[],int,int)", "", "Argument[this]", "Argument[0]", "taint", "manual"]
8990
- ["java.io", "InputStream", True, "readAllBytes", "", "", "Argument[this]", "ReturnValue", "taint", "manual"]

java/ql/lib/semmle/code/java/dispatch/VirtualDispatch.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ private module Dispatch {
102102
or
103103
t instanceof Interface and not t.fromSource()
104104
or
105+
t.hasQualifiedName("java.io", "InputStream")
106+
or
105107
t.hasQualifiedName("java.io", "Serializable")
106108
or
107109
t.hasQualifiedName("java.lang", "Iterable")

0 commit comments

Comments
 (0)