-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathMySQLFuzzer.java
More file actions
30 lines (23 loc) · 891 Bytes
/
MySQLFuzzer.java
File metadata and controls
30 lines (23 loc) · 891 Bytes
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
package sqlancer.mysql.oracle;
import sqlancer.Randomly;
import sqlancer.common.oracle.TestOracle;
import sqlancer.common.query.SQLQueryAdapter;
import sqlancer.mysql.MySQLGlobalState;
import sqlancer.mysql.MySQLVisitor;
import sqlancer.mysql.gen.MySQLRandomQuerySynthesizer;
public class MySQLFuzzer implements TestOracle<MySQLGlobalState> {
private final MySQLGlobalState globalState;
public MySQLFuzzer(MySQLGlobalState globalState) {
this.globalState = globalState;
}
@Override
public void check() throws Exception {
String s = MySQLVisitor.asString(MySQLRandomQuerySynthesizer.generate(globalState, Randomly.smallNumber() + 1))
+ ';';
try {
globalState.executeStatement(new SQLQueryAdapter(s));
globalState.getManager().incrementSelectQueryCount();
} catch (Error e) {
}
}
}