Skip to content

meltedinhex/analyst-ai-pack / skills/mapping-hunts-to-mitre-attack

mapping-hunts-to-mitre-attack

Verified

Maps hunts and detections to MITRE ATT&CK for coverage analysis: tagging hypotheses with techniques, building a coverage matrix from completed hunts, and identifying high-risk gaps to prioritize next. Activates for requests to map hunts to ATT&CK, build a coverage heatmap, or find detection gaps by technique.

FileKindSize
LICENSEother340 B
SKILL.mdskill md2.9 KB
references/api-reference.mdmarkdown1.2 KB
scripts/analyst.pyscript2.5 KB

scripts/analyst.py

View on GitHub
#!/usr/bin/env python3
"""Build an ATT&CK coverage summary and Navigator layer from a hunt inventory.

Reads a JSON list of hunts (each with ``name``, ``techniques``, and optional ``confidence``)
and produces a per-technique coverage summary plus a minimal ATT&CK Navigator layer file with
scores derived from confidence. It only reads/writes local JSON.
"""
from __future__ import annotations

import argparse
import json
import sys
from pathlib import Path

CONF_SCORE = {"high": 100, "medium": 60, "low": 30}


def build(hunts: list[dict]) -> dict:
    coverage: dict[str, dict] = {}
    for hunt in hunts:
        conf = hunt.get("confidence", "medium").lower()
        score = CONF_SCORE.get(conf, 60)
        for tech in hunt.get("techniques", []):
            entry = coverage.setdefault(tech, {"hunts": [], "best_score": 0})
            entry["hunts"].append(hunt.get("name", "<unnamed>"))
            entry["best_score"] = max(entry["best_score"], score)
    return coverage


def to_layer(coverage: dict, name: str) -> dict:
    return {
        "name": name,
        "versions": {"layer": "4.5", "navigator": "4.9.1"},
        "domain": "enterprise-attack",
        "description": "Hunt coverage generated by analyst-ai-pack",
        "techniques": [
            {"techniqueID": tid, "score": data["best_score"],
             "comment": ", ".join(data["hunts"])}
            for tid, data in sorted(coverage.items())
        ],
        "gradient": {"colors": ["#ffffff", "#66b1ff", "#0b5cad"], "minValue": 0,
                     "maxValue": 100},
    }


def main(argv: list[str] | None = None) -> int:
    parser = argparse.ArgumentParser(description="ATT&CK hunt coverage")
    sub = parser.add_subparsers(dest="cmd", required=True)
    p = sub.add_parser("coverage")
    p.add_argument("file", help="JSON list of hunts")
    p.add_argument("--out", default=None, help="write Navigator layer JSON here")
    p.add_argument("--name", default="Hunt Coverage")
    args = parser.parse_args(argv)

    hunts = json.loads(Path(args.file).read_text(encoding="utf-8"))
    coverage = build(hunts)
    summary = {tid: {"score": d["best_score"], "hunts": d["hunts"]}
               for tid, d in sorted(coverage.items())}
    print(json.dumps({"techniques_covered": len(coverage), "coverage": summary}, indent=2))
    if args.out:
        Path(args.out).write_text(json.dumps(to_layer(coverage, args.name), indent=2),
                                  encoding="utf-8")
    return 0


if __name__ == "__main__":
    sys.exit(main())
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall