New STIX 2.1 SCO extension name requirement: must end with "-ext" #370
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #364
I made more changes than you may think was strictly necessary, but I thought some aspects of the custom SCO extension code needed some improvement.
_custom_extension_builder
, which is the implementation for theCustomExtension
decorators (both 2.0 and 2.1). The former called_register_observable_extension
to enable the extension. So you could bypass most STIX2 requirements by bypassing the decorator and builder function and registering an extension directly. I decided that was undesirable, so I moved all of the requirement checking into the register function._CustomExtension
), which didn't make any sense and cluttered up the class. So a side effect of the above is that the class is a lot cleaner and clearer now.properties
had previously been documented as requiring a list of tuples. That seemed unnecessarily restrictive, so I changed the check to a more sensible one (I thought), and changed the exception message for a violation. Really, all you ever needed was something you can turn into a dict viaOrderedDict(...)
, which includes any mapping, as well as iterables of length-2-iterables (e.g. tuples of tuples, lists of lists, etc). One might argue that allowing unordered mappings means property order might be unpredictable. But if that's important, people don't have to use those types (and we never do that). I think the added flexibility is fine.version
default changed in the registration function. I needed a version so I could choose the right SCO extension name regex.None
doesn't fit the bill, but thestix2.DEFAULT_VERSION
does, and is immutable. The code already behaved that way, but didn't use the obvious implementation, so I simplified it and made my life easier.