mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Move test cases to their own directory to avoid conflict
This commit is contained in:
@@ -1,28 +1,104 @@
|
||||
package generatedtest;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class Test {
|
||||
static String[] regs = {
|
||||
"[A-Z\\d]++",
|
||||
"\\Q hello world [ *** \\Q ) ( \\E",
|
||||
"[\\Q hi ] \\E]",
|
||||
"[]]",
|
||||
"[^]]",
|
||||
"[abc[defg]]",
|
||||
"[abc&&[\\W\\p{Lower}\\P{Space}\\N{degree sign}]]\\b7\\b{g}8",
|
||||
"\\cA",
|
||||
"\\c(",
|
||||
"\\c\\(ab)",
|
||||
"(?>hi)(?<name>hell*?o*+)123\\k<name>",
|
||||
"a+b*c?d{2}e{3,4}f{,5}g{6,}h+?i*?j??k{7}?l{8,9}?m{,10}?n{11,}?o++p*+q?+r{12}+s{13,14}+t{,15}+u{16,}+",
|
||||
"(?i)(?=a)(?!b)(?<=c)(?<!d)",
|
||||
"a||b|c(d|e|)f|g",
|
||||
"\\018\\033\\0377\\0777\u1337",
|
||||
// Test case generated by GenerateFlowTestCase.ql
|
||||
public class Test {
|
||||
|
||||
};
|
||||
private final String str_pattern = "\\$\\{(.*)\\}";
|
||||
private final Pattern pattern = Pattern.compile(str_pattern);
|
||||
|
||||
void test() {
|
||||
for (int i = 0; i < regs.length; i++) {
|
||||
Pattern.compile(regs[i]);
|
||||
}
|
||||
Object source() { return null; }
|
||||
void sink(Object o) { }
|
||||
|
||||
public void test() throws Exception {
|
||||
|
||||
{
|
||||
// "java.util.regex;Matcher;false;group;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.group("foo");
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;group;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.group();
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;group;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.group(0);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;replaceAll;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.replaceAll("foo");
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;replaceAll;;;Argument[0];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher("foo");
|
||||
out = m.replaceAll(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;replaceFirst;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.replaceFirst("foo");
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;replaceFirst;;;Argument[0];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher("foo");
|
||||
out = m.replaceFirst(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Pattern;false;matcher;;;Argument[0];ReturnValue;taint"
|
||||
Matcher out = null;
|
||||
CharSequence in = (CharSequence)source();
|
||||
out = pattern.matcher(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Pattern;false;quote;;;Argument[0];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String)source();
|
||||
out = Pattern.quote(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Pattern;false;split;;;Argument[0];ReturnValue;taint"
|
||||
String[] out = null;
|
||||
CharSequence in = (CharSequence)source();
|
||||
out = pattern.split(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Pattern;false;split;;;Argument[0];ReturnValue;taint"
|
||||
String[] out = null;
|
||||
CharSequence in = (CharSequence)source();
|
||||
out = pattern.split(in, 0);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package generatedtest;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
// Test case generated by GenerateFlowTestCase.ql
|
||||
public class Test {
|
||||
|
||||
private final String str_pattern = "\\$\\{(.*)\\}";
|
||||
private final Pattern pattern = Pattern.compile(str_pattern);
|
||||
|
||||
Object source() { return null; }
|
||||
void sink(Object o) { }
|
||||
|
||||
public void test() throws Exception {
|
||||
|
||||
{
|
||||
// "java.util.regex;Matcher;false;group;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.group("foo");
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;group;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.group();
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;group;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.group(0);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;replaceAll;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.replaceAll("foo");
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;replaceAll;;;Argument[0];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher("foo");
|
||||
out = m.replaceAll(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;replaceFirst;;;Argument[-1];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher(in);
|
||||
out = m.replaceFirst("foo");
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Matcher;false;replaceFirst;;;Argument[0];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String) source();
|
||||
Matcher m = pattern.matcher("foo");
|
||||
out = m.replaceFirst(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Pattern;false;matcher;;;Argument[0];ReturnValue;taint"
|
||||
Matcher out = null;
|
||||
CharSequence in = (CharSequence)source();
|
||||
out = pattern.matcher(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Pattern;false;quote;;;Argument[0];ReturnValue;taint"
|
||||
String out = null;
|
||||
String in = (String)source();
|
||||
out = Pattern.quote(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Pattern;false;split;;;Argument[0];ReturnValue;taint"
|
||||
String[] out = null;
|
||||
CharSequence in = (CharSequence)source();
|
||||
out = pattern.split(in);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
// "java.util.regex;Pattern;false;split;;;Argument[0];ReturnValue;taint"
|
||||
String[] out = null;
|
||||
CharSequence in = (CharSequence)source();
|
||||
out = pattern.split(in, 0);
|
||||
sink(out); // $ hasTaintFlow
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
28
java/ql/test/library-tests/regex/parser/Test.java
Normal file
28
java/ql/test/library-tests/regex/parser/Test.java
Normal file
@@ -0,0 +1,28 @@
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class Test {
|
||||
static String[] regs = {
|
||||
"[A-Z\\d]++",
|
||||
"\\Q hello world [ *** \\Q ) ( \\E",
|
||||
"[\\Q hi ] \\E]",
|
||||
"[]]",
|
||||
"[^]]",
|
||||
"[abc[defg]]",
|
||||
"[abc&&[\\W\\p{Lower}\\P{Space}\\N{degree sign}]]\\b7\\b{g}8",
|
||||
"\\cA",
|
||||
"\\c(",
|
||||
"\\c\\(ab)",
|
||||
"(?>hi)(?<name>hell*?o*+)123\\k<name>",
|
||||
"a+b*c?d{2}e{3,4}f{,5}g{6,}h+?i*?j??k{7}?l{8,9}?m{,10}?n{11,}?o++p*+q?+r{12}+s{13,14}+t{,15}+u{16,}+",
|
||||
"(?i)(?=a)(?!b)(?<=c)(?<!d)",
|
||||
"a||b|c(d|e|)f|g",
|
||||
"\\018\\033\\0377\\0777\u1337",
|
||||
|
||||
};
|
||||
|
||||
void test() {
|
||||
for (int i = 0; i < regs.length; i++) {
|
||||
Pattern.compile(regs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user