← 返回 Skills 市场
charlie-morrison

branch-protection-auditor

作者 charlie-morrison · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
27
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install branch-protection-auditor
功能描述
Audit GitHub/GitLab branch protection rules across repositories. Check required reviews, status checks, force push restrictions, admin bypass, and CODEOWNERS...
使用说明 (SKILL.md)

Branch Protection Auditor

Audit branch protection rules across your GitHub or GitLab repos. Find repos with no protection on main, missing required reviews, disabled status checks, admin bypass enabled, and missing CODEOWNERS — then generate recommended rulesets to fix the gaps.

Use when: "audit branch protection", "are our repos protected", "who can push to main", "review requirements", "security audit repos", "branch rules", "CODEOWNERS check", or before compliance audits.

Commands

1. audit — Scan All Repos

Step 1: List Repositories

# GitHub — list org repos
gh api "orgs/$ORG/repos?per_page=100&type=all" --paginate | \
  python3 -c "
import json, sys
repos = json.load(sys.stdin)
for r in repos:
    if not r['archived']:
        print(f'{r[\"full_name\"]}	{r[\"default_branch\"]}	{r[\"private\"]}')
"

# Or list user repos
gh repo list --json nameWithOwner,defaultBranchRef --limit 100

Step 2: Check Protection Rules

# For each repo, check branch protection
gh api "repos/$REPO/branches/$DEFAULT_BRANCH/protection" 2>/dev/null | python3 -c "
import json, sys
try:
    p = json.load(sys.stdin)
    checks = {
        'required_reviews': p.get('required_pull_request_reviews') is not None,
        'min_reviewers': p.get('required_pull_request_reviews', {}).get('required_approving_review_count', 0),
        'dismiss_stale': p.get('required_pull_request_reviews', {}).get('dismiss_stale_reviews', False),
        'require_code_owner': p.get('required_pull_request_reviews', {}).get('require_code_owner_reviews', False),
        'status_checks': p.get('required_status_checks') is not None,
        'strict_checks': p.get('required_status_checks', {}).get('strict', False),
        'enforce_admins': p.get('enforce_admins', {}).get('enabled', False),
        'force_push': not p.get('allow_force_pushes', {}).get('enabled', True),
        'deletions': not p.get('allow_deletions', {}).get('enabled', True),
        'linear_history': p.get('required_linear_history', {}).get('enabled', False),
        'signed_commits': p.get('required_signatures', {}).get('enabled', False),
    }
    for k, v in checks.items():
        status = '✅' if v else '❌'
        print(f'  {status} {k}: {v}')
except:
    print('  ❌ NO PROTECTION RULES')
"

Step 3: Check CODEOWNERS

# Check if CODEOWNERS exists
for path in ".github/CODEOWNERS" "CODEOWNERS" "docs/CODEOWNERS"; do
  if gh api "repos/$REPO/contents/$path" --silent 2>/dev/null; then
    echo "✅ CODEOWNERS found at $path"
    break
  fi
done || echo "❌ No CODEOWNERS file"

Step 4: Generate Report

# Branch Protection Audit — [Org Name]

## Summary
- Repos scanned: 45
- Protected: 32 (71%)
- Unprotected: 13 (29%) 🔴
- Fully compliant: 18 (40%)

## Unprotected Repos (Critical)
| Repo | Default Branch | Public? | Last Commit | Risk |
|------|---------------|---------|-------------|------|
| api-service | main | No | 2 days ago | 🔴 Active, unprotected |
| legacy-app | master | No | 1 year ago | 🟡 Inactive |
| docs-site | main | Yes | 1 week ago | 🔴 Public, unprotected |

## Protection Gaps (Protected but incomplete)
| Repo | Reviews | Status Checks | Admin Enforce | Force Push Block | CODEOWNERS |
|------|---------|--------------|---------------|-----------------|------------|
| web-app | ✅ 2 | ✅ | ❌ | ✅ | ❌ |
| mobile-api | ✅ 1 | ❌ | ❌ | ✅ | ✅ |
| data-pipeline | ✅ 1 | ✅ | ✅ | ❌ | ❌ |

## Recommendations
1. Enable protection on 13 unprotected repos (script provided)
2. Require min 2 reviewers on all repos (currently 8 repos have 1)
3. Enable admin enforcement on 24 repos (admins can bypass)
4. Add CODEOWNERS to 27 repos
5. Block force push on 5 repos that allow it

2. fix — Apply Recommended Protection Rules

Generate a script to apply branch protection:

# Apply protection to a repo
gh api -X PUT "repos/$REPO/branches/main/protection" \
  -f required_pull_request_reviews='{"required_approving_review_count":2,"dismiss_stale_reviews":true,"require_code_owner_reviews":true}' \
  -f required_status_checks='{"strict":true,"contexts":["ci/test","ci/lint"]}' \
  -f enforce_admins=true \
  -f restrictions=null \
  -F allow_force_pushes=false \
  -F allow_deletions=false

3. compliance — Map to Security Frameworks

Generate compliance evidence for:

  • SOC 2: CC6.1 (access controls), CC8.1 (change management)
  • ISO 27001: A.12.1.2 (change management)
  • NIST: CM-3 (configuration change control)
  • PCI-DSS: 6.4 (change control procedures)
安全使用建议
This skill performs read and (optionally) write operations against GitHub repositories but the metadata omits critical details and claims GitLab support that is not implemented. Before installing or running it: 1) Verify you have the GitHub CLI ('gh') and python3 on the system — the SKILL.md expects them. 2) Understand authentication: 'gh' must be authenticated (or a CI GITHUB_TOKEN provided) and the token must have appropriate scopes; the 'fix' command requires elevated repo/org privileges. 3) Treat 'fix' as potentially destructive — run the 'audit' flow only first, review generated scripts, and test in a non-production org or a single repo. 4) Ask the publisher to correct the metadata: declare required binaries and required credentials, remove or implement GitLab support, and add safe defaults (dry-run, explicit confirmation, least-privilege guidance). 5) If you do not want an agent to make changes autonomously, disable model invocation for this skill or require manual confirmation before running 'fix'.
功能分析
Type: OpenClaw Skill Name: branch-protection-auditor Version: 1.0.0 The branch-protection-auditor skill is a legitimate security tool designed to audit and manage GitHub/GitLab repository settings. It uses standard GitHub CLI (gh) commands and inline Python scripts in SKILL.md to parse JSON responses and generate reports. There is no evidence of data exfiltration, malicious execution, or prompt injection; the logic is transparent and strictly aligned with its stated purpose of improving repository security posture.
能力评估
Purpose & Capability
The description claims GitHub/GitLab support, but every runtime command in SKILL.md uses the GitHub CLI and GitHub API only; there are no GitLab commands. The metadata lists no required binaries, yet the instructions depend on 'gh' and 'python3'. This mismatch between claimed purpose and actual capabilities is unexplained.
Instruction Scope
Instructions are narrowly scoped to listing repos, querying branch protection, checking CODEOWNERS, and applying protection rules via the GitHub API — they do not attempt to read unrelated system files or environment variables. However the 'fix' flow issues PUT requests that will change repository protections and therefore requires elevated repository/org privileges; the SKILL.md does not include safety controls (dry-run by default, confirmation, or scoping).
Install Mechanism
This is an instruction-only skill (no install spec), which is lower risk. But it implicitly requires external binaries ('gh', 'python3') and authenticated GitHub access which are not declared in the metadata.
Credentials
The skill declares no required environment variables or primary credential, yet the commands will only work with authenticated GitHub access and, for the 'fix' command, a token with repo/admin-level write permissions. The absence of declared credential requirements is disproportionate and could surprise users about what secrets or auth are needed.
Persistence & Privilege
always is false (good). The skill could be invoked autonomously (default), and if invoked it can apply destructive changes (branch protection updates). Combining autonomous invocation with the undocumented requirement for high-privilege GitHub credentials increases risk unless users explicitly control invocation and tokens.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install branch-protection-auditor
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /branch-protection-auditor 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of branch-protection-auditor: - Audit GitHub/GitLab branch protection rules across repositories. - Detect missing protections such as required reviews, status checks, and CODEOWNERS. - Generate detailed gap analysis and summary reports with compliance mapping. - Recommend and script fixes for common protection weaknesses. - Reference for SOC 2, ISO 27001, NIST, and PCI-DSS compliance.
元数据
Slug branch-protection-auditor
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

branch-protection-auditor 是什么?

Audit GitHub/GitLab branch protection rules across repositories. Check required reviews, status checks, force push restrictions, admin bypass, and CODEOWNERS... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 27 次。

如何安装 branch-protection-auditor?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install branch-protection-auditor」即可一键安装,无需额外配置。

branch-protection-auditor 是免费的吗?

是的,branch-protection-auditor 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

branch-protection-auditor 支持哪些平台?

branch-protection-auditor 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 branch-protection-auditor?

由 charlie-morrison(@charlie-morrison)开发并维护,当前版本 v1.0.0。

💬 留言讨论