Commit Graph

59 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 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 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
Chris Lenk 2528077eb0 Merge branch 'master' into dev-extensions-proposal 2021-06-13 01:48:33 -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 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 367b485fcd write some tests to check new MarkingDefinition constraints 2021-01-15 16:01:36 -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 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 49985cc51d fix ordering problem with Class definitions 2020-11-18 19:01:12 -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 4340be13c4 changes to the ExtensionsProperty 2020-11-09 20:58:34 -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 df92770d25
Merge pull request #384 from oasis-open/365-versioned-classes
Validate custom type/property name formats
2020-04-03 17:30:24 -04:00
Chris Lenk 9145bdf5e8
Merge pull request #374 from chisholm/version_precision
Support STIX 2.1 version precision
2020-04-03 15:52:42 -04:00
Chris Lenk 03cb225932 Merge branch 'master' into 365-versioned-classes 2020-04-02 06:02:20 -04:00
Chris Lenk c494a2e477 Use TypeProperty.clean() to verify type format 2020-04-01 21:52:04 -04:00
Rich Piazza 46219bf072 add 2.1 links 2020-03-27 09:36:10 -04:00
Chris Lenk e31634c32b Rework spec version detection for _STIXBase objs 2020-03-21 22:22:36 -04:00
Michael Chisholm 4aa69fa7c9 Add support for enforcing STIX 2.1 minimum precision requirement
on versioning timestamps.
2020-03-16 20:25:38 -04:00
Michael Chisholm a5dc514403 Fix external-references to force hash keys to come from
hash-algorithm-ov.
2020-03-04 20:55:52 -05:00
Emmanuelle Vargas-Gonzalez 9463884170 add optional "name" StringProperty to MarkingDefinition
update TLP_* v21 constants according to spec
2020-01-28 13:19:23 -05:00
Desai, Kartikey H 3a46d42aaa parse() handles observables in 2.1. Change mechanism for (in)valid_types in ReferenceProperty. Fix _custom_observable_builder to include ReferenceProperty instead of ObjectReferenceProperty, and added ID property to custom observables 2019-12-06 09:35:36 -05:00
Chris Lenk 401c9ad950
Merge branch 'master' into stix2.1 2019-09-23 12:26:27 -04:00
Zach Rush afa4af65c6 Fixing pre-commit things 2019-09-11 12:22:55 -04:00
Zach Rush e7a6554395 Fixing pre-commit issues 2019-09-11 12:12:26 -04:00
Zach Rush 53db47b447 Statement-type definitions will now match the timestamp precision given to them 2019-09-09 21:38:58 -04:00
Desai, Kartikey H f69b13a006 Some more updates, primarily to ReferenceProperty (and related code) 2019-08-29 17:15:51 -04:00
Desai, Kartikey H 49077352d7 Updates and corrections for SCO WD 05 updates. Temp backup; testing and more fixes coming soon 2019-08-27 17:36:45 -04:00
Michael Chisholm 8362d80206 Change "object_modified" property of LocationContent to be
optional.  Add a corresponding unit test.
2019-07-25 16:56:34 -04:00
Chris Lenk b8c5bec101 Merge branch 'master' into stix2.1 2019-06-26 12:22:40 -04:00
Michael Chisholm a150b0f4aa Change all uses of IDProperty and ReferenceProperty to specify
a particular spec_version.
2019-06-14 17:58:51 -04:00
Emmanuelle Vargas-Gonzalez d5f0c46dd5 re-organize imports in v20, v21 2019-05-08 10:35:53 -04:00
Emmanuelle Vargas-Gonzalez 46c47a0d08 new approach towards validation of tlp instances 2019-05-03 09:59:07 -04:00
Emmanuelle Vargas-Gonzalez 6f897bc91d small enhancements, fix property for TLPMarking 2018-11-29 10:26:20 -05:00
Emmanuelle Vargas-Gonzalez 5e5d10e7aa Finish alignment of 2.1 components 2018-11-01 08:17:34 -04:00
Emmanuelle Vargas-Gonzalez dec75082df Add new constrains parameters to IntegerProperty and FloatProperty
New constraints on timestamps, integer and floats for many objects
2018-10-15 15:02:59 -04:00
Emmanuelle Vargas-Gonzalez 51a499cb33 Formatting changes made by the new pre-commit hook 'add trailing commas'
closes #189
2018-07-13 11:10:05 -04:00
Emmanuelle Vargas-Gonzalez bdfc221cb0 Update v21 properties to latest spec changes 2018-07-12 14:31:14 -04:00
Emmanuelle Vargas-Gonzalez e513c8d638 Hide builder methods in 'custom.py' and update imports accordingly 2018-07-11 08:11:47 -04:00