Repository navigation
ci: release environment and secrets check #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| name: Check release secrets | ||
|
|
||
| # Manual, read-only check of the publishing secrets. It publishes nothing and never prints a secret value. | ||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| environment-secrets: | ||
| name: Secrets seen by the release environment | ||
| runs-on: ubuntu-latest | ||
| # Same protected environment as the publishing jobs: needs the maintainer's approval to run. | ||
| environment: release | ||
| steps: | ||
| - name: Check the secrets are present and the winget token works | ||
| shell: bash | ||
| env: | ||
| CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} | ||
| WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }} | ||
| WINGET_FORK_OWNER: ${{ secrets.WINGET_FORK_OWNER }} | ||
| run: | | ||
| missing=0 | ||
| { | ||
| echo "## Secrets seen by the release environment" | ||
| for name in CHOCOLATEY_API_KEY WINGET_GITHUB_TOKEN WINGET_FORK_OWNER; do | ||
| if [ -n "${!name}" ]; then echo "- $name: present"; else echo "- $name: MISSING"; missing=1; fi | ||
| done | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| if [ -n "$WINGET_GITHUB_TOKEN" ]; then | ||
| # Read-only call: who owns the token. Only a yes/no goes to the summary. | ||
| login=$(curl -fsS -H "Authorization: Bearer $WINGET_GITHUB_TOKEN" -H "Accept: application/vnd.github+json" https://api.github.com/user | jq -r .login) || login="" | ||
| if [ -z "$login" ]; then | ||
| echo "- WINGET_GITHUB_TOKEN: rejected by GitHub (expired or revoked)" >> "$GITHUB_STEP_SUMMARY" | ||
| missing=1 | ||
| elif [ "${login,,}" = "${WINGET_FORK_OWNER,,}" ]; then | ||
| echo "- WINGET_GITHUB_TOKEN: valid, belongs to WINGET_FORK_OWNER" >> "$GITHUB_STEP_SUMMARY" | ||
| else | ||
| echo "- WINGET_GITHUB_TOKEN: valid, but its user differs from WINGET_FORK_OWNER" >> "$GITHUB_STEP_SUMMARY" | ||
| fi | ||
| fi | ||
|
|
||
| exit $missing | ||
|
|
||
| repository-secrets: | ||
| name: Repository-level copies (MISSING once deleted) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check which repository-level copies still exist | ||
| shell: bash | ||
| env: | ||
| CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} | ||
| WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }} | ||
| WINGET_FORK_OWNER: ${{ secrets.WINGET_FORK_OWNER }} | ||
| run: | | ||
| { | ||
| echo "## Repository-level copies (outside the environment)" | ||
| for name in CHOCOLATEY_API_KEY WINGET_GITHUB_TOKEN WINGET_FORK_OWNER; do | ||
| if [ -n "${!name}" ]; then echo "- $name: still present"; else echo "- $name: MISSING"; fi | ||
| done | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the repository-level copies still exist, this job has no protected environment yet injects all three credentials. Any user with repository write access can manually dispatch a
workflow_dispatchworkflow against a selected branch (GitHub Docs); such a user can alter this job on their branch to exfiltrate the Chocolatey key or winget token without obtaining the intended release-environment approval. Delete the repository copies before exposing this workflow, or inspect secret metadata through an approved environment/API path instead of materializing the values in this unprotected job.Useful? React with 👍 / 👎.