Repository: oasis-open/cti-python-stix2
Pull request #69 (2017-10-06 14:31:27)

Update required properties in SDOs
Related to issue #68 


Patch:
diff --git a/README.rst b/README.rst
index 17efd8a..d4762c1 100644
--- a/README.rst
+++ b/README.rst
@@ -1,4 +1,4 @@
-|Build Status| |codecov|
+|Build_Status| |Coverage| |Version|
 
 cti-python-stix2
 ================
@@ -282,7 +282,9 @@ general questions about Open Repository participation to OASIS Staff at
 repository-admin@oasis-open.org and any specific CLA-related questions
 to repository-cla@oasis-open.org.
 
-.. |Build Status| image:: https://travis-ci.org/oasis-open/cti-python-stix2.svg?branch=master
+.. |Build_Status| image:: https://travis-ci.org/oasis-open/cti-python-stix2.svg?branch=master
    :target: https://travis-ci.org/oasis-open/cti-python-stix2
-.. |codecov| image:: https://codecov.io/gh/oasis-open/cti-python-stix2/branch/master/graph/badge.svg
+.. |Coverage| image:: https://codecov.io/gh/oasis-open/cti-python-stix2/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/oasis-open/cti-python-stix2
+.. |Version| image:: https://img.shields.io/pypi/v/stix2.svg?maxAge=3600
+   :target: https://pypi.python.org/pypi/stix2/
diff --git a/stix2/sdo.py b/stix2/sdo.py
index 53f965d..4664d99 100644
--- a/stix2/sdo.py
+++ b/stix2/sdo.py
@@ -116,7 +116,6 @@ class Indicator(STIXDomainObject):
         ('created_by_ref', ReferenceProperty(type="identity")),
         ('created', TimestampProperty(default=lambda: NOW, precision='millisecond')),
         ('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')),
-        ('labels', ListProperty(StringProperty, required=True)),
         ('name', StringProperty()),
         ('description', StringProperty()),
         ('pattern', PatternProperty(required=True)),
@@ -124,6 +123,7 @@ class Indicator(STIXDomainObject):
         ('valid_until', TimestampProperty()),
         ('kill_chain_phases', ListProperty(KillChainPhase)),
         ('revoked', BooleanProperty()),
+        ('labels', ListProperty(StringProperty, required=True)),
         ('external_references', ListProperty(ExternalReference)),
         ('object_marking_refs', ListProperty(ReferenceProperty(type="marking-definition"))),
         ('granular_markings', ListProperty(GranularMarking)),
@@ -191,7 +191,7 @@ class ObservedData(STIXDomainObject):
         ('first_observed', TimestampProperty(required=True)),
         ('last_observed', TimestampProperty(required=True)),
         ('number_observed', IntegerProperty(required=True)),
-        ('objects', ObservableProperty()),
+        ('objects', ObservableProperty(required=True)),
         ('revoked', BooleanProperty()),
         ('labels', ListProperty(StringProperty)),
         ('external_references', ListProperty(ExternalReference)),
@@ -212,8 +212,8 @@ class Report(STIXDomainObject):
         ('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')),
         ('name', StringProperty(required=True)),
         ('description', StringProperty()),
-        ('published', TimestampProperty()),
-        ('object_refs', ListProperty(ReferenceProperty)),
+        ('published', TimestampProperty(required=True)),
+        ('object_refs', ListProperty(ReferenceProperty, required=True)),
         ('revoked', BooleanProperty()),
         ('labels', ListProperty(StringProperty, required=True)),
         ('external_references', ListProperty(ExternalReference)),


Test patch:
diff --git a/stix2/test/test_bundle.py b/stix2/test/test_bundle.py
index d70f63a..c7c95a8 100644
--- a/stix2/test/test_bundle.py
+++ b/stix2/test/test_bundle.py
@@ -13,11 +13,11 @@ EXPECTED_BUNDLE = """{
             "id": "indicator--00000000-0000-0000-0000-000000000001",
             "created": "2017-01-01T12:34:56.000Z",
             "modified": "2017-01-01T12:34:56.000Z",
+            "pattern": "[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']",
+            "valid_from": "2017-01-01T12:34:56Z",
             "labels": [
                 "malicious-activity"
-            ],
-            "pattern": "[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']",
-            "valid_from": "2017-01-01T12:34:56Z"
+            ]
         },
         {
             "type": "malware",
diff --git a/stix2/test/test_indicator.py b/stix2/test/test_indicator.py
index 1f8e3bd..d2c046f 100644
--- a/stix2/test/test_indicator.py
+++ b/stix2/test/test_indicator.py
@@ -14,11 +14,11 @@ EXPECTED_INDICATOR = """{
     "id": "indicator--01234567-89ab-cdef-0123-456789abcdef",
     "created": "2017-01-01T00:00:01.000Z",
     "modified": "2017-01-01T00:00:01.000Z",
+    "pattern": "[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']",
+    "valid_from": "1970-01-01T00:00:01Z",
     "labels": [
         "malicious-activity"
-    ],
-    "pattern": "[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']",
-    "valid_from": "1970-01-01T00:00:01Z"
+    ]
 }"""
 
 EXPECTED_INDICATOR_REPR = "Indicator(" + " ".join("""
@@ -26,9 +26,9 @@ EXPECTED_INDICATOR_REPR = "Indicator(" + " ".join("""
     id='indicator--01234567-89ab-cdef-0123-456789abcdef',
     created='2017-01-01T00:00:01.000Z',
     modified='2017-01-01T00:00:01.000Z',
-    labels=['malicious-activity'],
     pattern="[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']",
-    valid_from='1970-01-01T00:00:01Z'
+    valid_from='1970-01-01T00:00:01Z',
+    labels=['malicious-activity']
 """.split()) + ")"
 
 
@@ -39,11 +39,11 @@ def test_indicator_with_all_required_properties():
     ind = stix2.Indicator(
         type="indicator",
         id=INDICATOR_ID,
-        labels=['malicious-activity'],
-        pattern="[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']",
         created=now,
         modified=now,
+        pattern="[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']",
         valid_from=epoch,
+        labels=['malicious-activity'],
     )
 
     assert str(ind) == EXPECTED_INDICATOR