Github Manage Security Alerts

Polar Sponsor
爱发电 赞助
.NET 9.0

当用户要求检查、分流、汇总、导出或安全更新 GitHub 安全警报(如代码扫描、Dependabot、恶意软件或密钥扫描)时使用。

GitHub 安全提醒管理

功能概述

GitHub 安全提醒管理是一项面向实际任务的技能,主要用于当用户要求检查或管理 GitHub 仓库安全提醒时, 请使用此技能, 包括: :. 代码扫描提醒;Dependabot 提醒;

核心要点

  • Dependabot mal。
  • 它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
  • 使用时应结合输入条件选择合适的执行方式,核对必要参数、依赖环境与输出内容,并按原始要求处理异常情况。

使用与执行

该技能适合需要稳定复用相关能力的场景,可作为自动化工作流的一部分,也便于后续检查、调整和扩展。从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;

结果检查与注意事项

若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。

GitHub 安全警报管理

概述

当用户请求检查或管理 GitHub 仓库的安全警报时,请使用本技能,涵盖以下类型:

  • 代码扫描警报(code scanning alerts)
  • Dependabot 警报(Dependabot alerts)
  • Dependabot 恶意软件警报(Dependabot malware alerts)
  • 机密扫描警报(secret scanning alerts)
  • 机密扫描警报位置(secret scanning alert locations)
  • 机密扫描扫描历史(secret scanning scan history)
  • 仓库安全设置概览(repository security settings overview)
  • 跨仓库的原始 GitHub 安全 API 检查(raw GitHub security API inspection across repositories)
  • 批量导出警报,用于离线分类或报告流程(bulk alert export for offline triage or reporting workflows)
  • 批量修改警报,用于高量级清理流程(bulk alert mutation for high-volume cleanup workflows)

所附带的辅助工具与具体仓库无关(repository-agnostic):

  • 通过 --repo 参数指向任意本地检出路径
  • 自动从 Git 远程地址中识别 owner/repo 和 GitHub 主机地址
  • 或显式传入 --repository owner/repo
  • 通过环境变量进行身份验证,避免将令牌(token)直接暴露在命令行中
  • 可选地覆盖 API 或 Web 基础 URL,以适配自定义部署环境

兼容性

要求 Python 3 环境。
直接使用 GitHub REST API,并通过环境变量(如 GITHUB_TOKEN 或 GH_TOKEN)提供认证令牌。
支持 GitHub.com 及标准 GHES(GitHub Enterprise Server)API 基础 URL 的自动推导(基于 Git 远程地址),并对尚未封装的功能提供原始 API 回退支持。

调用提示

当目标为本地检出路径时,使用 repo 参数,默认值为 .。
当自动检测不足以满足需求时,可选择性指定 repository、api_base_url、web_base_url 和 token_env 参数。
常用命令包括:summary、export-alerts、bulk-update-alerts、repo-security-overview、list-code-scanning、show-code-scanning、update-code-scanning、list-dependabot、show-dependabot、update-dependabot、list-malware、show-malware、update-malware、list-secret-scanning、show-secret-scanning、update-secret-scanning、list-secret-locations、secret-scan-history 和 api-call。

安全模型

切勿将 GitHub 令牌粘贴至命令行参数中。
除非用户明确要求输出未脱敏的机密值,并确认其暴露风险,否则请勿使用 --show-secret-values 参数。应优先使用已脱敏的警报元数据、机密位置、有效性及解决状态信息。若修复操作确实需要未脱敏输出,请勿将机密内容粘贴至聊天记录、议题评论(issue comments)、拉取请求(PRs)、提交(commits)、日志或已保存的报告中。

推荐做法如下:

$env:GITHUB_TOKEN = Get-Secret GITHUB_TOKEN -AsPlainText

若仓库使用了其他名称的环境变量,请先将其导出,或通过 --token-env 显式指定变量名。

示例:

python "/scripts/manage_github_security_alerts.py" summary --repo "."
python "/scripts/manage_github_security_alerts.py" summary --repo "." --token-env GITHUB_TOKEN

输入参数

  • repo:目标仓库本地检出路径中的子路径(默认为 .)
  • repository:可选的显式 owner/repo 覆盖值
  • api_base_url:可选的显式 API 基础 URL 覆盖值
  • web_base_url:可选的显式 Web 基础 URL 覆盖值(用于生成渲染链接)
  • token_env:可选的包含令牌的环境变量名;支持重复指定以实现备用机制
  • json:可选的机器可读输出标志

关于恶意软件警报的重要说明

GitHub 将恶意软件发现结果呈现为Dependabot 恶意软件警报(Dependabot malware alerts)。

GitHub 并未为恶意软件警报单独提供一套独立的仓库警报体系及其专属 REST 接口。因此,本辅助工具将恶意软件警报视为 Dependabot 警报的一个过滤子集,并通过交叉比对每条警报关联的 GHSA(GitHub Security Advisory)编号与 GitHub Advisory Database,识别出类型为 malware 的安全通告。

这意味着:

  • list-malware、show-malware 和 update-malware 均基于 Dependabot 警报 API 实现
  • 恶意软件分类能力在 GitHub.com 上最强,因其可访问 Advisory Database 接口
  • 若目标主机不支持 Advisory 类型查询,该工具将明确报告该状态,而不会静默猜测

快速入门

1. 检查当前安全状态

python "/scripts/manage_github_security_alerts.py" summary --repo "."

2. 查看仓库安全设置概览

python "/scripts/manage_github_security_alerts.py" repo-security-overview --repo "."

2.5 批量导出全部警报以供离线分类

python "/scripts/manage_github_security_alerts.py" export-alerts --repo "." --json

3. 列出代码扫描警报

python "/scripts/manage_github_security_alerts.py" list-code-scanning --repo "." --state open --severity high,error

3.5 批量忽略或重新打开警报

python "/scripts/manage_github_security_alerts.py" bulk-update-alerts --repo "." --surface code-scanning --select-state open --target-state dismissed --dismissed-reason "false positive" --comment "Reviewed and intentionally dismissed." --limit 10 --dry-run --json

python "/scripts/manage_github_security_alerts.py" bulk-update-alerts --repo "." --surface dependabot --select-state open --target-state dismissed --dismissed-reason tolerable_risk --comment "Accepted until the next dependency refresh." --limit 25 --dry-run --json

python "/scripts/manage_github_security_alerts.py" bulk-update-alerts --repo "." --surface secret-scanning --select-state open --target-state resolved --resolution used_in_tests --limit 25 --dry-run --json

4. 忽略或重新打开一条代码扫描警报

python "/scripts/manage_github_security_alerts.py" update-code-scanning --repo "." --alert 42 --state dismissed --dismissed-reason false_positive --comment "False positive after manual review." --dry-run
python "/scripts/manage_github_security_alerts.py" update-code-scanning --repo "." --alert 42 --state open

5. 列出 Dependabot 警报

python "/scripts/manage_github_security_alerts.py" list-dependabot --repo "." --state open --ecosystem npm --has patch

6. 忽略或重新打开一条 Dependabot 警报

python "/scripts/manage_github_security_alerts.py" update-dependabot --repo "." --alert 7 --state dismissed --dismissed-reason tolerable_risk --comment "Accepted until next quarterly upgrade." --dry-run
python "/scripts/manage_github_security_alerts.py" update-dependabot --repo "." --alert 7 --state open

7. 列出恶意软件警报

python "/scripts/manage_github_security_alerts.py" list-malware --repo "." --state open

8. 安全地列出机密扫描警报

python "/scripts/manage_github_security_alerts.py" list-secret-scanning --repo "." --state open

机密值默认隐藏。除非用户明确确认需要未脱敏的机密输出,否则请保持该默认行为。

9. 解决或重新打开一条机密扫描警报

python "/scripts/manage_github_security_alerts.py" update-secret-scanning --repo "." --alert 11 --state resolved --resolution revoked --comment "Token revoked and rotated." --dry-run
python "/scripts/manage_github_security_alerts.py" update-secret-scanning --repo "." --alert 11 --state open

10. 查看机密扫描警报位置与扫描历史

python "/scripts/manage_github_security_alerts.py" list-secret-locations --repo "." --alert 11
python "/scripts/manage_github_security_alerts.py" secret-scan-history --repo "."

11. 对尚未封装的功能使用原始 API 回退

python "/scripts/manage_github_security_alerts.py" api-call --repo "." --endpoint /repos/OWNER/REPO/code-scanning/default-setup

工作流

  1. 安全完成身份验证。
    • 优先使用类似 GITHUB_TOKEN 的环境变量。
    • 如有必要,先从密钥管理器加载令牌至环境变量。
    • 切勿在日志或聊天输出中打印令牌。
  2. 确定目标仓库。
    • 优先使用 --repo 并依赖 Git 远程地址自动识别。
    • 当本地检出不可用或不符合常规时,回退至 --repository owner/repo。
  3. 检查当前发现项。
    • 首先运行 summary。
    • 如需更全面的多维度 JSON 快照以支持批量分类或外部报告,请使用 export-alerts。
    • 针对您关注的警报类别,使用对应的 list/show 命令。
    • 如问题涉及启用状态或可用安全设置,请使用 repo-security-overview。
  4. 对发现项进行分类。
    • 在适当时,修复代码或依赖配置中的真实缺陷。
    • 仅在具备明确依据时才执行忽略操作。
    • 当先前的忽略或解决操作不再有效时,重新打开相关警报。
    • 当仓库中存在数十或数百条已审核但误分类、需统一处理的警报时,请使用 bulk-update-alerts。
  5. 谨慎执行变更操作。
    • 对于高风险变更,优先使用 --dry-run 预览效果。
    • 添加简短、可操作的忽略或解决说明。
    • 注意:写入操作需具备相应的 GitHub 权限。
  6. 验证变更后的状态。
    • 重新运行对应的 list/show 命令。
    • 对于代码或依赖修复,请等待下一轮 GitHub 分析周期(若预期警报将自然消失)。

所附资源

scripts/manage_github_security_alerts.py

与具体仓库无关的 GitHub 仓库安全警报辅助工具。

支持的命令:

  • summary
  • export-alerts
  • bulk-update-alerts
  • repo-security-overview
  • list-code-scanning
  • show-code-scanning
  • update-code-scanning
  • list-dependabot
  • show-dependabot
  • update-dependabot
  • list-malware
  • show-malware
  • update-malware
  • list-secret-scanning
  • show-secret-scanning
  • update-secret-scanning
  • list-secret-locations
  • secret-scan-history
  • api-call

实现模块:

  • github_security_api.py
  • github_security_cli.py
  • github_security_common.py
  • github_security_operations.py
  • github_security_render.py

示例:

python "/scripts/manage_github_security_alerts.py" summary --repo "." --json
python "/scripts/manage_github_security_alerts.py" export-alerts --repo "." --json
python "/scripts/manage_github_security_alerts.py" bulk-update-alerts --repo "." --surface code-scanning --select-state open --target-state dismissed --dismissed-reason "false positive" --comment "Reviewed and intentionally dismissed." --limit 10 --dry-run --json
python "/scripts/manage_github_security_alerts.py" list-code-scanning --repo "." --state open --per-page 100 --json
python "/scripts/manage_github_security_alerts.py" update-code-scanning --repo "." --alert 42 --state dismissed --dismissed-reason false_positive --comment "False positive after review." --dry-run
python "/scripts/manage_github_security_alerts.py" list-dependabot --repo "." --state open --ecosystem npm --json
python "/scripts/manage_github_security_alerts.py" list-malware --repo "." --json
python "/scripts/manage_github_security_alerts.py" update-dependabot --repo "." --alert 7 --state dismissed --dismissed-reason tolerable_risk --comment "Accepted temporarily." --dry-run
python "/scripts/manage_github_security_alerts.py" list-secret-scanning --repo "." --state open --json
python "/scripts/manage_github_security_alerts.py" update-secret-scanning --repo "." --alert 11 --state resolved --resolution revoked --comment "Revoked and rotated." --dry-run
python "/scripts/manage_github_security_alerts.py" list-secret-locations --repo "." --alert 11 --json
python "/scripts/manage_github_security_alerts.py" secret-scan-history --repo "." --json
python "/scripts/manage_github_security_alerts.py" api-call --repo "." --endpoint /repos/OWNER/REPO/dependabot/alerts --query-param state=open --json

相关专题

更多
GitHub官网入口版本汇总
GitHub官网入口版本汇总

本专题整合了GitHub入口版本地址汇总,阅读专题下面的文章了解更多详细内容。

2026.04.02

558

19

github中文官网入口 github中文版官网网页进入
github中文官网入口 github中文版官网网页进入

github中文官网入口https://docs.github.com/zh/get-started,GitHub 是一种基于云的平台,可在其中存储、共享并与他人一起编写代码。 通过将代码存储在GitHub 上的“存储库”中,你可以: “展示或共享”你的工作。 持续“跟踪和管理”对代码的更改。

2026.01.21

7965

27

git怎么对比两个版本的文件内容
git怎么对比两个版本的文件内容

要对比两个版本的 git 文件,请使用 git diff 命令:git diff 比较工作树和暂存区之间的差异。git diff 比较两个提交或标签之间的差异。git diff 输出显示差异块,其中 + 表示添加的行,- 表示删除的行, 表示修改的行。可使用 gitkraken、meld、beyond compare 等可视化工具更直观地查看差异。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

2024.04.09

2281

6

git提交错误怎么撤回
git提交错误怎么撤回

git提交错误撤回的方法:git reset head^:撤回最后一次提交,恢复到提交前状态。git revert head:创建新提交,内容与之前提交相反。git reset :使用提交的 sha-1 哈希撤回指定提交。交互式舞台区:标记要撤回的特定更改,然后提交,排除已撤回更改。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

2024.04.09

2517

7

git撤销提交的commit
git撤销提交的commit

Git是一个强大的版本控制系统,它提供了很多功能帮助开发人员有效地管理和控制代码的变更,本专题为大家提供git 撤销提交的commit相关的各种文章内容,供大家免费下载体验。

2023.07.24

714

5

git和svn的区别
git和svn的区别

git和svn的区别:1、定义不同;2、模型类型不同;3、存储单元不同;4、是否拥有全局版本号;5、内容完整性不同;6、版本库不同;7、克隆目录速度不同;8、分支不同。php中文网为大家带来了git和svn的相关知识、以及相关文章等内容。

2023.07.06

1260

6

自建git服务器
自建git服务器

git服务器是目前流行的分布式版本控制系统之一,可以让多人协同开发同一个项目。本专题为大家提供自建git服务器相关的各种文章、以及下载和课程。

2023.07.05

3859

9

Vite 项目如何打包和部署
Vite 项目如何打包和部署

Vite项目打包部署专题汇集生产构建、产物预览、输出目录、资源路径、Nginx与GitHub Pages部署及常见白屏和路由404问题的已审核文章,帮助读者完成上线流程。

2026.10.28

0

16

Vite 如何搭配 Vue.js
Vite 如何搭配 Vue.js

Vite搭配Vue.js专题汇集创建Vue 3项目、配置开发环境、路径别名、Vue插件、代理、多环境构建与调试的已审核文章,帮助读者完成从初始化到日常开发的配置。

2026.10.28

0

15

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
vscode手册
vscode手册

共0课时 | 0人学习

Git 教程
Git 教程

共21课时 | 8.1万人学习

Git版本控制工具
Git版本控制工具

共8课时 | 1.9万人学习