From 32d19347b9212377d592283320405d9818d11508 Mon Sep 17 00:00:00 2001 From: Terrtia Date: Thu, 15 Sep 2022 10:47:45 +0200 Subject: [PATCH] chg: [feeder] add bgp_monitor importer --- .../Ail_feeder_bgp_monitor.py | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 bin/import/ail_json_importer/Ail_feeder_bgp_monitor.py diff --git a/bin/import/ail_json_importer/Ail_feeder_bgp_monitor.py b/bin/import/ail_json_importer/Ail_feeder_bgp_monitor.py new file mode 100755 index 00000000..6a72fd6c --- /dev/null +++ b/bin/import/ail_json_importer/Ail_feeder_bgp_monitor.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# -*-coding:UTF-8 -* +""" +The JSON Receiver Module +================ + +Recieve Json Items (example: Twitter feeder) + +""" +import os +import json +import sys +import datetime +import uuid + +from packages import Tag + +sys.path.append(os.path.join(os.environ['AIL_BIN'], 'lib')) +import item_basic + +sys.path.append(os.path.join(os.environ['AIL_BIN'], 'import', 'ail_json_importer')) +from Default_json import Default_json + +class Ail_feeder_urlextract(Default_json): + """urlextract Feeder functions""" + + def __init__(self, name, json_item): + super().__init__(name, json_item) + + def get_feeder_name(self): + return 'bgp_monitor' + + # # define item id + # def get_item_id(self): + # # use twitter timestamp ? + # item_date = datetime.date.today().strftime("%Y/%m/%d") + # item_id = str(self.json_item['meta']['twitter:url-extracted']) + # item_id = item_id.split('//') + # if len(item_id) > 1: + # item_id = ''.join(item_id[1:]) + # else: + # item_id = item_id[0] + # item_id = item_id.replace('/', '_') + # if len(item_id) > 215: + # item_id = '{}{}.gz'.format(item_id[:215], str(uuid.uuid4())) + # else: + # item_id = '{}{}.gz'.format(item_id, str(uuid.uuid4())) + # return os.path.join('urlextract', item_date, item_id) + + def process_json_meta(self, process, item_id): + ''' + Process JSON meta filed. + ''' + json_meta = self.get_json_meta() + + tag = 'infoleak:automatic-detection=bgp_monitor' + Tag.add_tag('item', tag, item_id)