-
Notifications
You must be signed in to change notification settings - Fork 1
SRE-904: Extract the secret handoff into shared actions #103
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,43 @@ | ||
| name: Decrypt secret | ||
| description: >- | ||
| Decrypt a value produced by encrypt-secret, masking the plaintext before | ||
| anything else can read it. Run this before any step that executes code you | ||
| do not control. | ||
|
|
||
| inputs: | ||
| encrypted_value: | ||
| description: Base64 ciphertext from encrypt-secret. | ||
| required: true | ||
| encryption_key: | ||
| description: Symmetric passphrase shared with the encrypting job. | ||
| required: true | ||
|
|
||
| outputs: | ||
| value: | ||
| description: Decrypted plaintext, masked in logs. | ||
| value: ${{ steps.decrypt.outputs.value }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Decrypt | ||
| id: decrypt | ||
| shell: bash | ||
| env: | ||
| ENCRYPTED_VALUE: ${{ inputs.encrypted_value }} | ||
| ENC_KEY: ${{ inputs.encryption_key }} | ||
| run: | | ||
| : "${ENCRYPTED_VALUE:?}" "${ENC_KEY:?}" | ||
| value=$(printf '%s' "${ENCRYPTED_VALUE}" | openssl enc -d -aes-256-cbc -pbkdf2 -pass env:ENC_KEY -base64 -A) | ||
| # Masking is per line, so a multi-line value needs each line masked. | ||
| while IFS= read -r line; do | ||
| if [ -n "${line}" ]; then | ||
| echo "::add-mask::${line}" | ||
| fi | ||
| done <<<"${value}" | ||
| delimiter=$(openssl rand -hex 16) | ||
| { | ||
| echo "value<<${delimiter}" | ||
| echo "${value}" | ||
| echo "${delimiter}" | ||
| } >>"${GITHUB_OUTPUT}" | ||
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,32 @@ | ||
| name: Encrypt secret | ||
| description: >- | ||
| Encrypt a value so it can cross a job boundary. GitHub silently drops masked | ||
| plaintext from job outputs; ciphertext survives the trip and is useless | ||
| without the key. | ||
|
|
||
| inputs: | ||
| value: | ||
| description: Plaintext to encrypt. Must never be echoed. | ||
| required: true | ||
| encryption_key: | ||
| description: Symmetric passphrase shared with the decrypting job. | ||
| required: true | ||
|
|
||
| outputs: | ||
| encrypted_value: | ||
| description: Base64 ciphertext, safe to expose as a job output. | ||
| value: ${{ steps.encrypt.outputs.encrypted_value }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Encrypt | ||
| id: encrypt | ||
| shell: bash | ||
| env: | ||
| VALUE: ${{ inputs.value }} | ||
| ENC_KEY: ${{ inputs.encryption_key }} | ||
| run: | | ||
| : "${VALUE:?}" "${ENC_KEY:?}" | ||
| encrypted=$(printf '%s' "${VALUE}" | openssl enc -aes-256-cbc -pbkdf2 -salt -pass env:ENC_KEY -base64 -A) | ||
| echo "encrypted_value=${encrypted}" >>"${GITHUB_OUTPUT}" |
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.
Decrypt strips trailing newlines
Medium Severity
Capturing openssl decrypt output in
$()drops all trailing newlines before masking and writingvalue. The action advertises multi-line support, so secrets that require a final newline (for example PEM or SSH keys) will not round-trip faithfully for callers such as hash#9192.Reviewed by Cursor Bugbot for commit 98535f8. Configure here.