# ATT&CK Navigator로 Sigma 탐지 규칙 범위 그리기

> Sigma 규칙의 tags(attack.t1059.001 등)를 파이썬으로 읽어 기법별 규칙 개수를 세고, ATT&CK Navigator 레이어(JSON)로 저장해 로컬 Navigator 화면에서 열어 봅니다. 규칙이 없는 전술 칸과 이름이 바뀐 기법 ID를 찾아내는 방법, 그리고 규칙 개수가 탐지 품질을 뜻하지 않는다는 한계까지 다룹니다.

- 주소: https://copyandrun.com/blog/attack-navigator-sigma-coverage-map/
- 분야: 위협 인텔리전스
- 발행일: 2026-11-02
- 태그: ATT&CK Navigator, Sigma, 탐지 범위, 레이어 JSON, PyYAML

탐지 규칙을 쌓다 보면 어느 공격 기법을 얼마나 보고 있는지, 반대로 규칙이 하나도 없는 곳이 어디인지 한눈에 보고 싶어집니다. Sigma 규칙에는 `attack.t1059.001` 같은 tags가 붙어 있으므로, 이것을 읽어 기법별 개수를 세고 ATT&CK Navigator의 레이어 파일로 만들면 행렬 위에 색으로 볼 수 있습니다.

이 글의 규칙은 직접 만든 연습용 9개와 SigmaHQ 저장소의 공개 규칙입니다. 연습용 규칙은 모양을 보기 위한 것이라 실제 환경에 그대로 쓰지 않습니다. 명령은 Windows Git Bash 기준이고 Docker로 Navigator를 띄웠습니다.

## 준비물

| 항목 | 확인한 값 |
|---|---|
| Navigator | 5.3.2 (`mitre-attack/attack-navigator` 커밋 734a1ca, 2026-09-10) |
| 레이어 형식 | 4.5 |
| ATT&CK 데이터 | Enterprise 20.0 (2026-10-13 갱신) |
| Sigma 규칙 | SigmaHQ/sigma 커밋 05d1031 (2026-10-21), 규칙 라이선스 DRL 1.1 |
| Docker | 29.5.3 (빌드 단계는 `node:22-slim`, 실행은 `nginx:alpine`) |
| Python, PyYAML | 3.12.10, 6.0.3 |
| Git | 2.54.0 |

Navigator 이미지는 최종 크기가 101MB입니다. 작업 폴더의 파일은 세 개이고, 전체 내용은 글 끝의 `## 전체 코드`에 있습니다.

```
Dockerfile
sample_rules.yml
sigma_to_layer.py
```

## 1. Navigator를 로컬에서 빌드하고 띄우기

<!-- files: Dockerfile -->

공식 저장소를 받아 `Dockerfile`로 빌드합니다. 이 `Dockerfile`은 공식 저장소의 것에서 빌드 단계만 `node:22-slim`으로 줄인 것이고, 처음 빌드는 npm 패키지를 받느라 몇 분 걸립니다. 레이어 파일은 `layers` 폴더를 읽기 전용으로 연결해서 Navigator와 같은 주소에서 내려 주게 합니다.

```bash
git clone --depth 1 https://github.com/mitre-attack/attack-navigator.git nav
git -C nav log -1 --format='%h %cs'
docker build -q -f Dockerfile -t cr-c13-navigator:latest nav
mkdir -p layers
MSYS_NO_PATHCONV=1 docker run -d --name cr-c13-navigator -p 127.0.0.1:18084:80 -v "$(pwd -W)/layers:/usr/share/nginx/html/layers:ro" cr-c13-navigator:latest | cut -c1-12
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:18084/layers/layer.json
```

Linux와 macOS에서는 `MSYS_NO_PATHCONV=1`을 빼고 `-v "$PWD/layers:/usr/share/nginx/html/layers:ro"`로 적습니다. 마지막 `curl`은 2단계에서 `layer.json`을 만든 뒤에 200이 나오며, 이 글의 화면은 그 순서로 찍었습니다.

![Navigator 커밋 확인, 이미지 빌드, 컨테이너 실행 뒤 layer.json 응답이 200으로 나오는 것을 확인합니다.](https://copyandrun.com/img/attack-navigator-sigma-coverage-map/01-build-navigator.png)

Navigator 화면을 열면 브라우저가 ATT&CK 데이터를 GitHub(`raw.githubusercontent.com`)에서 내려받습니다(`config.json`의 `collection_index_url`). 그래서 이 컨테이너는 Navigator 화면 파일만 내주고, 브라우저는 인터넷에 연결되어 있어야 합니다.

## 2. 시험 규칙에서 기법별 개수 세기

<!-- files: sample_rules.yml, sigma_to_layer.py -->

`sample_rules.yml`에는 Sigma 모양의 연습용 규칙 9개가 `---`로 나뉘어 들어 있습니다. PowerShell 규칙 2개, 나머지 기법은 규칙 1개씩이고, 마지막 규칙은 일부러 `attack.*` tags가 없습니다. 이벤트 로그 삭제 규칙은 이전 방식의 tags(`attack.defense_evasion`, `attack.t1070.001`)를 일부러 남겨 두었습니다.

`sigma_to_layer.py`가 하는 일은 네 가지입니다.

- **tags 읽기:** `yaml.safe_load_all`로 규칙을 읽고 `attack.t1059.001` 모양의 tags에서 기법 ID를 뽑습니다. 대문자로 바꾸어 `T1059.001`로 정규화하며, 하위 기법(`.001`)이 없으면 `T1490`처럼 상위 기법만 남습니다.
- **전술 세기:** `attack.execution` 같은 전술 tags도 따로 세어, 규칙이 하나도 없는 전술을 표시합니다. 하이픈과 밑줄은 같은 것으로 봅니다(`attack.privilege-escalation`).
- **레이어 만들기:** 기법마다 규칙 개수를 `score`로, 규칙 제목 몇 개를 `comment`로 넣은 레이어 JSON을 씁니다. 상위 기법 칸에는 하위 기법 개수의 합이 보이게 `showAggregateScores`를 켭니다.
- **ID 점검:** `--attack`으로 ATT&CK STIX 파일을 주면, 현재 목록에 없는 기법 ID와 바뀐 대체 ID를 경고합니다.

레이어 형식은 공식 명세(`layers/spec/v4.5/layerformat.md`)의 필수 항목을 따랐습니다. `versions`의 `layer`는 `"4.5"`, `navigator`는 `"4.9.0"` 이상이어야 하고, `domain`은 `enterprise-attack`, 기법은 `techniqueID`와 `score` 등으로 적습니다.

ATT&CK 데이터 파일을 받고 실행합니다. 파일은 약 55MB입니다.

```bash
curl -sLo enterprise-attack-20.0.json https://raw.githubusercontent.com/mitre-attack/attack-stix-data/master/enterprise-attack/enterprise-attack-20.0.json
python -m pip install pyyaml
python -X utf8 sigma_to_layer.py sample_rules.yml --out layers/layer.json --name 'Sample rules' --attack enterprise-attack-20.0.json --expand
```

`--expand`는 하위 기법을 펼친 채로 열게 하는 옵션입니다.

![9개 규칙 중 8개에 기법 태그가 있고, 규칙이 없는 전술과 T1070.001 경고가 함께 출력되는 것을 확인합니다.](https://copyandrun.com/img/attack-navigator-sigma-coverage-map/02-sample-layer.png)

출력에서 읽을 것은 세 가지입니다. 기법은 7개이고 T1059.001만 규칙이 2개입니다. 규칙이 없는 전술은 `reconnaissance`, `initial_access`, `discovery` 등 열 개입니다. 마지막 두 줄은 이전 방식 tags의 문제로, 다음 단계에서 화면과 함께 봅니다.

## 3. Navigator 화면에서 레이어 열기

<!-- files: sigma_to_layer.py -->

주소 끝의 `#layerURL=`에 레이어 주소를 주면 Navigator가 시작할 때 그 레이어를 엽니다(공식 `USAGE.md`의 Default Layers 항목). 이 글에서는 헤드리스 Chrome으로 아래 주소를 열어 화면을 만들었습니다.

```
http://127.0.0.1:18084/#layerURL=http://127.0.0.1:18084/layers/layer.json
```

![규칙이 있는 전술 칸에만 파랑이 칠해지고 Stealth와 Defense Impairment 칸은 비어 있는 ATT&CK 행렬을 확인합니다.](https://copyandrun.com/img/attack-navigator-sigma-coverage-map/03-navigator-sample.png)

가로로 15개 전술이 펼쳐지고, 연습용 규칙이 있는 Execution, Persistence, Credential Access, Impact 쪽에만 색이 보입니다. 같은 기법이 여러 전술에 속하면 전술마다 색이 칠해집니다. `T1547.001`이 Persistence와 Privilege Escalation 양쪽에서 칠해진 것이 그 예입니다(`techniqueID`에 `tactic`을 적지 않았기 때문입니다).

![T1059.001 PowerShell은 진한 파랑, T1059.003과 T1547.001은 연한 파랑으로 칠해진 Execution과 Persistence 열을 확인합니다.](https://copyandrun.com/img/attack-navigator-sigma-coverage-map/04-navigator-closeup.png)

규칙이 2개인 `T1059.001`은 진하고 1개인 두 기법은 연합니다. 밑줄이 그어진 기법은 `comment`가 있는 것이고, 마우스를 올리면 규칙 제목이 보입니다. 이 글에서 마우스 올림 화면은 찍지 않았습니다.

## 4. 규칙이 없는 전술과 이름이 바뀐 ID 읽기

<!-- files: sigma_to_layer.py -->

앞 화면에서 `Stealth`와 `Defense Impairment` 칸이 통째로 비어 있습니다. 사실은 연습용 규칙 중 이벤트 로그 삭제 규칙이 이 자리에 있어야 합니다. 원인은 두 가지였습니다.

- **전술 이름이 바뀌었습니다.** 이 글에서 쓴 ATT&CK 20.0 데이터에는 전술이 15개이고 `defense-evasion`이 없습니다. 대신 `stealth`와 `defense-impairment`가 있습니다. 규칙의 `attack.defense_evasion`은 목록에 없어 출력에 "알 수 없는 전술 태그"로 나왔습니다.
- **기법 ID가 바뀌었습니다.** `T1070.001`(Clear Windows Event Logs)은 20.0 데이터에서 폐기 표시이고 `T1685.005`로 대체되었습니다(STIX의 `revoked-by` 관계로 확인했습니다). Navigator는 목록에 없는 ID를 오류 없이 건너뛰어서, 03번 화면의 `T1070` 칸이 `(0/8)`로 비어 보입니다.

레이어에는 이전 ID가 그대로 들어 있고 Navigator는 조용히 무시하기 때문에, 이 경고가 없으면 "그 기법은 규칙이 없다"로 잘못 읽게 됩니다. 이 스크립트는 자동으로 ID를 바꾸지 않고 경고만 합니다. 바꾸어도 되는지는 규칙을 보고 사람이 정합니다.

## 5. SigmaHQ 공개 규칙으로 실제 규모 보기

SigmaHQ 저장소에서 Windows와 Linux 규칙 폴더만 받아 같은 스크립트로 돌립니다. 규칙 파일은 Detection Rule License(DRL) 1.1이고, 저장소 `LICENSE`에 그렇게 적혀 있습니다. 이 글에는 규칙 본문을 싣지 않고 개수만 싣습니다.

```bash
git clone --depth 1 --filter=blob:none --sparse https://github.com/SigmaHQ/sigma.git sigma
git -C sigma sparse-checkout set rules/windows rules/linux
python -X utf8 sigma_to_layer.py sigma/rules/windows sigma/rules/linux --out layers/sigmahq.json --name 'SigmaHQ windows+linux' --attack enterprise-attack-20.0.json
```

![SigmaHQ 규칙 2636개 중 2369개에 기법 태그가 있고 15개 전술 모두에 규칙이 있는 결과를 확인합니다.](https://copyandrun.com/img/attack-navigator-sigma-coverage-map/05-sigmahq-layer.png)

이 시점(커밋 05d1031)의 Windows와 Linux 규칙 2636개 가운데 2369개에 기법 태그가 있고, 330개 기법에 걸쳐 있습니다. 가장 많은 것은 `T1059.001`(PowerShell) 181개입니다. 현재 SigmaHQ 규칙은 새 전술 이름(`attack.stealth`, `attack.defense-impairment`)을 쓰고 있어서, 전술 이름을 밑줄과 하이픈 모두 받도록 한 것이 이 결과에 필요했습니다. 처음에는 하이픈을 처리하지 않아 `credential_access`가 0으로 나왔습니다.

이번에는 `--expand` 없이 열어서 하위 기법을 접어 두었습니다. 주소는 `.../layers/sigmahq.json`으로 바꾸면 됩니다.

![기법별 규칙 개수가 파랑 농도로 칠해지고 상위 기법 칸에 하위 기법 개수(n/m)가 함께 보이는 SigmaHQ 레이어를 확인합니다.](https://copyandrun.com/img/attack-navigator-sigma-coverage-map/06-navigator-sigmahq.png)

## 6. 이 지도가 말해 주지 않는 것

색이 진하다는 것은 그 기법 tags가 붙은 규칙이 많다는 뜻이고, 탐지가 잘 된다는 뜻은 아닙니다.

- **개수는 품질이 아닙니다.** 규칙 하나가 넓은 범위를 잘 잡을 수도, 규칙 열 개가 같은 도구 이름 하나를 중복해서 찾을 수도 있습니다.
- **tags는 작성자의 주장입니다.** 규칙이 실제로 그 기법을 탐지하는지는 시험해 봐야 알 수 있고, 이 스크립트는 규칙 본문을 보지 않습니다.
- **한 규칙이 여러 기법에 세어집니다.** 규칙 하나에 기법 tags가 여러 개면 각 기법에 한 번씩 들어가고, 상위 기법 칸의 합도 겹쳐 세어집니다.
- **로그가 없으면 규칙도 소용없습니다.** 규칙은 해당 로그(예: 프로세스 생성 로그)가 수집될 때만 동작합니다. 이 지도는 수집 여부를 모릅니다.
- **빈 칸이 곧 위험은 아닙니다.** 규칙이 없는 칸은 다른 제품이나 통제로 막고 있을 수도 있고, 우리 환경에 해당하지 않는 기법일 수도 있습니다.
- **버전이 바뀌면 지도가 어긋납니다.** 4단계에서 본 것처럼 ATT&CK은 전술과 기법 ID가 바뀝니다.

그래서 이 지도는 "규칙이 없는 곳을 찾는 출발점"으로 쓰고, 색이 진한 곳은 실제 탐지 시험으로 따로 확인하는 편이 안전합니다.

## 결과 정리

- Sigma 규칙의 tags에서 기법 ID를 정규화해 세고, 레이어 JSON(`versions.layer` 4.5)으로 저장했습니다.
- `#layerURL=`로 로컬 Navigator에서 열면 기법별 개수가 색으로, 하위 기법 합이 상위 칸에 보입니다.
- 전술 이름과 기법 ID는 ATT&CK 버전마다 바뀌고 Navigator는 모르는 ID를 조용히 건너뜁니다. 그래서 STIX 파일로 ID를 점검했습니다.
- 개수가 많다는 것은 탐지가 좋다는 뜻이 아니며, 빈 전술 칸을 찾는 용도로 읽습니다.

## 전체 코드

작업 폴더 구조는 아래와 같습니다. 이 밖에 실행 중에 `nav`(Navigator 저장소), `sigma`(SigmaHQ 저장소), `enterprise-attack-20.0.json`, `layers`가 생깁니다.

```
Dockerfile
sample_rules.yml
sigma_to_layer.py
```

### Dockerfile

```
# 공식 저장소의 Dockerfile 에서 빌드 단계를 node:22-slim 으로 줄이고 layers 복사를 뺀 것입니다.
FROM node:22-slim AS build
WORKDIR /src/nav-app
COPY ./nav-app/package.json ./nav-app/package-lock.json ./
RUN npm ci
COPY ./nav-app/ ./
RUN npm run build -- --configuration production

FROM nginx:alpine
COPY --from=build /src/nav-app/dist/browser/ /usr/share/nginx/html/
EXPOSE 80
```

### sample_rules.yml

```yaml
title: Encoded PowerShell Command Line
id: 6c1a0b1e-0001-4a00-9000-000000000001
status: experimental
description: Practice rule. PowerShell started with an encoded command option.
logsource: {category: process_creation, product: windows}
detection:
  selection:
    Image|endswith: '\powershell.exe'
    CommandLine|contains: ' -enc'
  condition: selection
level: medium
tags:
  - attack.execution
  - attack.t1059.001
---
title: PowerShell Download Cradle Keywords
id: 6c1a0b1e-0002-4a00-9000-000000000002
status: experimental
description: Practice rule. PowerShell command line contains download keywords.
logsource: {category: process_creation, product: windows}
detection:
  selection:
    Image|endswith: '\powershell.exe'
    CommandLine|contains: 'DownloadString'
  condition: selection
level: medium
tags:
  - attack.execution
  - attack.t1059.001
---
title: Command Shell Spawned by Office Application
id: 6c1a0b1e-0003-4a00-9000-000000000003
status: experimental
description: Practice rule. cmd.exe started by a word processor process.
logsource: {category: process_creation, product: windows}
detection:
  selection:
    ParentImage|endswith: '\winword.exe'
    Image|endswith: '\cmd.exe'
  condition: selection
level: medium
tags:
  - attack.execution
  - attack.t1059.003
---
title: Scheduled Task Created With schtasks
id: 6c1a0b1e-0004-4a00-9000-000000000004
status: experimental
description: Practice rule. A scheduled task is created from the command line.
logsource: {category: process_creation, product: windows}
detection:
  selection:
    Image|endswith: '\schtasks.exe'
    CommandLine|contains: ' /create '
  condition: selection
level: low
tags:
  - attack.execution
  - attack.persistence
  - attack.privilege_escalation
  - attack.t1053.005
---
title: Run Key Modified With reg.exe
id: 6c1a0b1e-0005-4a00-9000-000000000005
status: experimental
description: Practice rule. A Run registry key is written through reg.exe.
logsource: {category: process_creation, product: windows}
detection:
  selection:
    Image|endswith: '\reg.exe'
    CommandLine|contains: 'CurrentVersion\Run'
  condition: selection
level: medium
tags:
  - attack.persistence
  - attack.t1547.001
---
title: LSASS Memory Dump With comsvcs
id: 6c1a0b1e-0006-4a00-9000-000000000006
status: experimental
description: Practice rule. rundll32 calls MiniDump from comsvcs.dll.
logsource: {category: process_creation, product: windows}
detection:
  selection:
    CommandLine|contains|all:
      - 'comsvcs'
      - 'MiniDump'
  condition: selection
level: high
tags:
  - attack.credential_access
  - attack.t1003.001
---
title: Shadow Copy Deleted With vssadmin
id: 6c1a0b1e-0007-4a00-9000-000000000007
status: experimental
description: Practice rule. Volume shadow copies are deleted from the command line.
logsource: {category: process_creation, product: windows}
detection:
  selection:
    Image|endswith: '\vssadmin.exe'
    CommandLine|contains: 'delete shadows'
  condition: selection
level: high
tags:
  - attack.impact
  - attack.t1490
---
title: Event Log Cleared With wevtutil
id: 6c1a0b1e-0008-4a00-9000-000000000008
status: experimental
description: Practice rule. Event logs are cleared. Old-style ATT&CK tags are kept on purpose.
logsource: {category: process_creation, product: windows}
detection:
  selection:
    Image|endswith: '\wevtutil.exe'
    CommandLine|contains: ' cl '
  condition: selection
level: medium
tags:
  - attack.defense_evasion
  - attack.t1070.001
---
title: Rule Without ATT&CK Tags
id: 6c1a0b1e-0009-4a00-9000-000000000009
status: experimental
description: Practice rule. Has no attack.* tags, so it does not appear on the map.
logsource: {category: process_creation, product: windows}
detection:
  selection:
    Image|endswith: '\whoami.exe'
  condition: selection
level: informational
tags:
  - custom.internal
```

### sigma_to_layer.py

```python
import argparse
import json
import re
import sys
from collections import defaultdict
from pathlib import Path

import yaml

# ATT&CK Enterprise 20.0 의 전술(행렬에 나오는 순서)
TACTICS = [
    "reconnaissance", "resource_development", "initial_access", "execution",
    "persistence", "privilege_escalation", "stealth", "defense_impairment",
    "credential_access", "discovery", "lateral_movement", "collection",
    "command_and_control", "exfiltration", "impact",
]
TECH = re.compile(r"^attack\.(t\d{4})(?:\.(\d{3}))?$", re.I)
SKIP_STATUS = {"deprecated", "unsupported"}


def load_rules(paths):
    files = []
    for p in paths:
        p = Path(p)
        files += sorted(p.rglob("*.yml")) if p.is_dir() else [p]
    for f in files:
        try:
            for doc in yaml.safe_load_all(f.read_text(encoding="utf-8")):
                if isinstance(doc, dict) and "title" in doc:
                    yield f, doc
        except yaml.YAMLError as e:
            print(f"읽지 못함: {f.name}: {str(e).splitlines()[0]}", file=sys.stderr)


def normalize(tag):
    """attack.t1059.001 -> T1059.001, 기법 태그가 아니면 None"""
    m = TECH.match(str(tag).strip())
    if not m:
        return None
    return m.group(1).upper() + ("." + m.group(2) if m.group(2) else "")


def load_attack(path):
    """ATT&CK STIX 파일에서 현재 기법 ID 와, 폐기된 ID 의 대체 ID 를 읽는다."""
    objs = json.loads(Path(path).read_text(encoding="utf-8"))["objects"]
    by_id = {o["id"]: o for o in objs}

    def ext_id(o):
        for r in o.get("external_references", []):
            if r.get("source_name") == "mitre-attack":
                return r.get("external_id")

    valid, old = set(), {}
    for o in objs:
        if o["type"] == "attack-pattern" and not o.get("revoked") and not o.get("x_mitre_deprecated"):
            valid.add(ext_id(o))
    for o in objs:
        if o["type"] == "relationship" and o["relationship_type"] == "revoked-by":
            src, dst = by_id.get(o["source_ref"]), by_id.get(o["target_ref"])
            if src and dst and src["type"] == "attack-pattern":
                old[ext_id(src)] = ext_id(dst)
    return valid, old


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("paths", nargs="+")
    ap.add_argument("--out", default="layer.json")
    ap.add_argument("--name", default="Sigma coverage")
    ap.add_argument("--expand", action="store_true", help="하위 기법을 펼친 채로 열기")
    ap.add_argument("--attack", help="ATT&CK STIX JSON 파일(있으면 없는 ID 를 알려 줌)")
    a = ap.parse_args()

    tech_rules = defaultdict(list)
    tactic_count = defaultdict(int)
    unknown_tactics = defaultdict(int)
    total = tagged = skipped = 0
    for f, rule in load_rules(a.paths):
        total += 1
        if str(rule.get("status", "")).lower() in SKIP_STATUS:
            skipped += 1
            continue
        tags = [str(t).lower().replace("-", "_") for t in (rule.get("tags") or [])]
        ids = {normalize(t) for t in tags} - {None}
        if ids:
            tagged += 1
        for t in ids:
            tech_rules[t].append(rule["title"])
        names = {t[len("attack."):] for t in tags if t.startswith("attack.")}
        for n in names:
            if n in TACTICS:
                tactic_count[n] += 1
            elif not re.match(r"^[a-z]{1,2}\d{4}", n):
                unknown_tactics[n] += 1

    techniques = []
    parents = {t.split(".")[0] for t in tech_rules if "." in t}
    for t in sorted(tech_rules):
        titles = tech_rules[t]
        comment = "규칙 %d개: %s" % (len(titles), "; ".join(titles[:3]) + (" ..." if len(titles) > 3 else ""))
        techniques.append({"techniqueID": t, "score": len(titles), "comment": comment, "enabled": True})
    if a.expand:
        for p in sorted(parents - set(tech_rules)):
            techniques.append({"techniqueID": p, "showSubtechniques": True})
        for item in techniques:
            if item["techniqueID"] in parents:
                item["showSubtechniques"] = True

    empty = [t for t in TACTICS if tactic_count[t] == 0]
    sums = defaultdict(int)  # 상위 기법 칸에는 하위 기법 규칙 수의 합이 표시된다
    for t, v in tech_rules.items():
        sums[t.split(".")[0]] += len(v)
    top = max(list(sums.values()) + [len(v) for v in tech_rules.values()] or [1])
    layer = {
        "name": a.name,
        "versions": {"attack": "20", "navigator": "5.3.2", "layer": "4.5"},
        "domain": "enterprise-attack",
        "description": "기법별 Sigma 규칙 개수. 규칙이 없는 전술: " + (", ".join(empty) or "없음"),
        "sorting": 0,
        "layout": {"layout": "side", "showName": True, "showID": True},
        "hideDisabled": False,
        "showAggregateScores": True,
        "aggregateFunction": "sum",
        "techniques": techniques,
        "gradient": {"colors": ["#ffffff", "#8ec6ff", "#1f5fbf"], "minValue": 0, "maxValue": top},
        "legendItems": [{"label": "규칙 개수가 많을수록 진한 파랑", "color": "#1f5fbf"}],
        "showTacticRowBackground": False,
        "selectTechniquesAcrossTactics": True,
    }
    Path(a.out).write_text(json.dumps(layer, ensure_ascii=False, indent=2), encoding="utf-8")

    print(f"규칙 {total}개 읽음, 기법 태그가 있는 규칙 {tagged}개, 건너뜀(deprecated/unsupported) {skipped}개")
    print(f"기법 {len(tech_rules)}개, 색 눈금 최댓값 {top}")
    print("기법별 규칙 수 상위:")
    for t, v in sorted(tech_rules.items(), key=lambda kv: (-len(kv[1]), kv[0]))[:8]:
        print(f"  {t:<10} {len(v)}")
    print("전술별 규칙 수:")
    for tac in TACTICS:
        n = tactic_count[tac]
        print(f"  {tac:<22} {n}" + ("   <- 규칙 없음" if n == 0 else ""))
    for n, c in sorted(unknown_tactics.items()):
        print(f"  알 수 없는 전술 태그 attack.{n}: 규칙 {c}개 (이름이 바뀌었을 수 있음)")
    if a.attack:
        valid, old = load_attack(a.attack)
        for t in sorted(set(tech_rules) - valid):
            hint = f" -> {old[t]} 로 바뀜" if t in old else " (현재 목록에 없음)"
            print(f"  경고 {t}: 규칙 {len(tech_rules[t])}개{hint}")
    print(f"레이어 저장: {a.out}")


if __name__ == "__main__":
    main()
```

## 자주 막히는 곳

- **`docker run`에서 `port is already allocated` 또는 `Only one usage of each socket address`가 납니다.** 다른 프로그램이 그 포트를 쓰고 있는 경우입니다. 이 글을 만들 때 18080과 18081이 이미 사용 중이어서 18084로 바꾸었습니다. `-p` 앞부분의 포트를 바꾸고 주소도 같은 포트로 고칩니다. 실패한 컨테이너 이름은 남으므로 `docker rm -f cr-c13-navigator` 뒤에 다시 실행합니다.
- **전술별 규칙 수가 이상하게 0으로 나옵니다.** 처음 스크립트는 `attack.credential-access`와 `attack.credential_access`를 다른 것으로 취급했습니다. 현재 SigmaHQ 규칙은 하이픈을 쓰므로 하이픈을 밑줄로 바꾸어 비교합니다.
- **규칙은 있는데 Navigator에서 색이 안 칠해집니다.** 그 기법 ID가 현재 ATT&CK 버전에 없는 경우입니다. `--attack`으로 STIX 파일을 주면 경고와 대체 ID가 나옵니다.
- **화면이 비어 있습니다.** 브라우저가 GitHub의 ATT&CK 데이터를 받지 못하면 행렬이 나오지 않을 수 있습니다. 이 글에서는 재현하지 않았고, 인터넷 연결이 필요하다는 점만 확인했습니다.

## 이어서 해 볼 것

- 우리 조직의 규칙 폴더를 `sigma_to_layer.py`에 넣고, 같은 방법으로 실제 지도를 만들어 봅니다.
- 규칙이 없는 전술 중 우리 환경에서 중요한 것을 골라, 그 전술의 기법 하나에 규칙을 만들어 봅니다.
- 시험 환경에서 규칙이 실제로 이벤트를 잡는지 따로 확인하고, 확인된 기법만 다른 색으로 표시하는 레이어를 만들어 봅니다.
- Navigator의 `Open Existing Layer`에서 `Upload from local`로 `layer.json`을 직접 올려 봅니다. 이 글에서는 실행하지 않았습니다.

## 확인 범위

- **확인한 것:** 위의 명령은 Windows Git Bash에서 실행한 결과이고, Navigator 이미지 빌드와 컨테이너 실행, 레이어 생성, `#layerURL=`로 레이어 열기, 화면 캡처까지 이 글과 같은 결과를 냈습니다.
- **공식 문서:** 레이어 형식은 [layerformat.md (4.5)](https://github.com/mitre-attack/attack-navigator/blob/master/layers/spec/v4.5/layerformat.md), `#layerURL=` 사용법은 [USAGE.md](https://github.com/mitre-attack/attack-navigator/blob/master/USAGE.md), tags 문법은 [Sigma 명세](https://sigmahq.io/sigma-specification/specification/sigma-rules-specification.html)에서 확인했습니다. 명세는 tags를 "소문자, 숫자, 밑줄, 하이픈"으로 쓰도록 권장하고 둘 중 하나를 정하지 않아서, 스크립트가 둘 다 받습니다. ATT&CK 데이터는 [attack-stix-data](https://github.com/mitre-attack/attack-stix-data)의 `enterprise-attack-20.0.json`입니다.
- **공식 문서와 달랐던 점:** Navigator의 공식 `Dockerfile`은 `node:22`이지만 이 글은 `node:22-slim`으로 빌드했고, 빌드는 성공했습니다. SigmaHQ 규칙의 전술 tags는 밑줄이 아니라 하이픈을 씁니다.
- **하지 못한 것:** Navigator에서 로컬 파일 올리기, 마우스 올림으로 보이는 `comment`, 화면 내보내기(SVG, Excel)는 해 보지 않았습니다. SigmaHQ의 `cloud`, `macos`, `network` 등 다른 규칙 폴더는 받지 않았고, Linux와 macOS 셸에서의 실행도 확인하지 않았습니다. `pip install`은 패키지가 이미 설치된 환경이라 실행하지 않았고, 그 출력은 확인하지 못했습니다.
- **범위의 한계:** 연습용 규칙 9개는 탐지 로직을 검증한 규칙이 아닙니다. SigmaHQ 숫자는 커밋 05d1031의 Windows와 Linux 폴더만 센 것이어서, 저장소가 갱신되면 달라집니다.
