Repository: oasis-open/cti-stix-validator
Pull request #82 (2018-12-13 16:20:30)

Enhancement: Issue #80 Observed Data
Addressed issue #80 by adding a direct error message for when an Observed Data object's object property is not in dictionary format.


Patch:
diff --git a/CHANGELOG b/CHANGELOG
index 70abde0..049fc40 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,12 +1,6 @@
 CHANGELOG
 =========
 
-1.1.1 - 2018-11-30
-
-* Added a flag to warn when all SDOs referenced by SROs are not contained in
-  the same bundle
-* Unpinned jsonschema version
-
 1.1.0 - 2018-10-16
 
 * Add ability to use stdin as input
diff --git a/docs/conf.py b/docs/conf.py
index 9f2fada..f7761a2 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -8,8 +8,8 @@ project = 'stix2-validator'
 copyright = '2018, OASIS Open'
 author = 'OASIS Open'
 
-version = '1.1.1'
-release = '1.1.1'
+version = '1.1.0'
+release = '1.1.0'
 
 language = None
 exclude_patterns = ['_build', '_templates', 'Thumbs.db', '.DS_Store']
diff --git a/docs/options.rst b/docs/options.rst
index f80b180..64735df 100644
--- a/docs/options.rst
+++ b/docs/options.rst
@@ -50,4 +50,4 @@ constructor.
 |                          |                       | validation.                                            |
 +--------------------------+-----------------------+--------------------------------------------------------+
 
-For the list of checks that can be used with the "enabled" or "disabled" options, see the :doc:`Best Practices page <best-practices>`_.
+For the list of checks that can be used with the "enabled" or "disabled" options, see the `Best Practices page <best-practices.rst>`_.
diff --git a/setup.cfg b/setup.cfg
index e247401..60f25d8 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 1.1.1
+current_version = 1.1.0
 commit = True
 tag = True
 
diff --git a/stix2validator/validator.py b/stix2validator/validator.py
index 154ab4a..5517d1b 100644
--- a/stix2validator/validator.py
+++ b/stix2validator/validator.py
@@ -588,7 +588,6 @@ def _get_error_generator(type, obj, schema_dir=None, default='core'):
     except schema_exceptions.RefResolutionError:
         raise SchemaInvalidError('Invalid JSON schema: a JSON '
                                  'reference failed to resolve')
-
     return error_gen
 
 
@@ -626,6 +625,12 @@ def _schema_validate(sdo, options):
 
     # Validate each cyber observable object separately
     if sdo['type'] == 'observed-data' and 'objects' in sdo:
+        # Check if observed data property is in dictionary format
+        if not isinstance(sdo['objects'], dict):
+            error_gens.append(([JSONError("Observed Data objects must be in dict format.", error_prefix)],
+                              error_prefix))
+            return error_gens
+
         for key, obj in iteritems(sdo['objects']):
             if 'type' not in obj:
                 error_gens.append(([JSONError("Observable object must contain a 'type' property.", error_prefix)],
diff --git a/stix2validator/version.py b/stix2validator/version.py
index a82b376..6849410 100644
--- a/stix2validator/version.py
+++ b/stix2validator/version.py
@@ -1,1 +1,1 @@
-__version__ = "1.1.1"
+__version__ = "1.1.0"


Test patch:
diff --git a/stix2validator/test/observed_data_tests.py b/stix2validator/test/observed_data_tests.py
index f102f97..e787223 100644
--- a/stix2validator/test/observed_data_tests.py
+++ b/stix2validator/test/observed_data_tests.py
@@ -842,6 +842,16 @@ class ObservedDataTestCases(ValidatorTest):
         observed_data['objects']['2']['value'] = "http://www.example.com/file.txt"
         self.assertTrueWithOptions(observed_data)
 
+    def test_invalid_objects_property(self):
+        observed_data = copy.deepcopy(self.valid_observed_data)
+        observed_data['objects'] = [
+            {
+                "type": "windows-registry-key",
+                "key": "HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Services\\WSALG2"
+            }
+            ]
+        self.assertFalseWithOptions(observed_data)
+
     def test_url_in_artifact(self):
         observed_data = copy.deepcopy(self.valid_observed_data)
         observed_data['objects']['2'] = {