oasis-tcs / cti-stix2

OASIS CTI TC: Provides issue tracking and wiki pages for the STIX 2.x Work Products
https://github.com/oasis-tcs/cti-stix2
Other
24 stars 9 forks source link

Clarification of default values and optional properties in spec #272

Open maybe-sybr opened 3 years ago

maybe-sybr commented 3 years ago

I submitted a couple of issues on the Python STIX2 implementation repo [0][1] which were the result of my misunderstanding the point of default values, specifically when applied to optional values. I had been under the impression that default values were an implementation convenience rather than something belonging to the STIX2 data model itself, and was suggesting that it should be easier to "unset" them when constructing new versions of objects using the Python implementation.

I was being foiled by the fact that, in a custom SCO definition, I had defined an optional timestamp field which defaulted to the current time; and I was unable to make that property go away for the purpose of naive object comparison (without those pesky timestamps which cause spurious diffs in my use cases) without serialising the object out of STIX into a native mapping object.

With a bit of discussion, @clenk pointed out the snippet which was added to section 3.6 regarding representations of STIX objects as a result of #150. This made it a bit more clear to me that default values aren't just implementation convenience and something a bit more embedded in the STIX data model. I also realised that part of my issue was that I was leaking information about a measuring system which wasn't meaningful to most of my observables of this type into the SCOs, and the spurious diffs were a symptom of that problem. I've since adjusted how I define my custom objects to be less pathological and life is good again.

The point of me making this issue is to see if it's worth adding some more content to the spec to describe that. It seems to me after jumping around a bit in the CS03 document, that default values are alluded to and used but not well described. I thought out loud a little in my most recent comment on [0] and I think in my perfect world, I'd like to see some or all of the following added to the spec:

Hopefully this isn't total nonsense :)

===== 8< ===== [0] oasis-open/cti-python-stix2#507 [1] oasis-open/cti-python-stix2#508