chg: [MispModules] use ConfigLoader

This commit is contained in:
Terrtia 2019-11-20 11:47:13 +01:00
parent f4fa811229
commit 96cbeddd92
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -10,18 +10,12 @@ misp_module_url = 'http://localhost:6666'
default_config_path = os.path.join(os.environ['AIL_HOME'], 'configs', 'misp_modules.cfg') default_config_path = os.path.join(os.environ['AIL_HOME'], 'configs', 'misp_modules.cfg')
configfile = os.path.join(os.environ['AIL_BIN'], 'packages/config.cfg') sys.path.append(os.path.join(os.environ['AIL_BIN'], 'lib/'))
if not os.path.exists(configfile): import ConfigLoader
raise Exception('Unable to find the configuration file. \
Did you set environment variables? \ config_loader = ConfigLoader.ConfigLoader()
Or activate the virtualenv.') r_serv = config_loader.get_redis_conn("ARDB_DB")
cfg = configparser.ConfigParser() config_loader = None
cfg.read(configfile)
r_serv = redis.StrictRedis(
host=cfg.get("ARDB_DB", "host"),
port=cfg.getint("ARDB_DB", "port"),
db=cfg.getint("ARDB_DB", "db"),
decode_responses=True)
def init_config(config_path=default_config_path): def init_config(config_path=default_config_path):
config = configparser.ConfigParser() config = configparser.ConfigParser()
@ -124,6 +118,8 @@ if __name__ == "__main__":
misp_module_url = 'http://localhost' misp_module_url = 'http://localhost'
misp_module_port = 6666 misp_module_port = 6666
test_content = build_enrichment_request_json('btc_steroids', 'btc', '1CSCdUXH2AzjsMb67KrshxyudThACT4Y8E')
bitcoin_address = 'bitcoin_address'
test_content = build_enrichment_request_json('btc_steroids', 'btc', bitcoin_address)
print(test_content) print(test_content)
misp_module_enrichment_request(misp_module_url, misp_module_port, test_content) misp_module_enrichment_request(misp_module_url, misp_module_port, test_content)