Commit Graph

31 Commits (3dba3f74f9df854498b2922d407f298776438b9e)

Author SHA1 Message Date
Michael Chisholm e99be67c1e Remove registration._get_extension_class() since it's redundant
with registry.class_for_type().
2021-07-09 18:11:11 -04:00
Michael Chisholm d27e9e6e55 Back out changes to the CustomMarking decorator and registration,
to revert its behavior to what it did before: register a type
for old-style non-extension custom markings.
2021-07-08 22:18:28 -04:00
Michael Chisholm 99a8ade4cd pre-commit stylistic fixes 2021-07-06 20:40:50 -04:00
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
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
Emmanuelle Vargas-Gonzalez a8b6fa2100 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into dev-extensions-proposal 2021-02-18 16:04:30 -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
Michael Chisholm f51e309775 Refactor stix2.parsing into more focused modules:
- stix2.registry, which contains the class mapping structure
  and code for scanning stix2 modules for its initial population
- stix2.registration, which contains code used to register custom
  STIX types with the registry
- stix2.parsing, which contains code for creating instances of
  registered stix2 classes from raw dicts.

This is intended to reduce circular import problems, by giving
dependent code the ability to import a module which has exactly
the functionality it needs, without pulling a lot of other stuff
it doesn't need.  Fewer imports means less chance of an import
cycle.
2021-01-08 22:08:33 -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
maybe-sybr 15344527aa fix: Respect name of `@Custom*` decorated defs 2020-07-28 11:13:59 +10:00
Chris Lenk 14540c0ea1 Clean up _register_* functions
Made them consistent with _register_observable_extension, by:
- moving validation logic there from _custom_*_builder functions
- using a new function for ensuring properties are dict-like
- using the library default spec version instead of None

Fix #371, fix #372, fix #373.
2020-04-02 14:15:45 -04:00
Chris Lenk c494a2e477 Use TypeProperty.clean() to verify type format 2020-04-01 21:52:04 -04:00
Chris Lenk 50df6f1474 Rename core.py -> parsing.py 2020-03-27 05:53:39 -04:00
Chris Lenk e31634c32b Rework spec version detection for _STIXBase objs 2020-03-21 22:22:36 -04:00
Rich Piazza 6e4151aeeb flaky 2020-03-19 16:49:46 -04:00
Rich Piazza fe919049b8 fix marking test 2020-03-19 16:43:37 -04:00
Rich Piazza f60e4170fd finish 365 2020-03-19 16:11:52 -04:00
Rich Piazza 844ec2c3bf more on issue 365 2020-03-19 14:16:48 -04:00
Rich Piazza 9699c78ad8 issue-365 2020-03-19 10:40:35 -04:00
Michael Chisholm d708537b85 Add enforcement of a new STIX 2.1 SCO extension name requirement:
that it must end with "-ext".
2020-03-10 20:24:53 -04:00
Desai, Kartikey H a5cd0fdc50 Change location of None-check for id_contrib_props. Fixes #351 2020-03-04 14:46:55 -05:00
Desai, Kartikey H fc95b400ff Change default parameters from empty lists to None. Fixes #351 2020-03-04 14:29:35 -05:00
Desai, Kartikey H 41e541959d Add _id_contributing_properties functionality to custom SCOs. Tests coming soon. Fixes #351 2020-02-24 21:11:42 -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
Emmanuelle Vargas-Gonzalez f8a72b0937 Custom builder code updated for 3.7 support.
Updated properties to support more constrains.
Make all regexes literal strings.
Update tests to align to new constrains.
Workbench problem. _check_object_constraints() uses instance class to
perform proper class resolution calls.
2018-10-17 07:34:15 -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 ee260b7574 Sort import check 2018-07-11 08:38:06 -04:00
Emmanuelle Vargas-Gonzalez e513c8d638 Hide builder methods in 'custom.py' and update imports accordingly 2018-07-11 08:11:47 -04:00
Emmanuelle Vargas-Gonzalez b76888c682 Add a new 'custom.py' module to store and consolidate all custom code 2018-07-10 14:54:17 -04:00