Skip to content

Commit bf22c6d

Browse files
authored
Merge pull request github#15766 from owen-mc/java/add-neutral-models
Java: add neutral models
2 parents fd82a06 + 0a8dfba commit bf22c6d

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,11 @@ extensions:
218218
- ["java.lang", "System", "currentTimeMillis", "()", "summary", "manual"]
219219
- ["java.lang", "System", "exit", "(int)", "summary", "manual"]
220220
- ["java.lang", "System", "getenv", "(String)", "summary", "manual"]
221+
- ["java.lang", "System", "getProperty", "", "summary", "manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
221222
- ["java.lang", "System", "identityHashCode", "(Object)", "summary", "manual"]
222223
- ["java.lang", "System", "lineSeparator", "()", "summary", "manual"]
223224
- ["java.lang", "System", "nanoTime", "()", "summary", "manual"]
225+
- ["java.lang", "System", "setProperty", "", "summary", "manual"] # needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
224226
- ["java.lang", "Thread", "currentThread", "()", "summary", "manual"]
225227
- ["java.lang", "Thread", "getContextClassLoader", "()", "summary", "manual"]
226228
- ["java.lang", "Thread", "interrupt", "()", "summary", "manual"]

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ extensions:
1515
- ["java.security", "KeyStoreSpi", True, "engineSetKeyEntry", "(String,Key,char[],Certificate[])", "", "Argument[2]", "credentials-password", "hq-generated"]
1616
- ["java.security", "KeyStoreSpi", True, "engineStore", "(OutputStream,char[])", "", "Argument[1]", "credentials-password", "hq-generated"]
1717
- ["java.security", "KeyStoreSpi", True, "engineSetKeyEntry", "(String,byte[],Certificate[])", "", "Argument[1]", "credentials-key", "hq-generated"]
18+
- addsTo:
19+
pack: codeql/java-all
20+
extensible: neutralModel
21+
data:
22+
- ["java.security", "MessageDigest", "digest", "()", "summary", "df-manual"]
23+
- ["java.security", "MessageDigest", "digest", "(byte[])", "summary", "df-manual"]
24+
- ["java.security", "MessageDigest", "digest", "(byte[],int,int)", "summary", "df-manual"]

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ extensions:
44
extensible: neutralModel
55
data:
66
# summary neutrals
7+
- ["java.text", "Format", "format", "", "summary", "manual"] # similar issue as `Object.toString`; depends on the object being passed as the argument
8+
- ["java.text", "MessageFormat", "format", "", "summary", "manual"] # similar issue as `Object.toString`; depends on the object being passed as the argument
9+
710
# The below APIs have numeric flow and are currently being stored as neutral models.
811
# These may be changed to summary models with kinds "value-numeric" and "taint-numeric" (or similar) in the future.
912
- ["java.text", "DateFormat", "format", "(Date)", "summary", "manual"] # taint-numeric

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ extensions:
417417
- ["java.util", "ArrayList", "ArrayList", "(int)", "summary", "manual"]
418418
- ["java.util", "ArrayList", "isEmpty", "()", "summary", "manual"]
419419
- ["java.util", "ArrayList", "size", "()", "summary", "manual"]
420+
- ["java.util", "Arrays", "deepToString", "(Object[])", "summary", "df-manual"]
420421
- ["java.util", "Arrays", "toString", "(Object[])", "summary", "manual"]
421422
- ["java.util", "Calendar", "getInstance", "()", "summary", "manual"]
422423
- ["java.util", "Collection", "contains", "(Object)", "summary", "manual"]
@@ -456,6 +457,8 @@ extensions:
456457
- ["java.util", "Set", "contains", "(Object)", "summary", "manual"]
457458
- ["java.util", "Set", "isEmpty", "()", "summary", "manual"]
458459
- ["java.util", "Set", "size", "()", "summary", "manual"]
460+
- ["java.util", "TreeMap", "TreeMap", "(Comparator)", "summary", "df-manual"]
461+
- ["java.util", "TreeSet", "TreeSet", "(Comparator)", "summary", "df-manual"]
459462
- ["java.util", "UUID", "equals", "(Object)", "summary", "manual"]
460463
- ["java.util", "UUID", "fromString", "(String)", "summary", "manual"]
461464
- ["java.util", "UUID", "randomUUID", "()", "summary", "manual"]

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ extensions:
9292
pack: codeql/java-all
9393
extensible: neutralModel
9494
data:
95+
- ["java.util.stream", "Collectors", "joining", "", "summary", "manual"] # cannot be modeled completely without a model for `java.util.stream.Stream#collect(Collector)` as well
9596
- ["java.util.stream", "Collectors", "toList", "()", "summary", "manual"]
97+
- ["java.util.stream", "Collectors", "toMap", "", "summary", "manual"] # specialized collectors flow
9698
- ["java.util.stream", "Collectors", "toSet", "()", "summary", "manual"]
99+
- ["java.util.stream", "Stream", "collect", "(Collector)", "summary", "manual"] # handled separately on a case-by-case basis as it is too complex for MaD
97100
- ["java.util.stream", "Stream", "count", "()", "summary", "manual"]
98101

99102
# The below APIs have numeric flow and are currently being stored as neutral models.
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
| java.lang.Runnable#run() | no manual model |
2-
| java.lang.System#getProperty(String) | no manual model |
3-
| java.lang.System#setProperty(String,String) | no manual model |
4-
| java.text.Format#format(Object) | no manual model |
5-
| java.text.MessageFormat#format(String,Object[]) | no manual model |
62
| java.util.Comparator#comparing(Function) | no manual model |
73
| java.util.function.BiConsumer#accept(Object,Object) | no manual model |
84
| java.util.function.BiFunction#apply(Object,Object) | no manual model |
95
| java.util.function.Consumer#accept(Object) | no manual model |
106
| java.util.function.Function#apply(Object) | no manual model |
117
| java.util.function.Supplier#get() | no manual model |
12-
| java.util.stream.Collectors#joining(CharSequence) | no manual model |
13-
| java.util.stream.Collectors#toMap(Function,Function) | no manual model |
14-
| java.util.stream.Stream#collect(Collector) | no manual model |

0 commit comments

Comments
 (0)