Skip to content

Commit bd724b1

Browse files
committed
Updates
1 parent 1da7930 commit bd724b1

7 files changed

Lines changed: 300 additions & 27 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
.pytest_cache/
66
cov.xml
77
dist/
8-
docs/_build
8+
docs/_build.env

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
## Overview
66

7-
This is the Sumo Logic backend for pySigma. It provides the package `sigma.backends.sumologic` with backend classes for converting Sigma rules into Sumo Logic Cloud SIEM (CSE) detection rules.
7+
This is the Sumo Logic backend for pySigma. It provides the package `sigma.backends.sumologic` with backend classes for converting Sigma rules into Sumo Logic Cloud SIEM (CSIEM) detection rules.
88

99
The backend includes:
10-
- **`SumoLogicCSEBackend`**: Converts Sigma rules to Sumo Logic CSE queries
11-
- **`SumoLogicCSERuleBackend`**: Converts Sigma rules to complete CSE rule JSON format
10+
- **`SumoLogicCSEBackend`**: Converts Sigma rules to Sumo Logic Cloud SIEM queries
11+
- **`SumoLogicCSERuleBackend`**: Converts Sigma rules to complete CSIEM rule JSON format
1212
- **`sumologic_cse_pipeline`**: Processing pipeline with field mappings for common log sources
1313

1414
## Supported Log Sources
@@ -19,14 +19,14 @@ The backend includes field mappings for the following log sources:
1919
- **Network**: Connection events, DNS queries, proxy logs
2020
- **Cloud**: AWS CloudTrail events
2121

22-
Field mappings align with Sumo Logic CSE's schema and [Anchor schema](https://github.com/SumoLogic/anchor-schema) where applicable.
22+
Field mappings align with Sumo Logic Cloud SIEM's normalized schema.
2323

2424
## Output Formats
2525

2626
The backend supports two output formats:
2727

28-
- **`default`**: Plain CSE query syntax (for manual rule creation)
29-
- **`cse_rule`**: Complete JSON rule format for CSE API import (includes metadata, severity, MITRE ATT&CK mapping)
28+
- **`default`**: Plain CSIEM query syntax (for manual rule creation)
29+
- **`cse_rule`**: Complete JSON rule format for Cloud SIEM API import (includes metadata, severity, MITRE ATT&CK mapping)
3030

3131
### Example Output
3232

@@ -42,7 +42,7 @@ detection:
4242
condition: selection
4343
```
4444
45-
**Output (CSE rule format):**
45+
**Output (CSIEM rule format):**
4646
```json
4747
{
4848
"name": "Suspicious PowerShell Execution",

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ services:
1010
- "8501:8501"
1111
volumes:
1212
# Mount the sigma rules repository
13-
# Update the path below to your local sigma repo
14-
- ./sigma-rules:/sigma-rules:ro
13+
# Set SIGMA_RULES_HOST_PATH environment variable or edit .env file
14+
- ${SIGMA_RULES_HOST_PATH:-./sigma-rules}:/sigma-rules:ro
1515
# Mount local development code for live updates
1616
- ./sigma:/app/sigma
1717
- ./sigma_rule_browser.py:/app/sigma_rule_browser.py

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "pysigma-backend-sumologic"
33
version = "0.2.0"
4-
description = "pySigma Sumo Logic backend with confidence scoring"
4+
description = "pySigma Sumo Logic Cloud SIEM backend with confidence scoring"
55
authors = ["Dinesh Meka <dinesh.meka@sumologic.com>"]
66
license = "LGPL-3.0-only"
77
repository = "https://github.com/SumoLogic/pySigma-backend-sumologic"

sigma/backends/sumologic/sumologic.py

Lines changed: 73 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@
1616

1717
class SumoLogicCSEBackend(TextQueryBackend):
1818
"""
19-
Sumo Logic Cloud SIEM (CSE) backend for converting Sigma rules to CSE Rule JSON format.
19+
Sumo Logic Cloud SIEM backend for converting Sigma rules to CSIEM Rule JSON format.
2020
21-
This backend converts Sigma rules into Sumo Logic Cloud SIEM Rule JSON format with:
22-
- CSE-compatible query expressions
21+
This backend converts Sigma rules into Sumo Logic CSIEM Rule JSON format with:
22+
- Cloud SIEM-compatible query expressions
2323
- MITRE ATT&CK technique and tactic mapping
2424
- Risk score calculation based on severity
2525
- Full rule metadata including name, description, and category
2626
"""
2727

28-
name: ClassVar[str] = "Sumo Logic Cloud SIEM (CSE) Backend"
28+
name: ClassVar[str] = "Sumo Logic Cloud SIEM Backend"
2929
formats: Dict[str, str] = {
30-
"default": "Sumo Logic CSE Rule JSON format",
31-
"cse_rule": "CSE Rule JSON with full metadata",
30+
"default": "Sumo Logic CSIEM Rule JSON format",
31+
"cse_rule": "CSIEM Rule JSON with full metadata",
3232
}
3333
requires_pipeline: bool = True
3434

35-
# CSE uses lowercase boolean operators
35+
# Cloud SIEM uses uppercase boolean operators
3636
precedence: ClassVar[Tuple[ConditionItem, ConditionItem, ConditionItem]] = (
3737
ConditionNOT,
3838
ConditionAND,
3939
ConditionOR,
4040
)
4141
group_expression: ClassVar[str] = "({expr})"
4242

43-
# CSE Query tokens - uppercase for CSE
43+
# Cloud SIEM Query tokens - uppercase operators
4444
token_separator: str = " "
4545
or_token: ClassVar[str] = "OR"
4646
and_token: ClassVar[str] = "AND"
@@ -492,8 +492,8 @@ def _inject_vendor_product_metadata(self, rule: SigmaRule, query: str) -> str:
492492
import warnings
493493
logsource_str = f"product={rule.logsource.product}, service={getattr(rule.logsource, 'service', None)}, category={getattr(rule.logsource, 'category', None)}"
494494
warnings.warn(
495-
f"No CSE parser mapping found for logsource: {logsource_str}. "
496-
f"Rule may not match expected log sources in CSE."
495+
f"No Cloud SIEM parser mapping found for logsource: {logsource_str}. "
496+
f"Rule may not match expected log sources in Cloud SIEM."
497497
)
498498
return query
499499

@@ -583,6 +583,61 @@ def _transform_windows_metadata_fields(self, rule: SigmaRule, query: str) -> str
583583

584584
return query
585585

586+
def _wrap_vendor_specific_fields(self, rule: SigmaRule, query: str) -> str:
587+
"""
588+
Wrap vendor-specific fields in fields[] syntax based on logsource context.
589+
590+
Rules with specific product/service are vendor-specific and their unmapped fields
591+
should use fields[] syntax. Rules with only category use normalized field names.
592+
593+
Args:
594+
rule: Sigma rule object with logsource information
595+
query: Generated CSE query expression
596+
597+
Returns:
598+
Query with vendor-specific fields wrapped in fields[] syntax
599+
"""
600+
if not rule.logsource:
601+
return query
602+
603+
# Determine if this is a vendor-specific logsource
604+
has_product = rule.logsource.product is not None
605+
has_service = rule.logsource.service is not None
606+
has_only_category = (
607+
rule.logsource.category is not None
608+
and not has_product
609+
and not has_service
610+
)
611+
612+
# Only process vendor-specific logsources (not generic categories)
613+
if not (has_product or has_service) or has_only_category:
614+
return query
615+
616+
# Find all bare field names (not already in fields[] syntax, not metadata fields)
617+
# Pattern: field name at word boundary, followed by operator (=, in, matches, etc.)
618+
# Exclude: metadata_, fields[, already wrapped fields
619+
pattern = r'\b(?!metadata_|fields\[)([a-zA-Z_][a-zA-Z0-9_]*)\b(?=\s*(?:=|!=|in\s|matches\s|<|>|<=|>=))'
620+
621+
def wrap_if_not_in_schema(match):
622+
field_name = match.group(1)
623+
624+
# Don't wrap if field is in CSE schema
625+
if self.schema and self.schema.field_exists(field_name):
626+
return field_name
627+
628+
# Don't wrap boolean operators
629+
if field_name.upper() in ('AND', 'OR', 'NOT'):
630+
return field_name
631+
632+
# Don't wrap CSE functions
633+
if field_name in ('isEmpty',):
634+
return field_name
635+
636+
# Wrap vendor-specific field
637+
return f"fields['{field_name}']"
638+
639+
return re.sub(pattern, wrap_if_not_in_schema, query)
640+
586641
def finalize_query_default(
587642
self, rule: SigmaRule, query: str, index: int, state: ConversionState
588643
) -> str:
@@ -623,6 +678,9 @@ def escape_regex_value(match):
623678
# Transform Windows metadata fields to fields[] syntax
624679
query = self._transform_windows_metadata_fields(rule, query)
625680

681+
# Wrap vendor-specific fields based on logsource context
682+
query = self._wrap_vendor_specific_fields(rule, query)
683+
626684
# Inject vendor/product metadata based on logsource
627685
query = self._inject_vendor_product_metadata(rule, query)
628686

@@ -1237,19 +1295,19 @@ def _determine_category_from_tags(self, mitre_tags: List[str]) -> str:
12371295

12381296
class SumoLogicCSERuleBackend(SumoLogicCSEBackend):
12391297
"""
1240-
Sumo Logic CSE Rule Backend that outputs complete JSON rules.
1298+
Sumo Logic Cloud SIEM Rule Backend that outputs complete JSON rules.
12411299
1242-
This backend extends SumoLogicCSEBackend to provide full CSE Rule JSON
1243-
output suitable for direct import via CSE API or UI.
1300+
This backend extends SumoLogicCSEBackend to provide full CSIEM Rule JSON
1301+
output suitable for direct import via Cloud SIEM API or UI.
12441302
"""
12451303

1246-
name: ClassVar[str] = "Sumo Logic CSE Rule JSON Backend"
1304+
name: ClassVar[str] = "Sumo Logic Cloud SIEM Rule JSON Backend"
12471305

12481306
def finalize_query_cse_rule(
12491307
self, rule: SigmaRule, query: str, index: int, state: ConversionState
12501308
) -> str:
12511309
"""
1252-
Finalize query as CSE Rule JSON for cse_rule format.
1310+
Finalize query as CSIEM Rule JSON for cse_rule format.
12531311
"""
12541312
rule_json = self.create_rule_json(rule, query)
12551313
self.rule_metadata.append(rule_json)

sigma/pipelines/sumologic/sumologic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def sumologic_cse_pipeline() -> ProcessingPipeline:
282282
Processing pipeline for Sumo Logic Cloud SIEM (CSE).
283283
284284
This pipeline transforms Sigma rules into Sumo Logic Cloud SIEM compatible queries by:
285-
- Mapping Sigma field names to Cloud SIEM schema field names
285+
- Mapping Sigma field names to CSIEM schema field names
286286
- Handling Windows event logs, Sysmon, security logs
287287
- Supporting process creation, network connection, DNS queries, file operations
288288
- Providing proper field mappings for authentication, user activity, and system events

0 commit comments

Comments
 (0)