Skip to content

Allow dashes in "1/all of" selector patterns - #593

Open
memx13 wants to merge 2 commits into
SigmaHQ:mainfrom
memx13:fix/selector-pattern-dash
Open

memx13 wants to merge 2 commits into
SigmaHQ:mainfrom
memx13:fix/selector-pattern-dash

Conversation

@memx13

@memx13 memx13 commented Oct 11, 2026

Copy link
Copy Markdown

What

Detection identifiers may contain - (identifier_chars = alphanums + "_-") and parse fine when referenced by name. But the pattern used by 1 of x-* / all of x-* only accepted alphanums + "*_", so referencing a dashed identifier through a wildcard pattern raised SigmaConditionError.

Reproduction

detection:
    sel-img:
        Image|endswith: '\powershell.exe'
    sel-cli:
        CommandLine|contains: ' -enc '
    condition: 1 of sel-*

1 of sel-* raises SigmaConditionError: Expected end of text, found '-', while the equivalent sel-img or sel-cli parses fine. The project already expects dashed identifiers elsewhere (test fixtures use keyword-list, field-value; filters.py builds a pattern containing -), and the Sigma spec does not restrict identifier characters.

Change

identifier_pattern now reuses identifier_chars (plus *), so the wildcard pattern accepts exactly the characters identifiers already allow. _ was added to this same pattern in 2021 (c86073b) for the same reason; this adds - alongside it.

Tests

Added test_selector_pattern_with_dash, covering 1 of / any of / all of over a dashed wildcard pattern. The three cases fail before the change (SigmaConditionError) and pass after it. Full tests/test_conditions.py is green and black --check is clean on both files.

Detection identifiers may contain "-" (identifier_chars = alphanums + "_-") and parse fine when referenced by name, but the pattern used by "1 of x-*" / "all of x-*" only accepted alphanums + "*_". Referencing a dashed identifier through a wildcard pattern therefore raised SigmaConditionError, even though the same identifier works when named directly. "_" was added to this pattern in 2021 (c86073b) for the same reason; this reuses identifier_chars so the wildcard pattern accepts exactly the characters identifiers already allow (plus "*").

This branch has not been deployed

No deployments
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.

1 participant