Ejemplo n.º 1
0
def main():
    db = tls_profiler_mongodb_wrapper(HOST, PORT, DATABASE)
    pprint(db.get_main_extension_count())
    pprint("ASC")
    pprint(db.get_certificate_issuer_count(SortOrder.ASCENDING))
    pprint("DESC")
    pprint(db.get_certificate_issuer_count(SortOrder.DESCENDING))
    db.dump_collection('main')
    db.close()
Ejemplo n.º 2
0
    def get_certificate_key_algorithms(self, sort=SortOrder.NONE, snap_shot=None):
        """
        :param sort: sorting ordering 1-Descending, -1-Ascending, None - 0.
        :param snap_shot: snap ID for a particular timestamp.
        :return: Dictionary of all Certificate key algorithms and it's accumulated count.
        """
        tls_cert_key_dict = {}
        db = tls_profiler_mongodb_wrapper(HOST, PORT, DATABASE)
        tls_cert_key_list = db.get_certificate_key_algorithm_count(sort, snap_shot)
        db.close()
        for item in tls_cert_key_list:
            tls_cert_key_dict.update({item['_id']: item['count']})

        return tls_cert_key_dict
Ejemplo n.º 3
0
    def get_main_tls_negotiated_ciphers(self, sort=SortOrder.NONE, snap_shot=None):
        """
        :param sort: sorting ordering 1-Descending, -1-Ascending, None - 0.
        :param snap_shot: snap ID for a particular timestamp.
        :return: Dictionary of all the negotiated ciphers
        """
        tls_cipher_dict = {}
        db = tls_profiler_mongodb_wrapper(HOST, PORT, DATABASE)
        tls_cipher_list = db.get_main_negotiated_cipher(sort, snap_shot)
        db.close()
        for item in tls_cipher_list:
            tls_cipher_dict.update({item['_id']: item['count']})

        return tls_cipher_dict
Ejemplo n.º 4
0
    def onLoad_tls_timestamp_options(self):
        """
        :return: list of all Tls timestamps, where tls profiler ran
        """
        tls_timestamp = list()
        db = tls_profiler_mongodb_wrapper(HOST, PORT, DATABASE)
        snap_list = db.get_snap_shots()
        db.close()
        for item in snap_list:
            temp_dict = {}
            temp_dict.update({'label': str(item['date']), 'value': item['snap']})
            tls_timestamp.append(temp_dict)

        return tls_timestamp
Ejemplo n.º 5
0
    def get_tls_extension_dict(self, tls_ext=None, snap_shot=None):
        """
        For a particular tls extension, get the count and
        return a dictionary in the below format, so that we can
        feed it to the Dash graph framework.
        dict = { "extension_label" : count,
                 "no extension_label" : no_count }
        :return: dictionary of the extension label and it's value
        """
        extension_dict = {}
        db = tls_profiler_mongodb_wrapper(HOST, PORT, DATABASE)
        ext_list = db.get_main_extension_count(snap_shot=snap_shot)
        db.close()
        for item in ext_list:
            if item['_id'] == tls_ext:
                total_count = db.get_main_entry_count()
                no_tls_ext = "No " + tls_ext
                no_count = total_count - item['count']
                extension_dict.update({tls_ext: item["count"], no_tls_ext: no_count})

        return extension_dict
Ejemplo n.º 6
0
    def get_top_certificate_issuer_dict(self, num=10, everyone=False, snap_shot=None):
        """
        :param num: Top n certificate issuers
        :param everyone: if everyone is set to True, we will return the
        entire list of certificate issuers.
        :return: dictionary of top "n" or all certificate issuer_dict
        default will return top 10 issuers dict
        """
        issuer_dict = {}
        db = tls_profiler_mongodb_wrapper(HOST, PORT, DATABASE)
        issuer_list = db.get_certificate_issuer_count(SortOrder.DESCENDING, snap_shot=snap_shot)
        db.close()
        issuer_count = len(issuer_list)
        if (num > issuer_count) or (everyone is True):
            """ if everyone is set to true, user wants to get the entire
                list of certificate issuers.
            """
            num = issuer_count
        iterator = islice(issuer_list, num)
        for item in iterator:
            issuer_dict.update({item['_id']: item["count"]})

        return issuer_dict
Ejemplo n.º 7
0
PORT = 27017


def main():
    db = tls_profiler_mongodb_wrapper(HOST, PORT, DATABASE)
    pprint(db.get_main_extension_count())
    pprint("ASC")
    pprint(db.get_certificate_issuer_count(SortOrder.ASCENDING))
    pprint("DESC")
    pprint(db.get_certificate_issuer_count(SortOrder.DESCENDING))
    db.dump_collection('main')
    db.close()


if __name__ == '__main__':
    #main()
    dashutil = Dashboard_Mongo_Util()
    db = tls_profiler_mongodb_wrapper(HOST, PORT, DATABASE)
    pprint(db.get_main_extension_count())
    temp = dashutil.get_ems_ext_dict()
    pprint(temp)
    temp = {}
    temp = dashutil.get_server_name_ext_dict()
    pprint(temp)
    pprint(dashutil.get_certificate_issuer_dict())
    pprint("==========================================")
    pprint(dashutil.get_top_certificate_issuer_dict(num=10))
    pprint("==========================================")

    pprint(db.get_certificate_entry_count())