Example #1
0
    def scanvizmulti(self, ids, gexf="1"):
        """Export entities results from multiple scans in GEXF format

        Args:
            ids (str): scan IDs
            gexf (str): TBD

        Returns:
            string: GEXF data
        """
        dbh = SpiderFootDb(self.config)
        data = list()
        roots = list()

        if not ids:
            return None

        for id in ids.split(','):
            data = data + dbh.scanResultEvent(id, filterFp=True)
            scan = dbh.scanInstanceGet(id)
            if scan:
                roots.append(scan[1])

        if gexf == "0":
            # Not implemented yet
            return None

        cherrypy.response.headers['Content-Disposition'] = "attachment; filename=SpiderFoot.gexf"
        cherrypy.response.headers['Content-Type'] = "application/gexf"
        cherrypy.response.headers['Pragma'] = "no-cache"
        return SpiderFootHelpers.buildGraphGexf(roots, "SpiderFoot Export", data)
Example #2
0
    def scanviz(self, id, gexf="0"):
        """Export entities from scan results for visualising

        Args:
            id (str): scan ID
            gexf (str): TBD

        Returns:
            string: GEXF data
        """

        if not id:
            return None

        dbh = SpiderFootDb(self.config)
        data = dbh.scanResultEvent(id, filterFp=True)
        scan = dbh.scanInstanceGet(id)

        if not scan:
            return None

        root = scan[1]

        if gexf == "0":
            return SpiderFootHelpers.buildGraphJson([root], data)

        cherrypy.response.headers['Content-Disposition'] = "attachment; filename=SpiderFoot.gexf"
        cherrypy.response.headers['Content-Type'] = "application/gexf"
        cherrypy.response.headers['Pragma'] = "no-cache"
        return SpiderFootHelpers.buildGraphGexf([root], "SpiderFoot Export", data)
    def test_buildGraphGexf_should_return_bytes(self):
        """
        Test buildGraphGexf(root, title, data, flt=[])
        """
        gexf = SpiderFootHelpers.buildGraphGexf('test root', 'test title', [[
            "test", "test", "test", "test", "test", "test", "test", "test",
            "test", "test", "test", "ENTITY", "test", "test", "test"
        ]])
        self.assertIsInstance(gexf, bytes)

        self.assertEqual('TBD', 'TBD')