def _mutate(self): current_sequence_templates = [] for stage in self._stages: stage.mutate() current_sequence_templates.extend(stage.get_sequence_templates()) sequence = [] cb = self.callback_generator(None, current_sequence_templates[0]) sequence.append(Connection(None, current_sequence_templates[0], cb)) prev = current_sequence_templates[0] for t in current_sequence_templates[1:]: cb = self.callback_generator(prev, t) sequence.append(Connection(prev, t, cb)) prev = t self._sequence = sequence
def _sequence_from_templates(self, templates): sequence = [] prev = self.ROOT_NODE for t in templates: cb = self.callback_generator(prev, t) sequence.append(Connection(prev, t, cb)) prev = t return sequence
def connect(self, src, dst=None, callback=None): ''' :param src: source node, if dst is None it will be destination node and the root (dummy) node will be source :param dst: destination node (default: None) :type callback: func(fuzzer, edge, response) -> None :param callback: a function to be called after the response for src received and before dst is sent ''' assert src if dst is None: dst = src src = self._root src_id = src.hash() dst_id = dst.hash() if src_id not in self._graph: raise KittyException('source node id (%#x) (%s) is not in the node list ' % (src_id, src)) self._graph[src_id].append(Connection(src, dst, callback)) if dst_id not in self._graph: self._graph[dst_id] = []