Skip to content
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

[microsoft-sentinel/microsoft-defender] Improve matching to identify Prevented and add match on parent process name (#1757) #48

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

isselparra
Copy link
Member

@isselparra isselparra commented Nov 5, 2024

Proposed changes

  • [microsoft-sentinel]: Use alert name to verify if prevented
  • [microsoft-sentinel]: Add match on parent_process_name
  • [microsoft-defender]: Add match on parent_process_name
  • [microsoft-defender]: Use last_update_date_time for alert_date

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality using different use cases
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

Comment on lines 126 to 134
def _extract_parent_process_name(self, columns_index, alert):
parent_process_names = []
entities = json.loads(alert[columns_index["Entities"]])
for entity in entities:
if "Type" in entity and entity["Type"] == "process":
if "ParentProcess" in entity and "ImageFile" in entity["ParentProcess"]:
if "ImageFile" in entity["ParentProcess"] and "Name" in entity["ParentProcess"]["ImageFile"]:
parent_process_names.append(entity["ParentProcess"]["ImageFile"]["Name"])
return parent_process_names
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): ifs nesting could be removed/improved

def _extract_parent_process_name(self, columns_index, alert):
    parent_process_names = []
    entities = json.loads(alert[columns_index["Entities"]])
    
    for entity in entities:
        if (entity.get("Type") == "process" and
            entity.get("ParentProcess", {}).get("ImageFile", {}).get("Name")):
            parent_process_names.append(entity["ParentProcess"]["ImageFile"]["Name"])
    
    return parent_process_names

cc @RomuDeuxfois

@isselparra isselparra marked this pull request as ready for review November 7, 2024 08:58
@isselparra isselparra changed the title [microsoft-sentinel] use alert name to verify if prevented [microsoft-sentinel] Use alert name to verify if prevented Nov 7, 2024
@isselparra isselparra changed the title [microsoft-sentinel] Use alert name to verify if prevented [microsoft-sentinel/microsoft-defender] Improve matching to identify Prevented and add match on parent process name Nov 7, 2024
@isselparra
Copy link
Member Author

Test OK with Eicar, no regression with in the introduction of matching on parent_process_name

@isselparra isselparra changed the title [microsoft-sentinel/microsoft-defender] Improve matching to identify Prevented and add match on parent process name [microsoft-sentinel/microsoft-defender] Improve matching to identify Prevented and add match on parent process name (#1757) Nov 7, 2024
@isselparra isselparra merged commit f4903c1 into main Nov 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Microsoft Sentinel - Improve our matching to accurately identify Blocked/Prevented
2 participants