Skip to content

Commit 3f4af37

Browse files
committed
ci: use --sandbox for dynamically generated sed scripts
sed scripts are capable of doing file I/O and executing arbitrary commands. The `--sandbox` option prevents this by rejecting sed commands with such capabilities; it's good practice to use this whenever the sed script is dynamically generated (e.g. if it involves a variable expansion). Also fixed an error in one sed script where `.*` had been placed outside of the quoted string (and would therefore be subject to shell globbing), presumably due to single-quotes having been changed to double-quotes at some point in the past. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
1 parent b9736e8 commit 3f4af37

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

.github/workflows/dev-bump.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
echo "::notice:: bumping z up to $devbump"
3535
fi
3636
37-
sed -i "s/const RawVersion = ".*"/const RawVersion = \"${devbump}\"/g" version/rawversion/version.go
37+
sed --sandbox -i -e "s/const RawVersion = \".*\"/const RawVersion = \"${devbump}\"/g" version/rawversion/version.go
3838
3939
echo "devbump=$devbump" >> $GITHUB_OUTPUT
4040
- name: Push
@@ -121,7 +121,7 @@ jobs:
121121
devbump="$(IFS=. ; echo "${arr[*]}")-dev"
122122
echo "::notice:: Bumping main to: $devbump"
123123
124-
sed -i "s/const RawVersion = \".*\"/const RawVersion = \"$devbump\"/g" version/rawversion/version.go
124+
sed --sandbox -i -e "s/const RawVersion = \".*\"/const RawVersion = \"${devbump}\"/g" version/rawversion/version.go
125125
126126
echo "devbump=$devbump" >> $GITHUB_OUTPUT
127127
- name: Push

.github/workflows/first_contrib_cert_generator.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ jobs:
7171
PR_NUMBER="${{ github.event.inputs.pr_number || github.event.pull_request.number }}"
7272
MERGE_DATE=$(date -u +"%B %d, %Y")
7373
74-
sed -i "/id=\"contributorName\"/s/value=\"[^\"]*\"/value=\"${CONTRIBUTOR_NAME}\"/" ${HTML_FILE} || { echo "ERROR: Failed to update contributor name."; exit 1; }
75-
sed -i "/id=\"prNumber\"/s/value=\"[^\"]*\"/value=\"#${PR_NUMBER}\"/" ${HTML_FILE} || { echo "ERROR: Failed to update PR number."; exit 1; }
76-
sed -i "/id=\"mergeDate\"/s/value=\"[^\"]*\"/value=\"${MERGE_DATE}\"/" ${HTML_FILE} || { echo "ERROR: Failed to update merge date."; exit 1; }
74+
sed --sandbox -i -e "/id=\"contributorName\"/s/value=\"[^\"]*\"/value=\"${CONTRIBUTOR_NAME}\"/" ${HTML_FILE} || { echo "ERROR: Failed to update contributor name."; exit 1; }
75+
sed --sandbox -i -e "/id=\"prNumber\"/s/value=\"[^\"]*\"/value=\"#${PR_NUMBER}\"/" ${HTML_FILE} || { echo "ERROR: Failed to update PR number."; exit 1; }
76+
sed --sandbox -i -e "/id=\"mergeDate\"/s/value=\"[^\"]*\"/value=\"${MERGE_DATE}\"/" ${HTML_FILE} || { echo "ERROR: Failed to update merge date."; exit 1; }
7777
7878
# Step 4: Setup Node.js environment
7979
- name: Setup Node.js

.github/workflows/machine-os-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ jobs:
8282
VERS: ${{steps.getversion.outputs.version}}
8383
run: |
8484
update=$(printf 's/export PODMAN_VERSION=".*"/export PODMAN_VERSION="%s"/g\n' "$VERS")
85-
sed -i "$update" podman-rpm-info-vars.sh
86-
sed -i 's/export PODMAN_PR_NUM=".*"/export PODMAN_PR_NUM="${{github.event.number}}"/g' podman-rpm-info-vars.sh
85+
sed --sandbox -i -e "$update" podman-rpm-info-vars.sh
86+
sed --sandbox -i -e "s/export PODMAN_PR_NUM=\".*\"/export PODMAN_PR_NUM=\"${{github.event.number}}\"/g" podman-rpm-info-vars.sh
8787
echo "Updated file:"
8888
cat podman-rpm-info-vars.sh
8989

.github/workflows/update-podmanio.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
steps.checkpr.outputs.prexists == 'false'
107107
run: |
108108
# Replace the version in static/data/global.ts file
109-
sed -i "s/export const LATEST_VERSION = '.*';/export const LATEST_VERSION = '${{ steps.getversion.outputs.version }}';/g" static/data/global.ts
109+
sed --sandbox -i -e "s/export const LATEST_VERSION = '.*';/export const LATEST_VERSION = '${{ steps.getversion.outputs.version }}';/g" static/data/global.ts
110110
echo "Updated file:"
111111
cat static/data/global.ts
112112

0 commit comments

Comments
 (0)