Commit Graph

404 Commits (3ae38fe687fa478f4c4228fbf70308eccc9c64d9)

Author SHA1 Message Date
Michael Chisholm 17970a3faa Fixed a couple filter tests.
- a length check should come before the access, so you can verify
whether the access will succeed.

- Also removed some tests which can't work, due to the filter
changes.  In fact, a lot of these tests should probably be
removed or changed if we want to disallow running
apply_common_filters() on plain dicts.  They will often
coincidentally still succeed though, so I left them in.
2018-11-27 18:42:51 -05:00
Michael Chisholm f57b9c34ef Add a newline to the end of a file 2018-11-27 17:58:01 -05:00
Michael Chisholm 3adf7800a8 Changed how filters work, with respect to datetime objects.
Timestamp properties can now be checked against filter values
which are either strings or datetime objects, using datetime
semantics (previously, it reduced to a string compare).
If a stix object property is datetime-valued and the filter
value is a string, the string is parsed to a datetime object,
rather than the other way around.

Filtering in the filesystem store now parses JSON dicts to
_STIXBase objects before applying the filters.

Due to the parsing change, bad JSON content can produce a
different kind of error, so I had to change one of the tests.
2018-11-27 17:36:17 -05:00
Michael Chisholm d8a775c60d Fix some more improper exception re-raises in the filesystem
datastore test suite.  Add a new test corpus file, located so
as to test the backward compatibility functionality of
FileSystemSource.  Add a test to the suite which ensures that
this new file is found.
2018-11-27 15:24:09 -05:00
Michael Chisholm f615161110 Added some tests for adding markings to sinks and stores. 2018-11-27 15:24:08 -05:00
Michael Chisholm 0cecbeb9d8 Ran trailing-whitespace pre-commit hook. It changed a bunch of
files, in ways we don't completely understand...
2018-11-27 15:24:08 -05:00
Michael Chisholm 0a8ff2ab2e Add some newer versions of a couple of object IDs in the stix2
test data corpus.  Updated filesystem store tests accordingly:
- Remove comments from all_versions tests stating that multiple
  versions are not supported.  Improve the tests to ensure that
  all versions are in fact retrieved.
- Update the get() test to assure that it gets only the latest
  version, when there is more than one version.
- Update some count checks, since there are more objects now
- Fix some typos
2018-11-27 15:24:07 -05:00
Michael Chisholm 9693c16cd1 Adjust import order to satisfy tox import check 2018-11-27 15:24:07 -05:00
Michael Chisholm 428a18ded2 Implemented clenk's suggested changes in multi-version filesystem
store:
- Use utils.get_type_from_id() instead of my own (I didn't know it
  was already there)
- Use dict-style instead of attribute-style access to get stix
  object properties
- Convert timezone-aware timestamps to UTC in _timestamp2filename()
  to ensure that different times always result in different
  filenames.

Also added a couple new tests for _timestamp2filename(), which
exercises the timezone conversion code.
2018-11-27 15:24:07 -05:00
Michael Chisholm 0096835cfc Add multi-version support to the filesystem datastore.
Factored out the _is_marking() function from the memory datastore
module to utils so it can be reused, and changed both filesystem
and memory datastore modules to import and use it.
2018-11-27 15:24:07 -05:00
Chris Lenk c4668f5dc1
Revert "Multi version filesystem store" 2018-11-07 10:10:06 -05:00
Chris Lenk 150457c1bb
Merge pull request #222 from chisholm/multi_version_filesystem_store
Multi version filesystem store
2018-11-06 16:32:07 -05:00
Michael Chisholm b235e5773c Added some tests for adding markings to sinks and stores. 2018-11-06 16:15:33 -05:00
Michael Chisholm 9f83f2140b Ran trailing-whitespace pre-commit hook. It changed a bunch of
files, in ways we don't completely understand...
2018-11-06 15:10:40 -05:00
Michael Chisholm a8d9aef673 Add some newer versions of a couple of object IDs in the stix2
test data corpus.  Updated filesystem store tests accordingly:
- Remove comments from all_versions tests stating that multiple
  versions are not supported.  Improve the tests to ensure that
  all versions are in fact retrieved.
- Update the get() test to assure that it gets only the latest
  version, when there is more than one version.
- Update some count checks, since there are more objects now
- Fix some typos
2018-11-01 20:25:00 -04:00
Michael Chisholm e2d9325356 Adjust import order to satisfy tox import check 2018-11-01 20:25:00 -04:00
Michael Chisholm ee57596d6a Implemented clenk's suggested changes in multi-version filesystem
store:
- Use utils.get_type_from_id() instead of my own (I didn't know it
  was already there)
- Use dict-style instead of attribute-style access to get stix
  object properties
- Convert timezone-aware timestamps to UTC in _timestamp2filename()
  to ensure that different times always result in different
  filenames.

Also added a couple new tests for _timestamp2filename(), which
exercises the timezone conversion code.
2018-11-01 20:25:00 -04:00
Michael Chisholm 9486b46f77 Add multi-version support to the filesystem datastore.
Factored out the _is_marking() function from the memory datastore
module to utils so it can be reused, and changed both filesystem
and memory datastore modules to import and use it.
2018-11-01 20:25:00 -04:00
Chris Lenk 3b297c17b5 Use consistent errors for observable extensions
Whether or not the Observable type is in the EXT_MAP already, using a
custom extension without also using allow_custom=True should result in
the same behavior/error message.
2018-11-01 17:23:55 -04:00
Chris Lenk 3542604b02
Merge pull request #209 from chisholm/taxii_api_updates
Fixed a test fixture to call the cti-taxii-client Collection constructor correctly
2018-10-31 12:04:34 -04:00
Chris Lenk db300d1f21 Fix `created` millisecond precision in TLPs
A marking definition's `created` property doesn't require millisecond
preprecision, but for TLP markings the TLP instances provided in the
spec must be used and they all use millisecond precision.
2018-10-25 13:58:21 -04:00
Michael Chisholm cbe8d22d0a Added support to multi-version memory stores for markings. Also
added some more unit tests which test storing/retrieving markings
from the stores.
2018-10-17 20:54:53 -04:00
Michael Chisholm 864ba05b71 Fix import order to satisfy isort-check 2018-10-15 19:23:28 -04:00
Michael Chisholm d9f6a213c1 Fixed Memory source/sink/store so that it supports multiple versions
of objects.  Fixed several bugs too.
2018-10-15 18:02:49 -04:00
Michael Chisholm 541c682bf6 Fixed a test fixture to call the cti-taxii-client Collection
constructor correctly.  It had been recently changed to address
issue #39 in that library.
2018-09-07 17:47:24 -04:00
mbastian1135 5648d2bc45 added to pattern guide; reverting pattern str conversion (as was already proper) 2018-08-30 11:57:20 -04:00
Greg Back 49c1931b4b
Merge pull request #203 from oasis-open/200-filter-contains
Add "contains" filter
2018-07-05 15:47:09 -05:00
Greg Back 25409b2099 GH-188: Update error message for invalid IDs. 2018-07-05 11:25:48 -05:00
Chris Lenk f47809eaaf Add "contains" filter
This allows filtering on, for example, observed-data objects that
contain a specific cyber observable.
2018-07-02 18:28:27 -04:00
Greg Back a2e2407025 GH-188: Fixes for old Python syntax. 2018-06-27 12:49:00 -05:00
Greg Back d2f703b9d0 Reuse reference regex to match IDs as well.
Note that this means that UUIDs will no longer be converted, even when
there's an unambiguous mapping.
2018-06-27 12:27:44 -05:00
Greg Back e749218f9b GH-188: Test that references are always valid UUID v4. 2018-06-27 12:02:13 -05:00
Greg Back e5903f1832 Sort constants. 2018-06-27 11:36:17 -05:00
Greg Back 845625c174 GH-188: WIP: Converting all IDs to be valid UUID v4. 2018-06-27 11:35:55 -05:00
Greg Back b2c6acfbf6 GH-188: Restrict valid UUID values. 2018-06-22 14:40:30 -05:00
Greg Back fdf5937a71 GH-194: Remove unnecessary allow_custom kwarg. 2018-06-21 12:15:28 -05:00
Greg Back 7baeb153fa Correct "image_weight" to "image_width".
Fix #194.
2018-06-20 15:24:27 -05: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 fcffb165ad Add tests for `find_property_index` and `iterate_over_values` 2018-06-12 14:38:35 -04:00
Emmanuelle Vargas-Gonzalez 94d6610ca1 Merge branch 'master' of github.com:LiamSennitt/cti-python-stix2 2018-06-12 12:58:01 -04:00
Emmanuelle Vargas-Gonzalez 9be819ea6a Minor tweaks to return immediately after recursive call. Ensure dicts are matched alphabetically 2018-06-12 12:57:25 -04:00
Liam Sennitt bdec14937d fix flake8 errors in new test 2018-06-12 17:45:48 +01:00
Liam Sennitt 02894b5be6 add test for nested dictionary case 2018-06-12 17:32:46 +01:00
Michael Chisholm 5a9f627669 Pickle-proof stix objects 2018-06-06 15:30:45 -04:00
Greg Back d67f2da0ea
Merge pull request #181 from oasis-open/http_error
Http error
2018-05-22 12:53:29 -05:00
= e484b7c25f formatting 2018-05-18 11:45:40 -04:00
= 6004ec597c solution to get 404 mocking problem 2018-05-18 11:19:05 -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