forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLite3Fuzzer.java
More file actions
45 lines (37 loc) · 1.43 KB
/
SQLite3Fuzzer.java
File metadata and controls
45 lines (37 loc) · 1.43 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
package sqlancer.sqlite3.queries;
import java.sql.SQLException;
import sqlancer.MainOptions;
import sqlancer.QueryAdapter;
import sqlancer.Randomly;
import sqlancer.TestOracle;
import sqlancer.sqlite3.SQLite3Provider.SQLite3GlobalState;
import sqlancer.sqlite3.SQLite3Visitor;
// tries to trigger a crash
public class SQLite3Fuzzer implements TestOracle {
private final SQLite3GlobalState globalState;
public SQLite3Fuzzer(SQLite3GlobalState globalState) {
this.globalState = globalState;
}
@Override
public void check() throws SQLException {
String s = SQLite3Visitor
.asString(SQLite3RandomQuerySynthesizer.generate(globalState, Randomly.smallNumber() + 1)) + ";";
MainOptions options = globalState.getOptions();
try {
if (options.logEachSelect()) {
globalState.getLogger().writeCurrent(s);
}
if (globalState.getDmbsSpecificOptions().printStatements) {
System.out.println(s);
}
if (globalState.getDmbsSpecificOptions().executeQuery) {
globalState.getManager().execute(new QueryAdapter(s));
if (globalState.getDmbsSpecificOptions().executeStatementsAndPrintSuccessfulOnes) {
System.out.println(s);
}
globalState.getManager().incrementSelectQueryCount();
}
} catch (Error e) {
}
}
}