deploy-vps should quote app-env values itself #54
Labels
No labels
priority/P0
priority/P1
priority/P2
priority/P3
size/L
size/M
size/S
size/XL
size/XS
state/blocked
state/done
state/in-progress
state/in-review
state/needs-refinement
state/ready
type/bug
type/chore
type/feature
type/refactor
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
amtronics/platform-actions#54
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
deploy-vpswrites theapp-envlines verbatim into the host.envand the remote step shell-sources that file (set -a; . ./.env). A consumer that writesKEY="value"gets$, backticks,\and"interpreted by the host shell; a generated password with any of them is silently altered or, for a backtick, executed on the host. Every consumer currently has to know this and quote correctly; expiro (ahmad/expiro#54) works around it with single quotes. The action's ownDEPLOY_DOMAIN="…"lines have the same shape.Scope
KEY=valuelines and writes them so that any value is preserved byte-for-byte after sourcing and after compose's.envparsing; the action's own lines use the same escaping; documentation of what a consumer may pass.Acceptance criteria
app-envvalue containing$, a backtick,\,"or', when the deploy runs, then the container sees the value unchanged.DEPLOY_DOMAINline, when the domain contains a shell-special character, then it is preserved.Plan.
Affected:
deploy-vps/action.yml(the "Write the runtime environment file" step and theapp-envinput description), README (input table, example, and the "exactly as given" paragraph).Approach: a
sq()helper single-quotes every value (embedded'as'\''), applied to the action's own lines (DEPLOY_DOMAIN,IMAGE_TAG,COMPOSE_PROFILES,GRAFANA_PROM_*) and to each app-env value. Single quotes because the sourcing shell is the effective parser — compose reads the same file, but the sourced process environment takes precedence in its interpolation, so the shell's reading is the one that counts.Criterion 2 (consumer-supplied quotes) — honoured, not rejected: a value already wrapped in matching quotes (single or double) is written as given; the consumer owns that quoting. Rejecting would break expiro's live workaround (ahmad/expiro#54 passes single-quoted values) on its very next deploy; honouring keeps it working unchanged, and expiro can drop the quotes at leisure. Documented on the input and in the README, whose example stops teaching the
KEY="…"shape.Guard: a line whose key is not a valid variable name (or has no
=) fails the deploy with a message naming only the key, never the value — previously it was sourced as whatever the shell made of it.Verification: local matrix extracting the exact
run:block from the YAML and driving it throughset -a; . ./file— hostile bytes ($, backtick,\,",', spaces, empty) in app-env and in the action's own values, pre-quoted values honoured verbatim, malformed keys rejected without leaking values, plus a negative control proving the old double-quote shape corrupts. 17/17 pass.