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

add: ability to state the field mappings per Sigma rules #26

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/droid/platforms/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from azure.mgmt.securityinsight.models import EventGroupingSettings
from azure.mgmt.securityinsight.models import IncidentConfiguration
from azure.mgmt.securityinsight.models import GroupingConfiguration
from azure.mgmt.securityinsight.models import EntityMapping, FieldMapping
from azure.monitor.query import LogsQueryClient, LogsQueryStatus
from datetime import datetime, timedelta, timezone
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
Expand Down Expand Up @@ -420,6 +421,14 @@ def create_rule(self, rule_content, rule_converted, rule_file):
else:
enabled = True

# Handling the entities
entity_mappings = []
if rule_content.get('custom', {}).get('entity_mappings'):
for mapping in rule_content['custom']['entity_mappings']:
field_mappings = [FieldMapping(identifier=field['identifier'], column_name=field['column_name'])
for field in mapping['field_mappings']]
entity_mappings.append(EntityMapping(entity_type=mapping['entity_type'], field_mappings=field_mappings))

# Handling the severity
if rule_content['level'] == 'critical':
severity = 'high'
Expand Down Expand Up @@ -471,6 +480,7 @@ def create_rule(self, rule_content, rule_converted, rule_file):
event_grouping_settings=EventGroupingSettings(aggregation_kind="SingleAlert"),
incident_configuration=IncidentConfiguration(create_incident=create_incident, grouping_configuration=grouping_config),
tactics=self.mitre_tactics(rule_content),
entity_mappings=entity_mappings,
techniques=self.mitre_techniques(rule_content)
)

Expand Down