Skip to content

Commit

Permalink
Added test for placeholders in fields with string replacements
Browse files Browse the repository at this point in the history
pySigma issue 284
  • Loading branch information
thomaspatzke committed Oct 9, 2024
1 parent 2b63ce2 commit bdd8048
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_processing_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from sigma.exceptions import SigmaTransformationError
from sigma.backends.test import TextQueryTestBackend
from sigma.processing.resolver import ProcessingPipelineResolver
from sigma.processing.pipeline import ProcessingPipeline, ProcessingItem
from sigma.processing.transformations import ValueListPlaceholderTransformation
from sigma.pipelines.crowdstrike import (
crowdstrike_fdr_pipeline,
crowdstrike_falcon_pipeline,
Expand Down Expand Up @@ -481,6 +483,27 @@ def test_crowdstrike_falcon_pipeline_process_creation(
== "event_platform=/^Win$/i #event_simpleName=/^ProcessRollup2$/i or #event_simpleName=/^SyntheticProcessRollup2$/i CommandLine=/^test\\.exe foo bar$/i ImageFileName=/\\\\test\\.exe$/i"
)

def test_crowdstrike_falcon_image_with_placeholder(resolver : ProcessingPipelineResolver):
sigma_rule = SigmaCollection.from_yaml("""
title: Image with Placeholder Test
status: test
logsource:
category: process_creation
product: windows
detection:
sel:
Image|expand: "%var%"
condition: sel
""")
pipeline = resolver.resolve_pipeline("crowdstrike_falcon") + ProcessingPipeline(
items=[
ProcessingItem(transformation=ValueListPlaceholderTransformation())
],
vars={"var": ["foo.exe", "bar.exe", "test.exe"]},
)
backend = LogScaleBackend(pipeline)
assert backend.convert(sigma_rule) == "event_platform=/^Win$/i #event_simpleName=/^ProcessRollup2$/i or #event_simpleName=/^SyntheticProcessRollup2$/i ImageFileName=/^foo\\.exe$/i or ImageFileName=/^bar\\.exe$/i or ImageFileName=/^test\\.exe$/i"


def test_crowdstrike_falcon_pipeline_parentimage(
resolver: ProcessingPipelineResolver, process_creation_sigma_rule_parentimage
Expand Down

0 comments on commit bdd8048

Please sign in to comment.