Skip to content

Commit a17fb13

Browse files
Fix #60 issue, rename ObjectEntity class to UcoObject class
1 parent 089c75f commit a17fb13

File tree

10 files changed

+58
-60
lines changed

10 files changed

+58
-60
lines changed

case_mapping/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class FacetEntity(UcoInherentCharacterizationThing):
192192
pass
193193

194194

195-
class ObjectEntity(UcoThing):
195+
class UcoObject(UcoThing):
196196
def __init__(
197197
self,
198198
*args: Any,
@@ -201,7 +201,7 @@ def __init__(
201201
facets: Union[None, FacetEntity, Sequence[FacetEntity]] = None,
202202
modified_time: Union[None, datetime, Sequence[datetime]] = None,
203203
object_created_time: Optional[datetime] = None,
204-
object_marking: Union[None, "ObjectEntity", Sequence["ObjectEntity"]] = None,
204+
object_marking: Union[None, "UcoObject", Sequence["UcoObject"]] = None,
205205
name: Optional[str] = None,
206206
spec_version: Optional[str] = None,
207207
tag: Union[None, str, Sequence[str]] = None,
@@ -287,7 +287,7 @@ def append_indexed_items(self, *args):
287287
self["olo:length"] = str(current_index)
288288

289289

290-
class IdentityAbstraction(ObjectEntity):
290+
class IdentityAbstraction(UcoObject):
291291
"""
292292
An identity abstraction is a grouping of identifying characteristics unique to an individual or organization. This class is an ontological structural abstraction for this concept. Implementations of this concept should utilize the identity:Identity class.
293293
"""

case_mapping/case/investigation.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from pytz import timezone
55

6-
from ..base import FacetEntity, ObjectEntity
6+
from ..base import FacetEntity, UcoObject
77
from ..uco.action import Action
88
from ..uco.location import Location
99

@@ -15,13 +15,13 @@ def __init__(
1515
description: Optional[str] = None,
1616
facets: Optional[List[FacetEntity]] = None,
1717
end_time: Optional[datetime] = None,
18-
environment: Optional[ObjectEntity] = None,
19-
instrument: Union[None, ObjectEntity, List[ObjectEntity]] = None,
18+
environment: Optional[UcoObject] = None,
19+
instrument: Union[None, UcoObject, List[UcoObject]] = None,
2020
location: Union[None, Location, List[Location]] = None,
2121
name: Optional[str] = None,
22-
objects: Union[None, ObjectEntity, List[ObjectEntity]] = None,
23-
performer: Optional[ObjectEntity] = None,
24-
results: Union[None, ObjectEntity, List[ObjectEntity]] = None,
22+
objects: Union[None, UcoObject, List[UcoObject]] = None,
23+
performer: Optional[UcoObject] = None,
24+
results: Union[None, UcoObject, List[UcoObject]] = None,
2525
start_time: Optional[datetime] = None,
2626
**kwargs: Any,
2727
) -> None:
@@ -46,7 +46,7 @@ def __init__(
4646
self["@type"] = "case-investigation:InvestigativeAction"
4747

4848

49-
class CaseInvestigation(ObjectEntity):
49+
class CaseInvestigation(UcoObject):
5050
def __init__(self, name=None, focus=None, description=None, core_objects=None):
5151
"""
5252
An investigative action is a CASE object that represents the who, where, when of investigation
@@ -69,11 +69,11 @@ def __init__(self, name=None, focus=None, description=None, core_objects=None):
6969
self.append_core_objects(core_objects)
7070

7171

72-
class ProvenanceRecord(ObjectEntity):
72+
class ProvenanceRecord(UcoObject):
7373
def __init__(
7474
self,
7575
exhibit_number: Optional[str] = None,
76-
uco_core_objects: Union[None, ObjectEntity, List[ObjectEntity]] = None,
76+
uco_core_objects: Union[None, UcoObject, List[UcoObject]] = None,
7777
):
7878
super().__init__()
7979
self["@type"] = "case-investigation:ProvenanceRecord"

case_mapping/drafting/entities.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ..base import FacetEntity, ObjectEntity, unpack_args_array
1+
from ..base import FacetEntity, UcoObject, unpack_args_array
22

33

44
class FacetPassiveDNS(FacetEntity):
@@ -109,7 +109,7 @@ def __init__(self, isp_name=None):
109109
self._str_vars(**{"drafting:ispName": isp_name})
110110

111111

112-
class ObservablePort(ObjectEntity):
112+
class ObservablePort(UcoObject):
113113
def __init__(self, port, has_changed=None, state=None):
114114
"""
115115
Used to represent a network port
@@ -475,7 +475,7 @@ def __init__(self, start_index, end_index, ml_job=None):
475475
self._node_reference_vars(**{"drafting:machineLearningJob": ml_job})
476476

477477

478-
class TextIntervals(ObjectEntity):
478+
class TextIntervals(UcoObject):
479479
def __init__(self, indexed_items=None):
480480
super().__init__()
481481
self["@type"] = "drafting:TextIntervals"

case_mapping/uco/action.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33

44
from pytz import timezone
55

6-
from ..base import FacetEntity, ObjectEntity, unpack_args_array
6+
from ..base import FacetEntity, UcoObject, unpack_args_array
77
from .location import Location
88

99

10-
class Action(ObjectEntity):
10+
class Action(UcoObject):
1111
def __init__(
1212
self,
1313
*args: Any,
1414
action_count: Optional[int] = None,
1515
action_status: Optional[str] = None,
1616
end_time: Optional[datetime] = None,
17-
environment: Optional[ObjectEntity] = None,
18-
error: Optional[ObjectEntity] = None,
19-
instrument: Union[None, ObjectEntity, Sequence[ObjectEntity]] = None,
17+
environment: Optional[UcoObject] = None,
18+
error: Optional[UcoObject] = None,
19+
instrument: Union[None, UcoObject, Sequence[UcoObject]] = None,
2020
location: Union[None, Location, Sequence[Location]] = None,
21-
objects: Union[None, ObjectEntity, Sequence[ObjectEntity]] = None,
22-
participant: Union[None, Sequence[ObjectEntity]] = None,
23-
performer: Optional[ObjectEntity] = None,
24-
results: Union[None, ObjectEntity, Sequence[ObjectEntity]] = None,
21+
objects: Union[None, UcoObject, Sequence[UcoObject]] = None,
22+
participant: Union[None, Sequence[UcoObject]] = None,
23+
performer: Optional[UcoObject] = None,
24+
results: Union[None, UcoObject, Sequence[UcoObject]] = None,
2525
start_time: Optional[datetime] = None,
26-
subaction: Optional[ObjectEntity] = None,
26+
subaction: Optional[UcoObject] = None,
2727
**kwargs: Any,
2828
) -> None:
2929
"""

case_mapping/uco/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
from pytz import timezone
55

6-
from ..base import ObjectEntity, unpack_args_array
6+
from ..base import UcoObject, unpack_args_array
77

88

9-
class Bundle(ObjectEntity):
9+
class Bundle(UcoObject):
1010
def __init__(
1111
self,
1212
*args: Any,
@@ -68,12 +68,12 @@ def append_to_uco_core_description(self, *args):
6868
self._append_strings("uco-core:description", *args)
6969

7070

71-
class Relationship(ObjectEntity):
71+
class Relationship(UcoObject):
7272
def __init__(
7373
self,
7474
*args: Any,
75-
source: ObjectEntity,
76-
target: ObjectEntity,
75+
source: UcoObject,
76+
target: UcoObject,
7777
start_time: Optional[datetime] = None,
7878
end_time: Optional[datetime] = None,
7979
kind_of_relationship: str,

case_mapping/uco/identity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Dict, Optional
22

3-
from ..base import FacetEntity, IdentityAbstraction, ObjectEntity
3+
from ..base import FacetEntity, IdentityAbstraction, UcoObject
44

55

66
class FacetBirthInformation(FacetEntity):

case_mapping/uco/location.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import Optional
22

3-
from ..base import FacetEntity, ObjectEntity
3+
from ..base import FacetEntity, UcoObject
44

55

6-
class Location(ObjectEntity):
6+
class Location(UcoObject):
77
def __init__(self, facets=None):
88
super().__init__()
99
self["@type"] = "uco-location:Location"

case_mapping/uco/observable.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
from cdo_local_uuid import local_uuid
55

6-
from ..base import FacetEntity, ObjectEntity, UcoInherentCharacterizationThing
6+
from ..base import FacetEntity, UcoInherentCharacterizationThing, UcoObject
77
from .action import Action
88
from .core import Relationship
99
from .identity import Identity
1010
from .location import Location
1111
from .types import Dictionary
1212

1313

14-
class ObservableDomainName(ObjectEntity):
14+
class ObservableDomainName(UcoObject):
1515
def __init__(self, has_changed=None, state=None, facets=None):
1616
"""
1717
Used to represent domain name objects
@@ -39,7 +39,7 @@ def __init__(self, domain, isTLD=False):
3939
self._bool_vars(**{"uco-observable:isTLD": isTLD})
4040

4141

42-
class ObservableHostName(ObjectEntity):
42+
class ObservableHostName(UcoObject):
4343
def __init__(self, hostname, has_changed=None, state=None):
4444
"""
4545
Used to represent host names of devices on a network
@@ -55,7 +55,7 @@ def __init__(self, hostname, has_changed=None, state=None):
5555
self._bool_vars(**{"uco-observable:hasChanged": has_changed})
5656

5757

58-
class ObservableIPv4Address(ObjectEntity):
58+
class ObservableIPv4Address(UcoObject):
5959
def __init__(self, has_changed=None, state=None, facets=None):
6060
"""
6161
Used to represent an IPv4 address object
@@ -80,7 +80,7 @@ def __init__(self, ip=None):
8080
self._str_vars(**{"uco-observable:addressValue": ip})
8181

8282

83-
class ObservableAutonomousSystem(ObjectEntity):
83+
class ObservableAutonomousSystem(UcoObject):
8484
def __init__(self, has_changed=None, state=None, facets=None):
8585
"""
8686
An autonomous system is a collection of connected Internet Protocol (IP) routing prefixes under the control of one or more network operators on behalf of a single administrative entity or domain that presents a common, clearly defined routing policy to the Internet.
@@ -110,7 +110,7 @@ def __init__(self, as_number, as_handle=None):
110110
self._str_vars(**{"uco-observable:asHandle": as_handle})
111111

112112

113-
class X509Certificate(ObjectEntity):
113+
class X509Certificate(UcoObject):
114114
def __init__(
115115
self,
116116
has_changed=False,
@@ -435,7 +435,7 @@ def __init__(self, name=None, address=None):
435435
)
436436

437437

438-
class Observable(ObjectEntity):
438+
class Observable(UcoObject):
439439
def __init__(
440440
self,
441441
*args: Any,
@@ -586,22 +586,20 @@ def __init__(self, browser=None, history_entries=None):
586586
self.__handle_var_type_errors(key, var, "int")
587587
elif key in keys_ref:
588588
if isinstance(var, list) or isinstance(var, tuple):
589-
is_object_entity = [
590-
isinstance(item, ObjectEntity) for item in var
591-
]
589+
is_object_entity = [isinstance(item, UcoObject) for item in var]
592590
if all(is_object_entity):
593591
history_entry[key] = [
594592
{"@id": item.get_id()} for item in var
595593
]
596594
else:
597595
self.__handle_list_type_errors(
598-
key, var, "ObjectEntity (no @id key)"
596+
key, var, "UcoObject (no @id key)"
599597
)
600-
elif isinstance(var, ObjectEntity):
598+
elif isinstance(var, UcoObject):
601599
history_entry[key] = {"@id": var.get_id()}
602600
else:
603601
self.__handle_var_type_errors(
604-
key, var, "ObjectEntity (no @id key)"
602+
key, var, "UcoObject (no @id key)"
605603
)
606604
elif key == "uco-observable:manuallyEnteredCount":
607605
history_entry[key] = {
@@ -1062,17 +1060,17 @@ def __init__(
10621060
class FacetCalendarEntry(FacetEntity):
10631061
def __init__(
10641062
self,
1065-
application: Union[None, ObjectEntity] = None,
1063+
application: Union[None, UcoObject] = None,
10661064
attendant: Union[None, Identity, List[Identity]] = None,
10671065
duration: Optional[int] = None,
10681066
end_time=None,
10691067
event_status: Optional[str] = None,
10701068
event_type: Optional[str] = None,
10711069
is_private: Optional[bool] = None,
1072-
location: Union[None, ObjectEntity] = None,
1070+
location: Union[None, UcoObject] = None,
10731071
modified_time=None,
10741072
observable_created_time=None,
1075-
owner: Union[None, ObjectEntity] = None,
1073+
owner: Union[None, UcoObject] = None,
10761074
recurrence: Optional[str] = None,
10771075
remind_time=None,
10781076
start_time=None,
@@ -1385,11 +1383,11 @@ def __init__(self, path: str) -> None:
13851383
class EventRecordFacet(FacetEntity):
13861384
def __init__(
13871385
self,
1388-
account: Union[None, ObjectEntity] = None,
1389-
application: Union[None, ObjectEntity] = None,
1390-
cyber_action: Union[None, ObjectEntity] = None,
1386+
account: Union[None, UcoObject] = None,
1387+
application: Union[None, UcoObject] = None,
1388+
cyber_action: Union[None, UcoObject] = None,
13911389
end_time: Optional[datetime] = None,
1392-
event_record_device: Union[None, ObjectEntity] = None,
1390+
event_record_device: Union[None, UcoObject] = None,
13931391
event_record_id: Optional[str] = None,
13941392
event_record_raw: Optional[str] = None,
13951393
event_record_service_name: Optional[str] = None,
@@ -1447,8 +1445,8 @@ class ObservableRelationship(Observable, Relationship):
14471445
def __init__(
14481446
self,
14491447
*args: Any,
1450-
source: ObjectEntity,
1451-
target: ObjectEntity,
1448+
source: UcoObject,
1449+
target: UcoObject,
14521450
start_time: Optional[datetime] = None,
14531451
end_time: Optional[datetime] = None,
14541452
kind_of_relationship: str,
@@ -1668,15 +1666,15 @@ def append_participants(self, *args):
16681666
self._append_refs("uco-observable:participant", *args)
16691667

16701668

1671-
class MessageThread(ObjectEntity):
1669+
class MessageThread(UcoObject):
16721670
def __init__(self, name=None, facets=None):
16731671
super().__init__()
16741672
self["@type"] = "uco-observable:MessageThread"
16751673
self._str_vars(**{"uco-core:name": name})
16761674
self.append_facets(facets)
16771675

16781676

1679-
class Message(ObjectEntity):
1677+
class Message(UcoObject):
16801678
def __init__(self, has_changed=None, state=None, indexed_items=None):
16811679
"""
16821680
A message is a discrete unit of electronic communication intended by the source for consumption by some

case_mapping/uco/tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from typing import Any, Optional
22

3-
from ..base import ObjectEntity
3+
from ..base import UcoObject
44
from .identity import Identity
55

66

7-
class Tool(ObjectEntity):
7+
class Tool(UcoObject):
88
def __init__(
99
self,
1010
*args: Any,

example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _next_timestamp() -> datetime:
4949
)
5050
bundle.append_to_uco_object(bundle_identity)
5151

52-
investigation_items: list[base.ObjectEntity] = []
52+
investigation_items: list[base.UcoObject] = []
5353

5454
############################################
5555
# A DeviceFacet and a OperatingSystemFacet #

0 commit comments

Comments
 (0)