Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error when a BaseObjectPropertyType has delimeter but no valueOf_ #297

@apsillers

Description

@apsillers

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions