@@ -54,6 +54,13 @@ def __init__(self, src_entity=None, **kwargs):
5454 self [k ] = ElevationToken (src_entity [k ])
5555 elif v == GeoLocation .__name__ :
5656 self [k ] = GeoLocation (src_entity [k ])
57+ elif v == Algorithm .__name__ :
58+ self [k ] = Algorithm (src_entity [k ])
59+ elif isinstance (v , tuple ):
60+ entity_list = []
61+ for col_entity in src_entity [k ]:
62+ entity_list .append (Entity .instantiate_entity (col_entity ))
63+ self [k ] = entity_list
5764 else :
5865 self [k ] = Entity .instantiate_entity (src_entity [k ])
5966 # add AdditionalData dictionary if it's populated
@@ -193,8 +200,14 @@ def instantiate_entity(cls, raw_entity: dict):
193200 elif (raw_entity ['Type' ] == 'registry-value' or
194201 raw_entity ['Type' ] == 'registryvalue' ):
195202 return RegistryValue (raw_entity )
196- elif raw_entity ['Type' ] == 'host-logon-session' :
203+ elif (raw_entity ['Type' ] == 'host-logon-session' or
204+ raw_entity ['Type' ] == 'hostlogonsession' ):
197205 return HostLogonSession (raw_entity )
206+ elif raw_entity ['Type' ] == 'filehash' :
207+ return FileHash (raw_entity )
208+ elif (raw_entity ['Type' ] == 'security-group' or
209+ raw_entity ['Type' ] == 'securitygroup' ):
210+ return SecurityGroup (raw_entity )
198211 elif (raw_entity ['Type' ] == 'alerts' or
199212 raw_entity ['Type' ] == 'alert' ):
200213 return Alert (raw_entity )
@@ -213,6 +226,7 @@ def __init__(self, src_entity=None, src_event=None, role='subject', **kwargs):
213226
214227 :param src_entity: instantiate entity using properties of src entity
215228 :param src_event: instantiate entity using properties of src event
229+ :param kwargs: key-value pair representation of entity
216230 """
217231# pylint: disable=locally-disabled, C0301
218232 super ().__init__ (src_entity = src_entity , ** kwargs )
@@ -279,6 +293,34 @@ def qualified_name(self) -> str:
279293 }
280294
281295
296+ @export
297+ class SecurityGroup (Entity ):
298+ """SecurityGroup Entity class."""
299+
300+ def __init__ (self , src_entity = None , ** kwargs ):
301+ """
302+ Create a new instance of the entity type.
303+
304+ :param src_entity: instantiate entity using properties of src entity
305+ :param kwargs: key-value pair representation of entity
306+ """
307+ super ().__init__ (src_entity = src_entity , ** kwargs )
308+
309+ @property
310+ def description_str (self ):
311+ """Return Entity Description."""
312+ return self .DistinguishedName
313+
314+ _entity_schema = {
315+ # DistinguishedName (type System.String)
316+ 'DistinguishedName' : None ,
317+ # SID (type System.String)
318+ 'SID' : None ,
319+ # ObjectGuid (type System.String)
320+ 'ObjectGuid' : None ,
321+ }
322+
323+
282324@export
283325class HostLogonSession (Entity ):
284326 """HostLogonSession Entity class."""
@@ -289,6 +331,7 @@ def __init__(self, src_entity=None, src_event=None, **kwargs):
289331
290332 :param src_entity: instantiate entity using properties of src entity
291333 :param src_event: instantiate entity using properties of src event
334+ :param kwargs: key-value pair representation of entity
292335 """
293336 super ().__init__ (src_entity = src_entity , ** kwargs )
294337
@@ -328,6 +371,7 @@ def __init__(self, src_entity=None, **kwargs):
328371 Create a new instance of the entity type.
329372
330373 :param src_entity: instantiate entity using properties of src entity
374+ :param kwargs: key-value pair representation of entity
331375 """
332376 super ().__init__ (src_entity = src_entity , ** kwargs )
333377
@@ -382,6 +426,7 @@ def __init__(self, src_entity=None, src_event=None, role='new', **kwargs):
382426
383427 :param src_entity: instantiate entity using properties of src entity
384428 :param src_event: instantiate entity using properties of src event
429+ :param kwargs: key-value pair representation of entity
385430 """
386431 super ().__init__ (src_entity = src_entity , ** kwargs )
387432
@@ -426,7 +471,8 @@ def description_str(self) -> str:
426471 # Sha256 (type System.String)
427472 'Sha256' : None ,
428473 # Sha256Ac (type System.String)
429- 'Sha256Ac' : None
474+ 'Sha256Ac' : None ,
475+ 'FileHashes' : (list , 'FileHash' )
430476 }
431477
432478 def _add_paths (self , full_path ):
@@ -442,6 +488,42 @@ def _add_paths(self, full_path):
442488 self .Directory = full_path .split (self .PathSeparator )[:- 1 ]
443489
444490
491+ @export
492+ class FileHash (Entity ):
493+ """File Hash class."""
494+
495+ def __init__ (self , src_entity = None , ** kwargs ):
496+ """
497+ Create a new instance of the entity type.
498+
499+ :param src_entity: instantiate entity using properties of src entity
500+ :param kwargs: key-value pair representation of entity
501+ """
502+ super ().__init__ (src_entity = src_entity , ** kwargs )
503+
504+ @property
505+ def description_str (self ) -> str :
506+ """Return Entity Description."""
507+ return f'{ self .Algorithm } : { self .Value } '
508+
509+ _entity_schema = {
510+ # The hash algorithm (type System.String)
511+ 'Algorithm' : 'Algorithm' ,
512+ # Value (type System.String)
513+ 'Value' : None ,
514+ }
515+
516+
517+ @export
518+ class Algorithm (Enum ):
519+ """FileHash Algorithm Enumeration."""
520+ Unknown = 0
521+ MD5 = 1
522+ SHA1 = 2
523+ SHA256 = 3
524+ SHA256AC = 4
525+
526+
445527@export
446528class Host (Entity ):
447529 """Host Entity class."""
@@ -514,6 +596,7 @@ def __init__(self, src_entity=None, src_event=None, **kwargs):
514596
515597 :param src_entity: instantiate entity using properties of src entity
516598 :param src_event: instantiate entity using properties of src event
599+ :param kwargs: key-value pair representation of entity
517600 """
518601 super ().__init__ (src_entity = src_entity , ** kwargs )
519602
@@ -555,6 +638,7 @@ def __init__(self, src_entity=None, **kwargs):
555638 Create a new instance of the entity type.
556639
557640 :param src_entity: instantiate entity using properties of src entity
641+ :param kwargs: key-value pair representation of entity
558642 """
559643 super ().__init__ (src_entity = src_entity , ** kwargs )
560644
@@ -590,6 +674,7 @@ def __init__(self, src_entity=None, **kwargs):
590674 Create a new instance of the entity type.
591675
592676 :param src_entity: instantiate entity using properties of src entity
677+ :param kwargs: key-value pair representation of entity
593678 """
594679 super ().__init__ (src_entity = src_entity , ** kwargs )
595680
@@ -604,7 +689,9 @@ def description_str(self) -> str:
604689 # Category (type System.String)
605690 'Category' : None ,
606691 # File (type Microsoft.Azure.Security.Detection.AlertContracts.V3.Entities.File)
607- 'File' : 'File'
692+ 'File' : 'File' ,
693+ 'Files' : (list , 'File' ),
694+ 'Processes' : (list , 'Process' ),
608695 }
609696
610697
@@ -617,6 +704,7 @@ def __init__(self, src_entity=None, **kwargs):
617704 Create a new instance of the entity type.
618705
619706 :param src_entity: instantiate entity using properties of src entity
707+ :param kwargs: key-value pair representation of entity
620708 """
621709 super ().__init__ (src_entity = src_entity , ** kwargs )
622710
@@ -654,6 +742,7 @@ def __init__(self, src_entity=None, src_event=None, role='new', **kwargs):
654742
655743 :param src_entity: instantiate entity using properties of src entity
656744 :param src_event: instantiate entity using properties of src event
745+ :param kwargs: key-value pair representation of entity
657746 """
658747 super ().__init__ (src_entity = src_entity , ** kwargs )
659748# pylint: disable=locally-disabled, C0301
@@ -720,7 +809,9 @@ def description_str(self) -> str:
720809 # .V3.Entities.Process)
721810 'ParentProcess' : 'Process' ,
722811 # Host (type Microsoft.Azure.Security.Detection.AlertContracts.V3.Entities.Host)
723- 'Host' : 'Host'
812+ 'Host' : 'Host' ,
813+ # Host (type Microsoft.Azure.Security.Detection.AlertContracts.V3.Entities.HostLogonSession)
814+ 'LogonSession' : 'HostLogonSession' ,
724815 }
725816
726817
@@ -759,6 +850,7 @@ def __init__(self, src_entity=None, **kwargs):
759850 Create a new instance of the entity type.
760851
761852 :param src_entity: instantiate entity using properties of src entity
853+ :param kwargs: key-value pair representation of entity
762854 """
763855 super ().__init__ (src_entity = src_entity , ** kwargs )
764856
@@ -784,6 +876,7 @@ def __init__(self, src_entity=None, **kwargs):
784876 Create a new instance of the entity type.
785877
786878 :param src_entity: instantiate entity using properties of src entity
879+ :param kwargs: key-value pair representation of entity
787880 """
788881 super ().__init__ (src_entity = src_entity , ** kwargs )
789882
@@ -830,6 +923,7 @@ def __init__(self, src_entity=None, **kwargs):
830923 Create a new instance of the entity type.
831924
832925 :param src_entity: instantiate entity using properties of src entity
926+ :param kwargs: key-value pair representation of entity
833927 """
834928 super ().__init__ (src_entity = src_entity , ** kwargs )
835929
@@ -857,6 +951,7 @@ def __init__(self, src_entity=None, **kwargs):
857951 Create a new instance of the entity type.
858952
859953 :param src_entity: instantiate entity using properties of src entity
954+ :param kwargs: key-value pair representation of entity
860955 """
861956 super ().__init__ (src_entity = src_entity , ** kwargs )
862957
@@ -888,6 +983,54 @@ def description_str(self) -> str:
888983 'ProviderName' : None
889984 }
890985
986+
987+ @export
988+ class Threatintelligence (Entity ):
989+ """Threatintelligence Entity class."""
990+
991+ def __init__ (self , src_entity = None , ** kwargs ):
992+ """
993+ Create a new instance of the entity type.
994+
995+ :param src_entity: instantiate entity using properties of src entity
996+ :param kwargs: key-value pair representation of entity
997+ """
998+ super ().__init__ (src_entity = src_entity , ** kwargs )
999+
1000+ def description_str (self ) -> str :
1001+ """Return Entity Description."""
1002+ return f'{ self .DisplayName } ({ self .StartTimeUtc } ) { self .CompromisedEntity } '
1003+
1004+ _entity_schema = {
1005+ # String Name of the provider from whom this Threat Intelligence information was received
1006+ 'ProviderName' : None ,
1007+
1008+ 'ThreatType' : None ,
1009+ 'ThreatName' : None ,
1010+ 'Confidence' : None ,
1011+ 'ReportLink' : None ,
1012+ 'ThreatDescription' : None ,
1013+ }
1014+
1015+ @export
1016+ class UnknownEntity (Entity ):
1017+ """Generic Entity class."""
1018+
1019+ def __init__ (self , src_entity = None , ** kwargs ):
1020+ """
1021+ Create a new instance of the entity type.
1022+
1023+ :param src_entity: instantiate entity using properties of src entity
1024+ :param kwargs: key-value pair representation of entity
1025+ """
1026+ super ().__init__ (src_entity = src_entity , ** kwargs )
1027+
1028+ def description_str (self ) -> str :
1029+ """Return Entity Description."""
1030+ return 'OtherEntity'
1031+
1032+ _entity_schema = {}
1033+
8911034# # test code
8921035# if __name__ == '__main__':
8931036# import json
0 commit comments