Skip to content

Commit 7d88f80

Browse files
committed
Add tests for summaries
1 parent ebd6529 commit 7d88f80

File tree

17 files changed

+1512
-9
lines changed

17 files changed

+1512
-9
lines changed

java/ql/lib/semmle/code/java/frameworks/Logging.qll

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ private class LoggingSummaryModels extends SummaryModelCsv {
77
override predicate row(string row) {
88
row =
99
[
10-
"org.apache.logging.log4j;Logger;true;entry;(Object[]);;Argument[0];ReturnValue;taint",
1110
"org.apache.logging.log4j;Logger;true;traceEntry;(Message);;Argument[0];ReturnValue;taint",
1211
"org.apache.logging.log4j;Logger;true;traceEntry;(String,Object[]);;Argument[0..1];ReturnValue;taint",
13-
"org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier);;Argument[0..1];ReturnValue;taint",
14-
"org.apache.logging.log4j;Logger;true;traceEntry;(Supplier);;Argument[0];ReturnValue;taint",
12+
"org.apache.logging.log4j;Logger;true;traceEntry;(String,Supplier[]);;Argument[0..1];ReturnValue;taint",
13+
"org.apache.logging.log4j;Logger;true;traceEntry;(Supplier[]);;Argument[0];ReturnValue;taint",
1514
"org.apache.logging.log4j;Logger;true;traceExit;(EntryMessage,Object);;Argument[1];ReturnValue;value",
1615
"org.apache.logging.log4j;Logger;true;traceExit;(Message,Object);;Argument[1];ReturnValue;value",
1716
"org.apache.logging.log4j;Logger;true;traceExit;(Object);;Argument[0];ReturnValue;value",
1817
"org.apache.logging.log4j;Logger;true;traceExit;(String,Object);;Argument[1];ReturnValue;value",
19-
"org.slf4j.spi.LoggingEventBuilder;true;addArgument;;;Argument[1];Argument[-1];taint",
20-
"org.slf4j.spi.LoggingEventBuilder;true;addArgument;;;Argument[-1];ReturnValue;value",
21-
"org.slf4j.spi.LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[-1];taint",
22-
"org.slf4j.spi.LoggingEventBuilder;true;addKeyValue;;;Argument[-1];ReturnValue;value",
23-
"org.slf4j.spi.LoggingEventBuilder;true;addMarker;;;Argument[-1];ReturnValue;value",
24-
"org.slf4j.spi.LoggingEventBuilder;true;setCause;;;Argument[-1];ReturnValue;value",
18+
"org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[1];Argument[-1];taint",
19+
"org.slf4j.spi;LoggingEventBuilder;true;addArgument;;;Argument[-1];ReturnValue;value",
20+
"org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[1];Argument[-1];taint",
21+
"org.slf4j.spi;LoggingEventBuilder;true;addKeyValue;;;Argument[-1];ReturnValue;value",
22+
"org.slf4j.spi;LoggingEventBuilder;true;addMarker;;;Argument[-1];ReturnValue;value",
23+
"org.slf4j.spi;LoggingEventBuilder;true;setCause;;;Argument[-1];ReturnValue;value",
2524
"java.util.logging;LogRecord;false;LogRecord;;;Argument[1];Argument[-1];taint"
2625
]
2726
}
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package generatedtest;
2+
3+
import java.util.logging.LogRecord;
4+
import org.apache.logging.log4j.Logger;
5+
import org.apache.logging.log4j.message.EntryMessage;
6+
import org.apache.logging.log4j.message.Message;
7+
import org.slf4j.spi.LoggingEventBuilder;
8+
9+
// Test case generated by GenerateFlowTestCase.ql
10+
public class Test {
11+
12+
Object source() {
13+
return null;
14+
}
15+
16+
void sink(Object o) {}
17+
18+
public void test() throws Exception {
19+
20+
{
21+
// "java.util.logging;LogRecord;false;LogRecord;;;Argument[1];Argument[-1];taint"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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[-1];ReturnValue;value"
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[-1];ReturnValue;value"
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[-1];ReturnValue;value"
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[-1];ReturnValue;value"
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[-1];taint"
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[-1];taint"
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[-1];ReturnValue;value"
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[-1];ReturnValue;value"
160+
LoggingEventBuilder out = null;
161+
LoggingEventBuilder in = (LoggingEventBuilder) source();
162+
out = in.setCause(null);
163+
sink(out); // $ hasValueFlow
164+
}
165+
166+
}
167+
168+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//semmle-extractor-options: --javac-args -cp ${testdir}/../../stubs/apache-log4j-2.14.1:${testdir}/../../stubs/slf4j-2.0.0

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

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import java
2+
import TestUtilities.InlineFlowTest

java/ql/test/stubs/apache-log4j-2.14.1/org/apache/logging/log4j/Level.java

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/ql/test/stubs/apache-log4j-2.14.1/org/apache/logging/log4j/LogBuilder.java

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)