mirror of
https://github.com/storytold/craft-common-actions.git
synced 2026-11-03 09:18:12 +00:00
security(release): keep app-title and version metadata out of shell source (#47)
draft-release and resolve-version interpolated caller-provided metadata directly into Bash source (CWE-78): - draft-release embedded app-title into the `title=` assignment in the step that has GH_TOKEN available. - resolve-version embedded input-version into a `v=` assignment before it was validated, and app-title into the job-summary `echo`. Both inputs now travel through the step `env:` and are read with quoted variable expansions; the version is validated before it is used to produce outputs, and the summary is written with a fixed `printf` format. No change to outputs or release behavior.
This commit is contained in:
1 parent
a4acae8e3a
commit
d04f2a42da
2 files changed
+7
-3
No files matched your search
@@ -37,12 +37,13 @@ runs:
|
||||
working-directory: artifacts
|
||||
env:
|
||||
VERSION: ${{ inputs.version }}
|
||||
APP_TITLE: ${{ inputs.app-title }}
|
||||
PRERELEASE: ${{ inputs.prerelease }}
|
||||
GH_TOKEN: ${{ inputs.github-token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
run: |
|
||||
tag="v$VERSION"
|
||||
title="${{ inputs.app-title }} v$VERSION"
|
||||
title="$APP_TITLE v$VERSION"
|
||||
pre=()
|
||||
if [ "$PRERELEASE" = "true" ]; then pre=(--prerelease); fi
|
||||
if draft="$(gh release view "$tag" --json isDraft --jq .isDraft 2>/dev/null)"; then
|
||||
|
||||
@@ -28,13 +28,16 @@ runs:
|
||||
- id: resolve
|
||||
name: Resolve version
|
||||
shell: bash
|
||||
env:
|
||||
INPUT_VERSION: ${{ inputs.input-version }}
|
||||
APP_TITLE: ${{ inputs.app-title }}
|
||||
run: |
|
||||
if [ -f packaging/env.sh ]; then
|
||||
. packaging/env.sh
|
||||
elif [ -f packaging/common.sh ]; then
|
||||
. packaging/common.sh
|
||||
fi
|
||||
v="${{ inputs.input-version }}"
|
||||
v="$INPUT_VERSION"
|
||||
v="${v#v}"
|
||||
v="${v:-$VERSION}"
|
||||
if ! printf '%s' "$v" | grep -Eq '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then
|
||||
@@ -47,4 +50,4 @@ runs:
|
||||
echo "date=$(date -u +%Y-%m-%d)"
|
||||
echo "prerelease=$pre"
|
||||
} >>"$GITHUB_OUTPUT"
|
||||
echo "### ${{ inputs.app-title }} v$v (\`${GITHUB_SHA::9}\`)" >>"$GITHUB_STEP_SUMMARY"
|
||||
printf '### %s v%s (`%s`)\n' "$APP_TITLE" "$v" "${GITHUB_SHA::9}" >>"$GITHUB_STEP_SUMMARY"
|
||||
Reference in new issue
Block a user