Skip to content

Commit 9bf0259

Browse files
committed
GH Actions: always use env for handling user input
> GitHub Actions allows workflows to define template expansions, which occur within special `${{ ... }}` delimiters. These expansions happen before workflow and job execution, meaning the expansion of a given expression appears verbatim in whatever context it was performed in. > > Template expansions aren't syntax-aware, meaning that they can result in unintended shell injection vectors. This is especially true when they're used with attacker-controllable expression contexts, such as `github.event.issue.title` (which the attacker can fully control by supplying a new issue title). Ref: * https://securitylab.github.com/resources/github-actions-untrusted-input/ * https://docs.zizmor.sh/audits/#template-injection
1 parent aaeea2a commit 9bf0259

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

action.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ runs:
4747
shell: bash
4848
run: |
4949
# Determine debug mode.
50-
if [[ "${{ env.DEBUG_INPUT }}" == "true" ]]; then
50+
if [[ "${DEBUG_INPUT}" == "true" ]]; then
5151
echo "DEBUG=true" >> "$GITHUB_ENV"
5252
else
5353
echo "DEBUG=false" >> "$GITHUB_ENV"
@@ -62,13 +62,13 @@ runs:
6262
run: |
6363
# Validate local file input.
6464
# Check for non-zero length file name.
65-
if [[ -n "${{ env.XSD_FILE }}" ]]; then
65+
if [[ -n "${XSD_FILE}" ]]; then
6666
# Check that file name ends on .xsd.
6767
if [[ "${{ endsWith( env.XSD_FILE, '.xsd' ) }}" == "false" ]]; then
6868
echo "::error title=XMLLint Validate::Local XSD file must use an '.xsd' file extension."
6969
exit 1
7070
# Check the file exists and has contents (file size greater than zero).
71-
elif [[ -f "${{ env.XSD_FILE }}" && -s "${{ env.XSD_FILE }}" ]]; then
71+
elif [[ -f "${XSD_FILE}" && -s "${XSD_FILE}" ]]; then
7272
echo 'Local XSD file found.'
7373
exit 0
7474
else
@@ -103,7 +103,7 @@ runs:
103103
run: |
104104
# Validate remote URL input and download file.
105105
# Check for non-zero length URL input.
106-
if [[ -n "${{ env.XSD_URL }}" ]]; then
106+
if [[ -n "${XSD_URL}" ]]; then
107107
# Check that URL uses http(s) protocol.
108108
if [[ "${{ startsWith( env.XSD_URL, 'http://' ) || startsWith( env.XSD_URL, 'https://' ) || startsWith( env.XSD_URL, 'ftp://' ) }}" == "false" ]]; then
109109
echo "::error title=XMLLint Validate::URL to the XSD file must be an 'http', 'https' or 'ftp' URL."
@@ -114,12 +114,12 @@ runs:
114114
exit 1
115115
# Try to download it.
116116
else
117-
if [[ "${{ env.DEBUG }}" == "false" ]]; then
118-
wget -nc -nv "${{ env.XSD_URL }}" -O "${{ env.DOWNLOADED_XSD_FILE }}"
117+
if [[ "${DEBUG}" == "false" ]]; then
118+
wget -nc -nv "${XSD_URL}" -O "${DOWNLOADED_XSD_FILE}"
119119
else
120-
wget -nc "${{ env.XSD_URL }}" -O "${{ env.DOWNLOADED_XSD_FILE }}"
120+
wget -nc "${XSD_URL}" -O "${DOWNLOADED_XSD_FILE}"
121121
fi
122-
if [[ -f "${{ env.DOWNLOADED_XSD_FILE }}" && -s "${{ env.DOWNLOADED_XSD_FILE }}" ]]; then
122+
if [[ -f "${DOWNLOADED_XSD_FILE}" && -s "${DOWNLOADED_XSD_FILE}" ]]; then
123123
echo 'Download of the XSD file succesfull.'
124124
exit 0
125125
else
@@ -138,7 +138,7 @@ runs:
138138
shell: bash
139139
run: |
140140
# Update package list.
141-
if [[ "${{ env.DEBUG }}" == "false" ]]; then
141+
if [[ "${DEBUG}" == "false" ]]; then
142142
sudo apt-get -q update > /dev/null
143143
else
144144
sudo apt-get update
@@ -148,7 +148,7 @@ runs:
148148
shell: bash
149149
run: |
150150
# Install xmllint.
151-
if [[ "${{ env.DEBUG }}" == "false" ]]; then
151+
if [[ "${DEBUG}" == "false" ]]; then
152152
sudo apt-get -q install --no-install-recommends -y libxml2-utils > /dev/null
153153
else
154154
sudo apt-get install --no-install-recommends -y libxml2-utils
@@ -190,9 +190,9 @@ runs:
190190
env:
191191
GLOB_PATTERN: ${{ inputs.pattern }}
192192
shell: bash
193-
run: xmllint --noout --schema ${{ env.DOWNLOADED_XSD_FILE }} $GLOB_PATTERN
193+
run: xmllint --noout --schema ${DOWNLOADED_XSD_FILE} $GLOB_PATTERN
194194

195195
- name: 'Clean up downloaded file'
196196
if: ${{ ! inputs.xsd-file && inputs.xsd-url }}
197197
shell: bash
198-
run: rm -f ${{ env.DOWNLOADED_XSD_FILE }}
198+
run: rm -f ${DOWNLOADED_XSD_FILE}

0 commit comments

Comments
 (0)