forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 0
Handle outside td #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8a3d222
Handle outside td
0279867
To prove that it wont bomb on unsupported types
8ab51e4
Save
7f4d82a
Handle no cats
5f514ec
Create integ yml
cebc8f3
Handle unsupported ets better
dbff2a0
Fix comment
662c7e8
Gen yml
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -338,10 +338,20 @@ def _create_category_filter(file_type): | |
class ObservationToSecurityQueryMapper(object): | ||
"""Class to simplify the process of mapping observation data to query objects.""" | ||
|
||
# Exfiltration consts | ||
_ENDPOINT_TYPE = "FedEndpointExfiltration" | ||
_CLOUD_TYPE = "FedCloudSharePermissions" | ||
|
||
# Query consts | ||
_PUBLIC_SEARCHABLE = "PublicSearchableShare" | ||
_PUBLIC_LINK = "PublicLinkShare" | ||
_OUTSIDE_TRUSTED_DOMAINS = "SharedOutsideTrustedDomain" | ||
|
||
exposure_type_map = { | ||
"PublicSearchableShare": ExposureType.IS_PUBLIC, | ||
"PublicLinkShare": ExposureType.SHARED_VIA_LINK, | ||
"SharedOutsideTrustedDomain": "OutsideTrustedDomains" | ||
} | ||
|
||
def __init__(self, observation, actor): | ||
self._obs = observation | ||
|
@@ -390,19 +400,26 @@ def _create_search_args(self): | |
|
||
return filters | ||
|
||
@logger | ||
def _create_exposure_filters(self, exposure_types): | ||
"""Determine exposure types based on alert type""" | ||
|
||
exp_types = [] | ||
if self._is_cloud_exfiltration: | ||
exp_types = [] | ||
if self._PUBLIC_SEARCHABLE in exposure_types: | ||
exp_types.append(ExposureType.IS_PUBLIC) | ||
if self._PUBLIC_LINK in exposure_types: | ||
exp_types.append(ExposureType.SHARED_VIA_LINK) | ||
return [ExposureType.is_in(exp_types)] | ||
for t in exposure_types: | ||
exp_type = self.exposure_type_map.get(t) | ||
if exp_type: | ||
exp_types.append(exp_type) | ||
else: | ||
LOG("Received unsupported exposure type {0}.".format(t)) | ||
if exp_types: | ||
return [ExposureType.is_in(exp_types)] | ||
else: | ||
# If not given a support exposure type, search for all unsupported exposure types | ||
supported_exp_types = list(self.exposure_type_map.values()) | ||
return [ExposureType.not_in(supported_exp_types)] | ||
elif self._is_endpoint_exfiltration: | ||
return [ | ||
EventType.is_in(["CREATED", "MODIFIED", "READ_BY_APP"]), | ||
EventType.is_in([EventType.CREATED, EventType.MODIFIED, EventType.READ_BY_APP]), | ||
ExposureType.is_in(exposure_types), | ||
] | ||
return [] | ||
|
@@ -411,7 +428,8 @@ def _create_file_category_filters(self): | |
"""Determine if file categorization is significant""" | ||
observed_file_categories = self._observation_data["fileCategories"] | ||
categories = [c["category"].upper() for c in observed_file_categories if c["isSignificant"]] | ||
return FileCategory.is_in(categories) | ||
if categories: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another missed bug that was messing up fetch (this one was my fault though) |
||
return FileCategory.is_in(categories) | ||
|
||
|
||
def map_observation_to_security_query(observation, actor): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the
exp_types
is empty due to it being unsupported, this will result in an ffs query of all events in the given time frame. If we returned[ExposureType.not_in(exp_types)]
, this would actually return the result set for the events they were looking for (unless we have two or more types of unsupported events, in which theres a case it would be a mix between those two).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we return
[ExposureType.not_in(exp_types)]
isexp_types
is empty?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we find an alert that was triggered by an unsupported type, doing
not_in(list_of_supported_types)
would return only the not supported ones