Skip to content

Commit d4eac51

Browse files
author
Juliya Smith
authored
Merge pull request #3 from code42/bufgix/handling-outside-td
Handle outside td
2 parents b7b2dc7 + 662c7e8 commit d4eac51

File tree

3 files changed

+315
-104
lines changed

3 files changed

+315
-104
lines changed

Packs/Code42/Integrations/Code42/Code42.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,20 @@ def _create_category_filter(file_type):
338338
class ObservationToSecurityQueryMapper(object):
339339
"""Class to simplify the process of mapping observation data to query objects."""
340340

341+
# Exfiltration consts
341342
_ENDPOINT_TYPE = "FedEndpointExfiltration"
342343
_CLOUD_TYPE = "FedCloudSharePermissions"
344+
345+
# Query consts
343346
_PUBLIC_SEARCHABLE = "PublicSearchableShare"
344347
_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+
}
345355

346356
def __init__(self, observation, actor):
347357
self._obs = observation
@@ -390,19 +400,26 @@ def _create_search_args(self):
390400

391401
return filters
392402

403+
@logger
393404
def _create_exposure_filters(self, exposure_types):
394405
"""Determine exposure types based on alert type"""
395-
406+
exp_types = []
396407
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)]
403420
elif self._is_endpoint_exfiltration:
404421
return [
405-
EventType.is_in(["CREATED", "MODIFIED", "READ_BY_APP"]),
422+
EventType.is_in([EventType.CREATED, EventType.MODIFIED, EventType.READ_BY_APP]),
406423
ExposureType.is_in(exposure_types),
407424
]
408425
return []
@@ -411,7 +428,8 @@ def _create_file_category_filters(self):
411428
"""Determine if file categorization is significant"""
412429
observed_file_categories = self._observation_data["fileCategories"]
413430
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)
415433

416434

417435
def map_observation_to_security_query(observation, actor):

0 commit comments

Comments
 (0)