Skip to content

Commit 32693de

Browse files
authored
Fix regression for reading unknown data types (#32)
1 parent 4dce1ea commit 32693de

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

dissect/cim/cim.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ClassDefinition,
2323
ClassDefinitionProperty,
2424
ClassInstance,
25+
ClassInstanceProperty,
2526
InstanceKey,
2627
PropertyDefaultValues,
2728
Qualifier,
@@ -302,12 +303,6 @@ def __init__(self, cim: CIM, namespace: Namespace, class_: Class, class_instance
302303
self.class_definition = class_.class_definition
303304
self.class_instance = class_instance
304305

305-
def __getattr__(self, attr: str) -> Any:
306-
try:
307-
return getattr(self.class_instance, attr)
308-
except AttributeError:
309-
return object.__getattribute__(self, attr)
310-
311306
@property
312307
def key(self) -> InstanceKey:
313308
return self.class_instance.key
@@ -328,6 +323,10 @@ def cd(self) -> ClassDefinition:
328323
def ci(self) -> ClassInstance:
329324
return self.class_instance
330325

326+
@property
327+
def properties(self) -> dict[str, ClassInstanceProperty]:
328+
return self.class_instance.properties
329+
331330

332331
class Property:
333332
def __init__(self, class_: Class, prop: ClassDefinitionProperty):

dissect/cim/classes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,18 @@ def get_value(self, value: CimType | BOOLEAN_STATES, value_type: c_cim.cim_type)
424424
if t in (CIM_TYPES.STRING, CIM_TYPES.REFERENCE, CIM_TYPES.DATETIME):
425425
return self.get_string(value)
426426

427+
if t in (
428+
CIM_TYPES.INT8,
429+
CIM_TYPES.UINT8,
430+
CIM_TYPES.INT16,
431+
CIM_TYPES.UINT16,
432+
CIM_TYPES.INT32,
433+
CIM_TYPES.UINT32,
434+
CIM_TYPES.INT64,
435+
CIM_TYPES.UINT64,
436+
):
437+
return value
438+
427439
if t == CIM_TYPES.BOOLEAN:
428440
return value == BOOLEAN_STATES.TRUE
429441

tests/test_cim.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@
88
def test_cim(index_bin: BinaryIO, objects_bin: BinaryIO, mappings_bin: list[BinaryIO]) -> None:
99
repo = CIM(index_bin, objects_bin, mappings_bin)
1010
assert repo
11+
12+
subscription_ns = repo.root.namespace("subscription")
13+
binding = next(subscription_ns.class_("__filtertoconsumerbinding").instances)
14+
consumer = subscription_ns.query(binding.properties["Consumer"].value)
15+
assert consumer.properties["SourceName"].value == "Service Control Manager"

0 commit comments

Comments
 (0)