Skip to content

Add workflow to export repo secrets #539

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 1 commit into from
May 13, 2025
Merged

Conversation

pgavlin
Copy link
Member

@pgavlin pgavlin commented May 12, 2025

This repository has repository-specific secrets that need to be migrated to ESC. These changes add a GitHub Actions workflow to perform this migration.

The workflow is configured to be run manually. It is only expected that the worflow will be run once. The workflow uses https://github.com/pulumi/esc-export-secrets-action to create a new ESC environment to hold the repository's secrets. This environment also imports the environment that holds the organization's secrets.

@pgavlin pgavlin requested a review from komalali May 12, 2025 20:23
oidc-auth: true
oidc-requested-token-type: urn:pulumi:token-type:access_token:organization
env:
GITHUB_SECRETS: ${{ toJSON(secrets) }}

Check warning

Code scanning / CodeQL

Excessive Secrets Exposure Medium

All organization and repository secrets are passed to the workflow runner in
toJSON(secrets)

Copilot Autofix

AI 15 days ago

To fix the issue, we need to replace the use of toJSON(secrets) with explicit references to only the secrets required by the workflow. This ensures that only the necessary secrets are passed to the workflow runner, adhering to the principle of least privilege. Specifically, we will replace the GITHUB_SECRETS environment variable with individual secret references. In this case, the workflow appears to require only EXPORT_SECRETS_PRIVATE_KEY, so we will explicitly pass it.


Suggested changeset 1
.github/workflows/export-repo-secrets.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/export-repo-secrets.yml b/.github/workflows/export-repo-secrets.yml
--- a/.github/workflows/export-repo-secrets.yml
+++ b/.github/workflows/export-repo-secrets.yml
@@ -24,2 +24,2 @@
         env:
-          GITHUB_SECRETS: ${{ toJSON(secrets) }}
+          EXPORT_SECRETS_PRIVATE_KEY: ${{ secrets.EXPORT_SECRETS_PRIVATE_KEY }}
EOF
@@ -24,2 +24,2 @@
env:
GITHUB_SECRETS: ${{ toJSON(secrets) }}
EXPORT_SECRETS_PRIVATE_KEY: ${{ secrets.EXPORT_SECRETS_PRIVATE_KEY }}
Copilot is powered by AI and may make mistakes. Always verify output.
@pgavlin pgavlin force-pushed the pgavlin/export-repo-secrets branch from bd906db to 23f31f0 Compare May 12, 2025 20:34
@pgavlin pgavlin force-pushed the pgavlin/export-repo-secrets branch from 23f31f0 to 95e3e01 Compare May 12, 2025 20:37
@pgavlin pgavlin merged commit cd56874 into main May 13, 2025
9 of 10 checks passed
@pgavlin pgavlin deleted the pgavlin/export-repo-secrets branch May 13, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants