def get_fuzz(valuelist, no_of_fuzzcases, radamsacmd):
    """Run Radamsa on a set of valid values

    :param valuelist: Valid cases to feed to Radamsa
    :param no_of_fuzzcases: Number of fuzz cases to generate
    :param radamsacmd: Command to run Radamsa
    :return:
    """

    # Radamsa is a file-based fuzzer so we need to write the valid strings
    # out to files
    valid_case_directory = tempfile.mkdtemp()
    fuzz_case_directory = tempfile.mkdtemp()
    for valid_string in valuelist:
        tempfilehandle = tempfile.mkstemp(suffix='.case',
                                          dir=valid_case_directory)
        with os.fdopen(tempfilehandle[0], "w") as filehandle:
            # Radamsa only operates on strings, so make numbers and booleans
            # into strings. (No, this won't fuzz effectively, use static
            # injection to cover those cases.)
            if isinstance(valid_string, (bool, int, long, float)):
                valid_string = str(valid_string)
            filehandle.write(bytearray(valid_string, "UTF-8"))

    # Run Radamsa
    try:
        subprocess.check_call(
            [radamsacmd, "-o", fuzz_case_directory + "/%n.fuzz", "-n",
             str(no_of_fuzzcases), "-r", valid_case_directory])
    except subprocess.CalledProcessError as error:
        assert False, "Could not execute Radamsa: %s" % error

    # Read the fuzz cases from the output directory and return as list
    fuzzlist = []
    for filename in os.listdir(fuzz_case_directory):
        filehandle = open(fuzz_case_directory + "/" + filename, "r")
        fuzzlist.append(filehandle.read())
    shutil.rmtree(valid_case_directory)
    shutil.rmtree(fuzz_case_directory)
    return fuzzlist
dataset/ETHPy150Open F-Secure/mittn/mittn/httpfuzzer/fuzzer.py/get_fuzz/original