CybOXProject / python-cybox

A Python library for parsing, manipulating, and generating CybOX content.

Home Page:http://cybox.readthedocs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when a `BaseObjectPropertyType` has `delimeter` but no `valueOf_`

apsillers opened this issue · comments

I have a file that includes the following structure:

<cybox:Properties xsi:type="FileObj:FileObjectType">
    <FileObj:File_Path apply_condition="ANY" condition="Equals" delimiter="##FOOBAR##" />
....

I can read this structure into a Python model, but when I call to_xml to render it back, I get a error:

File "/usr/local/lib/python3.6/site-packages/cybox/bindings/cybox_common.py", line 3375, in exportAttributes
  if self.apply_condition is not None and (self.delimiter is not None and self.delimiter in self.valueOf_):

To avoid this, the binding logic for apply_condition can check if valueOf_ is not None before attempting the delimiter in valueOf_ check:

if self.apply_condition is not None and (self.delimiter is not None and self.valueOf_ is not None and self.delimiter in self.valueOf_):

There may be other places where this error could manifest as well, wherever the generated bindings require a string instead of None in valueOf_.

This could also be fixed outside the bindings (perhaps) by enforcing an empty-string value instead of None for valueOf_ in a self-closing tag.

Fixed by #298