mirror of
https://github.com/github/codeql.git
synced 2026-02-12 05:01:06 +01:00
55 lines
1.6 KiB
Java
55 lines
1.6 KiB
Java
package com.mycompany.app;
|
|
|
|
import org.apache.commons.fileupload.util.Streams;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
// Test case generated by GenerateFlowTestCase.ql
|
|
public class Test {
|
|
|
|
Object source() {
|
|
return null;
|
|
}
|
|
|
|
void sink(Object o) {
|
|
}
|
|
|
|
public void test() throws Exception {
|
|
|
|
{
|
|
InputStream in = (InputStream)source();
|
|
OutputStream os = new ByteArrayOutputStream(1024);
|
|
|
|
InputStream in2 = (InputStream)source();
|
|
OutputStream os2 = new ByteArrayOutputStream(1024);
|
|
|
|
byte[] myArray = new byte[1024];
|
|
|
|
// "org.apache.commons.fileupload.util;Streams;true;copy;(InputStream,OutputStream,boolean,byte[]);;Argument[0];Argument[1];taint;manual"
|
|
long status = Streams.copy(in, os, true, myArray);
|
|
sink(os); // $ hasTaintFlow
|
|
// "org.apache.commons.fileupload.util;Streams;true;copy;(InputStream,OutputStream,boolean);;Argument[0];Argument[1];taint;manual"
|
|
long status2 = Streams.copy(in2, os2, true);
|
|
sink(os2); // $ hasTaintFlow
|
|
}
|
|
|
|
}
|
|
public void test2() throws Exception {
|
|
|
|
{
|
|
|
|
InputStream in = (InputStream)source();
|
|
// "org.apache.commons.fileupload.util;Streams;true;asString;(InputStream,String);;Argument[0];ReturnValue;taint;manual"
|
|
String result = Streams.asString(in);
|
|
sink(result); // $ hasTaintFlow
|
|
|
|
InputStream in1 = (InputStream)source();
|
|
// "org.apache.commons.fileupload.util;Streams;true;asString;(InputStream,String);;Argument[0];ReturnValue;taint;manual"
|
|
String result1 = Streams.asString(in1, "test");
|
|
sink(result1); // $ hasTaintFlow
|
|
}
|
|
|
|
}
|
|
|
|
} |