scripton8/Agent-Skill_Check-for-similar-SigmaHQ-rules

GitHub: scripton8/Agent-Skill_Check-for-similar-SigmaHQ-rules

这是一个集成GitHub Actions的工具,旨在通过关键词相似度分析,在提交新检测思路时自动检查并提示相似的Sigma规则。

Stars: 0 | Forks: 0

# 检查相似的 SigmaHQ 规则 – Agent Skill 一个 GitHub Copilot agent skill 和 GitHub Actions 工作流,当通过 issue 或 pull request 提交新的检测思路或 Sigma 规则时,自动扫描仓库现有的 Sigma 检测规则。 ## 功能说明 当打开(或编辑)一个 **issue** 或 **pull request** 时,该工作流会执行以下操作: 1. 读取 issue/PR 的标题和正文 2. 在仓库中搜索 Sigma 规则文件 (`.yml` / `.yaml`) 3. 使用关键词相似度对每个规则进行相关性评分 4. 发布一条评论,其中包含最相似规则的表格 – 包括规则名称、UUID、描述以及指向该文件的直接链接 如果未找到相似规则,评论会说明这一点,并鼓励创建新规则以填补覆盖缺口。 ### 示例评论 ## 仓库布局 ``` . ├── .github/ │ ├── skills/ │ │ └── check-similar-sigma-rules/ │ │ └── SKILL.md ← Agent skill definition │ └── workflows/ │ └── check-similar-sigma-rules.yml ← GitHub Actions workflow ├── scripts/ │ └── check_similar_rules.py ← Core matching logic ├── tests/ │ └── test_check_similar_rules.py └── requirements.txt ``` ## 如何在您自己的 Sigma 仓库中使用此 skill 1. **复制工作流** (`.github/workflows/check-similar-sigma-rules.yml`) 到目标仓库的 `.github/workflows/` 目录中。 2. **复制脚本** (`scripts/check_similar_rules.py`) 到目标仓库的 `scripts/` 目录中。 3. *(可选)* **复制 skill 定义** (`.github/skills/check-similar-sigma-rules/SKILL.md`),如果您希望 Copilot 能够将其作为命名 skill 调用。 4. `GITHUB_TOKEN` 密钥在 GitHub Actions 中自动可用 – 无需额外配置。 ### 支持的规则目录 脚本会按以下顺序在下列目录中查找 Sigma 规则文件: - `rules/` - `detections/` - `detection/` - `sigma/` - `rules-emerging-threats/` - `rules-placeholder/` - `rules-threat-hunting/` 如果这些目录都不存在,则扫描仓库中(排除 `.github/`)的所有 `.yml` / `.yaml` 文件。 ## 本地运行测试 ``` pip install -r requirements.txt pytest tests/ ``` ## 配置 可以调整 `scripts/check_similar_rules.py` 中的以下常量: | 常量 | 默认值 | 描述 | |---|---|---| | `MIN_SIMILARITY_SCORE` | `0.05` | 规则出现在结果中的最低分数 | | `MAX_RESULTS` | `10` | 评论中显示的规则最大数量 | | `RULES_DIRECTORIES` | 见上文 | 搜索 Sigma 规则的目录 | ## 相似度计算方式 对于每个 Sigma 规则,脚本会: 1. 从 `title`、`description`、`tags`、`detection`、`logsource`、`author`、`references` 和 `falsepositives` 中收集所有文本 2. 进行分词并过滤停用词 3. 计算查询关键词集与规则关键词集之间的 **Jaccard 相似度** 4. 当查询词出现在规则的 `title` (+0.3) 或 `description` (+0.1) 中时,增加额外分数 返回得分 ≥ `MIN_SIMILARITY_SCORE` 的规则,并按分数降序排列。
标签:Agent技能, AMSI绕过, GitHub Actions, GitHub Copilot, Sigma规则, YAML, 代码审查, 威胁检测, 安全库, 安全运营, 扫描框架, 目标导入, 相似性匹配, 自动笔记, 覆盖率分析, 规则去重, 逆向工具