From 7baeb153fafc50f1afa8efb6f9a5f899c6866b78 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Wed, 20 Jun 2018 15:24:27 -0500 Subject: [PATCH] Correct "image_weight" to "image_width". Fix #194. --- stix2/test/test_observed_data.py | 45 ++++++++++++++++++++++++++++++++ stix2/v20/observables.py | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/stix2/test/test_observed_data.py b/stix2/test/test_observed_data.py index 30c3cab..1242728 100644 --- a/stix2/test/test_observed_data.py +++ b/stix2/test/test_observed_data.py @@ -765,6 +765,51 @@ def test_file_example_with_RasterImageExt_Object(): assert f.extensions["raster-image-ext"].exif_tags["XResolution"] == 4928 +RASTER_IMAGE_EXT = """{ +"type": "observed-data", +"id": "observed-data--b67d30ff-02ac-498a-92f9-32f845f448cf", +"created": "2016-04-06T19:58:16.000Z", +"modified": "2016-04-06T19:58:16.000Z", +"first_observed": "2015-12-21T19:00:00Z", +"last_observed": "2015-12-21T19:00:00Z", +"number_observed": 1, +"objects": { + "0": { + "type": "file", + "name": "picture.jpg", + "hashes": { + "SHA-256": "35a01331e9ad96f751278b891b6ea09699806faedfa237d40513d92ad1b7100f" + }, + "extensions": { + "raster-image-ext": { + "image_height": 768, + "image_width": 1024, + "bits_per_pixel": 72, + "image_compression_algorithm": "JPEG", + "exif_tags": { + "Make": "Nikon", + "Model": "D7000", + "XResolution": 4928, + "YResolution": 3264 + } + } + } + } +} +} +""" + + +def test_raster_image_ext_parse(): + obj = stix2.parse(RASTER_IMAGE_EXT, allow_custom=False) + assert obj.objects["0"].extensions['raster-image-ext'].image_width == 1024 + + +def test_raster_images_ext_create(): + ext = stix2.RasterImageExt(image_width=1024) + assert "image_width" in str(ext) + + def test_file_example_with_WindowsPEBinaryExt(): f = stix2.File(name="qwerty.dll", extensions={ diff --git a/stix2/v20/observables.py b/stix2/v20/observables.py index 098c7dd..659929b 100644 --- a/stix2/v20/observables.py +++ b/stix2/v20/observables.py @@ -302,7 +302,7 @@ class RasterImageExt(_Extension): _properties = OrderedDict() _properties.update([ ('image_height', IntegerProperty()), - ('image_weight', IntegerProperty()), + ('image_width', IntegerProperty()), ('bits_per_pixel', IntegerProperty()), ('image_compression_algorithm', StringProperty()), ('exif_tags', DictionaryProperty()),