TerraSigma - Modern Detection Engineering for the Cloud-Native SIEM Microsoft Sentinel - Automated Updates
Terraform-converted Sigma rules for deployment to Microsoft Sentinel.
This repository automates conversion of Sigma → KQL → Terraform and back to Sentinel YAML, making it easy to manage detection rules with infrastructure-as-code.
Key points:
- The converters now preserve the original Sigma/TF source folder layout by default (
source). - You can alternatively group outputs by primary MITRE tactic (
tactics) using--output-structure. - Entity mappings were updated to use valid Microsoft Sentinel identifiers (Account, Host, Process, File, IP, Registry, URL, etc.).
- Clone the Sigma2KQL rules repository:
git clone https://github.com/Khadinxc/Sigma2KQL.git- Clone this repository (TerraSigma):
git clone https://github.com/Khadinxc/TerraSigma.git
cd TerraSigma- Create and activate a Python virtual environment:
Windows (PowerShell):
python -m venv .venv
.\.venv\Scripts\Activate.ps1Linux/macOS:
python -m venv .venv
source .venv/bin/activate- Install requirements:
pip install -r requirements.txtGenerate Terraform rules from the KQL rules you obtained from Sigma2KQL.
Default (preserve the source folder structure under ./TF):
python kql_to_terraform.py --kql-dir ./KQL --output-dir ./TF --schemas ./schemas.jsonGroup outputs by primary MITRE tactic instead (legacy behavior):
python kql_to_terraform.py --kql-dir ./KQL --output-dir ./TF --schemas ./schemas.json --output-structure tacticsNotes:
- The script tries to map fields to valid Microsoft Sentinel identifiers.
AccountandHostmappings are added where the table schema provides suitable fields.IPmappings appear for tables that include IP columns (e.g.,DeviceNetworkEvents). - File hashes are mapped to
FileHashidentifiers;Fileentity identifiers areNameandDirectory.
Convert Terraform rule resources to Azure Sentinel YAML ready for import.
Default (preserve TF folder layout under ./YAML):
python terraform_to_yaml.py --tf-dir ./TF --output-dir ./YAMLGroup YAML files by primary MITRE tactic instead:
python terraform_to_yaml.py --tf-dir ./TF --output-dir ./YAML --output-structure tactics