Skip to content

Core 1345 support skipping image build and testing when only nomad or nomad pack change made skip test#137

Draft
tundeaoni wants to merge 2 commits intomainfrom
CORE-1345-support-skipping-image-build-and-testing-when-only-nomad-or-nomad-pack-change-made-skip-test
Draft

Core 1345 support skipping image build and testing when only nomad or nomad pack change made skip test#137
tundeaoni wants to merge 2 commits intomainfrom
CORE-1345-support-skipping-image-build-and-testing-when-only-nomad-or-nomad-pack-change-made-skip-test

Conversation

@tundeaoni
Copy link
Contributor

@tundeaoni tundeaoni commented Oct 31, 2025

@tundeaoni tundeaoni requested a review from a team as a code owner October 31, 2025 18:42
@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.


- name: Get changed files
id: changed
uses: tj-actions/changed-files@v45

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Go checks' step
Uses Step: changed
uses 'tj-actions/changed-files' with ref 'v45', not a pinned commit hash
"Dockerfile"
)
echo "🔍 Changed files:"
echo "${{ steps.changed.outputs.all_changed_files }}"

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ steps.changed.outputs.all_changed_files }
, which may be controlled by an external user.

Copilot Autofix

AI 3 months ago

To fix this code injection vulnerability, we should avoid placing ${{ steps.changed.outputs.all_changed_files }} directly inside shell commands. Instead, we should pass the value as an environment variable and reference it using native shell syntax ($ALL_CHANGED_FILES). Specifically, in the affected step, set up an env mapping:

env:
  ALL_CHANGED_FILES: ${{ steps.changed.outputs.all_changed_files }}

and then refer to $ALL_CHANGED_FILES in the shell script. This change should be made in the step named "Check if only irrelevant files changed," covering all uses of steps.changed.outputs.all_changed_files inside the run block.

The affected lines are:

  • 100: echo "${{ steps.changed.outputs.all_changed_files }}"
  • 123: done <<< "$(echo "${{ steps.changed.outputs.all_changed_files }}" | tr ',' '\n')"

These should both refer to the environment variable using the shell-native form:

  • On line 100, change to echo "$ALL_CHANGED_FILES"
  • On line 123, change to done <<< "$(echo "$ALL_CHANGED_FILES" | tr ',' '\n')"

We will also add the appropriate env mapping in the step definition.

Suggested changeset 1
.github/workflows/go-checks.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/go-checks.yml b/.github/workflows/go-checks.yml
--- a/.github/workflows/go-checks.yml
+++ b/.github/workflows/go-checks.yml
@@ -80,6 +80,8 @@
 
       - name: Check if only irrelevant files changed
         id: check
+        env:
+          ALL_CHANGED_FILES: ${{ steps.changed.outputs.all_changed_files }}
         run: |
           #!/usr/bin/env bash
           set -euo pipefail
@@ -97,7 +99,7 @@
              "Dockerfile"
           )
           echo "🔍 Changed files:"
-          echo "${{ steps.changed.outputs.all_changed_files }}"
+          echo "$ALL_CHANGED_FILES"
           echo
 
           ONLY_IRRELEVANT=true
@@ -120,7 +122,7 @@
               ONLY_IRRELEVANT=false
               break
             fi
-          done <<< "$(echo "${{ steps.changed.outputs.all_changed_files }}" | tr ',' '\n')"
+          done <<< "$(echo "$ALL_CHANGED_FILES" | tr ',' '\n')"
 
           echo "🔎 Result: only_irrelevant=$ONLY_IRRELEVANT"
           echo "only_irrelevant=$ONLY_IRRELEVANT" >> "$GITHUB_OUTPUT"
EOF
@@ -80,6 +80,8 @@

- name: Check if only irrelevant files changed
id: check
env:
ALL_CHANGED_FILES: ${{ steps.changed.outputs.all_changed_files }}
run: |
#!/usr/bin/env bash
set -euo pipefail
@@ -97,7 +99,7 @@
"Dockerfile"
)
echo "🔍 Changed files:"
echo "${{ steps.changed.outputs.all_changed_files }}"
echo "$ALL_CHANGED_FILES"
echo

ONLY_IRRELEVANT=true
@@ -120,7 +122,7 @@
ONLY_IRRELEVANT=false
break
fi
done <<< "$(echo "${{ steps.changed.outputs.all_changed_files }}" | tr ',' '\n')"
done <<< "$(echo "$ALL_CHANGED_FILES" | tr ',' '\n')"

echo "🔎 Result: only_irrelevant=$ONLY_IRRELEVANT"
echo "only_irrelevant=$ONLY_IRRELEVANT" >> "$GITHUB_OUTPUT"
Copilot is powered by AI and may make mistakes. Always verify output.
ONLY_IRRELEVANT=false
break
fi
done <<< "$(echo "${{ steps.changed.outputs.all_changed_files }}" | tr ',' '\n')"

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ steps.changed.outputs.all_changed_files }
, which may be controlled by an external user.

Copilot Autofix

AI 3 months ago

To fix the issue, we need to avoid interpolating the untrusted input using ${{ ... }} directly in the shell context inside the run: block. The best practice is to pass the value to the shell via an intermediate environment variable (set via env:), and then reference it using $VARIABLE.

Steps to fix:

  • In the affected step (Check if only irrelevant files changed), under env:, add a variable like ALL_CHANGED_FILES: ${{ steps.changed.outputs.all_changed_files }}.
  • In the shell script, replace direct usage of ${{ steps.changed.outputs.all_changed_files }} with $ALL_CHANGED_FILES.
  • Specifically, the line:
    done <<< "$(echo "${{ steps.changed.outputs.all_changed_files }}" | tr ',' '\n')"
    
    should become:
    done <<< "$(echo "$ALL_CHANGED_FILES" | tr ',' '\n')"
    
  • Also, any other echo or usage of the same variable via ${{ ... }} should be updated to $ALL_CHANGED_FILES for consistency and safety.

No additional libraries are needed. You only need to add the environment variable definition and reference it using the shell’s $ syntax inside the script.


Suggested changeset 1
.github/workflows/go-checks.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/go-checks.yml b/.github/workflows/go-checks.yml
--- a/.github/workflows/go-checks.yml
+++ b/.github/workflows/go-checks.yml
@@ -80,6 +80,8 @@
 
       - name: Check if only irrelevant files changed
         id: check
+        env:
+          ALL_CHANGED_FILES: ${{ steps.changed.outputs.all_changed_files }}
         run: |
           #!/usr/bin/env bash
           set -euo pipefail
@@ -97,7 +99,7 @@
              "Dockerfile"
           )
           echo "🔍 Changed files:"
-          echo "${{ steps.changed.outputs.all_changed_files }}"
+          echo "$ALL_CHANGED_FILES"
           echo
 
           ONLY_IRRELEVANT=true
@@ -120,7 +122,7 @@
               ONLY_IRRELEVANT=false
               break
             fi
-          done <<< "$(echo "${{ steps.changed.outputs.all_changed_files }}" | tr ',' '\n')"
+          done <<< "$(echo "$ALL_CHANGED_FILES" | tr ',' '\n')"
 
           echo "🔎 Result: only_irrelevant=$ONLY_IRRELEVANT"
           echo "only_irrelevant=$ONLY_IRRELEVANT" >> "$GITHUB_OUTPUT"
EOF
@@ -80,6 +80,8 @@

- name: Check if only irrelevant files changed
id: check
env:
ALL_CHANGED_FILES: ${{ steps.changed.outputs.all_changed_files }}
run: |
#!/usr/bin/env bash
set -euo pipefail
@@ -97,7 +99,7 @@
"Dockerfile"
)
echo "🔍 Changed files:"
echo "${{ steps.changed.outputs.all_changed_files }}"
echo "$ALL_CHANGED_FILES"
echo

ONLY_IRRELEVANT=true
@@ -120,7 +122,7 @@
ONLY_IRRELEVANT=false
break
fi
done <<< "$(echo "${{ steps.changed.outputs.all_changed_files }}" | tr ',' '\n')"
done <<< "$(echo "$ALL_CHANGED_FILES" | tr ',' '\n')"

echo "🔎 Result: only_irrelevant=$ONLY_IRRELEVANT"
echo "only_irrelevant=$ONLY_IRRELEVANT" >> "$GITHUB_OUTPUT"
Copilot is powered by AI and may make mistakes. Always verify output.
@tundeaoni tundeaoni marked this pull request as draft November 4, 2025 13:45
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.

2 participants