Skip to content

Commit 470a2ca

Browse files
Add CopyTo
1 parent 61dcf3a commit 470a2ca

File tree

2 files changed

+5
-0
lines changed
  • java/ql
    • src/semmle/code/java/frameworks/guava
    • test/library-tests/frameworks/guava

2 files changed

+5
-0
lines changed

java/ql/src/semmle/code/java/frameworks/guava/IO.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ private class GuavaIoCsv extends SummaryModelCsv {
2525
"com.google.common.io;BaseEncoding;true;encode;(byte[],int,int);;Argument[-1];ReturnValue;taint",
2626
"com.google.common.io;ByteSource;true;asCharSource;(Charset);;Argument[-1];ReturnValue;taint",
2727
"com.google.common.io;ByteSource;true;concat;;;Argument[0];ReturnValue;taint",
28+
"com.google.common.io;ByteSource;true;copyTo;(OutputStream);;Argument[-1];Argument[0];taint",
2829
"com.google.common.io;ByteSource;true;openStream;();;Argument[-1];ReturnValue;taint",
2930
"com.google.common.io;ByteSource;true;openBufferedStream;();;Argument[-1];ReturnValue;taint",
3031
"com.google.common.io;ByteSource;true;read;();;Argument[-1];ReturnValue;taint",

java/ql/test/library-tests/frameworks/guava/TestIO.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.Reader;
66
import java.lang.StringBuffer;
77
import java.io.ByteArrayInputStream;
8+
import java.io.ByteArrayOutputStream;
89
import java.io.InputStream;
910
import java.io.Closeable;
1011
import java.nio.file.Path;
@@ -40,6 +41,9 @@ void test2() throws IOException {
4041
sink(ByteSource.concat(ByteSource.empty(), ByteSource.empty(), b)); // $numTaintFlow=1
4142
sink(ByteSource.concat(ImmutableList.of(ByteSource.empty(), ByteSource.empty(), b))); // $numTaintFlow=1
4243
sink(b.read(new MyByteProcessor())); // $ MISSING:numTaintFlow=1
44+
ByteArrayOutputStream out = new ByteArrayOutputStream();
45+
b.copyTo(out);
46+
sink(out.toByteArray()); // $numTaintFlow=1
4347

4448
CharSource c = CharSource.wrap(staint());
4549
sink(c.openStream()); // $numTaintFlow=1

0 commit comments

Comments
 (0)