Commit Graph

132 Commits (998b4c0725a5f6797a806517a29ecc9556e66cfb)

Author SHA1 Message Date
Desai, Kartikey H 998b4c0725 Change streamlined_obj_vals list to streamlined_object dict 2020-05-13 12:45:16 -05:00
Desai, Kartikey H 65d4060e6a Fixes #389 2020-05-13 11:23:26 -05:00
Desai, Kartikey H 0b1297b14a Fixes #389 2020-05-13 11:22:51 -05:00
Desai, Kartikey H de3fa99a12 Add property names to canonicalization for deterministic id gen 2020-05-13 11:20:16 -05:00
Chris Lenk 01ba190525 Reorganize bases, use isinstance to check version
Renamed STIXDomainObject -> _DomainObject.
Renamed STIXRelationshipObject -> _RelationshipObject.
2020-03-27 02:40:42 -04:00
Chris Lenk e31634c32b Rework spec version detection for _STIXBase objs 2020-03-21 22:22:36 -04:00
Rich Piazza 9e5e998c3d don't allow leading '_' on custom properties, whenever allow_custom is true 2020-03-20 12:49:20 -04:00
Rich Piazza 6e4151aeeb flaky 2020-03-19 16:49:46 -04:00
Rich Piazza f60e4170fd finish 365 2020-03-19 16:11:52 -04:00
Rich Piazza 9699c78ad8 issue-365 2020-03-19 10:40:35 -04:00
Desai, Kartikey H 796a4e20fa Correct bug in recursive dict loop. Fixes #334 2020-02-21 15:26:19 -05:00
Desai, Kartikey H 1084c75d33 Fixes #334 2020-02-19 16:29:13 -05:00
Chris Lenk 6c0fba0e67 Add Python3.8 support, fix import
Uses try/catch to still support 2.7 too
2020-01-04 13:50:06 -05:00
Desai, Kartikey H 6df7da65b8 Fixes #308 2019-12-17 11:57:55 -05:00
Michael Chisholm 216b43d49e Fix determinstic UUID handling when there are high-codepoint
unicode characters.  Make compatible with both python 2 and 3.
2019-10-11 17:12:44 -04:00
Desai, Kartikey H 113d481e84 Make SCO deterministic ID namespace a global var for better software hygiene 2019-09-19 10:31:14 -04:00
Desai, Kartikey H 9c7128d074 Fix indentation issue 2019-09-11 10:49:11 -04:00
Desai, Kartikey H d828e41c78 End of changes 2019-09-11 10:44:14 -04:00
Desai, Kartikey H 5b6592e2dc Some changes. More fixes coming soon, hopefully 2019-09-06 18:08:27 -04:00
Desai, Kartikey H 8f773fd556 Temp backup of some code changes. More coming soon 2019-09-06 00:25:42 -04:00
Desai, Kartikey H abf2980336 Fix tests and ReferenceProperty 2019-09-04 19:08:34 -04:00
Desai, Kartikey H 44ebd64a16 Some test fixes. More coming soon 2019-08-30 03:47:47 -04:00
Desai, Kartikey H 5825118ad4 Merge branch 'stix2.1' of https://github.com/oasis-open/cti-python-stix2 into wd05SCO 2019-08-27 17:37:14 -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 c212c7c678 Fix handling of custom extensions: make sure when
allow_custom=True that you never get a half-cleaned property
value.
2019-08-26 17:10:54 -04:00
Desai, Kartikey H 5e9d6a6a14 Fix small indentation error 2019-08-21 08:49:33 -04:00
Desai, Kartikey H bf1b8b567d Updates to allow existing tests to pass 2019-08-21 02:00:41 -04:00
Desai, Kartikey H 46359ead69 Modify a few things 2019-08-19 13:35:17 -04:00
Desai, Kartikey H ec55463398 Update SCO stuff to WD 05 2019-08-19 09:39:13 -04:00
Michael Chisholm 5589480980 Improved the exception class hierarchy:
- Removed all plain python base classes (e.g. ValueError, TypeError)
- Renamed InvalidPropertyConfigurationError -> PropertyPresenceError,
  since incorrect values could be considered a property config error, and
  I really just wanted this class to apply to presence (co-)constraint
  violations.
- Added ObjectConfigurationError as a superclass of InvalidValueError,
  PropertyPresenceError, and any other exception that could be raised
  during _STIXBase object init, which is when the spec compliance
  checks happen.  This class is intended to represent general spec
  violations.
- Did some class reordering in exceptions.py, so all the
  ObjectConfigurationError subclasses were together.

Changed how property "cleaning" errors were handled:
- Previous docs said they should all be ValueErrors, but that would require
  extra exception check-and-replace complexity in the property
  implementations, so that requirement is removed.  Doc is changed to just
  say that cleaning problems should cause exceptions to be raised.
  _STIXBase._check_property() now handles most exception types, not just
  ValueError.
- Decided to try chaining the original clean error to the InvalidValueError,
  in case the extra diagnostics would be helpful in the future.  This is
  done via 'six' adapter function and only works on python3.
- A small amount of testing was removed, since it was looking at custom
  exception properties which became unavailable once the exception was
  replaced with InvalidValueError.

Did another pass through unit tests to fix breakage caused by the changed
exception class hierarchy.

Removed unnecessary observable extension handling code from
parse_observable(), since it was all duplicated in ExtensionsProperty.
The redundant code in parse_observable() had different exception behavior
than ExtensionsProperty, which makes the API inconsistent and unit tests
more complicated.  (Problems in ExtensionsProperty get replaced with
InvalidValueError, but extensions problems handled directly in
parse_observable() don't get the same replacement, and so the exception
type is different.)

Redid the workbench monkeypatching.  The old way was impossible to make
work, and had caused ugly ripple effect hackage in other parts of the
codebase.  Now, it replaces the global object maps with factory functions
which behave the same way when called, as real classes.  Had to fix up a
few unit tests to get them all passing with this monkeypatching in place.
Also remove all the xfail markings in the workbench test suite, since all
tests now pass.

Since workbench monkeypatching isn't currently affecting any unit tests,
tox.ini was simplified to remove the special-casing for running the
workbench tests.

Removed the v20 workbench test suite, since the workbench currently only
works with the latest stix object version.
2019-07-19 14:50:11 -04:00
Desai, Kartikey H f79b3c9876 Add functionality to _valid_refs to accept actual cyber observable objects instead of just strings with their types 2019-05-10 10:22:45 -04:00
Desai, Kartikey H e748923f19 Fixes #248 2019-04-17 10:08:34 -04:00
Emmanuelle Vargas-Gonzalez e1f7cc4028 change "Notes" for "Note" to keep visual effect in documentation 2018-11-30 09:39:05 -05:00
Emmanuelle Vargas-Gonzalez 71a2aa2611 update project documentation. 2018-11-28 16:51:00 -05:00
Emmanuelle Vargas-Gonzalez b2ef77b322 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into stix2.1 2018-10-17 07:30:23 -04:00
Maciej Urbanski e80fb4f59a
python 3.7 support 2018-10-03 18:00:38 +02: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 21d5451d1c Small changes to tests 2018-07-06 14:11:59 -04:00
Emmanuelle Vargas-Gonzalez 7fd379d0b5 Minor style changes.
Removed OrderedDict and update()... Also a lot of single quoting except for errors
2018-06-29 18:38:04 -04:00
Emmanuelle Vargas-Gonzalez 9baaad6e08 Sort imports. 2018-06-26 12:23:53 -04:00
Emmanuelle Vargas-Gonzalez bee537137b
Update base.py
Fix STIXJSONIncludeOptionalDefaultsEncoder call to super()
2018-06-26 11:10:36 -04:00
Michael Chisholm f09960d7ff Revamp code related to "pretty" JSON serialization, fix lurking
crash bugs.
2018-06-14 21:29:50 -04:00
Greg Back 858a9752df
Merge pull request #185 from LiamSennitt/master
fix custom STIX objects with nested dictionary error #184
2018-06-12 14:40:55 -05:00
Emmanuelle Vargas-Gonzalez 60da259805 Add an example on how to call the serialize() method. 2018-06-08 15:42:59 -04:00
Michael Chisholm 5a9f627669 Pickle-proof stix objects 2018-06-06 15:30:45 -04:00
Chris Lenk ddc09f70c7 Set allow_custom if using a custom_properties dict
Fixes #179.
2018-05-17 09:04:44 -04:00
Chris Lenk cf972479ed Pass allow_custom to object dicts in a Bundle 2018-05-16 15:37:30 -04:00
Chris Lenk 69c31ca3fc Pass allow_custom to ExtensionsProperty
Also fix bug caused by _properties being a class variable rather than an
instance variable. If you created an object with allow_custom,
allow_custom would be set for all future instances.
2018-05-16 12:14:33 -04:00
Chris Lenk 14dce03616 Provide default for revoked, sighting:summary.
This allows filter on un-revoked objects. Changes default JSONEncoder to
drop optional properties with default values in the spec if set to the
default value. They can be included by passing
include_optional_defaults=True to serialize().
2018-04-16 14:37:07 -04:00
Chris Lenk fc6a33b23e Disallow missing 'type' property with allow_custom
There was a bug where if you allowed custom content the library would parse an
object without the required 'type' property.
2018-04-13 11:18:56 -04:00