Chris Lenk
01ba190525
Reorganize bases, use isinstance to check version
...
Renamed STIXDomainObject -> _DomainObject.
Renamed STIXRelationshipObject -> _RelationshipObject.
2020-03-27 02:40:42 -04:00
Michael Chisholm
a9ac7ce838
pre-commit hook changes, e.g. trailing commas, import sorting,
...
flake8 style.
2020-03-17 18:26:57 -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
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
96946d956d
fix: Avoid errors with custom object ids in the list of object refs in the Report object
2020-01-17 17:13:43 +01:00
chrisr3d
cbe109d815
fix: Avoiding issues with some extensions that are not dict but defaultdict
2020-01-08 17:00:18 +01:00
chrisr3d
36e4b41b9c
fix: Avoiding inconsistency in the id prefixes causing uuid check issues
2020-01-08 16:58:34 +01:00
chrisr3d
c8cd84925b
Merge branch 'master' of github.com:oasis-open/cti-python-stix2
2020-01-08 14:53:36 +01:00
Chris Lenk
e3c2a3a57b
Fix error: dict keys changing during iteration
2020-01-04 14:48:49 -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
7a47f348a0
Introduce and relocate version-based pattern checking. Fixes #307
2020-01-04 10:24:17 -05:00
Desai, Kartikey H
4350680e79
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
Chris Lenk
cde57ce8f7
Merge pull request #315 from khdesai/fix_issue_308
...
Fix issue 308
2019-12-17 12:13:25 -05:00
Desai, Kartikey H
6df7da65b8
Fixes #308
2019-12-17 11:57:55 -05:00
Desai, Kartikey H
8719a7206f
Fixes #308
2019-12-16 16:32:55 -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
54ecba736d
Add docstring for enumerate_types()
2019-12-06 09:35:36 -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
Zach Rush
46f1778d04
Fixed all issues brought up in issue #305 by Chris Lenk
2019-11-22 13:24:09 -05:00
chrisr3d
f89940ec0e
fix: Added missing param to the id validation function
2019-10-14 12:34:31 +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
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
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
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
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
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
8bb6c79f1d
Change import order to satisfy style checkers...
2019-06-21 14:25:36 -04:00
Michael Chisholm
ea98a53fae
Change all hard-coded spec_version defaults in property classes
...
to stix2.DEFAULT_VERSION.
2019-06-21 13:18:51 -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
Emmanuelle Vargas-Gonzalez
c3aecd76ba
update unnecesary property clean-up and add tests
2019-04-23 09:27:21 -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
83709358c3
Merge branch 'master' of github.com:oasis-open/cti-python-stix2
2019-01-10 09:51:41 +01:00
Chris Lenk
8c3ecd1c48
Merge pull request #237 from oasis-open/236-WindowsRegistryKey
...
Fix error when printing WindowsRegistryKey
2019-01-09 11:12:46 -05:00
Chris Lenk
1ad64dfc0c
Move CallableValues to prevent duplicate code
2019-01-09 10:46:48 -05:00
Chris Lenk
2966efa4f0
Remove dictionary/extension property non-empty req
...
Only bundle.objects and observed-data.objects have a requirement to
include at least one item.
2019-01-07 11:15:47 -05:00
chrisr3d
f527e279b3
fix: Using raw string in the regular expression compilation
2018-12-26 12:57:46 +01:00
chrisr3d
a68a43a732
Merge branch 'master' of github.com:oasis-open/cti-python-stix2
2018-12-14 10:09:58 +01:00
chrisr3d
3ae38fe687
fix: Applying the same parameter as for IDs in created_by_ref UUIDs
2018-12-11 10:16:17 +01:00
chrisr3d
067d76bb90
chg: Added parameter to accept UUIDs not v4
...
- This parameter is not used at the creation of
STIX objects, only while converting json format
into STIX objects.1
2018-12-11 10:16:17 +01:00
Emmanuelle Vargas-Gonzalez
71a2aa2611
update project documentation.
2018-11-28 16:51:00 -05:00
Emmanuelle Vargas-Gonzalez
aaddeb8b97
Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into 1.1.0-release
2018-11-28 11:21:27 -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
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
a042970a1f
Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into stix2.1
2018-07-11 09:41:42 -04:00
Emmanuelle Vargas-Gonzalez
7da6f1ed88
Add a package-wide 'properties.py'
...
Consolidated STIXObjectProperty, ExtensionsProperty, ObservableProperty code. Also added a 'spec_version' to allow validation changes per spec.
2018-07-10 14:50:03 -04:00
Greg Back
68aac583c9
Merge pull request #204 from oasis-open/refactor-properties
...
Refactor Properties
2018-07-05 17:16:25 -05:00
Greg Back
12a22c0939
Remove unnecessary code related to defining properties.
2018-07-05 11:39:44 -05:00
Greg Back
25409b2099
GH-188: Update error message for invalid IDs.
2018-07-05 11:25:48 -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
Trey Darley
6b1da856dd
split properties out by spec version
2018-06-26 09:22:04 +00:00
Greg Back
b2c6acfbf6
GH-188: Restrict valid UUID values.
2018-06-22 14:40:30 -05:00
Chris Lenk
f127d145c4
Merge pull request #166 from oasis-open/139-dict-filter-value
...
139 dict filter value
2018-04-13 16:35:32 -04:00
=
1a1e5e1616
WIP- getting close though
2018-04-13 11:08:03 -04:00
Chris Lenk
d08be151f7
Allow a ListProperty of DictionaryProperties
2018-04-12 21:26:48 -04:00
Chris Lenk
2b6023e7bb
Allow objects with custom properties in bundles
2017-10-09 17:33:12 -04:00
Chris Lenk
eac1ce94de
Improve docstrings for Sphinx output
...
Also remove package and module names from classes and functions.
Also remove stix2.base from docs. We hide all private classes and
functions from the docs, so the only thing the documentation for base
included was STIXJSONEncoder.
2017-09-22 11:24:55 -04:00
Chris Lenk
c0fd740e0a
Improve autodoc output
...
- Add markings and sources
- Tidy up some docstrings
2017-09-22 10:01:00 -04:00
Greg Back
124da846c3
Merge branch 'master' into markings
2017-08-31 20:36:59 +00:00
Emmanuelle Vargas-Gonzalez
415c53066f
Code coverage changes, fix some tests. Add stix2-validator dependency.
2017-08-28 15:19:55 -04:00
clenk
8687521111
Change object markings for immutable SDOs
2017-08-21 13:57:01 -04:00
clenk
d4edb8b0bc
Validate patterns when creating Indicators
2017-08-18 14:22:57 -04:00
clenk
ee8013d782
Parse bundles correctly
...
This required refactoring parts of the library. Code in __init__.py
merged into bundle.py, which was renamed core.py. Code in other.py was
merged into common.py.
Fixes #40 .
2017-08-11 16:18:20 -04:00
Greg Back
595ba10695
Merge pull request #34 from oasis-open/object-factory
...
Object factory
2017-07-19 13:54:24 +00:00
clenk
2e45cacd52
Add to list properties like `external_references`, but include option to
...
replace instead
2017-07-17 14:56:13 -04:00
clenk
e1330692c8
Move ObservableProperty, ExtensionsProperty, and Observable parsing code
...
into observables.py to prevent circular imports and fix #23 .
2017-07-14 15:10:12 -04:00
clenk
659ad3df89
Add object markings to object factory
2017-07-12 14:44:52 -04:00
clenk
29d9467ce0
Add more timestamp test cases, address suggestions
2017-06-28 15:55:23 -04:00
clenk
e01ce132db
Add timestamp precision for `created` and `modified`
...
Fix #24
2017-06-22 18:47:35 -04:00
clenk
860efcc230
Make object attribute access act like dictionary access, raising an
...
error for any property (including custom or optional) not set on the object.
2017-06-07 11:06:20 -04:00
clenk
3e0e80141b
For object reference properties, check the type of the object
...
referenced, not only that it is included in the local scope.
2017-05-17 15:21:02 -04:00
clenk
9761c37f20
Replace 'field' with 'property' to be consistent
...
with the specification
2017-05-16 12:27:30 -04:00
clenk
a520a67511
Add tests for the Network Traffic extension and
...
User Account extensions
2017-05-16 11:35:43 -04:00
clenk
2460fb75be
Rework select properties to use get_dict(),
...
which automatically coerces values to a dictionary if possible
2017-05-16 09:25:08 -04:00
Richard Piazza
6456e490cc
added rest of cyber observables extensions and embedded objects
...
set up EXT_MAPs
added FloatProperty
implemented ExtensionsProperty
2017-05-15 13:48:41 -04:00
clenk
0568a0e671
Add ExtensionsProperty and ArchiveExt
2017-05-12 11:22:23 -04:00
clenk
13245d28ce
Add EnumProperty, use it in WindowsRegistryValueType
2017-05-10 11:52:59 -04:00
clenk
67935d08fe
Fix isort settings, rename Observable to clarify
...
it's an internal class
2017-05-09 18:03:46 -04:00
clenk
bdd18be6c3
Switch to isort for checking import order
...
because it has a pre-commit hook
2017-05-09 15:10:53 -04:00
clenk
555c81d30f
Add EmailMessage and EmbeddedObjectProperty (for embedded object types
...
like EmailMIMEComponent)
2017-05-09 11:03:19 -04:00
clenk
04e3a72a7d
Add EmailAddress and ObjectReferenceProperty
2017-05-05 12:32:02 -04:00
clenk
1a75d830bb
Add Autonomous System
2017-05-03 18:19:30 -04:00
clenk
2c67b90638
Add Artifact type
2017-05-03 17:35:33 -04:00
clenk
c63ba8e447
Add ObservableProperty, DictionaryProperty, HashesProperty,
...
BinaryProperty, and HexProperty
2017-05-03 14:10:10 -04:00
clenk
c5ba5dad65
Modify UUID checking
2017-04-25 10:03:37 -04:00
clenk
cd815bfe84
Fix import order, add flake8-import-order plugin
...
to Tox
2017-04-24 18:29:56 -04:00
clenk
fe4c4d78fc
Fix typos, add to Property class documentation, small performance
...
boosts, and let strings and booleans in a ListProperty be handled by
__call__().
2017-04-24 17:34:16 -04:00