-
Notifications
You must be signed in to change notification settings - Fork 120
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
Dictionary Prop Adjustments #589
Dictionary Prop Adjustments #589
Conversation
|
We already have a way of expressing types via the Property subclasses. I think they should be used. Instead of "string_list", use ListProperty(StringProperty). You get much more generality for free that way, e.g. ListProperty(BooleanProperty), DictionaryProperty(DictionaryProperty(IntegerProperty)), etc. You can leverage the cleaning code which is already there, and gain consistency with how the type is dealt with in other places. E.g. insisting on ints for "integer" is not consistent with how they are handled in other properties. That full generality may be challenging to map into a relational database, but if there are limitations to that then it's good to know. Someone might create an object extension with a dictionary property which maps to something other than strings or ints, and want to use these facilities to enforce compliance. They can theoretically do pretty much whatever they want, and the library should support expressing that. Edit: spec section 2.3 says for dictionary values:
I think this includes all the basic common datatypes at least (integer, boolean, float, etc). So I think restricting values to strings, integers, and lists of strings, may lose spec compliance (e.g. prevent one from describing/processing compliant STIX content). |
When I originally wrote it, I used the Property classes, but the code got a little messy because StringProperty is a class, but ListProperty(StringProperty) is a class instance. However, because of the normative text you quoted, we should probably go back to using the Property classes. I have to think about what the implications are for the RelationalDB store. |
You say "You can leverage the cleaning code which is already there, and gain consistency with how the type is dealt with in other places." What Property class are you looking at? ReferenceProperties also takes property names. |
An example was:
IntegerProperty will try to convert non-ints to ints (via ReferenceProperty takes STIX object types and type categories (SCO, SDO, etc) in its constructor. That's not what we're dealing with here. We're dealing with property types (data types in the spec, section 2), which is different. There is no property of type "malware", for example. You wouldn't embed a whole object like that as a property value. You'd refer to it via a reference property, which is what ReferenceProperty is for. The property data type in this example is "identifier" (maybe the class should have been called IdentifierProperty?). Dealing with data types is what the property classes are for, so I thought we should use them. |
Again, looks good to me - but Andy knows this stuff better than I :-) Here are some things I noticed:
|
fe98187
to
cdd9707
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dictionary-property #589 +/- ##
=======================================================
+ Coverage 87.42% 87.45% +0.02%
=======================================================
Files 155 155
Lines 18096 18161 +65
=======================================================
+ Hits 15820 15882 +62
- Misses 2276 2279 +3 ☔ View full report in Codecov by Sentry. |
Address #588