Skip to content

Commit 039bea1

Browse files
committed
Java: Add more neutral JDK models
This is similar to #15766, in the sense that it adds neutral models to prevent the model generator from generating summaries for them. These models were spotted while evaluating #14919.
1 parent c190dd2 commit 039bea1

9 files changed

+45
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@ extensions:
44
extensible: summaryModel
55
data:
66
- ["java.beans", "XMLDecoder", False, "XMLDecoder", "", "", "Argument[0]", "Argument[this]", "taint", "manual"]
7+
- addsTo:
8+
pack: codeql/java-all
9+
extensible: neutralModel
10+
data:
11+
# summary neutrals
12+
- ["java.beans", "PropertyEditor", "getAsText", "()", "summary", "manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
13+
- ["java.beans", "PropertyEditor", "getValue", "()", "summary", "manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
14+
- ["java.beans", "PropertyEditor", "setAsText", "()", "summary", "manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
15+
- ["java.beans", "PropertyEditor", "setValue", "()", "summary", "manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,12 @@ extensions:
116116
- ["java.io", "File", "isFile", "()", "summary", "manual"]
117117
- ["java.io", "File", "length", "()", "summary", "manual"]
118118
- ["java.io", "File", "isDirectory", "()", "summary", "manual"]
119+
- ["java.io", "File", "listFiles", "", "summary", "manual"]
119120
- ["java.io", "File", "mkdirs", "()", "summary", "manual"]
120121
- ["java.io", "FileInputStream", "FileInputStream", "(File)", "summary", "manual"]
122+
- ["java.io", "FileInputStream", "FileInputStream", "(String)", "summary", "manual"]
121123
- ["java.io", "InputStream", "close", "()", "summary", "manual"]
124+
- ["java.io", "ObjectInput", "readObject", "()", "summary", "manual"]
122125
- ["java.io", "OutputStream", "flush", "()", "summary", "manual"]
123126
# The below APIs have numeric flow and are currently being stored as neutral models.
124127
# These may be changed to summary models with kinds "value-numeric" and "taint-numeric" (or similar) in the future.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,10 @@ extensions:
6161
- ["java.net", "URL", False, "toURI", "", "", "Argument[this]", "ReturnValue", "taint", "manual"]
6262
- ["java.net", "URL", False, "toString", "", "", "Argument[this]", "ReturnValue", "taint", "manual"]
6363
- ["java.net", "URLDecoder", False, "decode", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
64+
- addsTo:
65+
pack: codeql/java-all
66+
extensible: neutralModel
67+
data:
68+
# summary neutrals
69+
- ["java.net", "Socket", "getOutputStream", "()", "summary", "manual"]
70+
- ["java.net", "Socket", "connect", "(SocketAddress,int)", "summary", "manual"]

java/ql/lib/ext/java.util.logging.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/java-all
4+
extensible: neutralModel
5+
data:
6+
# summary neutrals
7+
- ["java.util.logging", "LogRecord", "getResourceBundle", "()", "summary", "manual"]
8+
- ["java.util.logging", "LogRecord", "setParameters", "", "summary", "manual"]

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ extensions:
107107
- ["java.util", "Collections", False, "unmodifiableSortedMap", "(SortedMap)", "", "Argument[0].MapKey", "ReturnValue.MapKey", "value", "manual"]
108108
- ["java.util", "Collections", False, "unmodifiableSortedMap", "(SortedMap)", "", "Argument[0].MapValue", "ReturnValue.MapValue", "value", "manual"]
109109
- ["java.util", "Collections", False, "unmodifiableSortedSet", "(SortedSet)", "", "Argument[0].Element", "ReturnValue.Element", "value", "manual"]
110+
- ["java.util", "ConcurrentHashMap", False, "ConcurrentHashMap", "(Map)", "", "Argument[0].MapKey", "Argument[this].MapKey", "value", "manual"]
111+
- ["java.util", "ConcurrentHashMap", False, "ConcurrentHashMap", "(Map)", "", "Argument[0].MapValue", "Argument[this].MapValue", "value", "manual"]
110112
- ["java.util", "Deque", True, "addFirst", "(Object)", "", "Argument[0]", "Argument[this].Element", "value", "manual"]
111113
- ["java.util", "Deque", True, "addLast", "(Object)", "", "Argument[0]", "Argument[this].Element", "value", "manual"]
112114
- ["java.util", "Deque", True, "descendingIterator", "()", "", "Argument[this].Element", "ReturnValue.Element", "value", "manual"]
@@ -428,6 +430,7 @@ extensions:
428430
- ["java.util", "Collections", "emptySet", "()", "summary", "manual"]
429431
- ["java.util", "Collections", "sort", "", "summary", "manual"]
430432
- ["java.util", "Enumeration", "hasMoreElements", "()", "summary", "manual"]
433+
- ["java.util", "EnumSet", "copyOf", "(EnumSet)", "summary", "manual"]
431434
- ["java.util", "HashMap", "containsKey", "(Object)", "summary", "manual"]
432435
- ["java.util", "HashMap", "HashMap", "(int)", "summary", "manual"]
433436
- ["java.util", "HashMap", "size", "()", "summary", "manual"]
@@ -454,6 +457,7 @@ extensions:
454457
- ["java.util", "Optional", "isEmpty", "()", "summary", "manual"]
455458
- ["java.util", "Optional", "isPresent", "()", "summary", "manual"]
456459
- ["java.util", "Random", "nextInt", "(int)", "summary", "manual"]
460+
- ["java.util", "ResourceBundle", "getBundle", "", "summary", "manual"]
457461
- ["java.util", "Set", "contains", "(Object)", "summary", "manual"]
458462
- ["java.util", "Set", "isEmpty", "()", "summary", "manual"]
459463
- ["java.util", "Set", "size", "()", "summary", "manual"]

java/ql/lib/ext/java.util.prefs.model.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ extensions:
33
pack: codeql/java-all
44
extensible: neutralModel
55
data:
6+
# summary neutrals
7+
- ["java.util.prefs", "Preferences", "get", "(String,String)", "summary", "manual"]
68
# sink neutrals
79
- ["java.util.prefs", "AbstractPreferences", "nodeExists", "", "sink", "hq-manual"]
810
- ["java.util.prefs", "Preferences", "nodeExists", "", "sink", "hq-manual"]

java/ql/lib/ext/java.util.regex.model.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ extensions:
3030
pack: codeql/java-all
3131
extensible: neutralModel
3232
data:
33+
- ["java.util.regex", "Matcher", "appendReplacement", "(StringBuffer,String)", "summary", "manual"]
34+
- ["java.util.regex", "Matcher", "appendTail", "(StringBuffer)", "summary", "manual"]
3335
- ["java.util.regex", "Matcher", "find", "()", "summary", "manual"]
36+
- ["java.util.regex", "Matcher", "pattern", "()", "summary", "manual"]
37+
- ["java.util.regex", "Pattern", "compile", "(String,int)", "summary", "manual"]
38+
- ["java.util.regex", "Pattern", "pattern", "()", "summary", "manual"]

java/ql/lib/ext/javax.crypto.model.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ extensions:
2424
- ["javax.crypto", "Cipher", "update", "", "summary", "manual"]
2525
- ["javax.crypto", "Cipher", "updateAAD", "", "summary", "manual"]
2626
- ["javax.crypto", "Cipher", "wrap", "", "summary", "manual"]
27+
- ["javax.crypto", "Mac", "init", "(Key)", "summary", "manual"]
28+
- ["javax.crypto", "Mac", "doFinal", "()", "summary", "manual"]

java/ql/lib/ext/javax.crypto.spec.model.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ extensions:
2626
- ["javax.crypto.spec", "PBEParameterSpec", False, "PBEParameterSpec", "", "", "Argument[0]", "encryption-salt", "manual"]
2727
- ["javax.crypto.spec", "SecretKeySpec", False, "SecretKeySpec", "(byte[],String)", "", "Argument[0]", "credentials-key", "hq-generated"]
2828
- ["javax.crypto.spec", "SecretKeySpec", False, "SecretKeySpec", "(byte[],int,int,String)", "", "Argument[0]", "credentials-key", "hq-generated"]
29+
- addsTo:
30+
pack: codeql/java-all
31+
extensible: neutralModel
32+
data:
33+
- ["javax.crypto.spec", "SecretKeySpec", "SecretKeySpec", "(byte[],String)", "summary", "manual"]

0 commit comments

Comments
 (0)