Skip to content

Commit 080b6b9

Browse files
committed
Don't directly inline contexts
While I don't see how a malicious actor would be able to influence these contexts I'd rather be in the habbit of always passing contexts to scripts by way of environment variables. Also, I suspect that it this way is more likely that an unexpected context will result in a meaningful error message.
1 parent 8a93d18 commit 080b6b9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ jobs:
3333
- name: Deploy site
3434
if: github.ref == 'refs/heads/main'
3535
run: >
36-
rsync -e "ssh -i '${{ steps.ssh_cert.outputs.key_path }}'"
36+
rsync -e "ssh -i '$SSH_CERT_PATH'"
3737
--verbose --recursive --delete-after --perms --chmod=D755,F644
3838
build/ deployer@site.example.net:/var/www/site/
39+
env:
40+
SSH_CERT_PATH: ${{ steps.ssh_cert.outputs.key_path }}
3941
```
4042
4143
Do note that all client certification configuration is expected to

action.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ runs:
4040
run: |
4141
import os
4242
from urllib.parse import urlparse
43-
aud = "${{ inputs.jwt_audience }}".strip()
43+
aud = os.environ["JWT_AUDIENCE"].strip()
4444
if not aud:
45-
url = "${{ inputs.vault_server }}"
45+
url = os.environ["VAULT_SERVER"]
4646
fqdn = urlparse(url).netloc.split(":")[0]
4747
aud = fqdn
4848
with open(os.environ["GITHUB_OUTPUT"], "a") as ghof:
4949
ghof.write(f"audience={aud}\n")
5050
shell: python
51+
env:
52+
JWT_AUDIENCE: ${{ inputs.jwt_audience }}
53+
VAULT_SERVER: ${{ inputs.vault_server }}
5154

5255
- name: Authenticate towards Vault
5356
id: vault_auth
@@ -64,8 +67,9 @@ runs:
6467
- name: Generate and sign SSH client certificate
6568
id: generator
6669
shell: bash
67-
run: ${{ github.action_path }}/generate-and-sign
70+
run: "${ACTION_PATH}/generate-and-sign"
6871
env:
72+
ACTION_PATH: ${{ github.action_path }}
6973
VAULT_SERVER: ${{ inputs.vault_server }}
7074
VAULT_TOKEN: ${{ steps.vault_auth.outputs.vault_token }}
7175
SSH_BACKEND: ${{ inputs.ssh_backend }}
@@ -75,4 +79,8 @@ runs:
7579
- name: Revoke Vault token
7680
if: success() || failure()
7781
shell: bash
78-
run: 'curl --fail --silent --show-error --header "X-Vault-Token: ${{ steps.vault_auth.outputs.vault_token }}" --data "" "${{ inputs.vault_server }}/v1/auth/token/revoke-self"'
82+
run: |
83+
curl --fail --silent --show-error --header "X-Vault-Token: ${VAULT_TOKEN}" --data "" "${VAULT_SERVER}/v1/auth/token/revoke-self"
84+
env:
85+
VAULT_SERVER: ${{ inputs.vault_server }}
86+
VAULT_TOKEN: ${{ steps.vault_auth.outputs.vault_token }}

0 commit comments

Comments
 (0)