From e82aaef29df80890dbdb15b5957694a9c16c56cd Mon Sep 17 00:00:00 2001 From: Amaury Leroy Date: Thu, 25 Oct 2018 14:41:03 +0200 Subject: [PATCH 1/3] Extract description from stix_header --- misp_stix_converter/converters/buildMISPAttribute.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misp_stix_converter/converters/buildMISPAttribute.py b/misp_stix_converter/converters/buildMISPAttribute.py index 0a4a28d..ec5d471 100644 --- a/misp_stix_converter/converters/buildMISPAttribute.py +++ b/misp_stix_converter/converters/buildMISPAttribute.py @@ -257,6 +257,10 @@ def buildEvent(pkg, **kwargs): title = "STIX Import" else: title = pkg.stix_header.title + if hasattr(pkg.stix_header, "description"): + log.debug("Found description %s", pkg.stix_header.description.value) + event.add_attribute("comment", pkg.stix_header.description.value) + log.info("Using title %s", title) log.debug("Seting up MISPEvent...") @@ -266,10 +270,6 @@ def buildEvent(pkg, **kwargs): event.analysis = kwargs.get("analysis", 0) event.info = title - if hasattr(pkg, "description"): - log.debug("Found description %s", pkg.description) - event.add_attribute("comment", pkg.description) - log.debug("Beginning to Lint_roll...") ids = [] to_process = [] From 983b31684a9cd56bb8461b9b15af6690158d0c06 Mon Sep 17 00:00:00 2001 From: Amaury Leroy Date: Fri, 26 Oct 2018 12:57:08 +0200 Subject: [PATCH 2/3] Fix -- variable 'event' referenced before assignment --- misp_stix_converter/converters/buildMISPAttribute.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/misp_stix_converter/converters/buildMISPAttribute.py b/misp_stix_converter/converters/buildMISPAttribute.py index ec5d471..ba39dec 100644 --- a/misp_stix_converter/converters/buildMISPAttribute.py +++ b/misp_stix_converter/converters/buildMISPAttribute.py @@ -257,9 +257,6 @@ def buildEvent(pkg, **kwargs): title = "STIX Import" else: title = pkg.stix_header.title - if hasattr(pkg.stix_header, "description"): - log.debug("Found description %s", pkg.stix_header.description.value) - event.add_attribute("comment", pkg.stix_header.description.value) log.info("Using title %s", title) @@ -270,6 +267,10 @@ def buildEvent(pkg, **kwargs): event.analysis = kwargs.get("analysis", 0) event.info = title + if pkg.stix_header and hasattr(pkg.stix_header, "description"): + log.debug("Found description %s", pkg.stix_header.description.value) + event.add_attribute("comment", pkg.stix_header.description.value) + log.debug("Beginning to Lint_roll...") ids = [] to_process = [] From b75faf2203be9fbc9dc8acf939de8a5edc0a02ed Mon Sep 17 00:00:00 2001 From: Amaury Leroy Date: Fri, 26 Oct 2018 13:15:21 +0200 Subject: [PATCH 3/3] Check if value field exists --- misp_stix_converter/converters/buildMISPAttribute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misp_stix_converter/converters/buildMISPAttribute.py b/misp_stix_converter/converters/buildMISPAttribute.py index ba39dec..60ae8e9 100644 --- a/misp_stix_converter/converters/buildMISPAttribute.py +++ b/misp_stix_converter/converters/buildMISPAttribute.py @@ -267,7 +267,7 @@ def buildEvent(pkg, **kwargs): event.analysis = kwargs.get("analysis", 0) event.info = title - if pkg.stix_header and hasattr(pkg.stix_header, "description"): + if pkg.stix_header and hasattr(pkg.stix_header, "description") and hasattr(pkg.stix_header.description, 'value'): log.debug("Found description %s", pkg.stix_header.description.value) event.add_attribute("comment", pkg.stix_header.description.value)