2018-05-16 14:39:01 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
"""
|
|
|
|
The Tags Module
|
|
|
|
================================
|
|
|
|
|
|
|
|
This module create tags.
|
|
|
|
|
|
|
|
"""
|
|
|
|
import time
|
|
|
|
|
|
|
|
from pubsublogger import publisher
|
|
|
|
from Helper import Process
|
2020-01-06 17:07:52 +01:00
|
|
|
from packages import Tag
|
2019-02-18 14:33:34 +01:00
|
|
|
|
2018-05-16 14:39:01 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
# Port of the redis instance used by pubsublogger
|
|
|
|
publisher.port = 6380
|
|
|
|
# Script is the default channel used for the modules.
|
|
|
|
publisher.channel = 'Script'
|
|
|
|
|
|
|
|
# Section name in bin/packages/modules.cfg
|
|
|
|
config_section = 'Tags'
|
|
|
|
|
|
|
|
# Setup the I/O queues
|
|
|
|
p = Process(config_section)
|
|
|
|
|
|
|
|
# Sent to the logging a description of the module
|
|
|
|
publisher.info("Tags module started")
|
|
|
|
|
|
|
|
# Endless loop getting messages from the input queue
|
|
|
|
while True:
|
|
|
|
# Get one message from the input queue
|
|
|
|
message = p.get_from_set()
|
|
|
|
|
|
|
|
if message is None:
|
|
|
|
publisher.debug("{} queue is empty, waiting 10s".format(config_section))
|
|
|
|
time.sleep(10)
|
|
|
|
continue
|
|
|
|
|
|
|
|
else:
|
2020-01-07 16:14:56 +01:00
|
|
|
print(message)
|
2020-01-06 17:07:52 +01:00
|
|
|
tag, item_id = message.split(';')
|
2019-10-17 16:39:43 +02:00
|
|
|
|
2020-01-06 17:07:52 +01:00
|
|
|
Tag.add_tag("item", tag, item_id)
|
2018-06-14 16:51:06 +02:00
|
|
|
p.populate_set_out(message, 'MISP_The_Hive_feeder')
|