Unit 1: Detection lifecycle and ATT&CK coverage · Lesson 7 of 7 · 15 min
Share the gaps as a Navigator layer
Write a valid ATT&CK Navigator layer of the remaining gaps with jq, check it and commit it for the coverage review.
mission
- You are
- You are preparing slides for the coverage review.
- Situation
- Managers read ATT&CK as a coloured matrix. The ATT&CK Navigator opens layer files in format 4.5, so a layer of gaps is something they can open and discuss.
- Goal
- Build a layer of the techniques still uncovered, validate it and commit it.
- Hand in
- coverage/gaps-layer.json and coverage/rules-layer.json in git.
Rebuild coverage after the retag
sigma analyze attack count coverage/rules-layer.json rules/sigma
tail -n +2 coverage/threat-profile.csv | cut -d, -f1 | sort > /tmp/profile.txt
jq -r '.techniques[].techniqueID' coverage/rules-layer.json | sort -u > /tmp/covered.txt
comm -23 /tmp/profile.txt /tmp/covered.txt > /tmp/gaps.txt
wc -l < /tmp/gaps.txt
Parsing Sigma rules
9
you should see Nine gaps left. T1685.005 is now covered.
sigma- sigma-cli. Checks Sigma detection rules and converts them into queries for a SIEM. Install with pipx install sigma-cli.
tail- Prints the last lines of a file, or follows it as it grows with -f. Built into Linux and macOS.
cut- Keeps only chosen columns or characters from each line. Built into Linux and macOS.
sort- Sorts lines of text. Built into Linux and macOS.
jq- Picks fields out of JSON and reshapes it. Install with sudo apt install jq, or brew install jq on a Mac.
comm- Compares two sorted files and shows the lines unique to each, or shared. Built into Linux and macOS.
wc- Counts lines, words and bytes. Built into Linux and macOS.
Write the layer
jq -n starts from nothing and builds JSON. --rawfile gaps loads the gap list, split turns it into an array and map builds one technique object per line. Navigator needs name, domain and versions with layer 4.5.
jq -n --rawfile gaps /tmp/gaps.txt '{
name: "Kestrel gaps against the threat profile",
versions: {attack: "20", navigator: "5.3.2", layer: "4.5"},
domain: "enterprise-attack",
description: "Techniques in coverage/threat-profile.csv with no Sigma rule",
techniques: ($gaps | split("\n") | map(select(length > 0)) | map({techniqueID: ., color: "#e60d0d", comment: "No rule yet"}))
}' > coverage/gaps-layer.json
jq -c '.techniques[0]' coverage/gaps-layer.json
{"techniqueID":"T1021.002","color":"#e60d0d","comment":"No rule yet"}
you should see Each technique has an ID, a red colour and a comment.
Validate the required fields
jq -e exits with an error if the result is false or null, so this one line can be a CI check.
jq -e '.name and .domain == "enterprise-attack" and .versions.layer == "4.5" and (.techniques | all(.techniqueID | test("^T[0-9]{4}(\\.[0-9]{3})?$")))' coverage/gaps-layer.json
true
you should see true.
Check every ID exists in ATT&CK
A layer with a revoked or mistyped ID imports with a silent hole. Check each ID against the bundle.
jq -r '.techniques[].techniqueID' coverage/gaps-layer.json | while read t; do jq -e --arg t "$t" 'any(.objects[]; .type=="attack-pattern" and (.revoked|not) and .external_references[0].external_id==$t)' ~/attack/enterprise-attack.json >/dev/null && echo "$t ok" || echo "$t UNKNOWN"; done
T1021.002 ok
T1053.005 ok
T1071.001 ok
T1110.003 ok
T1204.002 ok
T1218.005 ok
T1546.008 ok
T1566.001 ok
T1567.002 ok
you should see All nine IDs are current techniques.
echo- Prints its arguments. Built into Linux and macOS.
Commit both layers
git add coverage
git commit -q -m 'Add coverage and gap layers'
git show --stat --format='%h %s' HEAD
8b9a36b Add coverage and gap layers
coverage/gaps-layer.json | 57 +++++++++++++++++++++++++++++++++++++++++
coverage/rules-layer.json | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 176 insertions(+)
git- Tracks changes to code and shows its history. Install with sudo apt install git, or brew install git on a Mac.
A layer file
- 1
{ "name": ...,Required. Shown on the tab - 2
"versions": {"attack":"20", "navigator":"5.3.2", "layer":"4.5"},Which ATT&CK and which file format - 3
"domain": "enterprise-attack",Required. enterprise, mobile or ics - 4
"techniques": [{"techniqueID":"T1053.005", "color":"#e60d0d", "comment":"No rule yet"}] }One object per technique, with score, colour or comment
What a defender takes away
- 1Navigator layers are plain JSON. Generate them, do not draw them by hand.
- 2Validate required fields and technique IDs before you share a layer.
- 3Keep layers in git so each review can be compared with the last.
Questions
0 of 2 solved
Answer each one from what you find on your lab machine.