mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Java: Inline expectation should have space after $
This was a regex-find-replace from `// \$(?! )` (using a negative lookahead) to `// $ `.
This commit is contained in:
@@ -33,50 +33,50 @@ public class Test {
|
||||
// top 100 JDK APIs tests
|
||||
{
|
||||
Exception e1 = new RuntimeException((String)source());
|
||||
sink((String)e1.getMessage()); // $hasValueFlow
|
||||
sink((String)e1.getMessage()); // $ hasValueFlow
|
||||
|
||||
Exception e2 = new RuntimeException((Throwable)source());
|
||||
sink((Throwable)e2.getCause()); // $hasValueFlow
|
||||
sink((Throwable)e2.getCause()); // $ hasValueFlow
|
||||
|
||||
Exception e3 = new IllegalArgumentException((String)source());
|
||||
sink((String)e3.getMessage()); // $hasValueFlow
|
||||
sink((String)e3.getMessage()); // $ hasValueFlow
|
||||
|
||||
Exception e4 = new IllegalStateException((String)source());
|
||||
sink((String)e4.getMessage()); // $hasValueFlow
|
||||
sink((String)e4.getMessage()); // $ hasValueFlow
|
||||
|
||||
Exception e5 = new UnsupportedOperationException((String)source());
|
||||
sink((String)e5.getMessage()); // $hasValueFlow
|
||||
sink((String)e5.getMessage()); // $ hasValueFlow
|
||||
|
||||
Throwable t = new Throwable((Throwable)source());
|
||||
sink((Throwable)t.getCause()); // $hasValueFlow
|
||||
sink((Throwable)t.getCause()); // $ hasValueFlow
|
||||
|
||||
String s2 = (String)source();
|
||||
int i = 0;
|
||||
sink(s2.charAt(i)); // $hasTaintFlow
|
||||
sink(s2.charAt(i)); // $ hasTaintFlow
|
||||
|
||||
ResultSet rs = (ResultSet)source();
|
||||
sink(rs.getString("")); // $hasTaintFlow
|
||||
sink(rs.getString("")); // $ hasTaintFlow
|
||||
}
|
||||
|
||||
// top 200 JDK APIs tests
|
||||
{
|
||||
// java.io
|
||||
Exception e1 = new IOException((String)source());
|
||||
sink((String)e1.getMessage()); // $hasValueFlow
|
||||
sink((String)e1.getMessage()); // $ hasValueFlow
|
||||
|
||||
File f = (File)source();
|
||||
sink(f.getName()); // $hasTaintFlow
|
||||
sink(f.getName()); // $ hasTaintFlow
|
||||
|
||||
// java.lang
|
||||
Exception e2 = new Exception((String)source());
|
||||
sink((String)e2.getMessage()); // $hasValueFlow
|
||||
sink((String)e2.getMessage()); // $ hasValueFlow
|
||||
|
||||
Exception e3 = new IndexOutOfBoundsException((String)source());
|
||||
sink((String)e3.getMessage()); // $hasValueFlow
|
||||
sink((String)e3.getMessage()); // $ hasValueFlow
|
||||
|
||||
Exception e4 = new RuntimeException((String)source(), (Throwable)source());
|
||||
sink((String)e4.getMessage()); // $hasValueFlow
|
||||
sink((Throwable)e4.getCause()); // $hasValueFlow
|
||||
sink((String)e4.getMessage()); // $ hasValueFlow
|
||||
sink((Throwable)e4.getCause()); // $ hasValueFlow
|
||||
|
||||
// java.sql
|
||||
Connection con = DriverManager.getConnection("");
|
||||
@@ -86,14 +86,14 @@ public class Test {
|
||||
|
||||
// java.util.concurrent.atomic
|
||||
AtomicReference ar = new AtomicReference(source());
|
||||
sink(ar.get()); // $hasValueFlow
|
||||
sink(ar.get()); // $ hasValueFlow
|
||||
|
||||
// java.util
|
||||
StringJoiner sj1 = new StringJoiner(",");
|
||||
sink(sj1.add((CharSequence)source())); // $hasTaintFlow
|
||||
sink(sj1.add((CharSequence)source())); // $ hasTaintFlow
|
||||
|
||||
StringJoiner sj2 = (StringJoiner)source();
|
||||
sink(sj2.add("test")); // $hasValueFlow
|
||||
sink(sj2.add("test")); // $ hasValueFlow
|
||||
}
|
||||
|
||||
// top 300-500 JDK APIs tests
|
||||
@@ -101,62 +101,62 @@ public class Test {
|
||||
|
||||
// java.awt
|
||||
Container container = new Container();
|
||||
sink(container.add((Component)source())); // $hasValueFlow
|
||||
sink(container.add((Component)source())); // $ hasValueFlow
|
||||
|
||||
// java.io
|
||||
File f1 = (File)source();
|
||||
sink(f1.getParentFile()); // $hasTaintFlow
|
||||
sink(f1.getParentFile()); // $ hasTaintFlow
|
||||
|
||||
File f2 = (File)source();
|
||||
sink(f2.getPath()); // $hasTaintFlow
|
||||
sink(f2.getPath()); // $ hasTaintFlow
|
||||
|
||||
StringWriter sw = (StringWriter)source();
|
||||
sink(sw.toString()); // $hasTaintFlow
|
||||
sink(sw.toString()); // $ hasTaintFlow
|
||||
|
||||
Exception e = new UncheckedIOException((IOException)source());
|
||||
sink((Throwable)e.getCause()); // $hasValueFlow
|
||||
sink((Throwable)e.getCause()); // $ hasValueFlow
|
||||
|
||||
// java.net
|
||||
URL url = (URL)source();
|
||||
sink(url.toURI()); // $hasTaintFlow
|
||||
sink(url.toURI()); // $ hasTaintFlow
|
||||
|
||||
// java.nio.file
|
||||
Path p = (Path)source();
|
||||
sink(p.getFileName()); // $hasTaintFlow
|
||||
sink(p.getFileName()); // $ hasTaintFlow
|
||||
|
||||
// java.util.concurrent.atomic
|
||||
AtomicReference ar = new AtomicReference();
|
||||
ar.set(source());
|
||||
sink(ar.get()); // $hasValueFlow
|
||||
sink(ar.get()); // $ hasValueFlow
|
||||
|
||||
// java.util.concurrent
|
||||
// `ThreadPoolExecutor` implements the `java.util.concurrent.ExecutorService` interface
|
||||
ThreadPoolExecutor tpe = new ThreadPoolExecutor(0, 0, 0, null, null);
|
||||
sink(tpe.submit((Runnable)source())); // $hasTaintFlow
|
||||
sink(tpe.submit((Runnable)source())); // $ hasTaintFlow
|
||||
|
||||
CompletionStage cs = (CompletionStage)source();
|
||||
sink(cs.toCompletableFuture()); // $hasTaintFlow
|
||||
sink(cs.toCompletableFuture()); // $ hasTaintFlow
|
||||
|
||||
CompletableFuture cf1 = new CompletableFuture();
|
||||
cf1.complete(source());
|
||||
sink(cf1.get()); // $hasValueFlow
|
||||
sink(cf1.join()); // $hasValueFlow
|
||||
sink(cf1.get()); // $ hasValueFlow
|
||||
sink(cf1.join()); // $ hasValueFlow
|
||||
|
||||
CompletableFuture cf2 = CompletableFuture.completedFuture(source());
|
||||
sink(cf2.get()); // $hasValueFlow
|
||||
sink(cf2.join()); // $hasValueFlow
|
||||
sink(cf2.get()); // $ hasValueFlow
|
||||
sink(cf2.join()); // $ hasValueFlow
|
||||
|
||||
// java.util.logging
|
||||
Logger logger = Logger.getLogger((String)source());
|
||||
sink(logger.getName()); // $hasValueFlow
|
||||
sink(logger.getName()); // $ hasValueFlow
|
||||
|
||||
// java.util.regex
|
||||
Pattern pattern = Pattern.compile((String)source());
|
||||
sink(pattern); // $hasTaintFlow
|
||||
sink(pattern); // $ hasTaintFlow
|
||||
|
||||
// java.util
|
||||
EventObject eventObj = new EventObject(source());
|
||||
sink(eventObj.getSource()); // $hasValueFlow
|
||||
sink(eventObj.getSource()); // $ hasValueFlow
|
||||
|
||||
// "java.util;ResourceBundle;true;getString;(String);;Argument[-1].MapValue;ReturnValue;value;manual"
|
||||
String out = null;
|
||||
@@ -166,33 +166,33 @@ public class Test {
|
||||
|
||||
// java.lang
|
||||
AssertionError assertErr = new AssertionError(source());
|
||||
sink((String)assertErr.getMessage()); // $hasValueFlow
|
||||
sink((String)assertErr.getMessage()); // $ hasValueFlow
|
||||
|
||||
sink(Test.class.cast(source())); // $hasValueFlow
|
||||
sink(Test.class.cast(source())); // $ hasValueFlow
|
||||
|
||||
Exception excep1 = new Exception((String)source(), (Throwable)source());
|
||||
sink((String)excep1.getMessage()); // $hasValueFlow
|
||||
sink((Throwable)excep1.getCause()); // $hasValueFlow
|
||||
sink((String)excep1.getMessage()); // $ hasValueFlow
|
||||
sink((Throwable)excep1.getCause()); // $ hasValueFlow
|
||||
|
||||
Exception excep2 = new NullPointerException((String)source());
|
||||
sink((String)excep2.getMessage()); // $hasValueFlow
|
||||
sink((String)excep2.getMessage()); // $ hasValueFlow
|
||||
|
||||
StringBuilder sb = (StringBuilder)source();
|
||||
sink(sb.delete(0, 1)); // $hasValueFlow
|
||||
sink(sb.delete(0, 1)); // $ hasValueFlow
|
||||
|
||||
Thread thread1 = new Thread((Runnable)source());
|
||||
sink(thread1); // $hasTaintFlow
|
||||
sink(thread1); // $ hasTaintFlow
|
||||
|
||||
Thread thread2 = new Thread((String)source());
|
||||
sink(thread2.getName()); // $hasValueFlow
|
||||
sink(thread2.getName()); // $ hasValueFlow
|
||||
|
||||
ThreadLocal threadloc = new ThreadLocal();
|
||||
threadloc.set(source());
|
||||
sink(threadloc.get()); // $hasValueFlow
|
||||
sink(threadloc.get()); // $ hasValueFlow
|
||||
|
||||
Throwable th = new Throwable((String)source());
|
||||
sink((String)th.getLocalizedMessage()); // $hasValueFlow
|
||||
sink(th.toString()); // $hasTaintFlow
|
||||
sink((String)th.getLocalizedMessage()); // $ hasValueFlow
|
||||
sink(th.toString()); // $ hasTaintFlow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user