@@ -338,10 +338,20 @@ def _create_category_filter(file_type):
338
338
class ObservationToSecurityQueryMapper (object ):
339
339
"""Class to simplify the process of mapping observation data to query objects."""
340
340
341
+ # Exfiltration consts
341
342
_ENDPOINT_TYPE = "FedEndpointExfiltration"
342
343
_CLOUD_TYPE = "FedCloudSharePermissions"
344
+
345
+ # Query consts
343
346
_PUBLIC_SEARCHABLE = "PublicSearchableShare"
344
347
_PUBLIC_LINK = "PublicLinkShare"
348
+ _OUTSIDE_TRUSTED_DOMAINS = "SharedOutsideTrustedDomain"
349
+
350
+ exposure_type_map = {
351
+ "PublicSearchableShare" : ExposureType .IS_PUBLIC ,
352
+ "PublicLinkShare" : ExposureType .SHARED_VIA_LINK ,
353
+ "SharedOutsideTrustedDomain" : "OutsideTrustedDomains"
354
+ }
345
355
346
356
def __init__ (self , observation , actor ):
347
357
self ._obs = observation
@@ -390,19 +400,26 @@ def _create_search_args(self):
390
400
391
401
return filters
392
402
403
+ @logger
393
404
def _create_exposure_filters (self , exposure_types ):
394
405
"""Determine exposure types based on alert type"""
395
-
406
+ exp_types = []
396
407
if self ._is_cloud_exfiltration :
397
- exp_types = []
398
- if self ._PUBLIC_SEARCHABLE in exposure_types :
399
- exp_types .append (ExposureType .IS_PUBLIC )
400
- if self ._PUBLIC_LINK in exposure_types :
401
- exp_types .append (ExposureType .SHARED_VIA_LINK )
402
- return [ExposureType .is_in (exp_types )]
408
+ for t in exposure_types :
409
+ exp_type = self .exposure_type_map .get (t )
410
+ if exp_type :
411
+ exp_types .append (exp_type )
412
+ else :
413
+ LOG ("Received unsupported exposure type {0}." .format (t ))
414
+ if exp_types :
415
+ return [ExposureType .is_in (exp_types )]
416
+ else :
417
+ # If not given a support exposure type, search for all unsupported exposure types
418
+ supported_exp_types = list (self .exposure_type_map .values ())
419
+ return [ExposureType .not_in (supported_exp_types )]
403
420
elif self ._is_endpoint_exfiltration :
404
421
return [
405
- EventType .is_in ([" CREATED" , " MODIFIED" , " READ_BY_APP" ]),
422
+ EventType .is_in ([EventType . CREATED , EventType . MODIFIED , EventType . READ_BY_APP ]),
406
423
ExposureType .is_in (exposure_types ),
407
424
]
408
425
return []
@@ -411,7 +428,8 @@ def _create_file_category_filters(self):
411
428
"""Determine if file categorization is significant"""
412
429
observed_file_categories = self ._observation_data ["fileCategories" ]
413
430
categories = [c ["category" ].upper () for c in observed_file_categories if c ["isSignificant" ]]
414
- return FileCategory .is_in (categories )
431
+ if categories :
432
+ return FileCategory .is_in (categories )
415
433
416
434
417
435
def map_observation_to_security_query (observation , actor ):
0 commit comments