diff --git a/cybox/objects/disk_object.py b/cybox/objects/disk_object.py index d316a543..f8800557 100644 --- a/cybox/objects/disk_object.py +++ b/cybox/objects/disk_object.py @@ -28,4 +28,4 @@ class Disk(ObjectProperties): disk_size = fields.TypedField('Disk_Size', UnsignedLong) free_space = fields.TypedField('Free_Space', UnsignedLong) partition_list = fields.TypedField('Partition_List', PartitionList) - type = fields.TypedField('Type', String) + type_ = fields.TypedField('Type', String) diff --git a/cybox/objects/disk_partition_object.py b/cybox/objects/disk_partition_object.py index c72cd1fb..f49919db 100644 --- a/cybox/objects/disk_partition_object.py +++ b/cybox/objects/disk_partition_object.py @@ -4,7 +4,8 @@ from mixbox import fields import cybox.bindings.disk_partition_object as disk_partition_binding -from cybox.common import ObjectProperties, String, Integer, Name, UnsignedLong +from cybox.common import (DateTime, Integer, Name, ObjectProperties, String, + UnsignedLong) class DiskPartition(ObjectProperties): @@ -14,7 +15,7 @@ class DiskPartition(ObjectProperties): _XSI_NS = "DiskPartitionObj" _XSI_TYPE = "DiskPartitionObjectType" - created = fields.TypedField('Created', String) + created = fields.TypedField('Created', DateTime) device_name = fields.TypedField('Device_Name', Name) mount_point = fields.TypedField('Mount_Point', String) partition_id = fields.TypedField('Partition_ID', Integer) @@ -23,4 +24,4 @@ class DiskPartition(ObjectProperties): space_left = fields.TypedField('Space_Left', UnsignedLong) space_used = fields.TypedField('Space_Used', UnsignedLong) total_space = fields.TypedField('Total_Space', UnsignedLong) - type = fields.TypedField('Type', UnsignedLong) + type_ = fields.TypedField('Type', String) diff --git a/cybox/objects/win_event_log_object.py b/cybox/objects/win_event_log_object.py index db19dfe8..9766e0a1 100644 --- a/cybox/objects/win_event_log_object.py +++ b/cybox/objects/win_event_log_object.py @@ -24,7 +24,7 @@ class WinEventLog(ObjectProperties): _XSI_TYPE = "WindowsEventLogObjectType" eid = fields.TypedField("EID", Long) - type = fields.TypedField("Type", String) + type_ = fields.TypedField("Type", String) log = fields.TypedField("Log", String) message = fields.TypedField("Message", String) category_num = fields.TypedField("Category_Num", Long) diff --git a/cybox/objects/win_network_share_object.py b/cybox/objects/win_network_share_object.py index ff8bbf98..b84ca6d5 100644 --- a/cybox/objects/win_network_share_object.py +++ b/cybox/objects/win_network_share_object.py @@ -26,4 +26,4 @@ class WinNetworkShare(ObjectProperties): local_path = fields.TypedField("Local_Path", String) max_uses = fields.TypedField("Max_Uses", NonNegativeInteger) netname = fields.TypedField("Netname", String) - type = fields.TypedField("Type", String) + type_ = fields.TypedField("Type", String) diff --git a/cybox/test/objects/disk_partition_test.py b/cybox/test/objects/disk_partition_test.py new file mode 100644 index 00000000..4658bc24 --- /dev/null +++ b/cybox/test/objects/disk_partition_test.py @@ -0,0 +1,38 @@ +# Copyright (c) 2015, The MITRE Corporation. All rights reserved. +# See LICENSE.txt for complete terms. + +import unittest + +from mixbox.vendor.six import u + +from cybox.objects.disk_partition_object import DiskPartition +from cybox.test.objects import ObjectTestCase + + +class TestDiskPartition(ObjectTestCase, unittest.TestCase): + object_type = "DiskPartitionObjectType" + klass = DiskPartition + + _full_dict = { + 'created': "2007-10-05T07:14:21+00:00", + 'device_name': u("C partition"), + 'mount_point': u("C:"), + 'partition_id': 8, + 'partition_length': 5000000, + 'partition_offset': 1000000, + 'space_left': 50000, + 'space_used': 50001, + 'total_space': 100001, + 'type': "PARTITION_FAT_12", + 'xsi:type': object_type, + } + + # https://github.com/CybOXProject/python-cybox/issues/267 + def test_type(self): + partition = DiskPartition() + partition.type_ = "PARTITION_FAT32" + self.assertTrue(b"PARTITION_FAT32" in partition.to_xml()) + + +if __name__ == "__main__": + unittest.main() diff --git a/cybox/test/objects/disk_test.py b/cybox/test/objects/disk_test.py new file mode 100644 index 00000000..cd168ce8 --- /dev/null +++ b/cybox/test/objects/disk_test.py @@ -0,0 +1,42 @@ +# Copyright (c) 2015, The MITRE Corporation. All rights reserved. +# See LICENSE.txt for complete terms. + +import unittest + +from mixbox.vendor.six import u + +from cybox.objects.disk_object import Disk +from cybox.test.objects import ObjectTestCase + + +class TestDisk(ObjectTestCase, unittest.TestCase): + object_type = "DiskObjectType" + klass = Disk + + _full_dict = { + 'disk_name': u("A disk"), + 'disk_size': 12345678, + 'free_space': 1234567, + 'partition_list': [ + { + 'device_name': u("A partition"), + 'xsi:type': "DiskPartitionObjectType", + }, + { + 'device_name': u("B partition"), + 'xsi:type': "DiskPartitionObjectType", + }, + ], + 'type': u("Fixed"), + 'xsi:type': object_type, + } + + # https://github.com/CybOXProject/python-cybox/issues/267 + def test_type(self): + disk = Disk() + disk.type_ = "Fixed" + self.assertTrue(b"Fixed" in disk.to_xml()) + + +if __name__ == "__main__": + unittest.main() diff --git a/cybox/test/objects/win_event_log_test.py b/cybox/test/objects/win_event_log_test.py new file mode 100644 index 00000000..18b3968a --- /dev/null +++ b/cybox/test/objects/win_event_log_test.py @@ -0,0 +1,51 @@ +# Copyright (c) 2015, The MITRE Corporation. All rights reserved. +# See LICENSE.txt for complete terms. + +import unittest + +from mixbox.vendor.six import u + +from cybox.objects.win_event_log_object import WinEventLog +from cybox.test.objects import ObjectTestCase + + +class TestWinEventLog(ObjectTestCase, unittest.TestCase): + object_type = "WindowsEventLogObjectType" + klass = WinEventLog + + _full_dict = { + 'eid': 4000000, + 'type': u("warning"), + 'log': u("Bad things that happened"), + 'message': u("Something bad happened"), + 'category_num': 43, + 'category': u("Things that go bump in the night"), + 'generation_time': "2014-10-05T07:14:21+00:00", + 'source': u("Under the bed"), + 'machine': u("apple"), + 'user': u("Timmy"), + 'blob': u("d234b6LKJSBLKB2453452"), + 'correlation_activity_id': u("abc123"), + 'correlation_related_activity_id': u("def456"), + 'execution_process_id': u("ghi789"), + 'execution_thread_id': u("jkl0ab"), + 'index': 123456789, + 'reserved': 0x654c664c, + 'unformatted_message_list': [ + u("I looked under the bed"), + u("and saw"), + u("a monster"), + ], + 'write_time': "2014-10-05T08:14:21+00:00", + 'xsi:type': "WindowsEventLogObjectType", + } + + # https://github.com/CybOXProject/python-cybox/issues/267 + def test_type(self): + log = WinEventLog() + log.type_ = "Success" + self.assertTrue(b"Success" in log.to_xml()) + + +if __name__ == "__main__": + unittest.main() diff --git a/cybox/test/objects/win_event_test.py b/cybox/test/objects/win_event_test.py index 974a83f5..9e580a5d 100644 --- a/cybox/test/objects/win_event_test.py +++ b/cybox/test/objects/win_event_test.py @@ -9,7 +9,7 @@ from cybox.test.objects import ObjectTestCase -class TestWinThread(ObjectTestCase, unittest.TestCase): +class TestWinEvent(ObjectTestCase, unittest.TestCase): object_type = "WindowsEventObjectType" klass = WinEvent diff --git a/cybox/test/objects/win_network_share_test.py b/cybox/test/objects/win_network_share_test.py index bc582ddb..93fd0186 100644 --- a/cybox/test/objects/win_network_share_test.py +++ b/cybox/test/objects/win_network_share_test.py @@ -30,5 +30,12 @@ class TestWinNetworkShare(ObjectTestCase, unittest.TestCase): 'xsi:type': object_type, } + # https://github.com/CybOXProject/python-cybox/issues/267 + def test_type(self): + share = WinNetworkShare() + share.type_ = "STREE_DISKTREE" + self.assertTrue(b"STREE_DISKTREE" in share.to_xml()) + + if __name__ == "__main__": unittest.main()