Add separate file output for converted rules with directory structure preservation#93
Merged
thomaspatzke merged 13 commits intoJul 7, 2026
Merged
Conversation
- Add --output-dir parameter to specify output directory
- Add --output-filename-template parameter with template variables
- Support template variables: {path}, {stem}, {index}
- Handle rules that emit multiple queries with index suffixes
- Create directories as needed for output
- Add comprehensive tests for new functionality
- Document --output-dir and --output-filename-template parameters
- Provide examples for flat and nested directory structures
- Explain template variables {path}, {stem}, {index}
- Change short option from -oT to -ot for consistency - Improve error messages with actionable guidance - Add context about expected formats in error messages
Copilot
AI
changed the title
[WIP] Add option to create separate files for converted rules
Add separate file output for converted rules with directory structure preservation
Jun 15, 2026
thomaspatzke
requested changes
Jun 15, 2026
- Add validation to prevent use of --output-dir with correlation rules - Correlation rules reference other rules and cannot be split individually - Add comprehensive tests for correlation rules and filters - Filters work correctly as they are resolved at collection load time - Exit with clear error message if correlation rules are detected
- Replace type().__name__ with isinstance(rule, SigmaCorrelationRule) - More Pythonic and handles inheritance correctly - Import SigmaCorrelationRule from sigma.correlations - Fix trailing whitespace in test file
thomaspatzke
requested changes
Jul 6, 2026
thomaspatzke
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Converting multiple Sigma rules currently outputs all results to a single file, making version control and selective deployment impractical. This adds support for writing each converted rule to a separate file with configurable naming and directory structure.
Changes
--output-dirparameter: Specifies output directory for individual rule files (mutually exclusive with--output)--output-filename-templateparameter: Controls output filenames using template variables:{path}: Relative source directory path{stem}: Source filename without extension{index}: Query index for rules emitting multiple queries (1, 2, 3...)--output-dir, allowing granular output control--output-dirwith correlation rules, which reference other rules and must be converted as part of the full collection. Exits with clear error message directing users to use--outputinstead.--output-diras they are resolved at collection load time and baked into individual rule detectionsUsage
Given source structure:
Template
{path}/{stem}.esqlproduces:Limitations
--output-dir. Correlation rules reference other rules by name and require the full collection context for conversion. Use--outputto write correlation rules to a single file.--output-dirand are applied to individual rules as expected.Testing
--output-dir