diff --git a/stix2/common.py b/stix2/common.py index 29cbf62..c8c243d 100644 --- a/stix2/common.py +++ b/stix2/common.py @@ -2,7 +2,7 @@ from .other import ExternalReference, GranularMarking from .properties import (BooleanProperty, ListProperty, ReferenceProperty, - TimestampProperty) + StringProperty, TimestampProperty) from .utils import NOW COMMON_PROPERTIES = { @@ -11,6 +11,7 @@ COMMON_PROPERTIES = { 'modified': TimestampProperty(default=lambda: NOW), 'external_references': ListProperty(ExternalReference), 'revoked': BooleanProperty(), + 'labels': ListProperty(StringProperty), 'created_by_ref': ReferenceProperty(type="identity"), 'object_marking_refs': ListProperty(ReferenceProperty(type="marking-definition")), 'granular_markings': ListProperty(GranularMarking), diff --git a/stix2/sdo.py b/stix2/sdo.py index 693b750..a2f0062 100644 --- a/stix2/sdo.py +++ b/stix2/sdo.py @@ -57,7 +57,6 @@ class Identity(_STIXBase): _properties.update({ 'type': TypeProperty(_type), 'id': IDProperty(_type), - 'labels': ListProperty(StringProperty), 'name': StringProperty(required=True), 'description': StringProperty(), 'identity_class': StringProperty(required=True), diff --git a/stix2/test/test_attack_pattern.py b/stix2/test/test_attack_pattern.py index c0891a5..618875e 100644 --- a/stix2/test/test_attack_pattern.py +++ b/stix2/test/test_attack_pattern.py @@ -67,4 +67,15 @@ def test_parse_attack_pattern(data): assert ap.external_references[0].source_name == 'capec' assert ap.name == "Spear Phishing" + +def test_attack_pattern_invalid_labels(): + with pytest.raises(stix2.exceptions.InvalidValueError): + stix2.AttackPattern( + id="attack-pattern--0c7b5b88-8ff7-4a4d-aa9d-feb398cd0061", + created="2016-05-12T08:17:27Z", + modified="2016-05-12T08:17:27Z", + name="Spear Phishing", + labels=1 + ) + # TODO: Add other examples