forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLite3Options.java
More file actions
178 lines (144 loc) · 7.41 KB
/
SQLite3Options.java
File metadata and controls
178 lines (144 loc) · 7.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package sqlancer.sqlite3;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import sqlancer.CompositeTestOracle;
import sqlancer.MainOptions.DBMSConverter;
import sqlancer.TestOracle;
import sqlancer.sqlite3.SQLite3Provider.SQLite3GlobalState;
import sqlancer.sqlite3.queries.SQLite3Fuzzer;
import sqlancer.sqlite3.queries.SQLite3NoRECTester;
import sqlancer.sqlite3.queries.SQLite3PivotedQuerySynthesizer;
import sqlancer.sqlite3.queries.SQLite3QueryPartitioningAggregateTester;
import sqlancer.sqlite3.queries.SQLite3QueryPartitioningDistinctTester;
import sqlancer.sqlite3.queries.SQLite3QueryPartitioningGroupByTester;
import sqlancer.sqlite3.queries.SQLite3QueryPartitioningHavingTester;
import sqlancer.sqlite3.queries.SQLite3QueryPartitioningWhereTester;
@Parameters(separators = "=", commandDescription = "SQLite3")
public class SQLite3Options {
@Parameter(names = { "--test-fts" }, description = "Test the FTS extensions", arity = 1)
public boolean testFts = true;
@Parameter(names = { "--test-rtree" }, description = "Test the R*Tree extensions", arity = 1)
public boolean testRtree = true;
@Parameter(names = {
"--test-dbstats" }, description = "Test the DBSTAT Virtual Table (see https://www.sqlite.org/dbstat.html)", arity = 1)
public boolean testDBStats = false;
@Parameter(names = { "--test-generated-columns" }, description = "Test generated columns", arity = 1)
public boolean testGeneratedColumns = true;
@Parameter(names = { "--test-foreign-keys" }, description = "Test foreign key constraints", arity = 1)
public boolean testForeignKeys = true;
@Parameter(names = { "--test-without-rowids" }, description = "Generate WITHOUT ROWID tables", arity = 1)
public boolean testWithoutRowids = true;
@Parameter(names = { "--test-temp-tables" }, description = "Generate TEMP/TEMPORARY tables", arity = 1)
public boolean testTempTables = true;
@Parameter(names = { "--test-check-constraints" }, description = "Allow CHECK constraints in tables", arity = 1)
public boolean testCheckConstraints = true;
@Parameter(names = {
"--test-nulls-first-last" }, description = "Allow NULLS FIRST/NULLS LAST in ordering terms", arity = 1)
public boolean testNullsFirstLast = true;
@Parameter(names = { "--test-joins" }, description = "Allow the generation of JOIN clauses", arity = 1)
public boolean testJoins = true;
@Parameter(names = {
"--test-functions" }, description = "Allow the generation of functions in expressions", arity = 1)
public boolean testFunctions = true;
@Parameter(names = {
"--test-soundex" }, description = "Test the soundex function, which can be enabled using a compile-time option.", arity = 1)
public boolean testSoundex = false;
@Parameter(names = { "--test-match" }, description = "Allow the generation of the MATCH operator", arity = 1)
public boolean testMatch = true;
@Parameter(names = {
"--test-distinct-in-view" }, description = "DISTINCT in views might cause occasional false positives in NoREC and TLP", arity = 1)
public boolean testDistinctInView = false;
@Parameter(names = "--oracle", converter = DBMSConverter.class)
public SQLite3Oracle oracle = SQLite3Oracle.NoREC;
@Parameter(names = {
"--delete-existing-databases" }, description = "Delete a database file if it already exists", arity = 1)
public boolean deleteIfExists = true;
@Parameter(names = {
"--generate-new-database" }, description = "Specifies whether new databases should be generated", arity = 1)
public boolean generateDatabase = true;
@Parameter(names = {
"--print-statements" }, description = "Specifies whether to print SQL statements to stdout", arity = 1)
public boolean printStatements = false;
@Parameter(names = {
"--execute-queries" }, description = "Specifies whether the query in the fuzzer should be executed", arity = 1)
public boolean executeQuery = true;
@Parameter(names = {
"--print-successful-statements" }, description = "Specifies whether to print SQL statements to stdout", arity = 1)
public boolean executeStatementsAndPrintSuccessfulOnes = false;
@Parameter(names = {
"--exit-after-first-database" }, description = "Specifies whether to stop SQLancer after creating and executing the test oracle on the first database", arity = 1)
public boolean exitAfterFirstDatabase = false;
public enum SQLite3Oracle {
PQS {
@Override
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
return new SQLite3PivotedQuerySynthesizer(globalState);
}
},
NoREC {
@Override
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
return new SQLite3NoRECTester(globalState);
}
},
FUZZER {
@Override
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
return new SQLite3Fuzzer(globalState);
}
},
AGGREGATE {
@Override
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
return new SQLite3QueryPartitioningAggregateTester(globalState);
}
},
WHERE {
@Override
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
return new SQLite3QueryPartitioningWhereTester(globalState);
}
},
DISTINCT {
@Override
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
return new SQLite3QueryPartitioningDistinctTester(globalState);
}
},
GROUP_BY {
@Override
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
return new SQLite3QueryPartitioningGroupByTester(globalState);
}
},
HAVING {
@Override
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
return new SQLite3QueryPartitioningHavingTester(globalState);
}
},
QUERY_PARTITIONING {
@Override
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
List<TestOracle> oracles = new ArrayList<>();
oracles.add(new SQLite3QueryPartitioningWhereTester(globalState));
oracles.add(new SQLite3QueryPartitioningDistinctTester(globalState));
oracles.add(new SQLite3QueryPartitioningGroupByTester(globalState));
oracles.add(new SQLite3QueryPartitioningHavingTester(globalState));
oracles.add(new SQLite3QueryPartitioningAggregateTester(globalState));
return new CompositeTestOracle(oracles);
}
};
public abstract TestOracle create(SQLite3GlobalState globalState) throws SQLException;
}
public class SQLite3OracleConverter implements IStringConverter<SQLite3Oracle> {
@Override
public SQLite3Oracle convert(String value) {
return SQLite3Oracle.valueOf(value);
}
}
}