-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathjvm_requirement_coverage_fixing.txt
94 lines (81 loc) · 5.9 KB
/
jvm_requirement_coverage_fixing.txt
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
I'm a security engineer looking to write good fuzzing harnesses. I want you to help me improve my fuzzing harness so it covers more of the code in the target project.
The target library is {TARGET_REPO}.
The target project is implemented in the Java programming language; therefore, the harness should also be written in Java.
The fuzzing harness must be executable within the Jazzer fuzzing framework.
Below is the source code of the target fuzzing harness that I would like to improve:
<code>
{GENERATED_HARNESS}
</code>
For reference, the source code for all existing harnesses of the project is provided below, separated by `---`:
<code>
{EXISTING_HARNESS}
</code>
Additionally, a list of all public methods and constructors of the project is included for your reference, you should try to expand the fuzzing harness that calls these targets to improve the overall fuzzing coverage:
{PUBLIC_METHODS}
Your task is to improve the target fuzzing harness provided above to increase code coverage for additional parts of the project that are not covered by the existing fuzzing harnesses. Please ensure that the changes made are minimal.
In your response, include ONLY the code for the harness, nothing more. You should wrap the code in <code></code> tags.
Here is an additional list of requirements that you MUST follow.
<requirements>
<item>NEVER use any methods from the <code>java.lang.Random</code> class in the generated code.</item>
<item>NEVER use any classes or methods in the <code>java.lang.reflect</code> package in the generated code.</item>
<item>NEVER use the @FuzzTest annotation for specifying the fuzzing method.</item>
<item>NEVER use any assert, printing and logging statements in the generated harness.</item>
<item>NEVER use any multithreading or multi-processing approach.</item>
<item>You MUST create the object before calling the target method.</item>
<item>Please use {HARNESS_NAME} as the Java class name.</item>
<item>You MUST invoke the close method of any resource class objects that implements the java.lang.AutoCloseable interface in the finally block after the target method is invoked.</item>
<item>Always create the fuzzing harness from the following templates:
<code>
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
// Other imports
public class {HARNESS_NAME} {
public static void fuzzerInitialize() {
// Initializing objects for fuzzing
}
public static void fuzzerTearDown() {
// Tear down objects after fuzzing
}
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
// Use the FuzzedDataProvider object to generate random data for fuzzing
// Fuzz by invoking the target method with random parameters / objects generated above.
}
}
</code></item>
<item>
You MUST ONLY use any of the following methods from the FuzzedDataProvider of the Jazzer framework for generating random data for fuzzing.
If the needed return value is not found in the table, try to use constructors or methods to create the needed random object. But you MUST try your best to randomise the random object with the methods in the table.
| Method | Return Value |
|---------------------------------------------|---------------------------------------|
| `consumeBytes(int length)` | `byte[]` |
| `consumeRemainingAsBytes()` | `byte[]` |
| `consumeString(int length)` | `String` |
| `consumeRemainingAsString()` | `String` |
| `consumeBoolean()` | `boolean` |
| `consumeInt(int min, int max)` | `int` |
| `consumeInt()` | `int` |
| `consumeLong(long min, long max)` | `long` |
| `consumeLong()` | `long` |
| `consumeFloat(float min, float max)` | `float` |
| `consumeFloat()` | `float` |
| `consumeDouble(double min, double max)` | `double` |
| `consumeDouble()` | `double` |
| `consumeChar()` | `char` |
| `consumeChar(char min, char max)` | `char` |
| `consumeShort(short min, short max)` | `short` |
| `consumeShort()` | `short` |
| `consumeRemainingAsCharSequence()` | `CharSequence` |
| `consumeBytestring()` | `byte[]` |
| `consumeBigInteger(int minNumBits)` | `BigInteger` |
| `consumeEnum(Class<E> enumType)` | `E` (Enum type) |
| `consumeProbabilityDouble()` | `double` |
| `consumeFraction()` | `double` |
| `pickValue(T... values)` | `T` (Type of value) |
| `pickValue(List<T> values)` | `T` (Type of value) |
| `consumeByte()` | `byte` |
| `consumeIntList(int length)` | `List<Integer>` |
| `consumeLongList(int length)` | `List<Long>` |
| `consumeFloatList(int length)` | `List<Float>` |
| `consumeDoubleList(int length)` | `List<Double>` |
| `consumeCharList(int length)` | `List<Character>` |
</item>
</requirements>