def create_fuzzed_message(self, previousTemplates, previousFields,
                              next_template, fuzzer):
        """ Craft a fuzzed message according to previous templates
        and new selected template or a forced transition if a similarity
        based transition has been triggered.
        """
        try:
            transition = self.generateTransitionLabel(previousTemplates,
                                                      next_template)
        except:
            transition = None

        fields = dict(zip([str(ind) for ind in range(-len(previousFields)-1,
                                                     -1)], previousFields))

        template_rules = [r for t, r in self.rules.items() if t.endswith(next_template.ID)]
        rules = [item for sublist in template_rules for item in sublist]
        dst_fields = {}
        fields["-1"] = dst_fields
        fuzz_fields = fuzzer.get_fuzz_fields(next_template.ID)
        non_fuzzed_values = []

        for rule in rules:
            src_id = rule.src_id
            dst = rule.dst_field
            src = rule.src_field
            if rule.typ == "rule.ExactRule":
                try:
                    data = fields[src_id][src]
                except:
                    data = ""
                dst_fields[dst] = fuzzer.fuzz(rule, data, fuzz_fields)
                continue
            if rule.typ == "rule.DataRule":
                try:
                    data = random.choice(rule.data[5:].split(","))
                except:
                    data = ""
                dst_fields[dst] = fuzzer.fuzz(rule, data, fuzz_fields)
                continue
            if rule.typ == "rule.CopyCompleteRule":
                try:
                    if rule.data[6:20] == "COPY_AS_PREFIX":
                        data = fields[src_id][src]+random.choice(rule.data[26:].split(","))
                    else:
                        data = random.choice(rule.data[26:].split(","))+fields[src_id][src]
                except:
                    data = ""
                dst_fields[dst] = fuzzer.fuzz(rule, data, fuzz_fields)
                continue
            if rule.typ == "rule.CopyPartialRule":
                try:
                    split_data = fields[src_id][src].split(rule.data[26:], 1)
                    if rule.data[6:20] == "COPY_THE_PREFIX":
                        if len(split_data) == 2:
                            data = split_data[0]
                        else:
                            # we could not split the data with the seperator...
                            # ... so we cannot enter anything at this point
                            data = ""
                    else:
                        if len(split_data) == 2:
                            data = split_data[1]
                        else:
                            # we could not split the data with the seperator...
                            # ... so we cannot enter anything at this point
                            data = ""
                except:
                    data = ""
                dst_fields[dst] = fuzzer.fuzz(rule, data, fuzz_fields)
                continue
            if rule.typ == "rule.SeqRule":
                try:
                    data = int(fields[src_id][src])+int(rule.data[5:])
                except:
                    data = 0
                dst_fields[dst] = fuzzer.fuzz(rule, data, fuzz_fields)
                continue

            #save original not fuzzed values for the log trace
            if dst_fields[dst] == data:
                non_fuzzed_values += [data]

        # Fill new template fields with new content
        message = next_template.fillFields(dst_fields)
        fields = dst_fields.items()
        fields.sort(key=operator.itemgetter(0))

        #update tracker
        fuzzer.update_tracker(next_template.ID)
        fuzzer.trace = list(fuzz_fields), non_fuzzed_values
        print "fields_to_fuzz: ", fuzz_fields
        print ">>> FUZZING msg..."

        return (urllib.unquote(''.join(str(n) for n in message)),
                [f[1] for f in fields], transition)
dataset/ETHPy150Open hgascon/pulsar/pulsar/core/lens.py/RuleList.create_fuzzed_message/original