Skip to content

security: replaced injected variables with environment variables#13

Open
fearphage wants to merge 1 commit into
actions:mainfrom
fearphage:security/replace-injected-variables
Open

security: replaced injected variables with environment variables#13
fearphage wants to merge 1 commit into
actions:mainfrom
fearphage:security/replace-injected-variables

Conversation

@fearphage

@fearphage fearphage commented Jun 15, 2026

Copy link
Copy Markdown

Replaced injected variables with environment variables to remove an attack vector.

This also has the side effect of simplifying the remaining Bash script. Along those lines I moved the set call to the shell property so it is not as easily overwritten.

Copilot AI review requested due to automatic review settings June 15, 2026 20:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the composite GitHub Action to derive PR context (commit SHA, PR number, ref) via environment variables and simplify the runtime script used for uploading the coverage report.

Changes:

  • Moves set -euo pipefail behavior from the script body into the shell: declaration.
  • Introduces env vars for COMMIT_OID, REF, PR metadata, and uses them in the bash logic.
  • Adjusts PR number discovery for non-PR events using gh pr list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread action.yml
steps:
- name: Upload coverage report
shell: bash
shell: bash -euo pipefail {0}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is false information. This works and has worked for a long time. There are hundreds of examples available:

https://github.com/search?type=code&q=%22shell%3A+bash+-euo+pipefail+%7B0%7D%22+path%3A.github%2Fworkflows

It's also in the official GH docs: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defaultsrunshell

Comment thread action.yml
Comment on lines +29 to +36
COMMIT_OID: >-
${{
case(
github.event_name == 'pull_request' || github.event_name == 'pull_request_target',
github.event.pull_request.head.sha,
github.sha
)
}}

@fearphage fearphage Jun 15, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update your corpus. Check the docs.

Comment thread action.yml
Comment on lines +47 to +54
REF: >-
${{
case(
github.event_name == 'pull_request' || github.event_name == 'pull_request_target',
'',
github.ref
)
}}
Comment thread action.yml
Comment on lines +29 to +36
COMMIT_OID: >-
${{
case(
github.event_name == 'pull_request' || github.event_name == 'pull_request_target',
github.event.pull_request.head.sha,
github.sha
)
}}

@fearphage fearphage Jun 15, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you don't know how YAML folding works or you think that shas contain new line characters.

Comment thread action.yml
Comment on lines +47 to +54
REF: >-
${{
case(
github.event_name == 'pull_request' || github.event_name == 'pull_request_target',
'',
github.ref
)
}}
Comment thread action.yml
run: |
set -euo pipefail

export GH_HOST="${GITHUB_SERVER_URL#*://}"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a reference to this variable anywhere. Should this be cleaned up?

➜  upload-code-coverage git:(security/replace-injected-variables) ag --hidden GH_HOST
action.yml
56:        export GH_HOST="${GITHUB_SERVER_URL#*://}"
➜  upload-code-coverage git:(security/replace-injected-variables)

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.

2 participants