Add Sentinel field mapping validator and CI job#78
Merged
Conversation
Scripts/validate_field_mapping.py checks every ARM template in sentinel/analytics-rules/ for: required properties, valid severity/duration format, MITRE technique codes, entityMappings structure, required customDetails fields (PlaybookTrigger, RiskScore), and cross-references entity mapping column names against KQL output columns. Adds field-mapping-validation as job 6 in ci.yml and includes it in the ci-success gate. Closes #72
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Restores proper newlines in test_kql_rules.py (was stored as a single line with literal \n sequences). Removes unused `import os` from validate_field_mapping.py (flake8 F401).
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.
Summary
Closes #72
Adds
scripts/validate_field_mapping.py— a static validator that checks every ARM analytics rule template insentinel/analytics-rules/— and wires it into CI as a newfield-mapping-validationjob (job 6, included in theci-successgate).What the validator checks
displayName,severity,query,queryFrequency,queryPeriod,tactics,techniques,entityMappings,customDetailsqueryFrequencyandqueryPeriodmust matchPT#M/H/D/ST####orT####.###entityTypeandidentifierin fieldMappingsPlaybookTriggerandRiskScoreextend/project/summarizeanalysis)The validator exits 0 with a message when
sentinel/analytics-rules/doesn't exist yet (so CI passes on branches that predate that directory).CI change
Added job
field-mapping-validationto.github/workflows/ci.ymlbetween the existing job 5 (frontend-build) and the gate. Added toneedslist inci-success.How to test
Run locally (clean):
Introduce a deliberate error — edit any
sentinel/analytics-rules/*.jsonand remove the"RiskScore"key fromcustomDetails. Re-run the script and confirm it exits 1 with a clear error message.Invalid technique code — change a
"T1566.001"to"1566"in techniques, confirm the validator catches it.CI — the new
field-mapping-validationjob should appear in the Actions run for this PR and show green (directory absent → exit 0).Generated by Claude Code