Exemple #1
0
    def _get_infected_island_net_edges(monkey_island_monkey):
        existing_ids = [
            x.src_node_id for x in EdgeService.get_by_dst_node(
                dst_node_id=monkey_island_monkey["_id"])
        ]
        monkey_ids = [
            x.id for x in Monkey.objects()
            if ("tunnel" not in x) and (x.id not in existing_ids) and (
                x.id != monkey_island_monkey["_id"])
        ]
        edges = []

        count = 0
        for monkey_id in monkey_ids:
            count += 1
            # generating fake ID, because front end requires unique ID's for each edge. Collision
            # improbable
            fake_id = ObjectId(hex(count)[2:].zfill(24))
            src_label = NodeService.get_label_for_endpoint(monkey_id)
            dst_label = NodeService.get_label_for_endpoint(
                monkey_island_monkey["_id"])
            edge = DisplayedEdgeService.generate_pseudo_edge(
                edge_id=fake_id,
                src_node_id=monkey_id,
                dst_node_id=monkey_island_monkey["_id"],
                src_label=src_label,
                dst_label=dst_label,
            )
            edges.append(edge)

        return edges
Exemple #2
0
 def get_displayed_edges_by_dst(dst_id: str, for_report=False):
     edges = EdgeService.get_by_dst_node(dst_node_id=ObjectId(dst_id))
     return [
         DisplayedEdgeService.edge_to_displayed_edge(edge, for_report)
         for edge in edges
     ]