Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of variables, inputs, platforms, and options with spaces #143

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

SanjulaGanepola
Copy link
Owner

✍ Changes

  • Wrap variables, inputs, platforms, and options with double quotes to fix issues with spaces

I tested this on Windows, but will need some help with testing on Linux and MacOS.

📋 Checklist

  • I tested my changes
  • I updated relevant documentation
  • I added myself to the contributors' list

@SanjulaGanepola SanjulaGanepola linked an issue Jan 18, 2025 that may be closed by this pull request
@SanjulaGanepola
Copy link
Owner Author

@ChristopherHX When you have a chance, could you test out this change as I do not have a Mac or Linux

Signed-off-by: Sanjula Ganepola <[email protected]>
src/utils.ts Fixed Show fixed Hide fixed
SanjulaGanepola and others added 2 commits January 18, 2025 19:46
…ng or encoding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Sanjula Ganepola <[email protected]>
@SanjulaGanepola
Copy link
Owner Author

@ChristopherHX Turns out there is an issue with handling quotes in inputs. Variables are fine however. Is this an issue in act?

[Echo Test/SAMPLE] variable with spaces and quotes"
[Echo Test/SAMPLE] /var/run/act/workflow/0: line 3: unexpected EOF while looking for matching `"'
act --workflows ".github/workflows/sample.yaml" --secret-file "" --var MY_VAR="variable with spaces and quotes\"" --var-file "" --input MY_INPUT="input with spaces and quotes\"" --input-file "" --eventpath ""
name: Echo Test

on:
  push:
    branches: ["main"]

jobs:
  sample:
    name: SAMPLE

    runs-on: ubuntu-latest

    steps:
      - name: Echo
        run: |
          echo '${{ vars.MY_VAR }}'
          echo ${{ github.event.inputs.MY_INPUT }}

@ChristopherHX
Copy link
Contributor

Is this an issue in act?

No, your workflow just has a script injection vulnerability. Regardless of using act or not

It's best practice to use shell environment variables for passing untrusted data.

Learn more here
https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#example-of-a-script-injection-attack

Variables are fine however

Your variable line has an incomplete mitigation of a special case of script injection by using single quotes '

Yes I just accept this risk myself a lot, mitigation adds more code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Variables with spaces are not handled correctly
2 participants