oasis-open / cti-stix-slider

OASIS TC Open Repository: The repository cti-stix-slider supports development of a Python application to convert STIX 2.0 content to STIX 1.x content
https://cti-stix-slider.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
21 stars 15 forks source link

SerializerFieldNotFoundError: Could not generate an XPath for <stix.extensions.identity.ciq_identity_3_0.CIQIdentity3_0Instance object at 0x7fd6906b8400> #24

Closed ajnovice closed 6 years ago

ajnovice commented 6 years ago

In [2]: from stix2slider import slide_file ...: from stix2slider.options import initialize_options as slider_options ...: from stix2validator import validate_file ...: slider_options() ...: result=validate_file(file_name) ...: print("Valid :",result.is_valid) ...: if result.is_valid: ...: results = slide_file(file_name) ...: print(results) ...:
Valid : True [stixmarx.fields] [INFO ] [2018-05-18 14:47:43,608] No compatible cybox 2.1.0.17 mappings found. Loaded latest unchanged 2.1.0.16 field mappings. [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,829] labels not representable in a STIX 1.x ToolInformation. Found in tool--ce45f721-af14-4fc0-938c-000c16186418 [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,831] labels not representable in a STIX 1.x ToolInformation. Found in tool--e9778c42-bc2f-4eda-9fb4-6a931834f68c [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,832] labels not representable in a STIX 1.x ToolInformation. Found in tool--1cf6a3b8-be43-4c1a-b042-546a890c31b2 [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,833] labels not representable in a STIX 1.x ToolInformation. Found in tool--4d82bd3e-24a3-4f9d-b8f3-b57267fe06a9 [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,834] labels not representable in a STIX 1.x ToolInformation. Found in tool--7de5dfcc-6809-4772-9f11-cf26c2be53aa [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,835] labels not representable in a STIX 1.x ToolInformation. Found in tool--266b12f2-aa16-4607-809e-f2d33eebb52e [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,836] labels not representable in a STIX 1.x ToolInformation. Found in tool--98fd8dc1-6cc7-4908-899f-07473f55149a [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,838] labels not representable in a STIX 1.x ToolInformation. Found in tool--4215b0e5-928e-4b2a-9b5f-64819f287f48 [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,839] labels not representable in a STIX 1.x ToolInformation. Found in tool--a6dd62d0-9683-48bf-a9cd-61e7eceae57e [stix2slider.options] [502] [WARNING] [2018-05-18 14:47:43,840] labels not representable in a STIX 1.x ToolInformation. Found in tool--806a8f83-4913-4216-bb19-02b48ae25da5

SerializerFieldNotFoundError Traceback (most recent call last)

in () 6 print("Valid :",result.is_valid) 7 if result.is_valid: ----> 8 results = slide_file(file_name) 9 print(results) 10 ~/Cyware/source-code/CTIX-S/ctixserver/stix2slider/__init__.py in slide_file(fn, encoding) 17 obj = stix2.parse(json_content) 18 # TODO: validate STIX 2.0 content - what to do if it is invalid?? ---> 19 stix_package = convert_bundle(obj) 20 21 if stix_package: ~/Cyware/source-code/CTIX-S/ctixserver/stix2slider/convert_stix.py in convert_bundle(bundle_obj) 960 for k, v in _KILL_CHAINS.items(): 961 pkg.ttps.kill_chains.append(v["kill_chain"]) --> 962 CONTAINER.flush() 963 CONTAINER = None 964 return pkg ~/Cyware/source-code/CTIX-S/venv/lib/python3.5/site-packages/stixmarx/container.py in flush(self) 319 """ 320 writer = serializer.MarkingSerializer(marking_container=self) --> 321 writer._apply_markings() 322 323 # Reset the collections so we don't return duplicates ~/Cyware/source-code/CTIX-S/venv/lib/python3.5/site-packages/stixmarx/serializer.py in _apply_markings(self) 96 def _apply_markings(self): 97 self._apply_global_markings() ---> 98 self._apply_field_markings() 99 self._apply_null_markings() 100 ~/Cyware/source-code/CTIX-S/venv/lib/python3.5/site-packages/stixmarx/serializer.py in _apply_field_markings(self) 79 80 for field, markings_info in iteritems(field_markings): ---> 81 self._apply_markings_to_field(field, markings_info) 82 83 def _apply_null_markings(self): ~/Cyware/source-code/CTIX-S/venv/lib/python3.5/site-packages/stixmarx/serializer.py in _apply_markings_to_field(self, field, marking_info) 68 marking = copy.deepcopy(marking) 69 marking.controlled_structure, handling =\ ---> 70 self._find_path_and_handling(field, descendants) 71 72 handling.add_marking(marking) ~/Cyware/source-code/CTIX-S/venv/lib/python3.5/site-packages/stixmarx/serializer.py in _find_path_and_handling(self, field, descendants) 210 error = "Could not generate an XPath for {0}".format(field) 211 raise errors.SerializerFieldNotFoundError(entity=field, --> 212 message=error) 213 214 xpath = xml.XPATH_SELECT_OPERATOR.join(xpath) SerializerFieldNotFoundError: Could not generate an XPath for
rpiazza commented 6 years ago

Hi @ajnovice,

I think we have a fix for this which will be merged in soon. Basically, data markings in STIX 1.x do not have an information_source property, so we can't find the CIQ object when it is trying to create the XPath.

gtback commented 6 years ago

@rpiazza @emmanvg what is the status of this?

rpiazza commented 6 years ago

Fixed in 7fe85e744c4bf6f9c2e1ec9190a9c689f124431d