Repository navigation
ci: read the bot's key from the stable-only data-update environment - #323
Conversation
daily-update.yml and python-tests.yml's publish job, the only two jobs that use cloudcheck-update-bot's key, now run in the data-update environment (deployment branch: stable only, no admin bypass). They read the App ID from the environment variable CLOUDCHECK_APP_ID and the key (and BBOT_IO_API_KEY) from environment secrets, so no other branch, pull request or dispatched copy of a workflow can read them. The App token is minted for this repository only, with contents write only, and both jobs drop to contents: read: the push and the tag push already use the App token, not GITHUB_TOKEN. Safe to merge before the new key is in place: inside an environment job an environment secret overrides the repository secret of the same name, and the repository secret still applies when the environment has none. Refs blacklanternsecurity/bbot-enterprise#406, blacklanternsecurity/.github-config#16 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@pjhartlieb thanks, this matches step 1 of the plan, and I've checked the environment config (stable-only branch policy, admin bypass off). Two changes before merge: 1. Drop 2. Take
After that, good to merge, with the new key and |
Review on #323: - create-github-app-token with owner set and repositories empty mints a token for every repository in the installation. On a scheduled run github.event.repository.name may be empty, so drop owner and repositories: with neither set, the token covers only this repository. - publish used the bot's key only to push the release tag, and held a token that can push straight to stable while maturin runs third-party build code. It now pushes the tag with GITHUB_TOKEN (contents: write), which the stable PR rule applies to, and leaves data-update. Checkout keeps no credentials, so only the tag step gets the token; the build steps can't push branches or move tags. daily-update is now the only job that uses the bot's key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@liquidsec thanks, both are right and both are in
One addition, following your point about third-party build code: with default checkout credentials, Checks: The PR is still safe to merge before the new key exists: |
liquidsec
left a comment
There was a problem hiding this comment.
Thanks, both changes look right, and persist-credentials: false with the token passed only to the tag step is a good addition.
One thing to confirm before merging: moving publish to GITHUB_TOKEN assumes the stable ruleset's bypass list contains only the cloudcheck-update-bot app. If "GitHub Actions" (or a role that covers it) is on that list, GITHUB_TOKEN with contents: write could push to stable. I can't see bypass actors at my permission level, so could an admin check Settings → Rules → default?
Also, the PR description still says both jobs run in data-update and that the tag push uses the App token. Please update it before squashing.
chore: merge stable into dev (#323 workflows, signature data)
@liquidsec this is step 0 of the bot hardening discussed in #406 (mapping). It needs your review.
Change
The only two jobs that use
cloudcheck-update-bot's key,daily-update.ymlandpython-tests.yml'spublish, now:data-updateenvironment, which accepts deployments fromstableonly, with admin bypass off and no reviewers, since it runs on a schedule;CLOUDCHECK_APP_ID(already set,4078637), and the key andBBOT_IO_API_KEYfrom environment secrets;contents: read. The push and the tag push already use the App token, notGITHUB_TOKEN.Nothing else changes. The data generation, the commit, the push and the publish steps are untouched. The data validation, pre-push path check, SHA pins and
--lockedstay in your Phase 1 PR.Why
Today any writer can run a modified copy of
daily-update.ymlfrom a branch (workflow_dispatch, or apull_requestrun). That copy can readCLOUDCHECK_APP_PRIVATE_KEY, a repository secret, and then push tostablethrough the bot's bypass. In the environment, those secrets are released only to jobs running onstable.Safe to merge before the new key exists
Inside an environment job, an environment secret overrides a repository secret of the same name, and the repository secret still applies when the environment has none. So until an org owner puts the new key in
data-update, both jobs keep using today's key. Nothing breaks if this merges first.Verification after merge
daily-updateby hand fromstable, and confirm it pushes, or reports no change.stablepush, thepublishjob runs indata-update.BBOT_IO_API_KEYare in the environment, delete the repository copies, revoke the old key, and rundaily-updateonce more.devhas the same copies of both files, so a back-merge ofstableintodevkeeps them in step. Theirdevcopies can't readdata-updateanyway, because it acceptsstableonly.Lint: actionlint clean; zizmor finds nothing on either file, before or after.