INNER CODE UNIT · Python
grab_external_id
mitre-attack/attack-scripts · scripts/technique_mappings_to_csv.py:65
def grab_external_id(stix_object, source_name):
"""Grab external id from STIX2 object"""
for external_reference in stix_object.get("external_references", []):
if external_reference.get("source_name") == source_name:
return external_reference["external_id"]
def remove_deprecated(stix_objects):
"""Will remove any revoked or deprecated objects from queries made to the data source"""
# Note we use .get() because the property may not be present in the JSON data. The default is False
# if the property is not set.
return list(
filter(
lambda x: x.get("x_mitre_deprecated", False) is False and x.get("revoked", False) is False,
stix_objects
)
)