Skip to content

Conversation

@tundeaoni
Copy link
Contributor

@tundeaoni tundeaoni commented Jan 14, 2026

@tundeaoni tundeaoni requested a review from a team as a code owner January 14, 2026 13:00
@remerge-hal
Copy link

This comment ensures that the correct Slack channel is notified after the team/project label CORE has been added to this pull request.

See this comment for details.

hollow
hollow previously approved these changes Jan 14, 2026
--var='environment=${{ inputs.environment }}' \
--var='code_version=${{ inputs.code_version || steps.checkout.outputs.commit }}' \
--var-file=${{ inputs.variables_file_name }} \
--var-file=${{ inputs.variables_file_name }} --ignore-missing-vars \

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ inputs.variables_file_name }
, which may be controlled by an external user.

Copilot Autofix

AI about 1 month ago

In general, the fix is to avoid using the GitHub expression ${{ inputs.variables_file_name }} directly inside the shell script body. Instead, assign the input to an environment variable in the env: section of the step, and then reference that variable using native shell syntax ($VAR) inside the run: block. This prevents a malicious value from being re-interpreted as part of the script, because GitHub’s expression engine substitutes only the env var value (without re-parsing), and the shell performs a simple variable expansion within a single argument.

For this specific workflow, we should update the "Validate Nomad Configurations" step. Add an environment variable, for example NOMAD_VAR_FILE, set to ${{ inputs.variables_file_name }} in the step’s env: block. Then, in the run: script, replace --var-file=${{ inputs.variables_file_name }} with --var-file="$NOMAD_VAR_FILE". This preserves the existing behavior (the same value is passed to nomad-pack), but removes the direct GitHub expression from the shell script, aligning with GitHub’s secure usage guidance. No new imports or external tools are needed; this is entirely a YAML and shell change within .github/workflows/nomad-pack.yml.

Suggested changeset 1
.github/workflows/nomad-pack.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/nomad-pack.yml b/.github/workflows/nomad-pack.yml
--- a/.github/workflows/nomad-pack.yml
+++ b/.github/workflows/nomad-pack.yml
@@ -185,6 +185,7 @@
           NOMAD_VAR_task_image: ${{ inputs.image_name }}
           NOMAD_VAR_cluster: ${{ inputs.cluster }}
           NOMAD_VAR_environment: ${{ inputs.environment }}
+          NOMAD_VAR_FILE: ${{ inputs.variables_file_name }}
         run: |
           nomad-pack render ${{ inputs.pack_name }} \
           --var='task_image=${{ inputs.image_name }}' \
@@ -192,7 +193,7 @@
           --var='cluster=${{ inputs.cluster }}' \
           --var='environment=${{ inputs.environment }}' \
           --var='code_version=${{ inputs.code_version || steps.checkout.outputs.commit }}' \
-          --var-file=${{ inputs.variables_file_name }} --ignore-missing-vars  \
+          --var-file="$NOMAD_VAR_FILE" --ignore-missing-vars  \
           --name=${{ inputs.name }} --registry=remerge-pack \
           | tail -n +2 | nomad job validate -
 
EOF
@@ -185,6 +185,7 @@
NOMAD_VAR_task_image: ${{ inputs.image_name }}
NOMAD_VAR_cluster: ${{ inputs.cluster }}
NOMAD_VAR_environment: ${{ inputs.environment }}
NOMAD_VAR_FILE: ${{ inputs.variables_file_name }}
run: |
nomad-pack render ${{ inputs.pack_name }} \
--var='task_image=${{ inputs.image_name }}' \
@@ -192,7 +193,7 @@
--var='cluster=${{ inputs.cluster }}' \
--var='environment=${{ inputs.environment }}' \
--var='code_version=${{ inputs.code_version || steps.checkout.outputs.commit }}' \
--var-file=${{ inputs.variables_file_name }} --ignore-missing-vars \
--var-file="$NOMAD_VAR_FILE" --ignore-missing-vars \
--name=${{ inputs.name }} --registry=remerge-pack \
| tail -n +2 | nomad job validate -

Copilot is powered by AI and may make mistakes. Always verify output.
--var='environment=${{ inputs.environment }}' \
--var='code_version=${{ inputs.code_version || steps.checkout.outputs.commit }}' \
--var-file=${{ inputs.variables_file_name }} \
--var-file=${{ inputs.variables_file_name }} --ignore-missing-vars \

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ inputs.variables_file_name }
, which may be controlled by an external user.

Copilot Autofix

AI 30 days ago

In general, to fix this type of problem, any user‑controlled values used in run: scripts should not be interpolated directly using GitHub expression syntax within the script body. Instead, assign them to environment variables at the step level using ${{ ... }} and then reference them inside the script using the shell’s native variable expansion (e.g., $VAR), which avoids the templating engine rewriting and allows safe quoting and escaping.

For this concrete issue, we should stop using ${{ inputs.variables_file_name }} inside the run: block and instead expose it via an environment variable such as VARIABLES_FILE_NAME. Then, update both the Validate Nomad Configurations and Run Nomad Pack Plan steps to use "${VARIABLES_FILE_NAME}" in the --var-file argument. To keep behavior unchanged, we will:

  • Add VARIABLES_FILE_NAME: ${{ inputs.variables_file_name }} to the env: section of both steps.
  • Replace --var-file=${{ inputs.variables_file_name }} with --var-file="$VARIABLES_FILE_NAME" in the run: scripts.

This preserves the same effective argument content while removing direct expression interpolation from the shell command and allowing proper shell quoting.


Suggested changeset 1
.github/workflows/nomad-pack.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/nomad-pack.yml b/.github/workflows/nomad-pack.yml
--- a/.github/workflows/nomad-pack.yml
+++ b/.github/workflows/nomad-pack.yml
@@ -185,6 +185,7 @@
           NOMAD_VAR_task_image: ${{ inputs.image_name }}
           NOMAD_VAR_cluster: ${{ inputs.cluster }}
           NOMAD_VAR_environment: ${{ inputs.environment }}
+          VARIABLES_FILE_NAME: ${{ inputs.variables_file_name }}
         run: |
           nomad-pack render ${{ inputs.pack_name }} \
           --var='task_image=${{ inputs.image_name }}' \
@@ -192,7 +193,7 @@
           --var='cluster=${{ inputs.cluster }}' \
           --var='environment=${{ inputs.environment }}' \
           --var='code_version=${{ inputs.code_version || steps.checkout.outputs.commit }}' \
-          --var-file=${{ inputs.variables_file_name }} --ignore-missing-vars  \
+          --var-file="$VARIABLES_FILE_NAME" --ignore-missing-vars  \
           --name=${{ inputs.name }} --registry=remerge-pack \
           | tail -n +2 | nomad job validate -
 
@@ -202,6 +203,7 @@
         env:
           NOMAD_TOKEN: ${{ env.NOMAD_TOKEN }}
           NOMAD_ADDR: ${{ inputs.api_url }}
+          VARIABLES_FILE_NAME: ${{ inputs.variables_file_name }}
         # continue on error; default is `bash -e {0}`
         shell: bash {0}
         run: |
@@ -211,7 +213,7 @@
           --var='cluster=${{ inputs.cluster }}' \
           --var='environment=${{ inputs.environment }}' \
           --var='code_version=${{ inputs.code_version || steps.checkout.outputs.commit }}' \
-          --var-file=${{ inputs.variables_file_name }} --ignore-missing-vars  \
+          --var-file="$VARIABLES_FILE_NAME" --ignore-missing-vars  \
           --name=${{ inputs.name }} --registry=remerge-pack  \
           --exit-code-makes-changes=0)
 
EOF
@@ -185,6 +185,7 @@
NOMAD_VAR_task_image: ${{ inputs.image_name }}
NOMAD_VAR_cluster: ${{ inputs.cluster }}
NOMAD_VAR_environment: ${{ inputs.environment }}
VARIABLES_FILE_NAME: ${{ inputs.variables_file_name }}
run: |
nomad-pack render ${{ inputs.pack_name }} \
--var='task_image=${{ inputs.image_name }}' \
@@ -192,7 +193,7 @@
--var='cluster=${{ inputs.cluster }}' \
--var='environment=${{ inputs.environment }}' \
--var='code_version=${{ inputs.code_version || steps.checkout.outputs.commit }}' \
--var-file=${{ inputs.variables_file_name }} --ignore-missing-vars \
--var-file="$VARIABLES_FILE_NAME" --ignore-missing-vars \
--name=${{ inputs.name }} --registry=remerge-pack \
| tail -n +2 | nomad job validate -

@@ -202,6 +203,7 @@
env:
NOMAD_TOKEN: ${{ env.NOMAD_TOKEN }}
NOMAD_ADDR: ${{ inputs.api_url }}
VARIABLES_FILE_NAME: ${{ inputs.variables_file_name }}
# continue on error; default is `bash -e {0}`
shell: bash {0}
run: |
@@ -211,7 +213,7 @@
--var='cluster=${{ inputs.cluster }}' \
--var='environment=${{ inputs.environment }}' \
--var='code_version=${{ inputs.code_version || steps.checkout.outputs.commit }}' \
--var-file=${{ inputs.variables_file_name }} --ignore-missing-vars \
--var-file="$VARIABLES_FILE_NAME" --ignore-missing-vars \
--name=${{ inputs.name }} --registry=remerge-pack \
--exit-code-makes-changes=0)

Copilot is powered by AI and may make mistakes. Always verify output.
@tundeaoni tundeaoni merged commit 07ed16b into main Jan 14, 2026
3 checks passed
@tundeaoni tundeaoni deleted the CORE-1540-nomad-pack-0.4.1 branch January 14, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants