当用户要求检查、分流、汇总、导出或安全更新 GitHub 安全警报(如代码扫描、Dependabot、恶意软件或密钥扫描)时使用。
GitHub 安全提醒管理是一项面向实际任务的技能,主要用于当用户要求检查或管理 GitHub 仓库安全提醒时, 请使用此技能, 包括: :. 代码扫描提醒;Dependabot 提醒;
该技能适合需要稳定复用相关能力的场景,可作为自动化工作流的一部分,也便于后续检查、调整和扩展。从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;
若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
当用户请求检查或管理 GitHub 仓库的安全警报时,请使用本技能,涵盖以下类型:
所附带的辅助工具与具体仓库无关(repository-agnostic):
--repo 参数指向任意本地检出路径owner/repo 和 GitHub 主机地址--repository owner/repo要求 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 实现python "/scripts/manage_github_security_alerts.py" summary --repo "."
python "/scripts/manage_github_security_alerts.py" repo-security-overview --repo "."
python "/scripts/manage_github_security_alerts.py" export-alerts --repo "." --json
python "/scripts/manage_github_security_alerts.py" list-code-scanning --repo "." --state open --severity high,error
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
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
python "/scripts/manage_github_security_alerts.py" list-dependabot --repo "." --state open --ecosystem npm --has patch
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
python "/scripts/manage_github_security_alerts.py" list-malware --repo "." --state open
python "/scripts/manage_github_security_alerts.py" list-secret-scanning --repo "." --state open
机密值默认隐藏。除非用户明确确认需要未脱敏的机密输出,否则请保持该默认行为。
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
python "/scripts/manage_github_security_alerts.py" list-secret-locations --repo "." --alert 11 python " /scripts/manage_github_security_alerts.py" secret-scan-history --repo "."
python "/scripts/manage_github_security_alerts.py" api-call --repo "." --endpoint /repos/OWNER/REPO/code-scanning/default-setup
GITHUB_TOKEN 的环境变量。--repo 并依赖 Git 远程地址自动识别。--repository owner/repo。summary。export-alerts。list/show 命令。repo-security-overview。bulk-update-alerts。--dry-run 预览效果。list/show 命令。与具体仓库无关的 GitHub 仓库安全警报辅助工具。
支持的命令:
summaryexport-alertsbulk-update-alertsrepo-security-overviewlist-code-scanningshow-code-scanningupdate-code-scanninglist-dependabotshow-dependabotupdate-dependabotlist-malwareshow-malwareupdate-malwarelist-secret-scanningshow-secret-scanningupdate-secret-scanninglist-secret-locationssecret-scan-historyapi-call实现模块:
github_security_api.pygithub_security_cli.pygithub_security_common.pygithub_security_operations.pygithub_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