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