Beispiel #1
0
def do_mutator_plugin():
  """Return whether or not to use a mutator_plugin."""
  # TODO(metzman): Support Windows.
  if environment.platform() == 'WINDOWS':
    return False

  return engine_common.decide_with_probability(
      engine_common.get_strategy_probability(
          strategy.MUTATOR_PLUGIN_STRATEGY, default=MUTATOR_PLUGIN_PROBABILITY))
def choose_generator(strategy_pool):
  """Chooses whether to use radamsa, ml rnn, or no generator and updates the
  strategy pool."""

  radamsa_prob = engine_common.get_strategy_probability(
      strategy.CORPUS_MUTATION_RADAMSA_STRATEGY.name,
      default=strategy.CORPUS_MUTATION_RADAMSA_STRATEGY.probability)

  ml_rnn_prob = engine_common.get_strategy_probability(
      strategy.CORPUS_MUTATION_ML_RNN_STRATEGY.name,
      default=strategy.CORPUS_MUTATION_ML_RNN_STRATEGY.probability)

  if engine_common.decide_with_probability(radamsa_prob + ml_rnn_prob):
    if engine_common.decide_with_probability(
        radamsa_prob / (radamsa_prob + ml_rnn_prob)):
      strategy_pool.add_strategy(strategy.CORPUS_MUTATION_RADAMSA_STRATEGY)
    else:
      strategy_pool.add_strategy(strategy.CORPUS_MUTATION_ML_RNN_STRATEGY)
Beispiel #3
0
def do_fork():
  """Return whether or not to do fork mode."""
  # TODO(metzman): Find a workaround for Windows command line limit before
  # re-enabling this.
  if environment.platform() == 'WINDOWS':
    return False

  return engine_common.decide_with_probability(
      engine_common.get_strategy_probability(
          strategy.FORK_STRATEGY, default=FORK_PROBABILITY))
Beispiel #4
0
def do_fork():
    """Return whether or not to do fork mode."""
    # TODO(crbug.com/920355): Reenable this when fork mode works with ChromeOS's
    # MSAN.
    job_name = environment.get_value('JOB_NAME')
    memory_tool = environment.get_memory_tool_name(job_name)
    if memory_tool == 'MSAN' and environment.is_chromeos_system_job():
        return False

    return engine_common.decide_with_probability(
        engine_common.get_strategy_probability(strategy.FORK_STRATEGY,
                                               default=FORK_PROBABILITY))
Beispiel #5
0
def do_fork():
    """Return whether or not to do fork mode."""
    # TODO(metzman): Find a workaround for Windows command line limit before
    # re-enabling this.
    if environment.platform() == 'WINDOWS':
        return False

    # TODO(crbug.com/920355): Reenable this when fork mode works with ChromeOS's
    # MSAN.
    job_name = environment.get_value('JOB_NAME')
    memory_tool = environment.get_memory_tool_name(job_name)
    if memory_tool == 'MSAN' and environment.is_chromeos_system_job():
        return False

    return engine_common.decide_with_probability(
        engine_common.get_strategy_probability(strategy.FORK_STRATEGY,
                                               default=FORK_PROBABILITY))
Beispiel #6
0
    def decide_fast_cal_random(self, num_files):
        """Decides whether to use AFL_FAST_CAL, based on probabilities that are
    dependant on |num_files| (listed in FAST_CAL_PROBS), sets self.fast_cal
    to FastCal.RANDOM if we decide yes, or sets it to FastCal.OFF. Does nothing
    if use_fast_cal was already set. Idempotent.
    """
        # Don't do anything if we have already made a decision about randomly using
        # fast_cal.
        if self.fast_cal != strategies.FastCal.NOT_SET:
            return

        # Decide if we want to use it.
        for cutoff, prob in self.FAST_CAL_PROBS:
            # Find the correct probability based on the number of input files.
            if num_files <= cutoff:
                if engine_common.decide_with_probability(prob):
                    self.fast_cal = strategies.FastCal.RANDOM
                else:
                    self.fast_cal = strategies.FastCal.OFF
                return

        assert None, 'This should not be reached'
Beispiel #7
0
def do_value_profile():
    """Return whether or not to do value profile."""
    return engine_common.decide_with_probability(
        engine_common.get_strategy_probability(
            strategy.VALUE_PROFILE_STRATEGY,
            default=VALUE_PROFILE_PROBABILITY))
Beispiel #8
0
def do_recommended_dictionary():
    """Retrn whether or not to use the recommended dictionary."""
    return engine_common.decide_with_probability(
        engine_common.get_strategy_probability(
            strategy.RECOMMENDED_DICTIONARY_STRATEGY,
            default=RECOMMENDED_DICTIONARY_PROBABILITY))
Beispiel #9
0
def do_ml_rnn_generator():
    """Return whether or not to do additional mutations."""
    return engine_common.decide_with_probability(
        engine_common.get_strategy_probability(
            strategy.CORPUS_MUTATION_ML_RNN_STRATEGY,
            default=CORPUS_MUTATION_ML_RNN_PROBABILITY))
Beispiel #10
0
def do_radamsa_generator():
    """Return whether or not to do radamsa mutations."""
    return engine_common.decide_with_probability(
        engine_common.get_strategy_probability(
            strategy.CORPUS_MUTATION_RADAMSA_STRATEGY,
            default=CORPUS_MUTATION_RADAMSA_PROBABILITY))
Beispiel #11
0
def do_random_max_length():
    """Return whether or not to do value profile."""
    return engine_common.decide_with_probability(
        engine_common.get_strategy_probability(
            strategy.RANDOM_MAX_LENGTH_STRATEGY,
            default=RANDOM_MAX_LENGTH_PROBABILITY))
Beispiel #12
0
def do_strategy(strategy_tuple):
    """Return whether or not to use a given strategy."""
    return engine_common.decide_with_probability(
        engine_common.get_strategy_probability(strategy_tuple.name,
                                               strategy_tuple.probability))
Beispiel #13
0
def do_fork():
    """Return whether or not to do fork mode."""
    return engine_common.decide_with_probability(
        engine_common.get_strategy_probability(strategy.FORK_STRATEGY,
                                               default=FORK_PROBABILITY))