Skip to content

Commit 2dbbcc2

Browse files
committed
Java: Avoid low-confidence dispatch to InputStream methods
Also adds a neutral model for `InputStream.read`, which offers a high-confidence alternative for this method.
1 parent 8a46ff3 commit 2dbbcc2

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ extensions:
116116
- ["java.io", "File", "isDirectory", "()", "summary", "manual"]
117117
- ["java.io", "File", "mkdirs", "()", "summary", "manual"]
118118
- ["java.io", "FileInputStream", "FileInputStream", "(File)", "summary", "manual"]
119+
- ["java.io", "InputStream", "read", "()", "summary", "manual"]
119120
- ["java.io", "InputStream", "close", "()", "summary", "manual"]
120121
- ["java.io", "OutputStream", "flush", "()", "summary", "manual"]
121122
# The below APIs have numeric flow and are currently being stored as neutral models.

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)