<commit_before># -*- coding: utf-8 -*-

"""
    A Bot to collect data from the Certificate Transparency Log (CTL)
    This bot works based on certstream libary (https://github.com/CaliDog/certstream-python)
    @author: <NAME>, <NAME> (Telekom Security)
    No parameters necessary.

"""
import json
import sys
import certstream

from intelmq.lib.bot import Bot
from intelmq.lib.message import Report


class CertstreamCollectorBot(CollectorBot):

    def init(self):

        self.logger.debug("Nothing to init.")

    def callback(self, message, context=None):  # callback handler for certstream events.
        CertstreamCollectorBot.send_update(message=message, self=self)

    def process(self):
        certstream.listen_for_events(self.callback)

    def send_update(self, message):

        # self.logger.debug("Received new certificate update.")
        report = Report()

        if message['message_type'] == 'heartbeat':
            return

        if message['message_type'] == 'certificate_update':
            new_report = report.copy()
            new_report.add("feed.name", "Certstream")
            new_report.add("raw", json.dumps(message))
<commit_msg>Removed init message (was a good idea to see that the bot initialized, but anyway)<commit_after># -*- coding: utf-8 -*-

"""
    A Bot to collect data from the Certificate Transparency Log (CTL)
    This bot works based on certstream libary (https://github.com/CaliDog/certstream-python)
    @author: <NAME>, <NAME> (Telekom Security)
    No parameters necessary.

"""
import json
import sys
import certstream

from intelmq.lib.bot import Bot
from intelmq.lib.message import Report


class CertstreamCollectorBot(CollectorBot):

    def init(self):

        return

    def callback(self, message, context=None):  # callback handler for certstream events.
        CertstreamCollectorBot.send_update(message=message, self=self)

    def process(self):
        certstream.listen_for_events(self.callback)

    def send_update(self, message):

        # self.logger.debug("Received new certificate update.")
        report = Report()

        if message['message_type'] == 'heartbeat':
            return

        if message['message_type'] == 'certificate_update':
            new_report = report.copy()
            new_report.add("feed.name", "Certstream")
            new_report.add("raw", json.dumps(message))

{'fraction_non_alphanumeric': 0.10906040268456375, 'fraction_numerical': 0.0008389261744966443, 'mean_word_length': 3.2137809187279154, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '978174', 'n_tokens_mistral': 676, 'n_tokens_neox': 652, 'n_words': 186}