Closed xg5-simon closed 7 months ago
Although I think its better to remove hard coded newlines, here is how I used Jinja2 statements and filters to convert the query output to JSON.
postprocessing:
- type: template
template: |+
{
"queryDescription": "{{ rule.title }}",
"query": {% set timesort = " | order by Timestamp asc" %} {% set query = query|replace('\n', ' ') ~ timerange %} {{ query | tojson }}
}
finalizers:
- type: concat
separator: |
,
prefix: |
[
suffix: |
]
Hi Team,
First, awesome work on this sigma backend!
The
finalize_query_default
function in the microsoft365defender.py backend has a hardcoded \n . This is great for an analysts readability when printing the rule to the terminal but has the potential to break when creating rules to be consumed by an API.FYSA, I'm using the following post processing pipeline to convert sigma rules to KQL wrapped in JSON for use with the MDE API and the rule is rendered as:
mdepipeline.yml
My recommendation is to remove the hard coded newline to support rule conversion to be consumed by APIs and users can use the Format Document or Format Selection options within MDE or Sentinel.