Class ReproServerGuidance

  • All Implemented Interfaces:
    Guidance

    public class ReproServerGuidance
    extends Object
    implements Guidance
    Author:
    Rohan Padhye
    • Field Detail

      • coverageFile

        protected File coverageFile
      • inputFile

        protected File inputFile
      • inputFileStream

        protected InputStream inputFileStream
    • Method Detail

      • hasInput

        public boolean hasInput()
        Description copied from interface: Guidance
        Returns whether an input is ready for a new trial to be executed.

        This method may block until a new input stream is made ready. If this method returns false, then JQF stops fuzzing and this guidance will not be used further.

        Specified by:
        hasInput in interface Guidance
        Returns:
        whether a new trial should be executed
      • handleResult

        public void handleResult​(Result result,
                                 Throwable error)
        Description copied from interface: Guidance
        Handles the end of a fuzzing trial.

        This method is guaranteed to be invoked by JQF exactly once after each invocation of Guidance.getInput(). Therefore, it is safe to open resources such as files in a call to Guidance.getInput() and only close them inside this method.

        If result is SUCCESS, then error is either null or it is an instance of a throwable that is declared by the test method in its throws clause.

        If result is INVALID, then error is either an AssumptionViolatedException, if the argument of an assume() statement was false, or it is a GuidanceException, indicating that fuzzing was interrupted during the execution of this trial (and will not continue further).

        If result is FAILURE, then error is some other throwable that was thrown by the test execution but was not listed in its throws clause. This is the only way to detect test errors. Assertion errors will typically fall into this category. So will other unlisted RuntimeExceptions such as NPE.

        Specified by:
        handleResult in interface Guidance
        Parameters:
        result - the result of the fuzzing trial
        error - the error thrown during the trial, or null
      • generateCallBack

        public Consumer<TraceEvent> generateCallBack​(Thread thread)
        Description copied from interface: Guidance
        Returns 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:
        generateCallBack in interface Guidance
        Parameters:
        thread - the thread whose events to handle
        Returns:
        a callback that handles trace events generated by that thread