Compare commits

...

8 Commits

Author SHA1 Message Date
Christian Studer f6a53d1524 Merge branch 'master' of github.com:oasis-open/cti-python-stix2 2022-08-22 14:49:45 +02:00
Emily Ratliff 20bef319a2
Merge pull request #553 from jweissm/test_harness
Test harness update
2022-08-02 10:54:59 -05:00
Emily Ratliff 56396119e6
Merge pull request #542 from chisholm/fix_detect_spec_version
Fix detect_spec_version() with respect to 2.0 bundles
2022-08-02 10:54:10 -05:00
Emily Ratliff dd3a3a0315
Merge pull request #551 from oasis-open/update-maintainers
Update maintainers list
2022-08-01 11:19:04 -05:00
Joshua Weiss aab27b6559
Update python-ci-tests.yml 2022-08-01 09:48:21 -04:00
jweissm 07dddd1ac1 added python 3.10 to test harness removed 3.6 2022-07-29 07:22:46 -07:00
Chris Lenk 3ab3a9c33f Update maintainers list 2022-07-13 15:10:48 -04:00
Michael Chisholm b5260c95f6 Fix utils.detect_spec_version() to use presence of the
spec_version property in a bundle to infer spec version, not
the property's value.  Update unit tests accordingly.
2022-02-18 21:33:13 -05:00
8 changed files with 63 additions and 21 deletions

View File

@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, '3.10']
name: Python ${{ matrix.python-version }} Build
steps:

View File

@ -135,18 +135,15 @@ select additional or substitute Maintainers, per `consensus agreements
**Current Maintainers of this TC Open Repository**
- `Chris Lenk <mailto:clenk@mitre.org>`__; GitHub ID:
https://github.com/clenk/; WWW: `MITRE Corporation <http://www.mitre.org/>`__
- `Rich Piazza <mailto:rpiazza@mitre.org>`__; GitHub ID:
https://github.com/rpiazza/; WWW: `MITRE Corporation <https://www.mitre.org/>`__
- `Andy Chisholm <mailto:chisholm@mitre.org>`__; GitHub ID:
https://github.com/chisholm/; WWW: `MITRE Corporation <https://www.mitre.org/>`__
- `Jason Keirstead <mailto:Jason.Keirstead@ca.ibm.com>`__; GitHub ID:
https://github.com/JasonKeirstead; WWW: `IBM <http://www.ibm.com/>`__
- `Emily Ratliff <mailto:Emily.Ratliff@ibm.com>`__; GitHub ID:
https://github.com/ejratl; WWW: `IBM <http://www.ibm.com/>`__
- `Duncan Sparrell <mailto:duncan@sfractal.com>`__; GitHub ID:
https://github.com/sparrell; WWW: `sFractal <http://sfractal.com/>`__
About OASIS TC Open Repositories
--------------------------------

View File

@ -31,8 +31,6 @@ setup(
url='https://oasis-open.github.io/cti-documentation/',
author='OASIS Cyber Threat Intelligence Technical Committee',
author_email='cti-users@lists.oasis-open.org',
maintainer='Chris Lenk',
maintainer_email='clenk@mitre.org',
license='BSD',
classifiers=[
'Development Status :: 4 - Beta',
@ -40,14 +38,14 @@ setup(
'Topic :: Security',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
keywords='stix stix2 json cti cyber threat intelligence',
packages=find_packages(exclude=['*.test', '*.test.*']),
python_requires='>=3.6',
python_requires='>=3.7',
install_requires=[
'pytz',
'requests',

View File

@ -77,6 +77,35 @@ from stix2.utils import detect_spec_version
},
"2.0",
),
(
{
"type": "bundle",
"id": "bundle--8379cb02-8131-47c8-8a7c-9a1f0e0986b1",
"spec_version": "2.1",
"objects": [
{
"type": "identity",
"spec_version": "2.1",
"id": "identity--d7f72e8d-657a-43ec-9324-b3ec67a97486",
"created": "1972-05-21T05:33:09.000Z",
"modified": "1973-05-28T02:10:54.000Z",
"name": "alice",
"identity_class": "individual",
},
{
"type": "marking-definition",
"spec_version": "2.1",
"id": "marking-definition--2a13090f-a493-4b70-85fe-fa021d91dcd2",
"created": "1998-03-27T19:44:53.000Z",
"definition_type": "statement",
"definition": {
"statement": "Copyright (c) ACME Corp.",
},
},
],
},
"2.0",
),
# STIX 2.1 examples
(
{

View File

@ -349,6 +349,10 @@ def test_is_not_sro_dict(dict_):
{"type": "identity"},
{"type": "software"},
{"type": "marking-definition"},
# Presence of spec_version property implies a STIX 2.0 bundle,
# regardless of the property's value. STIX 2.1 bundles don't have a
# "spec_version" property defined.
{"type": "bundle", "spec_version": "2.1"},
{
"type": "bundle",
"id": "bundle--8f431680-6278-4767-ba43-5edb682d7086",
@ -370,12 +374,20 @@ def test_is_object_dict(dict_):
{"type": "identity", "spec_version": "2.1"},
{"type": "software", "spec_version": "2.1"},
{"type": "marking-definition", "spec_version": "2.1"},
{"type": "bundle", "spec_version": "2.1"},
{"type": "language-content", "spec_version": "2.1"},
{"type": "relationship", "spec_version": "2.1"},
{"type": "sighting", "spec_version": "2.1"},
{"type": "foo", "spec_version": "2.1"},
{"type": "foo"},
{
"type": "bundle",
"id": "bundle--8f431680-6278-4767-ba43-5edb682d7086",
"objects": [
{"type": "identity"},
{"type": "software"},
{"type": "marking-definition"},
],
},
],
)
def test_is_not_object_dict(dict_):

View File

@ -382,7 +382,7 @@ def test_is_object_dict(dict_):
{"type": "identity"},
{"type": "software"},
{"type": "marking-definition"},
{"type": "bundle"},
{"type": "bundle", "spec_version": "2.1"},
{"type": "language-content"},
{"type": "relationship"},
{"type": "sighting"},

View File

@ -327,9 +327,15 @@ def detect_spec_version(stix_dict):
obj_type = stix_dict["type"]
if 'spec_version' in stix_dict:
# For STIX 2.0, applies to bundles only.
# For STIX 2.1+, applies to SCOs, SDOs, SROs, and markings only.
v = stix_dict['spec_version']
# For STIX 2.0, applies to bundles only. Presence in a bundle implies
# STIX 2.0; the value applies to the content of the bundle, not the
# bundle itself, so we don't care here about the value.
#
# For STIX 2.1+, applies to non-bundles only.
if obj_type == "bundle":
v = "2.0"
else:
v = stix_dict['spec_version']
elif "id" not in stix_dict:
# Only 2.0 SCOs don't have ID properties
v = "2.0"

View File

@ -1,5 +1,5 @@
[tox]
envlist = py36,py37,py38,py39,packaging,pre-commit-check
envlist = py37,py38,py39,py310,packaging,pre-commit-check
[testenv]
deps =
@ -32,7 +32,7 @@ commands =
[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39, packaging, pre-commit-check
3.10: py310