mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Java: Extend the logging test with a test case for parameters.
This commit is contained in:
@@ -6,163 +6,172 @@ import org.apache.logging.log4j.message.EntryMessage;
|
||||
import org.apache.logging.log4j.message.Message;
|
||||
import org.slf4j.spi.LoggingEventBuilder;
|
||||
|
||||
// Test case generated by GenerateFlowTestCase.ql
|
||||
// Test case originally generated by GenerateFlowTestCase.ql
|
||||
// Subsequently modified manually.
|
||||
public class Test {
|
||||
|
||||
Object source() {
|
||||
return null;
|
||||
}
|
||||
Object source() {
|
||||
return null;
|
||||
}
|
||||
|
||||
void sink(Object o) {}
|
||||
void sink(Object o) {}
|
||||
|
||||
public void test() throws Exception {
|
||||
|
||||
{
|
||||
// "java.util.logging;LogRecord;false;LogRecord;;;Argument[1];Argument[this];taint;manual"
|
||||
LogRecord out = null;
|
||||
String in = (String) source();
|
||||
out = new LogRecord(null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(Message);;Argument[0];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
Message in = (Message) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Object[]);;Argument[0..1];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
Object[] in = (Object[]) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry((String) null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Object[]);;Argument[0..1];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
String in = (String) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry(in, (Object[]) null);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier[]);;Argument[0..1];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
String in = (String) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry(in, (org.apache.logging.log4j.util.Supplier[]) null);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier[]);;Argument[0..1];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
org.apache.logging.log4j.util.Supplier[] in =
|
||||
(org.apache.logging.log4j.util.Supplier[]) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry((String) null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(Supplier[]);;Argument[0];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
org.apache.logging.log4j.util.Supplier[] in =
|
||||
(org.apache.logging.log4j.util.Supplier[]) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceExit;(EntryMessage,Object);;Argument[1];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Object in = (Object) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceExit((EntryMessage) null, in);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceExit;(Message,Object);;Argument[1];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Object in = (Object) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceExit((Message) null, in);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceExit;(Object);;Argument[0];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Object in = (Object) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceExit(in);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceExit;(String,Object);;Argument[1];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Object in = (Object) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceExit((String) null, in);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addArgument((Object) null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addArgument((java.util.function.Supplier) null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addKeyValue((String) null, (Object) null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addKeyValue((String) null, (java.util.function.Supplier) null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[this];taint;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
Object in = (Object) source();
|
||||
out.addKeyValue((String) null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[this];taint;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
java.util.function.Supplier in = (java.util.function.Supplier) source();
|
||||
out.addKeyValue((String) null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addMarker;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addMarker(null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;setCause;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.setCause(null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
|
||||
}
|
||||
public void test() throws Exception {
|
||||
|
||||
{
|
||||
// "java.util.logging;LogRecord;false;LogRecord;;;Argument[1];Argument[this];taint;manual"
|
||||
LogRecord out = null;
|
||||
String in = (String) source();
|
||||
out = new LogRecord(null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(Message);;Argument[0];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
Message in = (Message) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Object[]);;Argument[0..1];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
Object[] in = (Object[]) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry((String) null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Object[]);;Argument[0..1];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
String in = (String) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry(in, (Object[]) null);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier[]);;Argument[0..1];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
String in = (String) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry(in, (org.apache.logging.log4j.util.Supplier[]) null);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier[]);;Argument[0..1];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
org.apache.logging.log4j.util.Supplier[] in =
|
||||
(org.apache.logging.log4j.util.Supplier[]) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry((String) null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceEntry;(Supplier[]);;Argument[0];ReturnValue;taint;manual"
|
||||
EntryMessage out = null;
|
||||
org.apache.logging.log4j.util.Supplier[] in =
|
||||
(org.apache.logging.log4j.util.Supplier[]) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceEntry(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceExit;(EntryMessage,Object);;Argument[1];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Object in = (Object) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceExit((EntryMessage) null, in);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceExit;(Message,Object);;Argument[1];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Object in = (Object) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceExit((Message) null, in);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceExit;(Object);;Argument[0];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Object in = (Object) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceExit(in);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.apache.logging.log4j;Logger;true;traceExit;(String,Object);;Argument[1];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Object in = (Object) source();
|
||||
Logger instance = null;
|
||||
out = instance.traceExit((String) null, in);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addArgument((Object) null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addArgument((java.util.function.Supplier) null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addKeyValue((String) null, (Object) null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addKeyValue((String) null, (java.util.function.Supplier) null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[this];taint;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
Object in = (Object) source();
|
||||
out.addKeyValue((String) null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[this];taint;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
java.util.function.Supplier in = (java.util.function.Supplier) source();
|
||||
out.addKeyValue((String) null, in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;addMarker;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.addMarker(null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "org.slf4j.spi;LoggingEventBuilder;true;setCause;;;Argument[this];ReturnValue;value;manual"
|
||||
LoggingEventBuilder out = null;
|
||||
LoggingEventBuilder in = (LoggingEventBuilder) source();
|
||||
out = in.setCause(null);
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util.logging;LogRecord;true;getParameters;();;Argument[this].SyntheticField[java.util.logging.LogRecord.parameters].ArrayElement;ReturnValue.ArrayElement;value;manual
|
||||
// "java.util.logging;LogRecord;true;setParameters;(Object[]);Argument[0].ArrayElement;Argument[this].SyntheticField[java.util.logging.LogRecord.parameters].ArrayElement;value;manual
|
||||
LogRecord record = new LogRecord(null, null);
|
||||
Object[] parameters = new Object[1];
|
||||
parameters[0] = source();
|
||||
record.setParameters(parameters);
|
||||
Object[] out = record.getParameters();
|
||||
sink(out[0]); // $ hasValueFlow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user