Multiline string for packages breaks everything
panzi opened this issue · 1 comments
If you have a lot of packages and use a multiline string for the packages parameter the setup fails, because bash attempts top run the second line as a command.
Instead of directly using the GitHub action variable interpolation you should pass the parameters as environment variables in order to prevent breakage (and command injection):
runs:
using: "composite"
steps:
- id: pre-cache
run: |
${GITHUB_ACTION_PATH}/pre_cache_action.sh \
~/cache-apt-pkgs \
"$VERSION" \
"$EXEC_INSTALL_SCRIPTS" \
"$DEBUG" \
"$PACKAGES"
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
shell: bash
env:
VERSION: "${{ inputs.version }}"
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
DEBUG: "${{ inputs.debug }}"
PACKAGES: "${{ inputs.packages }}"
Change here:
cache-apt-pkgs-action/action.yml
Lines 44 to 52 in 9b2b4f2
cache-apt-pkgs-action/action.yml
Lines 61 to 73 in 9b2b4f2
Note that simply adding " " around ${{ inputs.packages }}
in the run command will still allow command injection if someone uses a " in the packages parameter. So using env vars is cleaner.
However, this then passes the packages as a single parameter, but since you then do this anyway it shouldn't matter (in fact make that simpler, since you merge it into a single string anyway):
cache-apt-pkgs-action/pre_cache_action.sh
Lines 28 to 31 in 9b2b4f2
cache-apt-pkgs-action/post_cache_action.sh
Lines 29 to 35 in 9b2b4f2
cache-apt-pkgs-action/install_and_cache_pkgs.sh
Lines 19 to 22 in 9b2b4f2