Class ExecutionIndexingGuidance
- All Implemented Interfaces:
Guidance
- Author:
- Rohan Padhye
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA candidate test input represented as a map from execution indices to integer values.classNested classes/interfaces inherited from class edu.berkeley.cs.jqf.fuzz.ei.ZestGuidance
ZestGuidance.Input<K>, ZestGuidance.LinearInput, ZestGuidance.SeedInput -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ThreadThe thread being instrumented for coverage-guided fuzzing.Maps a hash code of coverage bits to an index in savedInputs queue.protected final doubleProbability of splicing inExecutionIndexingGuidance.MappedInput.getOrGenerateFresh(ExecutionIndex, Random)protected AbstractExecutionIndexingStateThe execution indexing logic.protected StringThe entry point to the test method we are fuzzing.protected final intMax number of contiguous bytes to splice in from another input during the splicing stage.protected final doubleMean number of mutations to perform in each round.protected final doubleMean number of contiguous bytes to mutate in each mutation.protected final booleanWhether to splice only in the same sub-treeprotected final doubleProbability of splicing inExecutionIndexingGuidance.MappedInput.fuzz(Random, Map)protected booleanWhether the the entry point has been encountered in the current run.Fields inherited from class edu.berkeley.cs.jqf.fuzz.ei.ZestGuidance
allInputsDirectory, blind, branchCount, console, coverageFile, currentInput, currentInputFile, currentParentInputIdx, cyclesCompleted, DISABLE_SAVE_NEW_COUNTS, EXACT_CRASH_PATH, EXIT_ON_CRASH, firstThread, GENERATE_EOF_WHEN_OUT, lastNumTrials, lastRefreshTime, LIBFUZZER_COMPAT_OUTPUT, LOG_ALL_INPUTS, LOG_CURRENT_INPUT, logFile, MAX_INPUT_SIZE, maxCoverage, maxDurationMillis, maxTrials, multiThreaded, MUTATION_ZERO_PROBABILITY, NUM_CHILDREN_BASELINE, NUM_CHILDREN_MULTIPLIER_FAVORED, numChildrenGeneratedForCurrentParentInput, numFavoredLastCycle, numSavedInputs, numTrials, numValid, outputDirectory, QUIET_MODE, random, responsibleInputs, runCoverage, runStart, SAVE_ONLY_VALID, savedCorpusDirectory, savedFailuresDirectory, savedInputs, seedInputs, singleRunTimeoutMillis, startTime, STATS_REFRESH_TIME_PERIOD, statsFile, STEAL_RESPONSIBILITY, testName, totalCoverage, uniqueFailures, validCoverage, validityFuzzing, verbose -
Constructor Summary
ConstructorsConstructorDescriptionExecutionIndexingGuidance(String testName, Duration duration, Long trials, File outputDirectory, File[] seedFiles, Random sourceOfRandomness) Creates a new EI guidance instance with seed input files and optional duration.ExecutionIndexingGuidance(String testName, Duration duration, Long trials, File outputDirectory, File seedInputDir, Random sourceOfRandomness) Constructs a new EI guidance instance with seed input directory and optional duration, optional trial limit, an possibly deterministic PRNG.ExecutionIndexingGuidance(String testName, Duration duration, Long trials, File outputDirectory, Random sourceOfRandomness) Constructs a new EI guidance instance with optional duration, optional trial limit, and possibly deterministic PRNG. -
Method Summary
Modifier and TypeMethodDescriptionvoidRuns once before each trial, after its arguments are generated.protected voidHandles the end of fuzzing cycle (i.e., having gone through the entire queue)protected ZestGuidance.Input<?>Spawns a new input from thin air (i.e., actually random)protected InputStreamReturns an InputStream that delivers parameters to the generators.generateCallBack(Thread thread) Returns a callback generator for a thread's event trace.getInput()Returns a reference to a stream of values return from the pseudo-random number generator.protected StringgetTitle()Returns the banner to be displayed on the status screenprotected voidHandles a trace event generated during test executionvoidhandleResult(Result result, Throwable error) Handles the result of a test execution.protected voidsaveCurrentInput(org.eclipse.collections.impl.set.mutable.primitive.IntHashSet responsibilities, String why) Saves an interesting input to the queue.Methods inherited from class edu.berkeley.cs.jqf.fuzz.ei.ZestGuidance
appendLineToFile, checkSavingCriteriaSatisfied, computeResponsibilities, conditionallySynchronize, displayStats, getStatNames, getTargetChildrenForParent, getTotalCoverage, hasInput, infoLog, millisToDuration, observeGuidance, setBlind, updateCoverageFile, writeCurrentInputToFileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.berkeley.cs.jqf.fuzz.guidance.Guidance
observeGeneratedArgs
-
Field Details
-
eiState
The execution indexing logic. -
appThread
The thread being instrumented for coverage-guided fuzzing. -
entryPoint
The entry point to the test method we are fuzzing. -
testEntered
protected boolean testEnteredWhether the the entry point has been encountered in the current run. -
coverageHashToSavedInputIdx
Maps a hash code of coverage bits to an index in savedInputs queue. -
MEAN_MUTATION_COUNT
protected final double MEAN_MUTATION_COUNTMean number of mutations to perform in each round.- See Also:
-
MEAN_MUTATION_SIZE
protected final double MEAN_MUTATION_SIZEMean number of contiguous bytes to mutate in each mutation.- See Also:
-
MAX_SPLICE_SIZE
protected final int MAX_SPLICE_SIZEMax number of contiguous bytes to splice in from another input during the splicing stage.- See Also:
-
SPLICE_SUBTREE
protected final boolean SPLICE_SUBTREEWhether to splice only in the same sub-tree -
STANDARD_SPLICING_PROBABILITY
protected final double STANDARD_SPLICING_PROBABILITYProbability of splicing inExecutionIndexingGuidance.MappedInput.fuzz(Random, Map)- See Also:
-
DEMAND_DRIVEN_SPLICING_PROBABILITY
protected final double DEMAND_DRIVEN_SPLICING_PROBABILITYProbability of splicing inExecutionIndexingGuidance.MappedInput.getOrGenerateFresh(ExecutionIndex, Random)- See Also:
-
-
Constructor Details
-
ExecutionIndexingGuidance
public ExecutionIndexingGuidance(String testName, Duration duration, Long trials, File outputDirectory, Random sourceOfRandomness) throws IOException Constructs a new EI guidance instance with optional duration, optional trial limit, and possibly deterministic PRNG.- Parameters:
testName- the name of test to display on the status screenduration- the amount of time to run fuzzing for, wherenullindicates unlimited time.trials- the number of trials for which to run fuzzing, wherenullindicates unlimited trials.outputDirectory- the directory where fuzzing results will be writtensourceOfRandomness- a pseudo-random number generator- Throws:
IOException- if the output directory could not be prepared
-
ExecutionIndexingGuidance
public ExecutionIndexingGuidance(String testName, Duration duration, Long trials, File outputDirectory, File seedInputDir, Random sourceOfRandomness) throws IOException Constructs a new EI guidance instance with seed input directory and optional duration, optional trial limit, an possibly deterministic PRNG.- Parameters:
testName- the name of test to display on the status screenduration- the amount of time to run fuzzing for, wherenullindicates unlimited time.trials- the number of trials for which to run fuzzing, wherenullindicates unlimited trials.outputDirectory- the directory where fuzzing results will be writtenseedInputDir- the directory containing one or more input files to be used as initial inputssourceOfRandomness- a pseudo-random number generator- Throws:
IOException- if the output directory could not be prepared
-
ExecutionIndexingGuidance
public ExecutionIndexingGuidance(String testName, Duration duration, Long trials, File outputDirectory, File[] seedFiles, Random sourceOfRandomness) throws IOException Creates a new EI guidance instance with seed input files and optional duration.- Parameters:
testName- the name of test to display on the status screenduration- the amount of time to run fuzzing for, wherenullindicates unlimited time.trials- the number of trials for which to run fuzzing, wherenullindicates unlimited trials.outputDirectory- the directory where fuzzing results will be writtenseedFiles- the seed input files to be used as initial inputssourceOfRandomness- a pseudo-random number generator- Throws:
IOException- if the output directory could not be prepared
-
-
Method Details
-
getTitle
Returns the banner to be displayed on the status screen- Overrides:
getTitlein classZestGuidance
-
createFreshInput
Spawns a new input from thin air (i.e., actually random)- Overrides:
createFreshInputin classZestGuidance- Returns:
- a fresh input
-
createParameterStream
Returns an InputStream that delivers parameters to the generators. Note: The variable `currentInput` has been set to point to the input to mutate.- Overrides:
createParameterStreamin classZestGuidance- Returns:
- an InputStream that delivers parameters to the generators
-
getInput
Description copied from interface:GuidanceReturns a reference to a stream of values return from the pseudo-random number generator.This method is guaranteed to be invoked by JQF at most once after each invocation of
Guidance.hasInput()that has returnedtrue.If
Guidance.hasInput()returnsfalseor has not been invoked since the last call toGuidance.getInput(), then invoking this method may throw an IllegalStateException.- Specified by:
getInputin interfaceGuidance- Overrides:
getInputin classZestGuidance- Returns:
- a stream of bytes to be used by the input generator(s)
- Throws:
GuidanceException- if there was an I/O or other error in generating the input stream
-
beforeRun
public void beforeRun()Description copied from interface:GuidanceRuns once before each trial, after its arguments are generated.This is a hook for per-trial setup that a guidance needs but that is not itself test execution. For example, a coverage-guided guidance installs its coverage listener here. The default does nothing.
-
handleResult
Handles the result of a test execution. This method mostly delegates to theZestGuidance, but additionally incorporates some custom logic to support minimization- Specified by:
handleResultin interfaceGuidance- Overrides:
handleResultin classZestGuidance- Parameters:
result- the result of the fuzzing trialerror- the error thrown during the trial, ornull- Throws:
GuidanceException- if there was an I/O or other error in handling the result
-
saveCurrentInput
protected void saveCurrentInput(org.eclipse.collections.impl.set.mutable.primitive.IntHashSet responsibilities, String why) throws IOException Saves an interesting input to the queue.- Overrides:
saveCurrentInputin classZestGuidance- Throws:
IOException
-
completeCycle
protected void completeCycle()Handles the end of fuzzing cycle (i.e., having gone through the entire queue)- Overrides:
completeCyclein classZestGuidance
-
generateCallBack
Description copied from interface:GuidanceReturns a callback generator for a thread's event trace.The application under test is instrumented such that each thread generates a sequence of
TraceEvents that may be handled by a separate callback method (though it may also be the same callback).The callback provided by this method will typically be used for collection execution information such as branch coverage, which in turn is used for constructing the next input stream.
This method is a supplier of event consumers. It is invoked once per new application thread spawned during fuzzing.
- Specified by:
generateCallBackin interfaceGuidance- Overrides:
generateCallBackin classZestGuidance- Parameters:
thread- the thread whose events to handle- Returns:
- a callback that handles trace events generated by that thread
-
handleEvent
Handles a trace event generated during test execution- Overrides:
handleEventin classZestGuidance- Parameters:
e- the trace event to be handled
-