Exemplo n.º 1
0
    def handle_node(self, msg):
        meta_data = QueueNode.get_metadata(msg["task"]["nid"])
        payload = QueueNode.get_payload(meta_data["info"]["exit_reason"],
                                        meta_data["id"])

        results, new_payload = self.logic.process_node(payload, meta_data)
        if new_payload:
            default_info = {
                "method": "validate_bits",
                "parent": meta_data["id"],
                "IoControlCode": meta_data["info"]["IoControlCode"]
            }
            if self.validate_bits(new_payload, meta_data, default_info):
                log_slave(
                    "Stage %s found alternative payload for node %d" %
                    (meta_data["state"]["name"], meta_data["id"]),
                    self.slave_id)
            else:
                log_slave(
                    "Provided alternative payload found invalid - bug in stage %s?"
                    % meta_data["state"]["name"], self.slave_id)

        if self.exec_count > EXEC_LIMIT:  # Fuzzing next queue
            self.exec_count = 0
            self.conn.send_next_queue()

        self.conn.send_node_done(meta_data["id"], results, new_payload)
Exemplo n.º 2
0
 def handle_task(self, msg):
     if msg["task"]["type"] == "import":
         meta_data = {"state": {"name": "import"}}
         payload = msg["task"]["payload"]
     elif msg["task"]["type"] == "node":
         meta_data = QueueNode.get_metadata(msg["task"]["nid"])
         payload = QueueNode.get_payload(meta_data["info"]["exit_reason"],
                                         meta_data["id"])
     print
     "slave %d got task %d %s" % (self.slave_id, meta_data.get(
         "node", {}).get("id", -1), repr(meta_data))
     self.statistics.event_task(msg["task"])
     results, new_payload = self.logic.process(payload, meta_data)
     node_id = None
     if new_payload != payload:
         default_info = {
             "method": "validate_bits",
             "parent": meta_data["id"]
         }
         if self.validate_bits(new_payload, meta_data, default_info):
             print("VALIDATE BITS OK")
         else:
             print(
                 "VALIDATE BITS FAILED BUG IN TRANSFORMATION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
             )
             # assert False
     if results:
         node_id = meta_data["id"]
     self.conn.send_task_performed(node_id, results, new_payload)