You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
is_plain() in VocabString causes issues with to_dict()/from_dict() round trip #174
The use of the is_plain() in the to_dict() method in VocabString (https://github.com/CybOXProject/python-cybox/blob/master/cybox/common/vocabs.py#L65-66) means that the xsi:type of the vocabulary is typically not returned in the dictionary. Accordingly, subsequent calls to from_dict() on this output means that the xsi:type will be set to the default value of BAD_XSI_TYPE.
Honestly, I think we should consider getting rid of these is_plain() methods. While they do simplify the output a little, they also cause these round-trip headaches, as well as the expectation that consumers will have to parse two different data structures (strings and dictionaries) depending on the type of data contained within.
I ended up changing the behavior of is_plain() in python-stix so that the xsi_type key is almost always exported. Also, BAD_XSI_TYPE was removed so that plain VocabString instances could be exported.
I have been working on a local branch to port over some of these changes to python-cybox, though it hasn't been super easy due to the use of TypedField.
Ah, interesting - thanks for the heads up on the approach you've taken in python-stix. I think always exporting the xsi_type key if it exists is a sensible approach, so we can likely make a similar change to the is_plain() method in python-cybox, at least as an interim solution.
I like keeping the "plain" string where possible and not exporting the xsi:type if it is the "standard" XSI type for that vocab. I'm not sure if it's something we can easily check, though.
On the other hand, I guess I'm OK if we never export the "plain" string (though it makes the JSON more verbose), as long as we support reading in both the plain and "full dictionary" forms of vocab strings.
Activity
bworrell commentedon Jun 19, 2014
I ended up changing the behavior of
is_plain()inpython-stixso that the xsi_type key is almost always exported. Also, BAD_XSI_TYPE was removed so that plain VocabString instances could be exported.I am currently working on some other issues in VocabString here:https://github.com/STIXProject/python-stix/blob/vocabs/stix/common/vocabs.py
I have been working on a local branch to port over some of these changes to
python-cybox, though it hasn't been super easy due to the use ofTypedField.bworrell commentedon Jun 19, 2014
Here is the issue driving the
python-stix/vocabsbranch and change set: STIXProject/python-stix#145ikiril01 commentedon Jun 19, 2014
Ah, interesting - thanks for the heads up on the approach you've taken in
python-stix. I think always exporting the xsi_type key if it exists is a sensible approach, so we can likely make a similar change to the is_plain() method inpython-cybox, at least as an interim solution.gtback commentedon Jul 2, 2014
I like keeping the "plain" string where possible and not exporting the xsi:type if it is the "standard" XSI type for that vocab. I'm not sure if it's something we can easily check, though.
gtback commentedon Jul 2, 2014
On the other hand, I guess I'm OK if we never export the "plain" string (though it makes the JSON more verbose), as long as we support reading in both the plain and "full dictionary" forms of vocab strings.