Skip to content

Commit 157d3cb

Browse files
Potential fix for code scanning alert no. 349: Artifact poisoning
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com>
1 parent d44cac0 commit 157d3cb

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/npm.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,20 @@ jobs:
292292
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
293293
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
294294
NPM_REGISTRY_URL: ${{ env.NPM_REGISTRY_URL }}
295-
run: bun run build
295+
run: |
296+
set -euo pipefail
297+
bun run build
298+
299+
# Validate RELEASE_VERSION before exporting it. Only allow semantic-version-like strings,
300+
# e.g. 1.2.3 or 1.2.3-beta.1. Reject anything else to avoid artifact poisoning.
301+
if [[ -z "${RELEASE_VERSION:-}" ]]; then
302+
echo "RELEASE_VERSION is empty or unset; refusing to export." >&2
303+
exit 1
304+
fi
305+
if ! [[ "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
306+
echo "RELEASE_VERSION '$RELEASE_VERSION' has an invalid format; refusing to export." >&2
307+
exit 1
308+
fi
296309
297310
printf 'RELEASE_VERSION=%s\n' "$RELEASE_VERSION" >>"$GITHUB_OUTPUT"
298311

0 commit comments

Comments
 (0)