Skip to content

Commit 25a2ec4

Browse files
committed
fix(ci): add backend URL validation
- Validate backend_url input: reject multiline values, enforce http(s) URL format without query/hash, normalize trailing slash
1 parent 294bafd commit 25a2ec4

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/deploy-gh-pages.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ jobs:
4040
env:
4141
ENV_BACKEND_URL: ${{ github.event.inputs.backend_url || 'https://agent.bytedev.site/' }}
4242
run: |
43+
if [[ "$ENV_BACKEND_URL" == *$'\n'* || "$ENV_BACKEND_URL" == *$'\r'* ]]; then
44+
echo "::error::backend_url must be a single-line value"
45+
exit 1
46+
fi
47+
48+
if [[ ! "$ENV_BACKEND_URL" =~ ^https?://[^[:space:]/?#:]+(:[0-9]+)?(/[^[:space:]?#]*)?$ ]]; then
49+
echo "::error::backend_url must be an http(s) base URL without query or hash"
50+
exit 1
51+
fi
52+
53+
ENV_BACKEND_URL="${ENV_BACKEND_URL%/}/"
54+
4355
cat <<EOF >> designer-demo/env/.env.alpha
4456
# ---- appended by CI (gh-pages) ----
4557
VITE_ORIGIN=$ENV_BACKEND_URL
@@ -59,4 +71,4 @@ jobs:
5971
keep_files: true
6072
force_orphan: false
6173
user_name: 'github-actions[bot]'
62-
user_email: 'github-actions[bot]@users.noreply.github.com'
74+
user_email: 'github-actions[bot]@users.noreply.github.com'

0 commit comments

Comments
 (0)