feat(security): enable free CodeQL default-setup on every public org repo#10
Closed
JacobPEvans-personal wants to merge 1 commit into
Closed
feat(security): enable free CodeQL default-setup on every public org repo#10JacobPEvans-personal wants to merge 1 commit into
JacobPEvans-personal wants to merge 1 commit into
Conversation
…repo
Code scanning default-setup is FREE on public repos (no GHAS license
consumed). Adds a script under scripts/ that idempotently turns it on
for every public org repo with a supported language. Private repos are
never targeted (would require paid GHAS Code Security per AGENTS.md
"Cost policy").
Workaround for a provider gap: integrations/terraform-provider-github
does not expose a resource for
PUT /repos/{owner}/{repo}/code-scanning/default-setup. When upstream
ships one, this script becomes an "import.sh"-style one-shot and the
.tf takes over.
Cost impact: $0. Script enumerates --visibility public --no-archived
before the PUT loop, so a private repo name can never reach the call.
Belt-and-suspenders: org-default GHAS is off, so an accidental PUT
against a private repo would 403 anyway — no charge can land.
Member
Author
|
Closing — wrong approach. The whole point of this repo is declarative OpenTofu config, not bash scripts. Replacing with pure-IaC approach. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
scripts/enable-codeql-default-setup.sh— an idempotent helper that turns on free CodeQL default-setup on every public org repo with a supported language. README updated to list it under "What it manages today" and note the provider gap that keeps it script-managed for now.Why a script and not a Terraform resource
integrations/terraform-provider-githubdoes not expose a resource forPUT /repos/{owner}/{repo}/code-scanning/default-setup. Closest options:github_repository.security_and_analysis.code_security— requires GHAS (paid). Wrong knob.required_code_scanningruleset rule — gates merges on existing scans; doesn't enable scanning. Wrong knob.github_enterprise_security_analysis_settings— Enterprise plan only.So pure-Terraform-resource isn't on the table today. The script lives under
scripts/(allowed location per the workspace no-scripts rule's tier-4 fallback) and mirrors the precedent set by.github-tofu/scripts/import.sh. When upstream shipsgithub_repository_code_scanning_default_setupor equivalent, the .tf takes over and this becomes a one-shot.Cost impact
$0. Verified against AGENTS.md "Cost policy":
--visibility public --no-archivedbefore the PUT loop, so a private repo name can never reach the call.Idempotent
For each public, non-archived repo, the script:
code-scanning/default-setupto read{state, languages}.state == "configured"→ logskip (already on).languages == []→ logskip (no supported language).state=configured.Re-runs are no-ops on already-configured repos. Final line:
enabled: N · already-on: M · skipped-no-lang: K · errors: E.Test plan
scripts/enable-codeql-default-setup.sh— sanity-check the GET / PUT / counter logic.mainworktree:./scripts/enable-codeql-default-setup.sh. Expected ~5 enables (e.g.python-template,mlx-benchmarks,raycast-smart-issue,claude-code-best-practice, possiblynixos-ai), ~22 skips onactions-only repos, 0 errors.gh api repos/dryvist/python-template/code-scanning/default-setup --jq .state→configured.int_homelab) — confirm it was untouched:gh api repos/dryvist/int_homelab/code-scanning/default-setup --jq .state→not-configured(or 403).skip,enabled: 0.🤖 Generated with Claude Code