Skip to content

Commit

Permalink
Rename type to type_ in several objects. Fix #267
Browse files Browse the repository at this point in the history
  • Loading branch information
gtback committed Jul 6, 2015
1 parent 0a17850 commit 6316ca2
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cybox/objects/disk_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 4 additions & 3 deletions cybox/objects/disk_partition_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand All @@ -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)
2 changes: 1 addition & 1 deletion cybox/objects/win_event_log_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cybox/objects/win_network_share_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
38 changes: 38 additions & 0 deletions cybox/test/objects/disk_partition_test.py
Original file line number Diff line number Diff line change
@@ -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()
42 changes: 42 additions & 0 deletions cybox/test/objects/disk_test.py
Original file line number Diff line number Diff line change
@@ -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()
51 changes: 51 additions & 0 deletions cybox/test/objects/win_event_log_test.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion cybox/test/objects/win_event_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions cybox/test/objects/win_network_share_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 6316ca2

Please sign in to comment.