Fix minor mistakes in old Guava models

Also add tests for the affected functions
This commit is contained in:
Chris Smowton
2021-08-31 15:26:09 +01:00
parent c8a5397085
commit 7977d9c253
4 changed files with 18 additions and 3 deletions

View File

@@ -75,7 +75,7 @@ class TestBase {
}
void test6() {
sink(Suppliers.memoize(Suppliers.memoizeWithExpiration(Suppliers.synchronizedSupplier(Suppliers.ofInstance(taint())), 3, TimeUnit.HOURS))); // $numTaintFlow=1
sink(Suppliers.memoize(Suppliers.memoizeWithExpiration(Suppliers.synchronizedSupplier(Suppliers.ofInstance(taint())), 3, TimeUnit.HOURS)).get()); // $numTaintFlow=1
}
void test7() {

View File

@@ -8,7 +8,11 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.Closeable;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.IOException;
class TestIO {
@@ -16,6 +20,7 @@ class TestIO {
String staint(){ return (String) taint(); }
byte[] btaint() { return (byte[]) taint(); }
InputStream itaint() { return (InputStream) taint(); }
ReadableByteChannel rbctaint() { return (ReadableByteChannel) taint(); }
Reader rtaint() { return new InputStreamReader(itaint()); }
Path ptaint() { return (Path) taint(); }
@@ -75,6 +80,16 @@ class TestIO {
}
void test3() throws IOException {
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteStreams.copy(itaint(), out);
sink(out); // $numTaintFlow=1
}
{
WritableByteChannel out = FileChannel.open(Paths.get("/tmp/xyz"));
ByteStreams.copy(rbctaint(), out);
sink(out); // $numTaintFlow=1
}
sink(ByteStreams.limit(itaint(), 1337)); // $numTaintFlow=1
sink(ByteStreams.newDataInput(btaint())); // $numTaintFlow=1
sink(ByteStreams.newDataInput(btaint(), 0)); // $numTaintFlow=1