Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions misp_stix_converter/converters/buildMISPAttribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ def buildEvent(pkg, **kwargs):
log.debug("Found description %s", pkg.description)
event.add_attribute("comment", pkg.description)

if pkg.stix_header and hasattr(pkg.stix_header, "handling") and hasattr(pkg.stix_header.handling, "marking"):
for m in pkg.stix_header.handling.marking:
if hasattr(m, "controlled_structure") and hasattr(m.controlled_structure, "color"):
tlp = m.controlled_structure.color.lower()
log.debug("Found TLP %s", tlp)
tlp_tag = "tlp:" + tlp
log.debug("Add %s as MISP tag", tlp_tag)
event.add_tag(tlp_tag)
break

log.debug("Beginning to Lint_roll...")
ids = []
to_process = []
Expand Down
17 changes: 12 additions & 5 deletions misp_stix_converter/converters/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ def load_stix(stix):

ns_map = stixXml.nsmap

# Remove any "marking" sections because the US-Cert is evil
log.debug("Removing Marking elements...")
for element in stixXml.findall(".//{http://data-marking.mitre.org/Marking-1}Marking"):
element.getparent().remove(element)

log.debug("Writing cleaned XML to Tempfile")
f = SpooledTemporaryFile(max_size=10 * 1024)
f.write(etree.tostring(stixXml))
Expand Down Expand Up @@ -153,6 +148,18 @@ def load_stix(stix):
g.write(f.read())
raise STIXLoadError("Could not load stix file. {}".format(ex))

log.debug("Removing Marking elements except TLP...")
if hasattr(stix_package, 'stix_header') and hasattr(stix_package.stix_header, 'handling') and hasattr(stix_package.stix_header.handling, 'marking'):
for m in stix_package.stix_header.handling.marking:
if hasattr(m, 'marking_structures'):
for ms in m.marking_structures:
if hasattr(ms, 'color'):
log.debug('TLP found in marking_structures:%s', ms.color)
log.debug('Clear all handling elements')
stix_package.stix_header.handling.clear()
log.debug('Add only TLP marking_structures')
stix_package.stix_header.handling.add_marking(ms)
break
return stix_package

elif isinstance(stix, (str, bytes)):
Expand Down