Commit Graph

183 Commits (8bbf5fa4616efafb93bc089c8f1d9c8c0e6c2043)

Author SHA1 Message Date
Michael Chisholm 8bbf5fa461 Make extension instances work the same as other objects, with
respect to properties.  Before, properties were declared on
toplevel-property-extension extensions as if they were going
to be used in the normal way (as actual properties on instances
of the extension), but they were not used that way, and there
was some ugly hackage to make it work.  Despite the fact that
property instances were given during extension registration,
they were not used to typecheck, set defaults, etc on toplevel
property extension properties.

I changed how registration and object initialization works with
respect to properties associated with extensions.  Now,
extensions work the same as any other object and code is
cleaner.  Property instances associated with registered toplevel
extensions are used to enforce requirements like any other
object.

Added some unit tests specifically for property cleaning for
extensions.

Property order (for those contexts where it matters) is updated
to be spec-defined, toplevel extension, custom.
2021-07-06 14:27:40 -04:00
Michael Chisholm 93d2524d45 Remove excessive nested lists from CusomObservable decorator.
Remove iterable chaining from CustomObject decorator.  If all
values are guaranteed lists now, it no longer makes sense to use
it.  Simpler and clearer to use plain old list concatenation.
2021-07-02 21:10:52 -04:00
Michael Chisholm b9eba77008 Move the CustomExtension decorator from the v21.observables module
to v21.common.  Custom extensions are not specific to SCOs, so I
don't know why it was in that module.  Now, ExtensionDefinition
and CustomExtension are together in the same module, just like
MarkingDefinition and CustomMarking are together.  Made sense to
me.
2021-07-02 20:54:54 -04:00
Michael Chisholm d87718c15c Bug fixes, hackage removal, and some pre-commit stylistic
fixes.

- Fixed bugged logic in _STIXBase._check_at_least_one_property(),
and revamped the code to be simpler and clearer.

- Changed custom extension registration to auto-create an
"extension_type" property based on the attribute of that
name on the custom class, if present.

- The custom extension registration change above uncovered
what seemed like a bug in a unit test: a custom extension
was registered, but it was not given an extension type.  The
test used the extension as extension_type="property-extension";
this now causes a standard error about an extra property.  I
fixed the test to assign the custom extension the proper type.
2021-06-30 17:50:00 -04:00
Michael Chisholm 70718063d3 Remove relics of the old way customization was handled and
enforced, from _STIXBase20 and _STIXBase21.  That awkwardness
is no longer necessary.
2021-06-25 22:10:31 -04:00
Michael Chisholm 47b864cb4d Fix v21 ExtensionDefinition class to use the enum constant from
the vocab module for extension-type-enum, instead of replicating
that list.
2021-06-25 22:06:52 -04:00
Michael Chisholm e17f3e6c1c Add constants to the v21 vocab module for extension-type-enum 2021-06-25 22:04:59 -04:00
Chris Lenk 2528077eb0 Merge branch 'master' into dev-extensions-proposal 2021-06-13 01:48:33 -04:00
Michael Chisholm 2b064872a4 Add variables for each individual enum value in the vocab modules. 2021-04-15 22:06:57 -04:00
Michael Chisholm e735b537c7 Remove a workaround which was used in the 2.0 and 2.1 Report
objects, to structure object_refs type requirements as an empty
blacklist, instead of a whitelist.  I think it was originally
necessary due to the older implementation of ReferenceProperty
which was in place at the time.  With the implementation change
to invert whitelists with generics to blacklists when
allow_custom=True, a "full" whitelist is internally converted to
an empty blacklist anyway, so it winds up being the same thing.
But I think the full whitelist looks better in the code, so I
prefer that to the empty blacklist.
2021-03-31 20:56:31 -04:00
Emmanuelle Vargas-Gonzalez af046beeb5 add new-sdo or new-sro option in CustomObject decorator, add a test, and example in guide 2021-03-31 18:46:37 -04:00
Emmanuelle Vargas-Gonzalez 08d5781f54 add entry on extensions.ipynb, typos, and a couple of fixes for registry module and Marking decorator 2021-03-31 18:11:38 -04:00
Michael Chisholm c8c4e89415 Add back usage of spec_version where HashesProperty is used for
various STIX objects.  Also pre-commit stylistic fixes...
2021-03-31 16:20:33 -04:00
Michael Chisholm c590de8ea5 Add proper customization enforcement for open vocabs. This adds
a new OpenVocabProperty class.  It also requires a redesign of
HashesProperty and redoes general library support for hash
algorithms.
2021-03-31 16:20:28 -04:00
Michael Chisholm 387ce7e7cb Fix Report SDO: I'd fixed ReferenceProperty to work the way I
thought it should, but forgot to fix Report to use
ReferenceProperty in the way I thought it should!  Oops.
Added some tests to ensure Report is working property with
custom ID types in object_refs.
2021-03-31 15:22:00 -04:00
Michael Chisholm d2f960f2fc Initial revamp of customization enforcement and detection. 2021-03-31 15:21:55 -04:00
Emmanuelle Vargas-Gonzalez bde9aaa13e update some TODOs and clear out some backwards kept imports (breaking) 2021-03-30 22:40:41 -04:00
Emmanuelle Vargas-Gonzalez d5e6226c82 update hyperlinks to STIX 2.1 CS 02 2021-02-19 23:27:41 -05:00
Emmanuelle Vargas-Gonzalez 479cff818a few leftover changes... 2021-02-19 22:15:11 -05:00
Emmanuelle Vargas-Gonzalez 9043a9dc8e Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into dev-extensions-proposal 2021-02-19 21:54:46 -05:00
Emmanuelle Vargas-Gonzalez 5067a3ff76 couple of changes after merging against master 2021-02-19 10:05:56 -05:00
Chris Lenk b4a0a9ea10 Remove six dependency (backwards breaking)
We've already removed Python 2 from our test harness, but this removes
all python 2 compatibility code left in.
2021-02-18 12:38:35 -05:00
Emmanuelle Vargas-Gonzalez 77d20c787a
Update observables.py
Add missing common properties in decorator closes #484
2021-01-27 11:31:14 -05:00
Emmanuelle Vargas-Gonzalez a62dfbb41b missing common properties on CustomObservable decorator 2021-01-26 22:17:03 -05:00
Emmanuelle Vargas-Gonzalez 367b485fcd write some tests to check new MarkingDefinition constraints 2021-01-15 16:01:36 -05:00
Emmanuelle Vargas-Gonzalez 82390ba648 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into dev-extensions-proposal 2021-01-15 13:01:30 -05:00
Emmanuelle Vargas-Gonzalez 85c14d1502 all changes from add-trailing-commas v2.0.2 2021-01-13 17:52:15 -05:00
Emmanuelle Vargas-Gonzalez a86b21dbf7 add checks for MarkingDefinition requirements 2020-12-23 16:15:31 -05:00
Emmanuelle Vargas-Gonzalez 6a6f13c37b rename the Class auto-naming from 'STIXExtension' to 'ExtensionDefinition' 2020-12-23 16:07:30 -05:00
Emmanuelle Vargas-Gonzalez a3fce3686a Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into dev-extensions-proposal 2020-12-23 15:08:10 -05:00
Emmanuelle Vargas-Gonzalez ef2ef95c3a `stix-extension` to `extension-definition` 2020-12-22 21:59:18 -05:00
Emmanuelle Vargas-Gonzalez 4127ea9afd modify main codebase based on 7.3 Extension changes 2020-12-22 21:41:46 -05:00
Emmanuelle Vargas-Gonzalez 33a472d8f5 define Incident stub 2020-12-22 17:46:29 -05:00
Emmanuelle Vargas-Gonzalez 119364c889
Merge branch 'master' into 472-issue 2020-11-20 10:02:46 -05:00
Emmanuelle Vargas-Gonzalez e7242c9ae6 forgot one... 2020-11-19 08:48:57 -05:00
Emmanuelle Vargas-Gonzalez 49985cc51d fix ordering problem with Class definitions 2020-11-18 19:01:12 -05:00
Emmanuelle Vargas-Gonzalez c9bafaf5ae fix typo for Class X509V3ExtensionsType 2020-11-18 18:08:57 -05:00
Michael Chisholm f5bbbe7a3b Fix bug with reference type enforcement on property
where_sighted_refs on Sighting.
2020-11-16 15:04:24 -05:00
Emmanuelle Vargas-Gonzalez aa77f2b174 add test cases
additional file changes based on test cases
2020-11-10 21:09:17 -05:00
Emmanuelle Vargas-Gonzalez e4165f96aa major changes to support the extension mechanism
moved some version specific logic into their area, changes to decorators to support Object Registration with Extension
2020-11-10 18:32:58 -05:00
Emmanuelle Vargas-Gonzalez 22c4351688 flatten the extensions map, remove enclosing_type from ExtensionsProperty
other minor changes
2020-11-10 17:08:51 -05:00
Emmanuelle Vargas-Gonzalez 4340be13c4 changes to the ExtensionsProperty 2020-11-09 20:58:34 -05:00
Emmanuelle Vargas-Gonzalez 5cb52844dc fixing typos on Object types 2020-11-05 12:56:30 -05:00
Emmanuelle Vargas-Gonzalez b17f502e8f expose the "extensions" property on all object types
remove restriction on MarkingDefinition Object
2020-10-19 22:18:45 -04:00
Emmanuelle Vargas-Gonzalez 1bc11ce442 define the STIXExtension Object 2020-10-19 22:08:51 -04:00
Emmanuelle Vargas-Gonzalez 97dfe092f9 re-order properties 2020-10-19 19:23:30 -04:00
Chris Lenk 806389117f Allow mixing single objects and lists in bundles
...in bundle constructor

Related: #429.
2020-07-20 00:24:36 -04:00
Michael Chisholm d888eb60e2 Remove protocol_family and its uses from the v21 network
socket SCO extension.  It's a 2.0 property that got copied into
the 2.1 code by mistake.
2020-07-08 14:26:02 -04:00
Chris Lenk 8e785cbd05 Remove outdated comment 2020-07-06 16:42:33 -04:00
Emmanuelle Vargas-Gonzalez 9a0cb02ab3 nit-pick on v21 Indicator constructor 2020-06-30 13:58:19 -04:00