Commit Graph

110 Commits (65a943d8929c578041f789665b05810ea68986cb)

Author SHA1 Message Date
chrisr3d 65a943d892 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2020-04-02 17:55:24 +02: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
chrisr3d 0f0bc42681
Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2020-03-02 15:31:39 +01:00
Michael Chisholm be5274878d Add trailing commas for pre-commit hook... 2020-02-13 17:37:59 -05:00
Michael Chisholm 98a654884d Fix the memory store to support the new top-level 2.1 SCOs. 2020-02-13 17:11:58 -05:00
chrisr3d 5aaf07702d Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2020-02-05 21:18:14 +01:00
Michael Chisholm 176cb980a2 Remove workaround for "values" being both a Mapping method name
and sometimes a STIX property name.  It didn't work (caused
crashes under some circumstances).  Now, attributes whose names
conflict with Mapping methods will have the Mapping
interpretation.  Same-named STIX object properties will not be
accessible as attributes.
2020-01-28 18:13:36 -05:00
chrisr3d c8cd84925b
Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2020-01-08 14:53:36 +01:00
Desai, Kartikey H d50792b4d2 Fix tests. Fixes #307 2020-01-04 10:24:17 -05:00
Desai, Kartikey H 7a47f348a0 Introduce and relocate version-based pattern checking. Fixes #307 2020-01-04 10:24:17 -05:00
Desai, Kartikey H a18612bdfb Fixes #307 2020-01-04 10:24:17 -05:00
chrisr3d 31d944b159 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2019-12-12 22:59:39 +01: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
chrisr3d 4f1d68065a
fix: Making python imports happy in travis 2019-10-14 14:41:17 +02:00
chrisr3d bdba2c0a63
fix: Removed comment 2019-10-14 14:27:44 +02:00
chrisr3d bf45f26bfe
fix: Making pep8 happy 2019-10-14 14:15:26 +02:00
chrisr3d adbaec1942
Merge branch 'master' of github.com:oasis-open/cti-python-stix2 + fix interoperability param support 2019-10-14 12:30:15 +02:00
Desai, Kartikey H abf2980336 Fix tests and ReferenceProperty 2019-09-04 19:08:34 -04:00
chrisr3d a739c1154e Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2019-09-03 13:47:43 +02: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 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 94bb76f669 Fix docstring on the unit tests I added. I'd said "partially
cleaned" property, but actually, the cleaning algorithm works on
a dict copy, so aborting cleaning partway through doesn't
actually affect the object in that way.  It would actually cause
the extensions property to be completely uncleaned, rather than
partially cleaned.
2019-08-26 17:49:55 -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
Chris Lenk b981cdf4fc Fix tests
by removing certain human message assertions from test suites.
(These changes are cherry-picked from commit by @khdesai on a different
branch)
2019-08-09 16:04:29 -04:00
Michael Chisholm 38103ac6c5 Moved test/v20/test_workbench.py up one directory level since
it doesn't make sense to have a test per STIX version.  The
workbench only uses the latest supported STIX version.  In
order to make this work, the test suite was modified to
dynamically compute some settings like where to get demo data,
based on the value of stix2.DEFAULT_VERSION.

Switched stix2.DEFAULT_VERSION back to "2.0", since I figure it
should be sync'd up with the 'from .vxx import *' import
statement from the top level package.
2019-07-24 15:35:59 -04:00
Michael Chisholm 165d87e103 Revert the import in the top-level stix2 package, to v20. This
additionally required:

- Removing the v21 workbench test suite and reinstating the v20
  test suite
- Fixing up a few v20 unit tests to work with the workbench
  monkeypatching.
- I didn't revert the analogous changes I'd previously made to
  the v21 unit tests, because I think they make sense even when
  the workbench monkeypatching isn't happening.
2019-07-22 16:55:22 -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 b464a9cc0a Remove certain human message assertions from test suites 2019-07-09 13:34:19 -04:00
Chris Lenk b8c5bec101 Merge branch 'master' into stix2.1 2019-06-26 12:22:40 -04:00
chrisr3d 565acc7618 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2019-06-25 09:06:50 +02:00
Michael Chisholm 23d5bef2ec Change all uses of multi-STIX-version properties (i.e. those
with a spec_version constructor argument) in STIX-version-specific
contexts, to explicitly specify the STIX version.
2019-06-21 14:29:08 -04:00
Michael Chisholm d61b543266 Style changes to satisfy the 'style' tox check 2019-06-14 18:10:38 -04:00
Michael Chisholm da5978d317 Factored out more of the STIX identifier validity checking,
partly inspired by PR #263.  This resulted in some error message
format changes (an improvement, I think), which caused some
unit test breakage.  Removed those asserts from the unit tests,
since tests shouldn't be testing human-targeted error messages.
2019-06-13 18:37:21 -04:00
Michael Chisholm ed106f23ff Update IDProperty and ReferenceProperty to support both stix 2.0
and 2.1 rules regarding identifiers.  Change relevant property
tests to specify which spec version to use, and modify tests
according to the specs.
2019-06-12 20:19:47 -04:00
Chris Lenk a6fa3ff1d7 Slightly change bundle error message 2019-05-22 11:05:01 -04:00
Desai, Kartikey H ce86db2a12 Fixes #257 2019-05-20 15:36:35 -05:00
Desai, Kartikey H 86790a736f Fixes #257 2019-05-20 15:29:01 -05:00
Kartikey Desai 1bf12221a0 Update _valid_refs doc and add test to v20 test suite 2019-05-13 09:18:50 -04:00
Emmanuelle Vargas-Gonzalez 087ac35f38 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into 252-TLPMarking-constraints 2019-05-08 10:43:13 -04:00
Emmanuelle Vargas-Gonzalez 9c34e2f8ca update tests to make sure we are testing the serialized instance correctly 2019-05-08 10:36:31 -04:00
Emmanuelle Vargas-Gonzalez 4b21708e03 modify test to cover exception message 2019-05-03 11:05:32 -04:00
Emmanuelle Vargas-Gonzalez b3a601e4c8 add new files for marking-definition tests 2019-05-03 10:25:11 -04:00
Emmanuelle Vargas-Gonzalez fff0e9e731 update test_datastore_filesystem.py to create proper tlp markings 2019-05-03 09:58:45 -04:00
chrisr3d 92c0582d8f Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2019-04-29 16:35:46 +02:00
Desai, Kartikey H 84fc71add4 Add test to ensure fix. Fixes #248 2019-04-19 12:17:42 -04:00
Desai, Kartikey H e748923f19 Fixes #248 2019-04-17 10:08:34 -04:00
chrisr3d f049c98d43 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2019-02-08 15:24:22 +01:00
Chris Lenk 69d2529f0e Fix style issues 2019-02-06 15:23:00 -05:00
chrisr3d 469d17bcee Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2019-02-06 08:55:41 +01:00