Fraunhofer-FIT-DSAI/Playbook_Generation_and_Selection

GitHub: Fraunhofer-FIT-DSAI/Playbook_Generation_and_Selection

该项目是一个基于攻击图与本体语义的事件响应 Playbook 自动生成与选择研究工件,解决了 Playbook 与攻击场景覆盖匹配的溯源与量化评估问题。

Stars: 0 | Forks: 1

# Playbook 生成与选择 此仓库包含以下论文的代码、输入、生成的仓库文件、诊断信息及结果表: **基于攻击图的知识库增强:语义与溯源感知的事件响应 Playbook 选择** 已提交至 SecAI 2026 (ESORICS workshop) 该工件按方法阶段进行组织。它支持: - 基于攻击图条件的 playbook 生成; - 基于本体的社区 playbook 选择; - 生成式与社区 playbook 的严格溯源闭环集成; - 生成式知识库缩减; - 公平性/数据泄露检查、消融实验、覆盖率感知选择、组合选择以及论文发表用表格。 ## 仓库布局 ``` generation_phase/ source/ Attack-graph, incident, response-generation, and MulVAL helper code. selection_phase/ source/ Community playbook ontology, D3FEND mappings, scenario queries, and baseline selector inputs. integration_phase/ scripts/ Canonical scripts used for the closed-loop paper evaluation. data/ scenario_profiles/ Shared ATT&CK/CVE scenario profiles used by both phases. results/ generated_repository/ Exported generated playbooks, generated OWL, reduced OWL, manifests, and reduction report. evaluation/ Selection outputs, diagnostics, ablations, portfolio results, and publication tables. docs/ artifact_manifest.md File-level overview of the public artifact. ``` ## 环境设置 推荐使用 Python 3.9+。 ``` python3 -m venv .venv source .venv/bin/activate python -m pip install --upgrade pip setuptools wheel pip install -r requirements.txt ``` 可选依赖仅在需要进行遗留预处理或完全重新生成语义映射时才使用: ``` pip install -r requirements-optional.txt ``` 外部服务/工具: - 重新运行基于 SPARQL 的选择时,需要 **GraphDB 或其他兼容 RDF4J 的 triplestore**。 - 仅当需要从 `input.P` 重新生成攻击图时才需要 **MulVAL**;论文场景中已捆绑了预计算的 MulVAL 输出结果。 - 如果本地没有 MulVAL 命令,`generation_phase/source/AttackTree_generation/mulval_pipeline.py` 可以使用 **Docker**。 ## 外部资源 官方的 MITRE ATT&CK STIX 快照和 MITRE D3FEND 本体默认不会提交到 Git。在运行完整工作流之前,请先获取它们: ``` python integration_phase/scripts/download_mitre_resources.py ``` 下载器默认使用 MITRE CTI 标签 `ATT&CK-v19.1`,并将本地清单写入 `data/external_resource_manifest.json`。下载的 MITRE 文件会被 Git 忽略。 大型的完整生成知识库文件已作为 release/archive 附件提供。 ## 从捆绑的输出结果快速复现 `results/` 目录下的捆绑文件可以直接复现论文结果,无需重新运行 MulVAL 或 GraphDB。 它会根据捆绑的结果 CSV/JSON 文件重新生成论文发表用表格。 ``` python integration_phase/scripts/make_publication_tables.py ``` 输出: ``` results/evaluation/publication_tables/table_a_main_closed_loop_comparison.csv results/evaluation/publication_tables/table_a_main_closed_loop_comparison.tex results/evaluation/publication_tables/table_b_direct_vs_inferred.csv results/evaluation/publication_tables/table_b_direct_vs_inferred.tex results/evaluation/publication_tables/table_c_weakest_normalized_recall.csv results/evaluation/publication_tables/table_c_weakest_normalized_recall.tex ``` 对捆绑的结果文件运行一致性检查: ``` python integration_phase/scripts/check_closed_loop_sanity.py python integration_phase/scripts/run_fairness_checks.py python integration_phase/scripts/analyze_closed_loop_results.py ``` 关键诊断输出: ``` results/evaluation/diagnostics/sanity_summary.json results/evaluation/diagnostics/fairness_checks.json results/evaluation/diagnostics/closed_loop_diagnostics_summary.json ``` ## 完整复现工作流 以下步骤从各阶段的输入重新构建闭环工件。需要外部软件的步骤已作标记。 ### 1. 构建共享场景配置 ``` python integration_phase/scripts/build_scenario_profiles.py ``` 输出: ``` data/scenario_profiles/*.json data/scenario_profiles/index.json ``` 这些配置包含 ATT&CK 映射和可用的 `top_cve` 证据。它们不包含完整的主机、资产或工件标注;工件会在稍后通过 ATT&CK-D3FEND 关系推断出来。 ### 2. 生成基于场景条件的 MulVAL 输入 ``` python integration_phase/scripts/generate_scenario_mulval_inputs.py ``` 输出: ``` generation_phase/source/mulval-inputs/scenario_*/input.P generation_phase/source/mulval-inputs/scenario_*/rules.P data/scenario_profiles/CVE_MITRE_enriched.scenario.csv ``` ### 3. 使用 MulVAL 重新生成攻击图 由于已捆绑了预计算的攻击图输出,因此对于检查已发布的结果来说,此步骤是可选的。 使用 Docker: ``` cd generation_phase/source ./AttackTree_generation/mulval_pipeline.py "$PWD/mulval-inputs" --runner docker cd ../.. ``` 使用现有的名为 `mulval_exec` 的 shell 函数: ``` cd generation_phase/source ./AttackTree_generation/mulval_pipeline.py "$PWD/mulval-inputs" --runner function cd ../.. ``` ### 4. 导出生成的 Playbook ``` python integration_phase/scripts/export_generated_playbooks.py \ --all-cases \ --limit 500 \ --cve-table data/scenario_profiles/CVE_MITRE_enriched.scenario.csv ``` 输出: ``` results/generated_repository/export/generated_playbooks.jsonl results/generated_repository/export/generated_playbook_steps.csv results/generated_repository/export/summary.json ``` JSONL 文件是生成的 playbook 的紧凑规范化表示。单个 CACAO 结构的 JSON 文件刻意未包含在内,因为它们与 JSONL/OWL 工件存在重复。 ### 5. 将生成的 Playbook 转换为 OWL ``` python integration_phase/scripts/generated_playbooks_to_owl.py ``` 输出: ``` results/generated_repository/generated_playbooks.owl results/generated_repository/generated_playbooks_manifest.csv ``` OWL 具体化了: - playbook 级别和步骤级别的直接 ATT&CK 溯源; - D3FEND 防御技术链接; - 可用情况下的 CVE、主机、工件、风险、操作计数、阶段、场景和攻击路径元数据。 ### 6. 缩减生成的知识库 ``` python integration_phase/scripts/reduce_generated_playbooks.py \ --strategy hybrid \ --per-scenario 50 ``` 输出: ``` results/generated_repository/reduced_generated_playbooks.owl results/generated_repository/reduced_generated_playbooks_manifest.csv results/generated_repository/reduction_report.csv results/generated_repository/reduction_summary.json ``` 论文使用了 `hybrid` 策略以及 `--per-scenario 50` 参数。 ### 7. 加载 GraphDB 创建一个名为 `incident-response` 的 GraphDB 仓库,然后加载基础本体、D3FEND、社区 playbook、语义 playbook-D3FEND 映射以及生成的 playbook。 对于主要的增强缩减实验: ``` python integration_phase/scripts/load_graphdb_files.py --clear \ selection_phase/source/IncidentResponseSecurityOntology.rdf \ selection_phase/source/GraphDB/d3fend.owl \ selection_phase/source/GraphDB/playbooks.owl \ selection_phase/source/GraphDB/playbook_step_defend_mapping.owl \ results/generated_repository/reduced_generated_playbooks.owl ``` 对于 augmented-all 消融实验,请将 `reduced_generated_playbooks.owl` 替换为 `generated_playbooks.owl`。 ### 8. 运行选择模式 社区基线: ``` python integration_phase/scripts/run_mcdm_selection.py \ --mode community-only \ --scoring-profile coverage-only \ --out-dir results/evaluation/community-only ``` 主要的闭环 top-1 实验: ``` python integration_phase/scripts/run_mcdm_selection.py \ --mode augmented-reduced \ --scoring-profile closed-loop-balanced \ --out-dir results/evaluation/augmented-reduced ``` 仅限生成内容的缩减实验: ``` python integration_phase/scripts/run_mcdm_selection.py \ --mode generated-reduced \ --scoring-profile closed-loop-balanced \ --out-dir results/evaluation/generated-reduced ``` 默认情况下,生成的 playbook 仅限于其匹配的源场景/案例。`--allow-cross-scenario-generated` 标志仅用于消融实验。 ### 9. 运行评估变体 ``` python integration_phase/scripts/run_selection_profile_comparison.py python integration_phase/scripts/run_portfolio_selection.py python integration_phase/scripts/run_ablation_experiments.py python integration_phase/scripts/run_reduction_sensitivity.py python integration_phase/scripts/run_fairness_checks.py python integration_phase/scripts/check_closed_loop_sanity.py python integration_phase/scripts/analyze_closed_loop_results.py python integration_phase/scripts/make_publication_tables.py ``` ## 结果解读 - `combined_attack_recall` 是直接 ATT&CK 溯源与通过 ATT&CK-工件-D3FEND 路径推断出的 ATT&CK 覆盖率的并集。 - `achievable_combined_attack_recall` 是某个场景下候选池所能达到的覆盖率。 - `normalized_combined_attack_recall` 是已选覆盖率除以可达覆盖率。 - 组合召回率评估的是,与单个排名第一的 playbook 相比,一小组 playbook 是否能覆盖更多可达的场景覆盖率。
标签:Terrascan, 安全事件响应, 攻击图分析, 本体论, 网络安全, 请求拦截, 软件供应链, 逆向工具, 隐私保护