diff --git a/scripts/dependabot-digest/standards.sh b/scripts/dependabot-digest/standards.sh index fd10113..9a7feec 100755 --- a/scripts/dependabot-digest/standards.sh +++ b/scripts/dependabot-digest/standards.sh @@ -151,6 +151,37 @@ else .protection as $p | $p.required_status_checks as $rsc end JQ +# Rulesets can require the check too. Input: slurped rules/branches pages; +# $cs/$cd: classic verdict. A malformed rule is unreadable. +read -r -d '' rules_verdict <<'JQ' +def std: . == "run-standards-check" or endswith(" / run-standards-check"); +def rsc_ok: (.parameters | type) == "object" + and (.parameters.required_status_checks | type) == "array" + and all(.parameters.required_status_checks[]; type == "object" and (.context | type) == "string"); +if type != "array" or (all(.[]; type == "array") | not) then "unreadable\tthe ruleset rules response is malformed" +else [.[][]] as $r + | if all($r[]; type == "object" and (.type | type) == "string" + and (.type != "required_status_checks" or rsc_ok)) | not + then "unreadable\tthe ruleset rules response is malformed" + else [$r[] | select(.type == "required_status_checks") | .parameters.required_status_checks[].context] as $ctx + | if any($ctx[]; std) then "required\t" + elif $cs == "unreadable" or ($r | length) == 0 then $cs + "\t" + $cd + elif $cs == "unprotected" then + if ($ctx | length) == 0 + then "protected-no-standards\tprotected by rulesets, but they require no status checks" + else "protected-no-standards\trulesets require only: " + ($ctx | unique | join(", ")) + end + elif ($ctx | length) == 0 then $cs + "\t" + $cd + elif ($cco | length) == 0 then $cs + "\trulesets require only: " + ($ctx | unique | join(", ")) + else $cs + "\trequires only: " + ($cco + $ctx | unique | join(", ")) + end + end +end +JQ +# The 403 body for rulesets on a private repo of a free plan (live +# capture 2026-11-20, smartwatermelon/claude-config-backup). +RS_NO_PLAN='Upgrade to GitHub Pro or make this repository public to enable this feature.' + # Unprotected by decision, so counted, not flagged. Classes, not repo names. # Each reason carries its decision date; the digest prints it. declare -A EXEMPT_REASON=( @@ -186,15 +217,52 @@ set_prot() { # Sets PROT_JSON for one repo. Never fails: a failed read is a state. probe_protection() { - local nwo="$1" branch="$2" fork="$3" private="$4" body verdict state detail cls="" + local nwo="$1" branch="$2" fork="$3" private="$4" body="" verdict state detail cls="" rules why cco if ! body="$(api "repos/${nwo}/branches/${branch}")"; then - detail="$(last_err "no detail")" - set_prot unreadable "cannot read branch ${branch}: ${detail}" - return 0 + state=unreadable + detail="cannot read branch ${branch}: $(last_err "no detail")" + else + verdict="$(jq -r "${prot_verdict}" <<<"${body}" 2>/dev/null)" + state="${verdict%%$'\t'*}" + detail="${verdict#*$'\t'}" fi - verdict="$(jq -r "${prot_verdict}" <<<"${body}" 2>/dev/null)" - state="${verdict%%$'\t'*}" - detail="${verdict#*$'\t'}" + case "${state}" in + required) ;; + unprotected | protected-no-standards | unreadable) + # Classic protection is not the whole answer: read the rulesets too. + # Only metadata: read is needed. A failed read never clears a gap. + if ! rules="$(api --paginate --slurp "repos/${nwo}/rules/branches/${branch}?per_page=100")"; then + why="$(last_err "no detail")" + # A private repo on a free plan cannot have rulesets: the classic + # verdict is the whole answer. Both signals, as for CodeQL. + if [[ "${why}" == *"(HTTP 403)"* && "${private}" == "true" ]] \ + && jq -e --arg m "${RS_NO_PLAN}" '(if type == "array" then .[0] else . end) + | type == "object" and .message == $m' >/dev/null 2>&1 <<<"${rules}"; then + : + elif [[ "${state}" != "unreadable" ]]; then + state=unreadable + detail="cannot read ruleset rules for ${branch}: ${why}" + fi + else + # The checks classic protection enforces, so one list names both. + cco="$(jq -c 'if .protection.enabled == true + and .protection.required_status_checks.enforcement_level != "off" + then [.protection.required_status_checks.contexts[] | strings] else [] end' \ + <<<"${body}" 2>/dev/null)" + [[ "${state}" == "protected-no-standards" && -n "${cco}" ]] || cco='[]' + verdict="$(jq -r --arg cs "${state}" --arg cd "${detail}" --argjson cco "${cco}" \ + "${rules_verdict}" <<<"${rules}" 2>/dev/null)" + if [[ "${verdict}" == *$'\t'* ]]; then + state="${verdict%%$'\t'*}" + detail="${verdict#*$'\t'}" + else + state=unreadable + detail="the ruleset rules response is malformed" + fi + fi + ;; + *) ;; + esac case "${state}" in required | protected-no-standards | unreadable) ;; unprotected) diff --git a/scripts/dependabot-digest/tests/fixtures/standards/installation_repositories.json.s b/scripts/dependabot-digest/tests/fixtures/standards/installation_repositories.json.s new file mode 100644 index 0000000..62936fa --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/installation_repositories.json.s @@ -0,0 +1,70 @@ +[ + { + "total_count": 9, + "repositories": [ + { + "full_name": "s/rs-required", + "default_branch": "main", + "archived": false, + "fork": false, + "private": false + }, + { + "full_name": "s/rs-nochecks", + "default_branch": "main", + "archived": false, + "fork": false, + "private": false + }, + { + "full_name": "s/rs-refused", + "default_branch": "main", + "archived": false, + "fork": false, + "private": false + }, + { + "full_name": "s/rs-malformed", + "default_branch": "main", + "archived": false, + "fork": false, + "private": false + }, + { + "full_name": "s/rs-unprot", + "default_branch": "main", + "archived": false, + "fork": false, + "private": false + }, + { + "full_name": "s/rs-other", + "default_branch": "main", + "archived": false, + "fork": false, + "private": false + }, + { + "full_name": "s/rs-paywall-public", + "default_branch": "main", + "archived": false, + "fork": false, + "private": false + }, + { + "full_name": "s/rs-paywall-private", + "default_branch": "main", + "archived": false, + "fork": false, + "private": true + }, + { + "full_name": "s/rs-both", + "default_branch": "main", + "archived": false, + "fork": false, + "private": false + } + ] + } +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_nightowlstudiollc_nos-private_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_nightowlstudiollc_nos-private_rules_branches_main.json new file mode 100644 index 0000000..1721244 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_nightowlstudiollc_nos-private_rules_branches_main.json @@ -0,0 +1 @@ +[[]] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_nightowlstudiollc_nostd_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_nightowlstudiollc_nostd_rules_branches_main.json new file mode 100644 index 0000000..1721244 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_nightowlstudiollc_nostd_rules_branches_main.json @@ -0,0 +1 @@ +[[]] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_nightowlstudiollc_offcheck_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_nightowlstudiollc_offcheck_rules_branches_main.json new file mode 100644 index 0000000..1721244 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_nightowlstudiollc_offcheck_rules_branches_main.json @@ -0,0 +1 @@ +[[]] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-both_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-both_branches_main.json new file mode 100644 index 0000000..85100b5 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-both_branches_main.json @@ -0,0 +1,17 @@ +{ + "name": "main", + "protected": true, + "protection": { + "enabled": true, + "required_status_checks": { + "enforcement_level": "non_admins", + "contexts": ["test"], + "checks": [ + { + "context": "test", + "app_id": 15368 + } + ] + } + } +} diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-both_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-both_rules_branches_main.json new file mode 100644 index 0000000..341399f --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-both_rules_branches_main.json @@ -0,0 +1,63 @@ +[ + [ + { + "type": "required_status_checks", + "parameters": { + "strict_required_status_checks_policy": false, + "do_not_enforce_on_create": false, + "required_status_checks": [ + { + "context": "build" + } + ] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26970024 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 0, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": false, + "required_review_thread_resolution": true, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26970024 + }, + { + "type": "deletion", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "non_fast_forward", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 1, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": true, + "required_review_thread_resolution": false, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + } + ] +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-malformed_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-malformed_branches_main.json new file mode 100644 index 0000000..cf24d62 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-malformed_branches_main.json @@ -0,0 +1,12 @@ +{ + "name": "main", + "protected": true, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [], + "checks": [] + } + } +} diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-malformed_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-malformed_rules_branches_main.json new file mode 100644 index 0000000..322d0dd --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-malformed_rules_branches_main.json @@ -0,0 +1,59 @@ +[ + [ + { + "type": "required_status_checks", + "parameters": { + "strict_required_status_checks_policy": false, + "do_not_enforce_on_create": false, + "required_status_checks": null + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26970024 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 0, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": false, + "required_review_thread_resolution": true, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26970024 + }, + { + "type": "deletion", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "non_fast_forward", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 1, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": true, + "required_review_thread_resolution": false, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + } + ] +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-nochecks_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-nochecks_branches_main.json new file mode 100644 index 0000000..cf24d62 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-nochecks_branches_main.json @@ -0,0 +1,12 @@ +{ + "name": "main", + "protected": true, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [], + "checks": [] + } + } +} diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-nochecks_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-nochecks_rules_branches_main.json new file mode 100644 index 0000000..0f41497 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-nochecks_rules_branches_main.json @@ -0,0 +1,32 @@ +[ + [ + { + "type": "deletion", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "non_fast_forward", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 1, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": true, + "required_review_thread_resolution": false, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + } + ] +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-other_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-other_branches_main.json new file mode 100644 index 0000000..cf24d62 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-other_branches_main.json @@ -0,0 +1,12 @@ +{ + "name": "main", + "protected": true, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [], + "checks": [] + } + } +} diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-other_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-other_rules_branches_main.json new file mode 100644 index 0000000..341399f --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-other_rules_branches_main.json @@ -0,0 +1,63 @@ +[ + [ + { + "type": "required_status_checks", + "parameters": { + "strict_required_status_checks_policy": false, + "do_not_enforce_on_create": false, + "required_status_checks": [ + { + "context": "build" + } + ] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26970024 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 0, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": false, + "required_review_thread_resolution": true, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26970024 + }, + { + "type": "deletion", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "non_fast_forward", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 1, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": true, + "required_review_thread_resolution": false, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + } + ] +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-private_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-private_branches_main.json new file mode 100644 index 0000000..c13c38a --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-private_branches_main.json @@ -0,0 +1,12 @@ +{ + "name": "main", + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [], + "checks": [] + } + } +} diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-private_rules_branches_main.403.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-private_rules_branches_main.403.json new file mode 100644 index 0000000..2c1d920 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-private_rules_branches_main.403.json @@ -0,0 +1,7 @@ +[ + { + "message": "Upgrade to GitHub Pro or make this repository public to enable this feature.", + "documentation_url": "https://docs.github.com/rest/repos/rules#get-rules-for-a-branch", + "status": "403" + } +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-public_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-public_branches_main.json new file mode 100644 index 0000000..c13c38a --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-public_branches_main.json @@ -0,0 +1,12 @@ +{ + "name": "main", + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [], + "checks": [] + } + } +} diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-public_rules_branches_main.403.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-public_rules_branches_main.403.json new file mode 100644 index 0000000..2c1d920 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-paywall-public_rules_branches_main.403.json @@ -0,0 +1,7 @@ +[ + { + "message": "Upgrade to GitHub Pro or make this repository public to enable this feature.", + "documentation_url": "https://docs.github.com/rest/repos/rules#get-rules-for-a-branch", + "status": "403" + } +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-refused_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-refused_branches_main.json new file mode 100644 index 0000000..cf24d62 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-refused_branches_main.json @@ -0,0 +1,12 @@ +{ + "name": "main", + "protected": true, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [], + "checks": [] + } + } +} diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-required_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-required_branches_main.json new file mode 100644 index 0000000..cf24d62 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-required_branches_main.json @@ -0,0 +1,12 @@ +{ + "name": "main", + "protected": true, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [], + "checks": [] + } + } +} diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-required_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-required_rules_branches_main.json new file mode 100644 index 0000000..a629c9a --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-required_rules_branches_main.json @@ -0,0 +1,63 @@ +[ + [ + { + "type": "required_status_checks", + "parameters": { + "strict_required_status_checks_policy": false, + "do_not_enforce_on_create": false, + "required_status_checks": [ + { + "context": "standards-check / run-standards-check" + } + ] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26970024 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 0, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": false, + "required_review_thread_resolution": true, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26970024 + }, + { + "type": "deletion", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "non_fast_forward", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 1, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": true, + "required_review_thread_resolution": false, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + } + ] +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-unprot_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-unprot_branches_main.json new file mode 100644 index 0000000..c13c38a --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-unprot_branches_main.json @@ -0,0 +1,12 @@ +{ + "name": "main", + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [], + "checks": [] + } + } +} diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-unprot_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-unprot_rules_branches_main.json new file mode 100644 index 0000000..0f41497 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_s_rs-unprot_rules_branches_main.json @@ -0,0 +1,32 @@ +[ + [ + { + "type": "deletion", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "non_fast_forward", + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + }, + { + "type": "pull_request", + "parameters": { + "required_approving_review_count": 1, + "dismiss_stale_reviews_on_push": false, + "required_reviewers": [], + "require_code_owner_review": false, + "require_last_push_approval": true, + "required_review_thread_resolution": false, + "require_extra_approval_for_unattributed_changes": true, + "allowed_merge_methods": ["merge", "squash", "rebase"] + }, + "ruleset_source_type": "Organization", + "ruleset_source": "nightowlstudiollc", + "ruleset_id": 26880869 + } + ] +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_smartwatermelon_claude-config-backup_rules_branches_main.403.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_smartwatermelon_claude-config-backup_rules_branches_main.403.json new file mode 100644 index 0000000..2c1d920 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_smartwatermelon_claude-config-backup_rules_branches_main.403.json @@ -0,0 +1,7 @@ +[ + { + "message": "Upgrade to GitHub Pro or make this repository public to enable this feature.", + "documentation_url": "https://docs.github.com/rest/repos/rules#get-rules-for-a-branch", + "status": "403" + } +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_smartwatermelon_noflags_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_smartwatermelon_noflags_rules_branches_main.json new file mode 100644 index 0000000..1721244 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_smartwatermelon_noflags_rules_branches_main.json @@ -0,0 +1 @@ +[[]] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_twistedmelonman_Instapaper-MCP_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_twistedmelonman_Instapaper-MCP_rules_branches_main.json new file mode 100644 index 0000000..1721244 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_twistedmelonman_Instapaper-MCP_rules_branches_main.json @@ -0,0 +1 @@ +[[]] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_twistedmelonman_tm-private_rules_branches_main.403.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_twistedmelonman_tm-private_rules_branches_main.403.json new file mode 100644 index 0000000..2c1d920 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_twistedmelonman_tm-private_rules_branches_main.403.json @@ -0,0 +1,7 @@ +[ + { + "message": "Upgrade to GitHub Pro or make this repository public to enable this feature.", + "documentation_url": "https://docs.github.com/rest/repos/rules#get-rules-for-a-branch", + "status": "403" + } +] diff --git a/scripts/dependabot-digest/tests/fixtures/standards/repos_twistedmelonman_tm-public_rules_branches_main.json b/scripts/dependabot-digest/tests/fixtures/standards/repos_twistedmelonman_tm-public_rules_branches_main.json new file mode 100644 index 0000000..1721244 --- /dev/null +++ b/scripts/dependabot-digest/tests/fixtures/standards/repos_twistedmelonman_tm-public_rules_branches_main.json @@ -0,0 +1 @@ +[[]] diff --git a/scripts/dependabot-digest/tests/test-run-digest.sh b/scripts/dependabot-digest/tests/test-run-digest.sh index f867cbc..28b4d63 100755 --- a/scripts/dependabot-digest/tests/test-run-digest.sh +++ b/scripts/dependabot-digest/tests/test-run-digest.sh @@ -6,6 +6,9 @@ set -uo pipefail unset CDPATH unset BASH_ENV GH_TOKEN GH_HOST GITHUB_TOKEN +# Inside a Claude Code session gh can be an exported function, which a child +# bash runs instead of the stub on PATH (dev-env#215). +unset -f gh HERE="$(CDPATH='' cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DIR="${HERE}/.." diff --git a/scripts/dependabot-digest/tests/test-standards.sh b/scripts/dependabot-digest/tests/test-standards.sh index 79de55c..4019cfd 100755 --- a/scripts/dependabot-digest/tests/test-standards.sh +++ b/scripts/dependabot-digest/tests/test-standards.sh @@ -39,9 +39,10 @@ path="${path%%\?*}" file="${STUB_FIX}/${path//\//_}.json" [[ "${path}" == "installation/repositories" ]] && file="${file}.${STUB_OWNER}" # .403.json: a refusal with a body, written to both streams as real gh does. +# With --slurp, real gh wraps the body in an array (2026-11-20 capture). if [[ -f "${file%.json}.403.json" ]]; then cat "${file%.json}.403.json" - echo "gh: $(jq -r '.message' "${file%.json}.403.json") (HTTP 403)" >&2 + echo "gh: $(jq -r 'if type == "array" then .[0].message else .message end' "${file%.json}.403.json") (HTTP 403)" >&2 exit 1 fi # .404.json: a 404 with a body; gh prints its message @@ -291,6 +292,40 @@ else _fail "the protection result depends on the standards read (got '${dev_env}')" fi +# Rulesets (owner s). rs-required, rs-nochecks: live 2026-11-20 captures +# (amelia-boone, aomo). The rest change one field. +sout="${WORK}/s.ndjson" +survey s >"${sout}" 2>"${WORK}/s.err" || _fail "standards.sh exited non-zero for owner s" +_rs() { # _rs