Skip to content

Commit 30d906d

Browse files
authored
Merge pull request #15906 from atorralba/atorralba/java/jdk-neutrals
Java: Add more neutral JDK models
2 parents dacf7d7 + 9d44045 commit 30d906d

File tree

13 files changed

+68
-6
lines changed

13 files changed

+68
-6
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", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
13+
- ["java.beans", "PropertyEditor", "getValue", "()", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
14+
- ["java.beans", "PropertyEditor", "setAsText", "()", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
15+
- ["java.beans", "PropertyEditor", "setValue", "()", "summary", "df-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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ extensions:
8080
- ["java.io", "File", True, "getName", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]
8181
- ["java.io", "File", True, "getParentFile", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]
8282
- ["java.io", "File", True, "getPath", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]
83-
- ["java.io", "File", True, "listFiles", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]
8483
- ["java.io", "File", True, "toPath", "", "", "Argument[this]", "ReturnValue", "taint", "manual"]
8584
- ["java.io", "File", True, "toString", "", "", "Argument[this]", "ReturnValue", "taint", "manual"]
8685
- ["java.io", "File", True, "toURI", "", "", "Argument[this]", "ReturnValue", "taint", "manual"]
@@ -116,9 +115,12 @@ extensions:
116115
- ["java.io", "File", "isFile", "()", "summary", "manual"]
117116
- ["java.io", "File", "length", "()", "summary", "manual"]
118117
- ["java.io", "File", "isDirectory", "()", "summary", "manual"]
118+
- ["java.io", "File", "listFiles", "", "summary", "df-manual"]
119119
- ["java.io", "File", "mkdirs", "()", "summary", "manual"]
120120
- ["java.io", "FileInputStream", "FileInputStream", "(File)", "summary", "manual"]
121+
- ["java.io", "FileInputStream", "FileInputStream", "(String)", "summary", "df-manual"]
121122
- ["java.io", "InputStream", "close", "()", "summary", "manual"]
123+
- ["java.io", "ObjectInput", "readObject", "()", "summary", "df-manual"] # this is a deserialization sink modeled in regular CodeQL
122124
- ["java.io", "OutputStream", "flush", "()", "summary", "manual"]
123125
# The below APIs have numeric flow and are currently being stored as neutral models.
124126
# 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", "df-manual"]
70+
- ["java.net", "Socket", "connect", "(SocketAddress,int)", "summary", "df-manual"]

java/ql/lib/ext/java.nio.file.model.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ extensions:
9191
data:
9292
# summary neutrals
9393
- ["java.nio.file", "Files", "exists", "(Path,LinkOption[])", "summary", "manual"]
94+
- ["java.nio.file", "Files", "newInputStream", "(Path,LinkOption[])", "summary", "df-manual"]
9495
# sink neutrals
9596
- ["java.nio.file", "Files", "getLastModifiedTime", "", "sink", "hq-manual"]
9697
- ["java.nio.file", "Files", "getOwner", "", "sink", "hq-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", "df-manual"]
8+
- ["java.util.logging", "LogRecord", "setParameters", "", "summary", "df-manual"]

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

Lines changed: 11 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", "df-manual"]
111+
- ["java.util", "ConcurrentHashMap", False, "ConcurrentHashMap", "(Map)", "", "Argument[0].MapValue", "Argument[this].MapValue", "value", "df-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,14 @@ 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", "allOf", "(Class)", "summary", "df-manual"]
434+
- ["java.util", "EnumSet", "clone", "()", "summary", "df-manual"]
435+
- ["java.util", "EnumSet", "complementOf", "(EnumSet)", "summary", "df-manual"]
436+
- ["java.util", "EnumSet", "copyOf", "(Collection)", "summary", "df-manual"]
437+
- ["java.util", "EnumSet", "copyOf", "(EnumSet)", "summary", "df-manual"]
438+
- ["java.util", "EnumSet", "noneOf", "(Class)", "summary", "df-manual"]
439+
- ["java.util", "EnumSet", "of", "", "summary", "df-manual"]
440+
- ["java.util", "EnumSet", "range", "(Object,Object)", "summary", "df-manual"]
431441
- ["java.util", "HashMap", "containsKey", "(Object)", "summary", "manual"]
432442
- ["java.util", "HashMap", "HashMap", "(int)", "summary", "manual"]
433443
- ["java.util", "HashMap", "size", "()", "summary", "manual"]
@@ -454,6 +464,7 @@ extensions:
454464
- ["java.util", "Optional", "isEmpty", "()", "summary", "manual"]
455465
- ["java.util", "Optional", "isPresent", "()", "summary", "manual"]
456466
- ["java.util", "Random", "nextInt", "(int)", "summary", "manual"]
467+
- ["java.util", "ResourceBundle", "getBundle", "", "summary", "df-manual"]
457468
- ["java.util", "Set", "contains", "(Object)", "summary", "manual"]
458469
- ["java.util", "Set", "isEmpty", "()", "summary", "manual"]
459470
- ["java.util", "Set", "size", "()", "summary", "manual"]

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ extensions:
33
pack: codeql/java-all
44
extensible: neutralModel
55
data:
6+
# summary neutrals
7+
- ["java.util.prefs", "Preferences", "get", "(String,String)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
8+
- ["java.util.prefs", "Preferences", "getBoolean", "(String,boolean)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
9+
- ["java.util.prefs", "Preferences", "getByteArray", "(String,byte[])", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
10+
- ["java.util.prefs", "Preferences", "getDouble", "(String,double)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
11+
- ["java.util.prefs", "Preferences", "getFloat", "(String,float)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
12+
- ["java.util.prefs", "Preferences", "getInt", "(String,int)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
13+
- ["java.util.prefs", "Preferences", "getLong", "(String,int)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
14+
- ["java.util.prefs", "Preferences", "put", "(String,String)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
15+
- ["java.util.prefs", "Preferences", "putBoolean", "(String,boolean)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
16+
- ["java.util.prefs", "Preferences", "putByteArray", "(String,byte[])", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
17+
- ["java.util.prefs", "Preferences", "putDouble", "(String,double)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
18+
- ["java.util.prefs", "Preferences", "putFloat", "(String,float)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
19+
- ["java.util.prefs", "Preferences", "putInt", "(String,int)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
20+
- ["java.util.prefs", "Preferences", "putLong", "(String,int)", "summary", "df-manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
621
# sink neutrals
722
- ["java.util.prefs", "AbstractPreferences", "nodeExists", "", "sink", "hq-manual"]
823
- ["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", "df-manual"]
34+
- ["java.util.regex", "Matcher", "appendTail", "(StringBuffer)", "summary", "df-manual"]
3335
- ["java.util.regex", "Matcher", "find", "()", "summary", "manual"]
36+
- ["java.util.regex", "Matcher", "pattern", "()", "summary", "df-manual"]
37+
- ["java.util.regex", "Pattern", "compile", "(String,int)", "summary", "df-manual"]
38+
- ["java.util.regex", "Pattern", "pattern", "()", "summary", "df-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", "df-manual"]
28+
- ["javax.crypto", "Mac", "doFinal", "()", "summary", "df-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", "df-manual"]

0 commit comments

Comments
 (0)