Skip to content

Commit 395656a

Browse files
committed
Java: Extend the logging test with a test case for parameters.
1 parent e8595e2 commit 395656a

File tree

2 files changed

+335
-325
lines changed

2 files changed

+335
-325
lines changed

java/ql/test/library-tests/logging/Test.java

Lines changed: 163 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -6,163 +6,172 @@
66
import org.apache.logging.log4j.message.Message;
77
import org.slf4j.spi.LoggingEventBuilder;
88

9-
// Test case generated by GenerateFlowTestCase.ql
9+
// Test case originally generated by GenerateFlowTestCase.ql
10+
// Subsequently modified manually.
1011
public class Test {
1112

12-
Object source() {
13-
return null;
14-
}
13+
Object source() {
14+
return null;
15+
}
1516

16-
void sink(Object o) {}
17+
void sink(Object o) {}
1718

18-
public void test() throws Exception {
19-
20-
{
21-
// "java.util.logging;LogRecord;false;LogRecord;;;Argument[1];Argument[this];taint;manual"
22-
LogRecord out = null;
23-
String in = (String) source();
24-
out = new LogRecord(null, in);
25-
sink(out); // $ hasTaintFlow
26-
}
27-
{
28-
// "org.apache.logging.log4j;Logger;true;traceEntry;(Message);;Argument[0];ReturnValue;taint;manual"
29-
EntryMessage out = null;
30-
Message in = (Message) source();
31-
Logger instance = null;
32-
out = instance.traceEntry(in);
33-
sink(out); // $ hasTaintFlow
34-
}
35-
{
36-
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Object[]);;Argument[0..1];ReturnValue;taint;manual"
37-
EntryMessage out = null;
38-
Object[] in = (Object[]) source();
39-
Logger instance = null;
40-
out = instance.traceEntry((String) null, in);
41-
sink(out); // $ hasTaintFlow
42-
}
43-
{
44-
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Object[]);;Argument[0..1];ReturnValue;taint;manual"
45-
EntryMessage out = null;
46-
String in = (String) source();
47-
Logger instance = null;
48-
out = instance.traceEntry(in, (Object[]) null);
49-
sink(out); // $ hasTaintFlow
50-
}
51-
{
52-
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier[]);;Argument[0..1];ReturnValue;taint;manual"
53-
EntryMessage out = null;
54-
String in = (String) source();
55-
Logger instance = null;
56-
out = instance.traceEntry(in, (org.apache.logging.log4j.util.Supplier[]) null);
57-
sink(out); // $ hasTaintFlow
58-
}
59-
{
60-
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier[]);;Argument[0..1];ReturnValue;taint;manual"
61-
EntryMessage out = null;
62-
org.apache.logging.log4j.util.Supplier[] in =
63-
(org.apache.logging.log4j.util.Supplier[]) source();
64-
Logger instance = null;
65-
out = instance.traceEntry((String) null, in);
66-
sink(out); // $ hasTaintFlow
67-
}
68-
{
69-
// "org.apache.logging.log4j;Logger;true;traceEntry;(Supplier[]);;Argument[0];ReturnValue;taint;manual"
70-
EntryMessage out = null;
71-
org.apache.logging.log4j.util.Supplier[] in =
72-
(org.apache.logging.log4j.util.Supplier[]) source();
73-
Logger instance = null;
74-
out = instance.traceEntry(in);
75-
sink(out); // $ hasTaintFlow
76-
}
77-
{
78-
// "org.apache.logging.log4j;Logger;true;traceExit;(EntryMessage,Object);;Argument[1];ReturnValue;value;manual"
79-
Object out = null;
80-
Object in = (Object) source();
81-
Logger instance = null;
82-
out = instance.traceExit((EntryMessage) null, in);
83-
sink(out); // $ hasValueFlow
84-
}
85-
{
86-
// "org.apache.logging.log4j;Logger;true;traceExit;(Message,Object);;Argument[1];ReturnValue;value;manual"
87-
Object out = null;
88-
Object in = (Object) source();
89-
Logger instance = null;
90-
out = instance.traceExit((Message) null, in);
91-
sink(out); // $ hasValueFlow
92-
}
93-
{
94-
// "org.apache.logging.log4j;Logger;true;traceExit;(Object);;Argument[0];ReturnValue;value;manual"
95-
Object out = null;
96-
Object in = (Object) source();
97-
Logger instance = null;
98-
out = instance.traceExit(in);
99-
sink(out); // $ hasValueFlow
100-
}
101-
{
102-
// "org.apache.logging.log4j;Logger;true;traceExit;(String,Object);;Argument[1];ReturnValue;value;manual"
103-
Object out = null;
104-
Object in = (Object) source();
105-
Logger instance = null;
106-
out = instance.traceExit((String) null, in);
107-
sink(out); // $ hasValueFlow
108-
}
109-
{
110-
// "org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[this];ReturnValue;value;manual"
111-
LoggingEventBuilder out = null;
112-
LoggingEventBuilder in = (LoggingEventBuilder) source();
113-
out = in.addArgument((Object) null);
114-
sink(out); // $ hasValueFlow
115-
}
116-
{
117-
// "org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[this];ReturnValue;value;manual"
118-
LoggingEventBuilder out = null;
119-
LoggingEventBuilder in = (LoggingEventBuilder) source();
120-
out = in.addArgument((java.util.function.Supplier) null);
121-
sink(out); // $ hasValueFlow
122-
}
123-
{
124-
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[this];ReturnValue;value;manual"
125-
LoggingEventBuilder out = null;
126-
LoggingEventBuilder in = (LoggingEventBuilder) source();
127-
out = in.addKeyValue((String) null, (Object) null);
128-
sink(out); // $ hasValueFlow
129-
}
130-
{
131-
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[this];ReturnValue;value;manual"
132-
LoggingEventBuilder out = null;
133-
LoggingEventBuilder in = (LoggingEventBuilder) source();
134-
out = in.addKeyValue((String) null, (java.util.function.Supplier) null);
135-
sink(out); // $ hasValueFlow
136-
}
137-
{
138-
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[this];taint;manual"
139-
LoggingEventBuilder out = null;
140-
Object in = (Object) source();
141-
out.addKeyValue((String) null, in);
142-
sink(out); // $ hasTaintFlow
143-
}
144-
{
145-
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[this];taint;manual"
146-
LoggingEventBuilder out = null;
147-
java.util.function.Supplier in = (java.util.function.Supplier) source();
148-
out.addKeyValue((String) null, in);
149-
sink(out); // $ hasTaintFlow
150-
}
151-
{
152-
// "org.slf4j.spi;LoggingEventBuilder;true;addMarker;;;Argument[this];ReturnValue;value;manual"
153-
LoggingEventBuilder out = null;
154-
LoggingEventBuilder in = (LoggingEventBuilder) source();
155-
out = in.addMarker(null);
156-
sink(out); // $ hasValueFlow
157-
}
158-
{
159-
// "org.slf4j.spi;LoggingEventBuilder;true;setCause;;;Argument[this];ReturnValue;value;manual"
160-
LoggingEventBuilder out = null;
161-
LoggingEventBuilder in = (LoggingEventBuilder) source();
162-
out = in.setCause(null);
163-
sink(out); // $ hasValueFlow
164-
}
165-
166-
}
19+
public void test() throws Exception {
16720

21+
{
22+
// "java.util.logging;LogRecord;false;LogRecord;;;Argument[1];Argument[this];taint;manual"
23+
LogRecord out = null;
24+
String in = (String) source();
25+
out = new LogRecord(null, in);
26+
sink(out); // $ hasTaintFlow
27+
}
28+
{
29+
// "org.apache.logging.log4j;Logger;true;traceEntry;(Message);;Argument[0];ReturnValue;taint;manual"
30+
EntryMessage out = null;
31+
Message in = (Message) source();
32+
Logger instance = null;
33+
out = instance.traceEntry(in);
34+
sink(out); // $ hasTaintFlow
35+
}
36+
{
37+
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Object[]);;Argument[0..1];ReturnValue;taint;manual"
38+
EntryMessage out = null;
39+
Object[] in = (Object[]) source();
40+
Logger instance = null;
41+
out = instance.traceEntry((String) null, in);
42+
sink(out); // $ hasTaintFlow
43+
}
44+
{
45+
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Object[]);;Argument[0..1];ReturnValue;taint;manual"
46+
EntryMessage out = null;
47+
String in = (String) source();
48+
Logger instance = null;
49+
out = instance.traceEntry(in, (Object[]) null);
50+
sink(out); // $ hasTaintFlow
51+
}
52+
{
53+
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier[]);;Argument[0..1];ReturnValue;taint;manual"
54+
EntryMessage out = null;
55+
String in = (String) source();
56+
Logger instance = null;
57+
out = instance.traceEntry(in, (org.apache.logging.log4j.util.Supplier[]) null);
58+
sink(out); // $ hasTaintFlow
59+
}
60+
{
61+
// "org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier[]);;Argument[0..1];ReturnValue;taint;manual"
62+
EntryMessage out = null;
63+
org.apache.logging.log4j.util.Supplier[] in =
64+
(org.apache.logging.log4j.util.Supplier[]) source();
65+
Logger instance = null;
66+
out = instance.traceEntry((String) null, in);
67+
sink(out); // $ hasTaintFlow
68+
}
69+
{
70+
// "org.apache.logging.log4j;Logger;true;traceEntry;(Supplier[]);;Argument[0];ReturnValue;taint;manual"
71+
EntryMessage out = null;
72+
org.apache.logging.log4j.util.Supplier[] in =
73+
(org.apache.logging.log4j.util.Supplier[]) source();
74+
Logger instance = null;
75+
out = instance.traceEntry(in);
76+
sink(out); // $ hasTaintFlow
77+
}
78+
{
79+
// "org.apache.logging.log4j;Logger;true;traceExit;(EntryMessage,Object);;Argument[1];ReturnValue;value;manual"
80+
Object out = null;
81+
Object in = (Object) source();
82+
Logger instance = null;
83+
out = instance.traceExit((EntryMessage) null, in);
84+
sink(out); // $ hasValueFlow
85+
}
86+
{
87+
// "org.apache.logging.log4j;Logger;true;traceExit;(Message,Object);;Argument[1];ReturnValue;value;manual"
88+
Object out = null;
89+
Object in = (Object) source();
90+
Logger instance = null;
91+
out = instance.traceExit((Message) null, in);
92+
sink(out); // $ hasValueFlow
93+
}
94+
{
95+
// "org.apache.logging.log4j;Logger;true;traceExit;(Object);;Argument[0];ReturnValue;value;manual"
96+
Object out = null;
97+
Object in = (Object) source();
98+
Logger instance = null;
99+
out = instance.traceExit(in);
100+
sink(out); // $ hasValueFlow
101+
}
102+
{
103+
// "org.apache.logging.log4j;Logger;true;traceExit;(String,Object);;Argument[1];ReturnValue;value;manual"
104+
Object out = null;
105+
Object in = (Object) source();
106+
Logger instance = null;
107+
out = instance.traceExit((String) null, in);
108+
sink(out); // $ hasValueFlow
109+
}
110+
{
111+
// "org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[this];ReturnValue;value;manual"
112+
LoggingEventBuilder out = null;
113+
LoggingEventBuilder in = (LoggingEventBuilder) source();
114+
out = in.addArgument((Object) null);
115+
sink(out); // $ hasValueFlow
116+
}
117+
{
118+
// "org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[this];ReturnValue;value;manual"
119+
LoggingEventBuilder out = null;
120+
LoggingEventBuilder in = (LoggingEventBuilder) source();
121+
out = in.addArgument((java.util.function.Supplier) null);
122+
sink(out); // $ hasValueFlow
123+
}
124+
{
125+
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[this];ReturnValue;value;manual"
126+
LoggingEventBuilder out = null;
127+
LoggingEventBuilder in = (LoggingEventBuilder) source();
128+
out = in.addKeyValue((String) null, (Object) null);
129+
sink(out); // $ hasValueFlow
130+
}
131+
{
132+
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[this];ReturnValue;value;manual"
133+
LoggingEventBuilder out = null;
134+
LoggingEventBuilder in = (LoggingEventBuilder) source();
135+
out = in.addKeyValue((String) null, (java.util.function.Supplier) null);
136+
sink(out); // $ hasValueFlow
137+
}
138+
{
139+
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[this];taint;manual"
140+
LoggingEventBuilder out = null;
141+
Object in = (Object) source();
142+
out.addKeyValue((String) null, in);
143+
sink(out); // $ hasTaintFlow
144+
}
145+
{
146+
// "org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[this];taint;manual"
147+
LoggingEventBuilder out = null;
148+
java.util.function.Supplier in = (java.util.function.Supplier) source();
149+
out.addKeyValue((String) null, in);
150+
sink(out); // $ hasTaintFlow
151+
}
152+
{
153+
// "org.slf4j.spi;LoggingEventBuilder;true;addMarker;;;Argument[this];ReturnValue;value;manual"
154+
LoggingEventBuilder out = null;
155+
LoggingEventBuilder in = (LoggingEventBuilder) source();
156+
out = in.addMarker(null);
157+
sink(out); // $ hasValueFlow
158+
}
159+
{
160+
// "org.slf4j.spi;LoggingEventBuilder;true;setCause;;;Argument[this];ReturnValue;value;manual"
161+
LoggingEventBuilder out = null;
162+
LoggingEventBuilder in = (LoggingEventBuilder) source();
163+
out = in.setCause(null);
164+
sink(out); // $ hasValueFlow
165+
}
166+
{
167+
// "java.util.logging;LogRecord;true;getParameters;();;Argument[this].SyntheticField[java.util.logging.LogRecord.parameters].ArrayElement;ReturnValue.ArrayElement;value;manual
168+
// "java.util.logging;LogRecord;true;setParameters;(Object[]);Argument[0].ArrayElement;Argument[this].SyntheticField[java.util.logging.LogRecord.parameters].ArrayElement;value;manual
169+
LogRecord record = new LogRecord(null, null);
170+
Object[] parameters = new Object[1];
171+
parameters[0] = source();
172+
record.setParameters(parameters);
173+
Object[] out = record.getParameters();
174+
sink(out[0]); // $ hasValueFlow
175+
}
176+
}
168177
}

0 commit comments

Comments
 (0)