Detection-as-Code CI/CD Workflow Overview
Integrating Detection-as-Code (DaC) into a CI/CD pipeline enables scalable, testable, and automated management of your Sigma rules or platform-specific detections (e.g., KQL, SPL, Lucene). Below is a step-by-step guide to CI/CD integration tailored for platforms like Microsoft Sentinel, Splunk, Elastic, etc.
Detection-as-Code CI/CD Workflow Overview
Git Repo (Sigma Rules)
↓
Pull Request → Pre-Commit Validation
↓
CI Pipeline (Lint, Translate, Test)
↓
CD Pipeline (Deploy to SIEM via API or GitOps)Step-by-Step Integration Plan
1. Repository Structure
Use a standardized Git repo for rule management:
detection-rules/
├── sigma/
│ ├── windows/
│ ├── cloud/
│ ├── endpoint/
├── platform-translations/
│ ├── sentinel-kql/
│ ├── splunk-spl/
│ └── elastic-lucene/
├── tests/
│ └── sample-logs/
├── ci/
│ └── test-pipeline.yaml
└── .gitlab-ci.yml / .github/workflows/ci.yml2. Rule Validation (Pre-Commit Hook or CI Job)
Use sigma-cli or sigmac:
sigma-cli lint ./sigma/GitHub Actions Job:
- name: Validate Sigma Rules
run: |
pip install sigma-cli
sigma-cli lint ./sigma/3. Translate Sigma to SIEM-Specific Language
Example: Translate to Sentinel (KQL)
sigma-cli translate ./sigma/windows/ -t sentinel -o ./platform-translations/sentinel-kql/Example: Translate to Splunk (SPL)
sigma-cli translate ./sigma/windows/ -t splunk -o ./platform-translations/splunk-spl/4. Rule Testing (Unit Testing with Sample Data)
- Simulate detection hits with sample logs (EVTX, JSON).
- Use Sigma test cases or build your own YAML + sample log pair:
rule.yml+test-log.json
Tool suggestions:
- Sigma CLI test framework
- Custom Python-based test runners with log replay.
5. CI/CD Integration (Deployment)
Microsoft Sentinel
- Use Azure DevOps Pipelines + ARM/Bicep templates or REST API:
Deploy KQL analytics rules using:
az sentinel alert-rule create --workspace-name "SOC" --rule-name "HighRiskLogin" --rule-file "rule.json"
Splunk
- Use GitOps with the
etc/apps/search/local/directory and deploy via: - Splunk Deployment Server
- Ansible, Terraform, or Jenkins CI
- REST API to push saved searches
Elastic
- Use Elastic API or Fleet integration: Push rules to Kibana Detection Engine via
POST _security/roleor integration package.
6. Continuous Monitoring & Feedback
- Track false positive rates, detection coverage, and rule usage.
Feed feedback into:
- Rule suppression logic
- Telemetry gaps
- AI/ML enrichment triggers
Tools to Consider
Tool Use sigma-cli Translate/lint/test Sigma rules.
git-secrets, pre-commit Ensure YAML quality.
Jenkins/GitHub Actions/GitLab CI Automate the pipeline.
Terraform/Ansible Deploy rules to SIEM.
Pytest + Sample Logs Custom rule testing framework
