Skip to content

Commit e0c0c97

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: remove Format and MessageFormat
1 parent 702ca19 commit e0c0c97

File tree

4 files changed

+4
-20
lines changed

4 files changed

+4
-20
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
extensions:
2-
- addsTo:
3-
pack: codeql/java-all
4-
extensible: summaryModel
5-
data:
6-
- ["java.text", "Format", True, "format", "(Object)", "", "Argument[0]", "ReturnValue", "taint", "manual"]
7-
- ["java.text", "MessageFormat", False, "format", "(String,Object[])", "", "Argument[0]", "ReturnValue", "taint", "manual"]
8-
- ["java.text", "MessageFormat", False, "format", "(String,Object[])", "", "Argument[1].ArrayElement", "ReturnValue", "taint", "manual"]
9-
102
- addsTo:
113
pack: codeql/java-all
124
extensible: neutralModel

java/ql/test/ext/TestModels/Test.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import java.sql.DriverManager;
88
import java.sql.PreparedStatement;
99
import java.sql.ResultSet;
10-
import java.text.Format;
11-
import java.text.MessageFormat;
1210
import java.util.EventObject;
1311
import java.util.Locale;
1412
import java.util.ResourceBundle;
@@ -157,16 +155,6 @@ public void test() throws Exception {
157155
EventObject eventObj = new EventObject(source());
158156
sink(eventObj.getSource()); // $hasValueFlow
159157

160-
// java.text
161-
Format mf1 = new MessageFormat("test");
162-
sink(mf1.format(source())); // $hasTaintFlow
163-
164-
String mf2 = MessageFormat.format((String)source(), null);
165-
sink(mf2); // $hasTaintFlow
166-
167-
String mf3 = MessageFormat.format("test", source());
168-
sink(mf3); // $hasTaintFlow
169-
170158
// java.lang
171159
AssertionError assertErr = new AssertionError(source());
172160
sink((String)assertErr.getMessage()); // $hasValueFlow

java/ql/test/ext/TopJdkApis/TopJdkApis.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ class TopJdkApi extends SummarizedCallableBase {
310310
* `java.lang.System#getProperty(String)`: needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
311311
* `java.lang.System#setProperty(String,String)`: needs to be modeled by regular CodeQL matching the get and set keys to reduce FPs
312312
* `java.lang.Throwable#printStackTrace()`: should probably not be a general step, but there might be specialised queries that care
313+
* `java.text.Format#format(Object)`: similar issue as `Object.toString`; depends on the object being passed as the argument
314+
* `java.text.MessageFormat#format(String,Object[])`: similar issue as `Object.toString`; depends on the object being passed as the argument
313315
* `java.util.Comparator#comparing(Function)`: lambda flow
314316
* `java.util.function.BiConsumer#accept(Object,Object)`: specialized lambda flow
315317
* `java.util.function.BiFunction#apply(Object,Object)`: specialized lambda flow

java/ql/test/ext/TopJdkApis/TopJdkApisTest.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
| java.lang.System#getProperty(String) | no manual model |
33
| java.lang.System#setProperty(String,String) | no manual model |
44
| java.lang.Throwable#printStackTrace() | no manual model |
5+
| java.text.Format#format(Object) | no manual model |
6+
| java.text.MessageFormat#format(String,Object[]) | no manual model |
57
| java.util.Comparator#comparing(Function) | no manual model |
68
| java.util.function.BiConsumer#accept(Object,Object) | no manual model |
79
| java.util.function.BiFunction#apply(Object,Object) | no manual model |

0 commit comments

Comments
 (0)