Class Jazzer
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
A 32-bit random number that hooks can use to make pseudo-random choices between multiple possible mutations they could guide the fuzzer towards. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
exploreState
(byte state, int id) Instructs the fuzzer to attain as many possible values for the absolute value ofstate
as possible.static void
guideTowardsContainment
(String haystack, String needle, int id) Instructs the fuzzer to guide its mutations towards makinghaystack
containneedle
as a substring.static void
guideTowardsEquality
(byte[] current, byte[] target, int id) Instructs the fuzzer to guide its mutations towards makingcurrent
equal totarget
.static void
guideTowardsEquality
(String current, String target, int id) Instructs the fuzzer to guide its mutations towards makingcurrent
equal totarget
.static void
onFuzzTargetReady
(Runnable callback) Register a callback to be executed right before the fuzz target is executed for the first time.static void
reportFindingFromHook
(Throwable finding) Make Jazzer report the providedThrowable
as a finding.
-
Field Details
-
SEED
public static final int SEEDA 32-bit random number that hooks can use to make pseudo-random choices between multiple possible mutations they could guide the fuzzer towards. Hooks must not base the decision whether or not to report a finding on this number as this will make findings non-reproducible.This is the same number that libFuzzer uses as a seed internally, which makes it possible to deterministically reproduce a previous fuzzing run by supplying the seed value printed by libFuzzer as the value of the
-seed
.
-
-
Method Details
-
guideTowardsEquality
Instructs the fuzzer to guide its mutations towards makingcurrent
equal totarget
.If the relation between the raw fuzzer input and the value of
current
is relatively complex, running the fuzzer with the argument-use_value_profile=1
may be necessary to achieve equality.- Parameters:
current
- a non-constant string observed during fuzz target executiontarget
- a string thatcurrent
should become equal to, but currently isn'tid
- a (probabilistically) unique identifier for this particular compare hint
-
guideTowardsEquality
public static void guideTowardsEquality(byte[] current, byte[] target, int id) Instructs the fuzzer to guide its mutations towards makingcurrent
equal totarget
.If the relation between the raw fuzzer input and the value of
current
is relatively complex, running the fuzzer with the argument-use_value_profile=1
may be necessary to achieve equality.- Parameters:
current
- a non-constant byte array observed during fuzz target executiontarget
- a byte array thatcurrent
should become equal to, but currently isn'tid
- a (probabilistically) unique identifier for this particular compare hint
-
guideTowardsContainment
Instructs the fuzzer to guide its mutations towards makinghaystack
containneedle
as a substring.If the relation between the raw fuzzer input and the value of
haystack
is relatively complex, running the fuzzer with the argument-use_value_profile=1
may be necessary to satisfy the substring check.- Parameters:
haystack
- a non-constant string observed during fuzz target executionneedle
- a string that should be contained inhaystack
as a substring, but currently isn'tid
- a (probabilistically) unique identifier for this particular compare hint
-
exploreState
public static void exploreState(byte state, int id) Instructs the fuzzer to attain as many possible values for the absolute value ofstate
as possible.Call this function from a fuzz target or a hook to help the fuzzer track partial progress (e.g. by passing the length of a common prefix of two lists that should become equal) or explore different values of state that is not directly related to code coverage (see the MazeFuzzer example).
Note: This hint only takes effect if the fuzzer is run with the argument
-use_value_profile=1
.- Parameters:
state
- a numeric encoding of a state that should be varied by the fuzzerid
- a (probabilistically) unique identifier for this particular state hint
-
reportFindingFromHook
Make Jazzer report the providedThrowable
as a finding.Note: This method must only be called from a method hook. In a fuzz target, simply throw an exception to trigger a finding.
- Parameters:
finding
- the finding that Jazzer should report
-
onFuzzTargetReady
Register a callback to be executed right before the fuzz target is executed for the first time.This can be used to disable hooks until after Jazzer has been fully initializing, e.g. to prevent Jazzer internals from triggering hooks on Java standard library classes.
- Parameters:
callback
- the callback to execute
-