Skip to content

Commit 2eec2d2

Browse files
authored
Validate and safely pass setup-ddev ddev-version input (DataDog#23812)
* Validate and safely pass setup-ddev version input * Allow ddev version specifier sets
1 parent 73276c7 commit 2eec2d2

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

.github/actions/setup-ddev/action.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ runs:
2929
env:
3030
CACHE_PROFILE: ${{ inputs.cache-profile }}
3131
INSTALL_MODE: ${{ inputs.install-mode }}
32+
DDEV_VERSION: ${{ inputs.ddev-version }}
3233
run: |-
3334
case "$INSTALL_MODE" in
3435
local|pypi) ;;
@@ -46,6 +47,11 @@ runs:
4647
;;
4748
esac
4849
50+
if [[ -n "$DDEV_VERSION" && ! "$DDEV_VERSION" =~ ^(===|==|~=|!=|<=|>=|<|>)[A-Za-z0-9._*+!-]+(,(===|==|~=|!=|<=|>=|<|>)[A-Za-z0-9._*+!-]+)*$ ]]; then
51+
echo "::error::Invalid ddev-version '$DDEV_VERSION'. Use a PEP 440-style version specifier such as ==16.0.0 or >=16,<17."
52+
exit 1
53+
fi
54+
4955
- name: Compute cache date
5056
id: cache-date
5157
shell: bash
@@ -157,7 +163,9 @@ runs:
157163
- name: Install ddev from PyPI
158164
if: ${{ inputs.install-mode == 'pypi' }}
159165
shell: bash
160-
run: uv pip install --system "ddev${{ inputs.ddev-version }}"
166+
env:
167+
DDEV_VERSION: ${{ inputs.ddev-version }}
168+
run: uv pip install --system "ddev${DDEV_VERSION}"
161169

162170
- name: Save local ddev cache
163171
if: ${{ inputs.install-mode == 'local' && inputs.cache-profile == 'local-ddev-base' && steps.restore-local-ddev-base-cache.outputs.cache-hit != 'true' }}

0 commit comments

Comments
 (0)