fix: Allow misp_push to take multiple stix versions

pull/22/head
Hannah Ward 2017-08-18 10:52:42 +01:00
parent afd8a00c4e
commit e781d542b4
No known key found for this signature in database
GPG Key ID: 6F3BAD60DE190290
1 changed files with 20 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import pymisp
import warnings import warnings
from pyaml import yaml from pyaml import yaml
from cabby import create_client from cabby import create_client
from misp_stix_converter.converters import lint_roller
import logging import logging
# Set up logger # Set up logger
@ -72,12 +73,23 @@ while True:
log.debug("Loaded successfully!") log.debug("Loaded successfully!")
# Push the package to TAXII # Push the package to TAXII
try: for version in config.get("stix_versions", ["1.1.1"]):
cli.push(pkg.to_xml().decode("utf-8"), "urn:stix.mitre.org:xml:1.1.1", # Convert to that version
uri="{}://{}/services/inbox".format(config.get("protocol", "http"), config["domain"]), objs = lint_roller.lintRoll(pkg)
collection_names=config["taxii"].get("collections", ["collection"])) for i in objs:
# Set the object's version
if hasattr(i, "version"):
i.version = version
log.info("Pushed!") try:
except Exception as ex: cli.push(pkg.to_xml().decode("utf-8"),
log.fatal("COULD NOT PUSH") "urn:stix.mitre.org:xml:{}".format(version),
log.exception(ex) uri="{}://{}/services/inbox".format(config.get("protocol", "http"),
config["domain"]),
collection_names=config["taxii"].get("collections", ["collection"]))
log.info("Pushed! (%s)", version)
except Exception as ex:
log.fatal("COULD NOT PUSH")
log.exception(ex)