From 1f95fa10fb4a7eb9d914a3fd890acba849bf2b3d Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Mon, 30 Sep 2024 15:08:56 +0200 Subject: [PATCH 1/4] Java: Fix comment re. neutrals and WithoutElement. The remove methods should not have been in this section, as they're plain neutrals. --- java/ql/lib/ext/java.util.model.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/java/ql/lib/ext/java.util.model.yml b/java/ql/lib/ext/java.util.model.yml index cb49a50fbdfc..0ce06d9ea0c0 100644 --- a/java/ql/lib/ext/java.util.model.yml +++ b/java/ql/lib/ext/java.util.model.yml @@ -430,6 +430,7 @@ extensions: - ["java.util", "Collection", "contains", "(Object)", "summary", "manual"] - ["java.util", "Collection", "containsAll", "(Collection)", "summary", "manual"] - ["java.util", "Collection", "isEmpty", "()", "summary", "manual"] + - ["java.util", "Collection", "removeIf", "(Predicate)", "summary", "manual"] - ["java.util", "Collection", "size", "()", "summary", "manual"] - ["java.util", "Collections", "emptyList", "()", "summary", "manual"] - ["java.util", "Collections", "emptyMap", "()", "summary", "manual"] @@ -451,12 +452,14 @@ extensions: - ["java.util", "HashMap", "size", "()", "summary", "manual"] - ["java.util", "HashSet", "HashSet", "(int)", "summary", "manual"] - ["java.util", "Iterator", "hasNext", "()", "summary", "manual"] + - ["java.util", "Iterator", "remove", "()", "summary", "manual"] - ["java.util", "List", "contains", "(Object)", "summary", "manual"] - ["java.util", "List", "equals", "(Object)", "summary", "manual"] - ["java.util", "List", "hashCode", "()", "summary", "manual"] - ["java.util", "List", "indexOf", "(Object)", "summary", "manual"] - ["java.util", "List", "isEmpty", "()", "summary", "manual"] - ["java.util", "List", "of", "()", "summary", "manual"] + - ["java.util", "List", "remove", "(Object)", "summary", "manual"] - ["java.util", "List", "sort", "(Comparator)", "summary", "manual"] - ["java.util", "List", "size", "()", "summary", "manual"] - ["java.util", "Locale$Builder", "addUnicodeLocaleAttribute", "(String)", "summary", "df-manual"] @@ -535,6 +538,8 @@ extensions: - ["java.util", "Scanner", "locale", "()", "summary", "df-manual"] - ["java.util", "Set", "contains", "(Object)", "summary", "manual"] - ["java.util", "Set", "isEmpty", "()", "summary", "manual"] + - ["java.util", "Set", "remove", "(Object)", "summary", "manual"] + - ["java.util", "Set", "removeAll", "(Collection)", "summary", "manual"] - ["java.util", "Set", "size", "()", "summary", "manual"] - ["java.util", "TreeMap", "TreeMap", "(Comparator)", "summary", "df-manual"] - ["java.util", "TreeSet", "TreeSet", "(Comparator)", "summary", "df-manual"] @@ -545,14 +550,8 @@ extensions: - ["java.util", "TimeZone", "getTimeZone", "(String)", "summary", "manual"] - ["java.util", "Vector", "size", "()", "summary", "manual"] - # The below APIs are currently being stored as neutral models since `WithoutElement` has not yet been implemented for Java. - # When `WithoutElement` is implemented, these should be changed to summary models of the form `Argument[this].WithoutElement -> Argument[this]`. - - ["java.util", "Collection", "removeIf", "(Predicate)", "summary", "manual"] - - ["java.util", "Iterator", "remove", "()", "summary", "manual"] - - ["java.util", "List", "remove", "(Object)", "summary", "manual"] + # The below API is currently being stored as neutral models since `WithoutElement` does not yet have a counterpart for MapValue/MapKey. - ["java.util", "Map", "clear", "()", "summary", "manual"] - - ["java.util", "Set", "remove", "(Object)", "summary", "manual"] - - ["java.util", "Set", "removeAll", "(Collection)", "summary", "manual"] # The below APIs have numeric flow and are currently being stored as neutral models. # These may be changed to summary models with kinds "value-numeric" and "taint-numeric" (or similar) in the future. From 38818f3cd2e222a377bbfc64415656136e74673a Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Mon, 30 Sep 2024 15:10:46 +0200 Subject: [PATCH 2/4] Java: Adjust Set.clear model to apply to overrides. --- java/ql/lib/ext/java.util.model.yml | 2 +- .../library-tests/dataflow/collections/containerflow.expected | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/ql/lib/ext/java.util.model.yml b/java/ql/lib/ext/java.util.model.yml index 0ce06d9ea0c0..f7e97e9e6689 100644 --- a/java/ql/lib/ext/java.util.model.yml +++ b/java/ql/lib/ext/java.util.model.yml @@ -362,7 +362,7 @@ extensions: - ["java.util", "SequencedMap", True, "sequencedValues", "", "", "Argument[this].MapValue", "ReturnValue.Element", "value", "manual"] - ["java.util", "SequencedSet", True, "reversed", "", "", "Argument[this].Element", "ReturnValue.Element", "value", "manual"] - ["java.util", "Set", False, "copyOf", "(Collection)", "", "Argument[0].Element", "ReturnValue.Element", "value", "manual"] - - ["java.util", "Set", False, "clear", "()", "", "Argument[this].WithoutElement", "Argument[this]", "value", "manual"] + - ["java.util", "Set", True, "clear", "()", "", "Argument[this].WithoutElement", "Argument[this]", "value", "manual"] - ["java.util", "Set", False, "of", "(Object)", "", "Argument[0]", "ReturnValue.Element", "value", "manual"] - ["java.util", "Set", False, "of", "(Object,Object)", "", "Argument[0..1]", "ReturnValue.Element", "value", "manual"] - ["java.util", "Set", False, "of", "(Object,Object,Object)", "", "Argument[0..2]", "ReturnValue.Element", "value", "manual"] diff --git a/java/ql/test/library-tests/dataflow/collections/containerflow.expected b/java/ql/test/library-tests/dataflow/collections/containerflow.expected index 384f23c95b6e..baa0442fe88a 100644 --- a/java/ql/test/library-tests/dataflow/collections/containerflow.expected +++ b/java/ql/test/library-tests/dataflow/collections/containerflow.expected @@ -297,7 +297,7 @@ models | 296 | Summary: java.util; SequencedMap; true; sequencedValues; ; ; Argument[this].MapValue; ReturnValue.Element; value; manual | | 297 | Summary: java.util; SequencedSet; true; reversed; ; ; Argument[this].Element; ReturnValue.Element; value; manual | | 298 | Summary: java.util; Set; false; copyOf; (Collection); ; Argument[0].Element; ReturnValue.Element; value; manual | -| 299 | Summary: java.util; Set; false; clear; (); ; Argument[this].WithoutElement; Argument[this]; value; manual | +| 299 | Summary: java.util; Set; true; clear; (); ; Argument[this].WithoutElement; Argument[this]; value; manual | | 300 | Summary: java.util; Set; false; of; (Object); ; Argument[0]; ReturnValue.Element; value; manual | | 301 | Summary: java.util; Set; false; of; (Object,Object); ; Argument[0..1]; ReturnValue.Element; value; manual | | 302 | Summary: java.util; Set; false; of; (Object,Object,Object); ; Argument[0..2]; ReturnValue.Element; value; manual | From fcb677e84ddf29fd31676a393f08433a316e387e Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Mon, 30 Sep 2024 15:11:43 +0200 Subject: [PATCH 3/4] Java: Add a neutral for Collection.remove. --- java/ql/lib/ext/java.util.model.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/java/ql/lib/ext/java.util.model.yml b/java/ql/lib/ext/java.util.model.yml index f7e97e9e6689..bfae915d36ad 100644 --- a/java/ql/lib/ext/java.util.model.yml +++ b/java/ql/lib/ext/java.util.model.yml @@ -430,6 +430,7 @@ extensions: - ["java.util", "Collection", "contains", "(Object)", "summary", "manual"] - ["java.util", "Collection", "containsAll", "(Collection)", "summary", "manual"] - ["java.util", "Collection", "isEmpty", "()", "summary", "manual"] + - ["java.util", "Collection", "remove", "(Object)", "summary", "manual"] - ["java.util", "Collection", "removeIf", "(Predicate)", "summary", "manual"] - ["java.util", "Collection", "size", "()", "summary", "manual"] - ["java.util", "Collections", "emptyList", "()", "summary", "manual"] From 222ae6ad2dd2d471ff49bbb167417d527b3c1aec Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Mon, 30 Sep 2024 15:51:48 +0200 Subject: [PATCH 4/4] Java: Add a neutral for Comparable.compareTo --- java/ql/lib/ext/java.lang.model.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/java/ql/lib/ext/java.lang.model.yml b/java/ql/lib/ext/java.lang.model.yml index 6f00368c1ec6..fa020831b78b 100644 --- a/java/ql/lib/ext/java.lang.model.yml +++ b/java/ql/lib/ext/java.lang.model.yml @@ -200,6 +200,7 @@ extensions: - ["java.lang", "ClassLoader", "loadClass", "(String,boolean)", "summary", "df-manual"] - ["java.lang", "ClassLoader", "setClassAssertionStatus", "(String,boolean)", "summary", "df-manual"] - ["java.lang", "ClassLoader", "setPackageAssertionStatus", "(String,boolean)", "summary", "df-manual"] + - ["java.lang", "Comparable", "compareTo", "", "summary", "manual"] - ["java.lang", "Enum", "Enum", "(String,int)", "summary", "manual"] - ["java.lang", "Enum", "equals", "(Object)", "summary", "manual"] - ["java.lang", "Enum", "hashCode", "()", "summary", "manual"]