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

import os
import unittest

import intelmq.lib.test as test
import intelmq.lib.utils as utils

from intelmq.bots.parsers.nothink.parser_dns_attacks import NothinkDNSAttackParserBot

with open(os.path.join(os.path.dirname(__file__), 'honeypot_dns_attacks.txt')) as handle:
    EXAMPLE_FILE = handle.read()

EXAMPLE_REPORT = {'feed.url': 'http://www.nothink.org/honeypot_dns_attacks.txt',
                  'feed.name': 'DNS Attacks',
                  '__type': 'Report',
                  'raw': utils.base64_encode(EXAMPLE_FILE),
                  'time.observation': '2016-11-22T08:26:00+00:00'
                  }

EXAMPLE_EVENT = {'feed.url': 'http://www.nothink.org/honeypot_dns_attacks.txt',
                 'feed.name': 'DNS Attacks',
                 '__type': 'Event',
                 'raw': 'MjAxNi0xMS0xMSAxNToxMzoyMCwxODYuMi4xNjcuMTQsMjYyMjU0LERBTkNPTSBMVEQsLCwgQlosZGRvcy1ndWFyZC5uZXQsQlo=',
                 'time.source': '2016-11-11T15:13:20+00:00',
                 'source.ip': '172.16.31.10',
                 'source.asn': '262254',
                 'source.as_name': 'DANCOM LTD,,, BZ',
                 'source.reverse_dns': 'ddos-guard.net',
                 'source.geolocation.cc': 'BZ',
                 'classification.type': 'ddos',
                 'event_description.text': 'On time.source the source.ip was seen performing '
                                           'DNS amplification attacks against honeypots',
                 'protocol.application': 'dns'
                 }

class TestNothinkDNSAttackParserBot(test.BotTestCase, unittest.TestCase):
    """ A TestCase for NothinkDNSAttackParserBot """

    @classmethod
    def set_bot(cls):
        cls.bot_reference = NothinkDNSAttackParserBot
        cls.default_input_message = EXAMPLE_REPORT<commit_msg>Nothink DNS Attack Parser<commit_after># -*- coding: utf-8 -*-

import os
import unittest

import intelmq.lib.test as test
import intelmq.lib.utils as utils

from intelmq.bots.parsers.nothink.parser_dns_attacks import NothinkDNSAttackParserBot

with open(os.path.join(os.path.dirname(__file__), 'honeypot_dns_attacks.txt')) as handle:
    EXAMPLE_FILE = handle.read()

EXAMPLE_REPORT = {'feed.url': 'http://www.nothink.org/honeypot_dns_attacks.txt',
                  'feed.name': 'DNS Attacks',
                  '__type': 'Report',
                  'raw': utils.base64_encode(EXAMPLE_FILE),
                  'time.observation': '2016-11-22T08:26:00+00:00'
                  }

EXAMPLE_EVENT = {'feed.url': 'http://www.nothink.org/honeypot_dns_attacks.txt',
                 'feed.name': 'DNS Attacks',
                 '__type': 'Event',
                 'raw': 'MjAxNi0xMS0xMSAxNToxMzoyMCwxODYuMi4xNjcuMTQsMjYyMjU0LERBTkNPTSBMVEQsLCwgQlosZGRvcy1ndWFyZC5uZXQsQlo=',
                 'time.source': '2016-11-11T15:13:20+00:00',
                 'source.ip': '172.16.31.10',
                 'source.asn': 262254,
                 'source.as_name': 'DANCOM LTD,,, BZ',
                 'source.reverse_dns': 'ddos-guard.net',
                 'source.geolocation.cc': 'BZ',
                 'classification.type': 'ddos',
                 'event_description.text': 'On time.source the source.ip was seen performing '
                                           'DNS amplification attacks against honeypots',
                 'protocol.application': 'dns'
                 }

class TestNothinkDNSAttackParserBot(test.BotTestCase, unittest.TestCase):
    """ A TestCase for NothinkDNSAttackParserBot """

    @classmethod
    def set_bot(cls):
        cls.bot_reference = NothinkDNSAttackParserBot
        cls.default_input_message = EXAMPLE_REPORT
{'fraction_non_alphanumeric': 0.12214983713355049, 'fraction_numerical': 0.03257328990228013, 'mean_word_length': 2.2784697508896796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2013140', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1235, 'n_words': 188}