Merge branch 'master' of github.com:oasis-open/cti-python-stix2 into 1.1.0-release
commit
aaddeb8b97
|
@ -1,7 +1,7 @@
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
1.1.0 - 2018-11-01
|
1.1.0 - 2018-11-28
|
||||||
|
|
||||||
- Most (if not all) STIX 2.1 SDOs/SROs and core objects have been implemented according to the latest CSD/WD document
|
- Most (if not all) STIX 2.1 SDOs/SROs and core objects have been implemented according to the latest CSD/WD document
|
||||||
- There is an implementation for the conversion scales
|
- There is an implementation for the conversion scales
|
||||||
|
@ -10,6 +10,11 @@ CHANGELOG
|
||||||
- #189 Added extra checks for the pre-commit tool
|
- #189 Added extra checks for the pre-commit tool
|
||||||
- #202 It is now possible to pass a Bundle into add() method in Memory datastores
|
- #202 It is now possible to pass a Bundle into add() method in Memory datastores
|
||||||
|
|
||||||
|
1.0.4 - 2018-11-15
|
||||||
|
|
||||||
|
* #225 MemorySource fix to support custom objects
|
||||||
|
* #212 More consistency in Observable extensions behavior/error messages
|
||||||
|
|
||||||
1.0.3 - 2018-10-31
|
1.0.3 - 2018-10-31
|
||||||
|
|
||||||
* #187 Pickle proof objects
|
* #187 Pickle proof objects
|
||||||
|
|
|
@ -131,6 +131,10 @@ select additional or substitute Maintainers, per `consensus agreements
|
||||||
- `Chris Lenk <mailto:clenk@mitre.org>`__; GitHub ID:
|
- `Chris Lenk <mailto:clenk@mitre.org>`__; GitHub ID:
|
||||||
https://github.com/clenk/; WWW: `MITRE Corporation <http://www.mitre.org/>`__
|
https://github.com/clenk/; WWW: `MITRE Corporation <http://www.mitre.org/>`__
|
||||||
|
|
||||||
|
- `Emmanuelle Vargas-Gonzalez <mailto:emmanuelle@mitre.org>`__; GitHub ID:
|
||||||
|
https://github.com/emmanvg/; WWW: `MITRE
|
||||||
|
Corporation <https://www.mitre.org/>`__
|
||||||
|
|
||||||
About OASIS TC Open Repositories
|
About OASIS TC Open Repositories
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 1.1.0
|
current_version = 1.0.4
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,8 @@ class _ObjectFamily(object):
|
||||||
|
|
||||||
def add(self, obj):
|
def add(self, obj):
|
||||||
self.all_versions[obj["modified"]] = obj
|
self.all_versions[obj["modified"]] = obj
|
||||||
if self.latest_version is None or \
|
if (self.latest_version is None or
|
||||||
obj["modified"] > self.latest_version["modified"]:
|
obj["modified"] > self.latest_version["modified"]):
|
||||||
self.latest_version = obj
|
self.latest_version = obj
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
|
@ -503,8 +503,7 @@ class ExtensionsProperty(DictionaryProperty):
|
||||||
|
|
||||||
v = 'v' + self.spec_version.replace('.', '')
|
v = 'v' + self.spec_version.replace('.', '')
|
||||||
|
|
||||||
if self.enclosing_type in STIX2_OBJ_MAPS[v]['observable-extensions']:
|
specific_type_map = STIX2_OBJ_MAPS[v]['observable-extensions'].get(self.enclosing_type, {})
|
||||||
specific_type_map = STIX2_OBJ_MAPS[v]['observable-extensions'][self.enclosing_type]
|
|
||||||
for key, subvalue in dictified.items():
|
for key, subvalue in dictified.items():
|
||||||
if key in specific_type_map:
|
if key in specific_type_map:
|
||||||
cls = specific_type_map[key]
|
cls = specific_type_map[key]
|
||||||
|
@ -521,8 +520,6 @@ class ExtensionsProperty(DictionaryProperty):
|
||||||
raise ValueError("Cannot determine extension type.")
|
raise ValueError("Cannot determine extension type.")
|
||||||
else:
|
else:
|
||||||
raise CustomContentError("Can't parse unknown extension type: {}".format(key))
|
raise CustomContentError("Can't parse unknown extension type: {}".format(key))
|
||||||
else:
|
|
||||||
raise ValueError("The enclosing type '{}' has no extensions defined".format(self.enclosing_type))
|
|
||||||
return dictified
|
return dictified
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -884,9 +884,10 @@ def test_parse_observable_with_custom_extension():
|
||||||
assert parsed.extensions['x-new-ext'].property2 == 12
|
assert parsed.extensions['x-new-ext'].property2 == 12
|
||||||
|
|
||||||
|
|
||||||
def test_parse_observable_with_unregistered_custom_extension():
|
@pytest.mark.parametrize("data", [
|
||||||
input_str = """{
|
# URL is not in EXT_MAP
|
||||||
"type": "domain-name",
|
"""{
|
||||||
|
"type": "url",
|
||||||
"value": "example.com",
|
"value": "example.com",
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"x-foobar-ext": {
|
"x-foobar-ext": {
|
||||||
|
@ -894,13 +895,25 @@ def test_parse_observable_with_unregistered_custom_extension():
|
||||||
"property2": 12
|
"property2": 12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}"""
|
}""",
|
||||||
|
# File is in EXT_MAP
|
||||||
|
"""{
|
||||||
|
"type": "file",
|
||||||
|
"name": "foo.txt",
|
||||||
|
"extensions": {
|
||||||
|
"x-foobar-ext": {
|
||||||
|
"property1": "foo",
|
||||||
|
"property2": 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}""",
|
||||||
|
])
|
||||||
|
def test_parse_observable_with_unregistered_custom_extension(data):
|
||||||
with pytest.raises(ValueError) as excinfo:
|
with pytest.raises(ValueError) as excinfo:
|
||||||
stix2.parse_observable(input_str, version='2.0')
|
stix2.parse_observable(data, version='2.0')
|
||||||
assert "Can't parse unknown extension type" in str(excinfo.value)
|
assert "Can't parse unknown extension type" in str(excinfo.value)
|
||||||
|
|
||||||
parsed_ob = stix2.parse_observable(input_str, allow_custom=True, version='2.0')
|
parsed_ob = stix2.parse_observable(data, allow_custom=True, version='2.0')
|
||||||
assert parsed_ob['extensions']['x-foobar-ext']['property1'] == 'foo'
|
assert parsed_ob['extensions']['x-foobar-ext']['property1'] == 'foo'
|
||||||
assert not isinstance(parsed_ob['extensions']['x-foobar-ext'], stix2.base._STIXBase)
|
assert not isinstance(parsed_ob['extensions']['x-foobar-ext'], stix2.base._STIXBase)
|
||||||
|
|
||||||
|
|
|
@ -452,7 +452,7 @@ def test_extension_property_invalid_type():
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert 'no extensions defined' in str(excinfo.value)
|
assert "Can't parse unknown extension" in str(excinfo.value)
|
||||||
|
|
||||||
|
|
||||||
def test_extension_at_least_one_property_constraint():
|
def test_extension_at_least_one_property_constraint():
|
||||||
|
|
|
@ -888,9 +888,10 @@ def test_parse_observable_with_custom_extension():
|
||||||
assert parsed.extensions['x-new-ext'].property2 == 12
|
assert parsed.extensions['x-new-ext'].property2 == 12
|
||||||
|
|
||||||
|
|
||||||
def test_parse_observable_with_unregistered_custom_extension():
|
@pytest.mark.parametrize("data", [
|
||||||
input_str = """{
|
# URL is not in EXT_MAP
|
||||||
"type": "domain-name",
|
"""{
|
||||||
|
"type": "url",
|
||||||
"value": "example.com",
|
"value": "example.com",
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"x-foobar-ext": {
|
"x-foobar-ext": {
|
||||||
|
@ -898,13 +899,25 @@ def test_parse_observable_with_unregistered_custom_extension():
|
||||||
"property2": 12
|
"property2": 12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}"""
|
}""",
|
||||||
|
# File is in EXT_MAP
|
||||||
|
"""{
|
||||||
|
"type": "file",
|
||||||
|
"name": "foo.txt",
|
||||||
|
"extensions": {
|
||||||
|
"x-foobar-ext": {
|
||||||
|
"property1": "foo",
|
||||||
|
"property2": 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}""",
|
||||||
|
])
|
||||||
|
def test_parse_observable_with_unregistered_custom_extension(data):
|
||||||
with pytest.raises(ValueError) as excinfo:
|
with pytest.raises(ValueError) as excinfo:
|
||||||
stix2.parse_observable(input_str, version='2.1')
|
stix2.parse_observable(data, version='2.1')
|
||||||
assert "Can't parse unknown extension type" in str(excinfo.value)
|
assert "Can't parse unknown extension type" in str(excinfo.value)
|
||||||
|
|
||||||
parsed_ob = stix2.parse_observable(input_str, allow_custom=True, version='2.1')
|
parsed_ob = stix2.parse_observable(data, allow_custom=True, version='2.1')
|
||||||
assert parsed_ob['extensions']['x-foobar-ext']['property1'] == 'foo'
|
assert parsed_ob['extensions']['x-foobar-ext']['property1'] == 'foo'
|
||||||
assert not isinstance(parsed_ob['extensions']['x-foobar-ext'], stix2.base._STIXBase)
|
assert not isinstance(parsed_ob['extensions']['x-foobar-ext'], stix2.base._STIXBase)
|
||||||
|
|
||||||
|
|
|
@ -461,7 +461,7 @@ def test_extension_property_invalid_type():
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert 'no extensions defined' in str(excinfo.value)
|
assert "Can't parse unknown extension" in str(excinfo.value)
|
||||||
|
|
||||||
|
|
||||||
def test_extension_at_least_one_property_constraint():
|
def test_extension_at_least_one_property_constraint():
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = "1.1.0"
|
__version__ = "1.0.4"
|
||||||
|
|
Loading…
Reference in New Issue