def convert_marking_definition(marking20): definition = marking20["definition"] marking_spec = MarkingSpecification() if marking20["definition_type"] == "statement": tou = TermsOfUseMarkingStructure(terms_of_use=definition["statement"]) tou.id_ = convert_id20(marking20["id"]) marking_spec.marking_structures.append(tou) elif marking20["definition_type"] == "tlp": tlp = TLPMarkingStructure(color=definition["tlp"]) tlp.id_ = convert_id20(marking20["id"]) marking_spec.marking_structures.append(tlp) elif marking20["definition_type"] == "ais": identity20_tuple = _EXPLICIT_OBJECT_USED[marking20["created_by_ref"]] color = definition["tlp"].upper() if definition["is_proprietary"] == "true": proprietary = IsProprietary() consent = "EVERYONE" else: proprietary = NotProprietary() consent = definition["consent"].upper() proprietary.ais_consent = AISConsentType(consent=consent) proprietary.tlp_marking = TLPMarkingType(color=color) ais_marking = AISMarkingStructure() ais_marking.id_ = convert_id20(marking20["id"]) if isinstance(proprietary, IsProprietary): ais_marking.is_proprietary = proprietary else: ais_marking.not_proprietary = proprietary marking_spec.controlled_structure = "//node() | //@*" marking_spec.marking_structures.append(ais_marking) marking_spec.information_source = create_information_source( identity20_tuple) # Remove marking to CIQ identity. Special case for AIS. for mark_spec in CONTAINER.get_markings(identity20_tuple[0]): mark_struct = mark_spec.marking_structures[0] if mark_struct.idref and mark_struct.idref == ais_marking.id_: CONTAINER.remove_marking(identity20_tuple[0], mark_spec, True) record_id_object_mapping(marking20["id"], marking_spec.marking_structures[0]) if "object_marking_refs" in marking20: for m_id in marking20["object_marking_refs"]: ms = create_marking_specification(m_id) if ms: CONTAINER.add_marking(marking_spec, ms, descendants=True) if "granular_markings" in marking20: error( "Granular Markings present in '%s' are not supported by stix2slider", 604, marking20["id"]) return marking_spec