Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
4a39ef6
fix(push-protection): use alerts API proxy when security_and_analysis…
github-actions[bot] May 8, 2026
10368a8
Merge branch 'main' into claude/issue-117-20260508-1733
github-actions[bot] May 13, 2026
c8f7c5c
Merge branch 'main' into claude/issue-117-20260508-1733
github-actions[bot] May 13, 2026
c9607be
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 14, 2026
756fb0f
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 14, 2026
16e1571
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 15, 2026
53241a1
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 15, 2026
de86ccb
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 16, 2026
6163cb7
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 16, 2026
274c895
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 16, 2026
2369045
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 16, 2026
eca5458
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 16, 2026
1db91bd
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
60a3b1f
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
158b9df
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
e526058
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
4b86a51
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
cea8f99
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
da4c2b8
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
7233be5
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
6b8aeae
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
4b96c57
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
bed4577
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
cc1a621
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
402d791
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 17, 2026
51a8191
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 18, 2026
906d701
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 19, 2026
6a5bca3
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 19, 2026
49a5a6d
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 20, 2026
8d7365f
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 21, 2026
a711de7
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 21, 2026
9ede7c8
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 21, 2026
516ad3b
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 21, 2026
dd4166b
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 21, 2026
743b279
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 24, 2026
b1847ea
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 24, 2026
1c8de43
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 24, 2026
1924a29
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 24, 2026
6aa0342
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 26, 2026
7e61840
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 31, 2026
005681a
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry May 31, 2026
7365466
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 6, 2026
f29c570
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 7, 2026
d86fa6d
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 7, 2026
7a20c3e
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 7, 2026
def764d
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 7, 2026
6d9d8b1
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 7, 2026
04c0ff0
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 8, 2026
9726066
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 8, 2026
2b69d2a
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 8, 2026
1b7582d
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 8, 2026
cc5484c
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 8, 2026
93e9db8
chore: apply manual instructions [skip ci-relay]
donpetry-bot Jun 8, 2026
9726c85
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 8, 2026
842652e
Merge branch 'main' into claude/issue-117-20260508-1733
don-petry Jun 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions scripts/lib/push-protection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ pp_apply_security_and_analysis() {
current=$(gh api "repos/$ORG/$repo" --jq '.security_and_analysis // {}' 2>/dev/null || echo "{}")

if [ "$current" = "{}" ] || [ -z "$current" ]; then
err "Could not fetch security_and_analysis for $ORG/$repo — check token has admin scope"
return 1
# Cannot read the current security_and_analysis state — the token may lack
# admin or security_events scope, or the settings have not yet been
# configured. Apply all required settings unconditionally: every required
# value is "enabled", so this is idempotent and safe.
info " security_and_analysis is currently unreadable — applying all required settings"
fi

local needs_patch=false
Expand Down Expand Up @@ -114,7 +117,7 @@ pp_apply_security_and_analysis() {
if echo "$full_payload" | gh api -X PATCH "repos/$ORG/$repo" --input - > /dev/null 2>&1; then
ok "$ORG/$repo security_and_analysis updated successfully"
else
err "Failed to PATCH security_and_analysis for $ORG/$repo — check admin scope and that the org plan supports these features"
err "Failed to PATCH security_and_analysis for $ORG/$repo — the authenticated token must have repository admin permissions (or the org plan may not support these features)"
return 1
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
Expand All @@ -131,9 +134,36 @@ pp_check_security_and_analysis() {
sa=$(gh_api "repos/$ORG/$repo" --jq '.security_and_analysis // {}' 2>/dev/null || echo "{}")

if [ "$sa" = "{}" ] || [ -z "$sa" ]; then
add_finding "$repo" "push-protection" "security_and_analysis_unavailable" "warning" \
"Could not fetch security_and_analysis — token may lack admin scope, or the repo's plan does not expose these settings" \
"$PP_STANDARD_REF#required-repo-level-settings"
# security_and_analysis is not readable via the current token (requires
# admin permissions on the repository). Use the secret-scanning alerts
# endpoint as a proxy: an admin with the security_events scope (but not
# the full repo scope) can access the alerts endpoint even when
# security_and_analysis is unavailable due to scope differences. Note:
# the alerts endpoint requires repository admin privileges regardless of
# visibility — public repositories do not bypass the admin requirement.
# A valid array response confirms scanning is active; a non-array
# response (404/error) suggests it may be disabled.
local alerts_response
alerts_response=$(gh_api \
"repos/$ORG/$repo/secret-scanning/alerts?state=open&per_page=1" \
2>/dev/null || echo "null")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

if echo "$alerts_response" | jq -e 'type == "array"' > /dev/null 2>&1; then
# Alerts API returned a valid array — secret scanning is active.
# Remaining settings (push_protection, ai_detection, non_provider_patterns,
# dependabot_security_updates) cannot be individually verified without
# admin / security_events scope; report as partially unverifiable so the
# finding reflects the actual state of knowledge.
add_finding "$repo" "push-protection" "security_and_analysis_unverifiable" "warning" \
"Secret scanning is active but secret_scanning_push_protection, secret_scanning_ai_detection, secret_scanning_non_provider_patterns, and dependabot_security_updates cannot be individually verified — the audit token lacks repository admin permissions. To enable audit verification: regenerate the PAT backing ORG_SCORECARD_TOKEN with the security_events scope (Developer Settings → Personal access tokens) and update the secret value. To enforce all required settings: run \`scripts/apply-repo-settings.sh $repo\` with a repository-admin token." \
"$PP_STANDARD_REF#required-repo-level-settings"
else
# Both the primary API field and the proxy check indicate that scanning
# may be disabled or the token cannot reach the API at all.
add_finding "$repo" "push-protection" "security_and_analysis_unavailable" "warning" \
"Could not fetch security_and_analysis and the secret-scanning alerts proxy check also returned a non-array response — token may lack admin or \`security_events\` OAuth scope, or secret scanning may be disabled. Run \`scripts/apply-repo-settings.sh $repo\` with an admin token to enable all required settings, then add \`security_events\` scope to \`ORG_SCORECARD_TOKEN\` to allow the audit to verify them." \
"$PP_STANDARD_REF#required-repo-level-settings"
fi
return
fi

Expand Down
22 changes: 22 additions & 0 deletions standards/push-protection.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,28 @@ both at once:
Findings are reported as GitHub Issues labeled `security` + `compliance-audit`
per the existing audit flow.

### Token scope requirement

The `security_and_analysis` field in `GET /repos/{owner}/{repo}` is only
populated when the requesting token has **admin access** to the repository or
the **`security_events` OAuth scope**. When the audit token (`ORG_SCORECARD_TOKEN`)
lacks these, the check falls back to a proxy verification:

1. If `GET /repos/{owner}/{repo}/secret-scanning/alerts` returns a valid array,
secret scanning is confirmed active and the finding is downgraded to
`security_and_analysis_unverifiable` (warning) — the specific settings
(push protection, AI detection, etc.) cannot be individually confirmed.
2. If the alerts endpoint also fails, `security_and_analysis_unavailable`
(warning) is reported.

**To enable audit verification:** regenerate the classic PAT backing
`ORG_SCORECARD_TOKEN` (Developer Settings → Personal access tokens) with the
`security_events` scope, then update the stored value in org Settings →
Secrets → Actions. **To enforce required settings:** run
`scripts/apply-repo-settings.sh <repo>` with a repository-admin token.
Note: running the apply script configures settings but does not grant the
audit token the visibility it needs — both steps may be needed.

---

## Related Standards
Expand Down
Loading