Example #1
0
    def test_edge_to_displayed_edge(self):
        src_node_id = ObjectId()
        dst_node_id = ObjectId()
        edge = EdgeService(src_node_id=src_node_id,
                           dst_node_id=dst_node_id,
                           scans=SCAN_DATA_MOCK,
                           exploits=EXPLOIT_DATA_MOCK,
                           exploited=True,
                           domain_name=None,
                           ip_address="10.2.2.2",
                           dst_label="Ubuntu-4ubuntu2.8",
                           src_label="Ubuntu-4ubuntu3.2")

        displayed_edge = DisplayedEdgeService.edge_to_displayed_edge(edge)

        self.assertEqual(displayed_edge['to'], dst_node_id)
        self.assertEqual(displayed_edge['from'], src_node_id)
        self.assertEqual(displayed_edge['ip_address'], "10.2.2.2")
        self.assertListEqual(displayed_edge['services'],
                             ["tcp-8088: unknown", "tcp-22: ssh"])
        self.assertEqual(displayed_edge['os'], {
            "type": "linux",
            "version": "Ubuntu-4ubuntu2.8"
        })
        self.assertEqual(displayed_edge['exploits'], EXPLOIT_DATA_MOCK)
        self.assertEqual(
            displayed_edge['_label'],
            "Ubuntu-4ubuntu3.2 " + RIGHT_ARROW + " Ubuntu-4ubuntu2.8")
        self.assertEqual(displayed_edge['group'], "exploited")
        return displayed_edge
Example #2
0
    def test_edge_to_displayed_edge(self):
        src_node_id = ObjectId()
        dst_node_id = ObjectId()
        edge = EdgeService(
            src_node_id=src_node_id,
            dst_node_id=dst_node_id,
            scans=SCAN_DATA_MOCK,
            exploits=EXPLOIT_DATA_MOCK,
            exploited=True,
            domain_name=None,
            ip_address="10.2.2.2",
            dst_label="Ubuntu-4ubuntu2.8",
            src_label="Ubuntu-4ubuntu3.2",
        )

        displayed_edge = DisplayedEdgeService.edge_to_displayed_edge(edge)

        assert displayed_edge["to"] == dst_node_id
        assert displayed_edge["from"] == src_node_id
        assert displayed_edge["ip_address"] == "10.2.2.2"
        assert displayed_edge["services"] == [
            "tcp-8088: unknown", "tcp-22: ssh"
        ]
        assert displayed_edge["os"] == {
            "type": "linux",
            "version": "Ubuntu-4ubuntu2.8"
        }
        assert displayed_edge["exploits"] == EXPLOIT_DATA_MOCK
        assert displayed_edge[
            "_label"] == "Ubuntu-4ubuntu3.2 " + RIGHT_ARROW + " Ubuntu-4ubuntu2.8"
        assert displayed_edge["group"] == "exploited"
        return displayed_edge