Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinEventLog (possibly others) type field cannot be serialized to XML #267

Closed
bworrell opened this issue Jul 6, 2015 · 2 comments
Closed
Assignees
Milestone

Comments

@bworrell
Copy link
Contributor

bworrell commented Jul 6, 2015

If I build a WinEventLog object and set the type field on it, I get the following error during to_xml():

Python 2.7.8 (default, Jul 28 2014, 01:34:03)
[GCC 4.8.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cybox.objects.win_event_log_object import WinEventLog
>>> w = WinEventLog()
>>> w.type = "foobar"
>>> print w.to_xml()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bworrell/.virtualenvs/openioc-to-stix/lib/python2.7/site-packages/cybox/__init__.py", line 295, in to_xml
    self.to_obj().export(
  File "/home/bworrell/.virtualenvs/openioc-to-stix/lib/python2.7/site-packages/cybox/common/object_properties.py", line 105, in to_obj
    return super(ObjectProperties, self).to_obj(return_obj=return_obj, ns_info=ns_info)
  File "/home/bworrell/.virtualenvs/openioc-to-stix/lib/python2.7/site-packages/cybox/__init__.py", line 142, in to_obj
    val = getattr(self, field.attr_name)
AttributeError: 'WinEventLog' object has no attribute 'type_'

I believe this is due to the TypedField.attrname property, which converts the XML fieldname "Type" to "type" and then appends an underscore because it's a builtin function. We should probably convert those to type_ as we did in #213.

This probably causes issues with the WinNetworkShare object's type field as well.

Related to #188.

@bworrell
Copy link
Contributor Author

bworrell commented Jul 6, 2015

I am using 2.1.0.11.

@gtback gtback self-assigned this Jul 6, 2015
@gtback
Copy link
Contributor

gtback commented Jul 6, 2015

Yep. This never got caught in our round-trip tests since those just go to and from dictionaries, never with direct attribute assignment. This also affects Disk and DiskPartition. I'm fixing all of them.

@gtback gtback closed this as completed in 6316ca2 Jul 6, 2015
@gtback gtback added this to the v2.1.0.12 milestone May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants