Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/linters/.jscpd.json

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/Linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
VALIDATE_BIOME_FORMAT: false
VALIDATE_JSCPD: false
VALIDATE_JSON_PRETTIER: false
VALIDATE_MARKDOWN_PRETTIER: false
VALIDATE_YAML_PRETTIER: false
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Auto-Release
name: Release

run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
run-name: "Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"

on:
pull_request:
Expand All @@ -12,6 +12,9 @@ on:
- reopened
- synchronize
- labeled
paths:
- 'action.yml'
- 'src/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -22,15 +25,15 @@ permissions:
pull-requests: write # Required to create comments on the PRs

jobs:
Auto-Release:
Release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Auto-Release
uses: PSModule/Auto-Release@eabd533035e2cb9822160f26f2eda584bd012356 # v1.9.5
- name: Release
uses: PSModule/Release-GHRepository@88c70461c8f16cc09682005bcf3b7fca4dd8dc1a # v2.0.1
env:
GITHUB_TOKEN: ${{ github.token }}
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ runs:
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
try {
${{ github.action_path }}/scripts/init.ps1
${{ github.action_path }}/scripts/info.ps1
${{ github.action_path }}/src/init.ps1

Check warning

Code scanning / CodeQL

Code injection

Potential code injection in [${{ github.action_path }}](1), which may be controlled by an external user.

Copilot Autofix

AI 10 months ago

In general, to address code injection warnings in GitHub Actions, move expression values (${{ ... }}) into environment variables and then reference them using the shell’s native syntax instead of embedding expressions directly inside the run: script. This eliminates the opportunity for shell parsing of templated strings and aligns with GitHub’s recommended pattern.

For this specific file, we should:

  1. Define an environment variable (for example PSMODULE_GITHUB_ACTION_PATH) set to ${{ github.action_path }} under env: for the step.
  2. Replace all occurrences of ${{ github.action_path }} in the PowerShell script with the PowerShell environment variable reference $env:PSMODULE_GITHUB_ACTION_PATH.
  3. While doing so, preserve the rest of the logic and keep ${{ inputs.Script }} untouched, since changing that behavior would alter functionality and go beyond the requested change.

Concretely, in action.yml within the composite runs.steps block for RunGitHubScript, we add a new env: entry (e.g., on a new line after line 95) and then adjust lines 102–105 and 108 so that they call the PowerShell scripts using $env:PSMODULE_GITHUB_ACTION_PATH instead of ${{ github.action_path }}. No additional external dependencies or imports are required.

Suggested changeset 1
action.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/action.yml b/action.yml
--- a/action.yml
+++ b/action.yml
@@ -93,17 +93,18 @@
         PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
         PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
         PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
+        PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
       run: |
         # ${{ inputs.Name }}
         $ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
         $DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
         $VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
         try {
-          ${{ github.action_path }}/src/init.ps1
-          ${{ github.action_path }}/src/info.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/info.ps1"
           ${{ inputs.Script }}
-          ${{ github.action_path }}/src/outputs.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/outputs.ps1"
         }
         finally {
-          ${{ github.action_path }}/src/clean.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/clean.ps1"
         }
EOF
@@ -93,17 +93,18 @@
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
run: |
# ${{ inputs.Name }}
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
try {
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/info.ps1"
${{ inputs.Script }}
${{ github.action_path }}/src/outputs.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/outputs.ps1"
}
finally {
${{ github.action_path }}/src/clean.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/clean.ps1"
}
Copilot is powered by AI and may make mistakes. Always verify output.
${{ github.action_path }}/src/info.ps1

Check warning

Code scanning / CodeQL

Code injection

Potential code injection in [${{ github.action_path }}](1), which may be controlled by an external user.

Copilot Autofix

AI 10 months ago

General fix: avoid using ${{ ... }} expressions directly inside the run: script. Instead, assign those values to environment variables (or to action inputs that are already mapped to env vars), and inside the PowerShell script refer to them via $env:VAR or normal PowerShell variables. This follows GitHub’s recommended pattern and prevents the expression language from being mixed with shell syntax.

Concrete change here: we will add an environment variable (e.g. PSMODULE_GITHUB_ACTION_PATH) set to ${{ github.action_path }}, and then update the PowerShell script so it invokes the scripts via $env:PSMODULE_GITHUB_ACTION_PATH\src\*.ps1. That way, no ${{ ... }} appears inside the run: block for these paths, and CodeQL’s injection concern is removed, while functionality remains the same. We will not alter ${{ inputs.Script }} because the entire action is built around intentionally executing that content as PowerShell.

Changes to make in action.yml:

  • In the env: section of the RunGitHubScript step, add:
    • PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
  • In the run: script:
    • Replace:
      • ${{ github.action_path }}/src/init.ps1
      • ${{ github.action_path }}/src/info.ps1
      • ${{ github.action_path }}/src/outputs.ps1
      • ${{ github.action_path }}/src/clean.ps1
    • With proper PowerShell invocations that reference the environment variable, e.g.:
      • & "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
      • etc.

Using & ensures the script is actually executed as a PowerShell script even if the path contains spaces. All other behavior (inputs, outputs) remains unchanged.

No extra imports or external libraries are necessary; all changes are within action.yml.


Suggested changeset 1
action.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/action.yml b/action.yml
--- a/action.yml
+++ b/action.yml
@@ -93,17 +93,18 @@
         PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
         PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
         PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
+        PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
       run: |
         # ${{ inputs.Name }}
         $ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
         $DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
         $VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
         try {
-          ${{ github.action_path }}/src/init.ps1
-          ${{ github.action_path }}/src/info.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/info.ps1"
           ${{ inputs.Script }}
-          ${{ github.action_path }}/src/outputs.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/outputs.ps1"
         }
         finally {
-          ${{ github.action_path }}/src/clean.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/clean.ps1"
         }
EOF
@@ -93,17 +93,18 @@
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
run: |
# ${{ inputs.Name }}
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
try {
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/info.ps1"
${{ inputs.Script }}
${{ github.action_path }}/src/outputs.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/outputs.ps1"
}
finally {
${{ github.action_path }}/src/clean.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/clean.ps1"
}
Copilot is powered by AI and may make mistakes. Always verify output.
${{ inputs.Script }}
${{ github.action_path }}/scripts/outputs.ps1
${{ github.action_path }}/src/outputs.ps1

Check warning

Code scanning / CodeQL

Code injection

Potential code injection in [${{ github.action_path }}](1), which may be controlled by an external user.

Copilot Autofix

AI 10 months ago

General approach: Avoid embedding GitHub expression syntax (${{ ... }}) directly in the run: script where it becomes part of the PowerShell code. Instead, assign those values to environment variables (already done for inputs) or to step outputs, and then read and use them via native PowerShell syntax ($env:VAR, variables, & to invoke scripts). For script paths, construct them from a safe base directory in PowerShell rather than concatenating expression results into the script body.

Best concrete fix here:

  1. Add an environment variable (or variables) in the step’s env: section that captures github.action_path as a value, e.g. PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}.
  2. Update the PowerShell run: block so it does not contain ${{ github.action_path }} or ${{ inputs.Script }} directly. Instead:
    • Define a PowerShell variable $actionPath = $env:PSMODULE_GITHUB_ACTION_PATH.
    • Safely build the script paths using Join-Path $actionPath 'src/init.ps1', etc., and execute them via & (the call operator).
    • Move the user-supplied script out of the expression context: pass inputs.Script via an env var (e.g. PSMODULE_GITHUB_SCRIPT_INPUT_Script) and invoke it using PowerShell’s Invoke-Expression on that env var. This avoids GitHub expression injection; note that if inputs.Script itself is attacker-controlled PowerShell code, that is by design for this action (it runs arbitrary user PowerShell), so we only need to prevent extra commands being smuggled through the GitHub expression layer.
  3. Keep existing behavior: the same init, info, user script, outputs, and clean scripts still run in the same order; inputs already exposed via env remain unchanged.

Concretely, within action.yml we will:

  • Add a new env entry: PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}.
  • Add a new env entry for the script text: PSMODULE_GITHUB_SCRIPT_INPUT_Script: ${{ inputs.Script }}.
  • Replace the body of the run: block to:
    • Set $actionPath and $scriptToRun from the environment.
    • Use Join-Path and & to run init.ps1, info.ps1, the user script, outputs.ps1, and clean.ps1.

Suggested changeset 1
action.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/action.yml b/action.yml
--- a/action.yml
+++ b/action.yml
@@ -93,17 +93,23 @@
         PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
         PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
         PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
+        PSMODULE_GITHUB_SCRIPT_INPUT_Script: ${{ inputs.Script }}
+        PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
       run: |
         # ${{ inputs.Name }}
         $ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
         $DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
         $VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
+        $actionPath = $env:PSMODULE_GITHUB_ACTION_PATH
+        $scriptToRun = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Script
         try {
-          ${{ github.action_path }}/src/init.ps1
-          ${{ github.action_path }}/src/info.ps1
-          ${{ inputs.Script }}
-          ${{ github.action_path }}/src/outputs.ps1
+          & (Join-Path $actionPath 'src/init.ps1')
+          & (Join-Path $actionPath 'src/info.ps1')
+          if ($scriptToRun) {
+            Invoke-Expression $scriptToRun
+          }
+          & (Join-Path $actionPath 'src/outputs.ps1')
         }
         finally {
-          ${{ github.action_path }}/src/clean.ps1
+          & (Join-Path $actionPath 'src/clean.ps1')
         }
EOF
@@ -93,17 +93,23 @@
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
PSMODULE_GITHUB_SCRIPT_INPUT_Script: ${{ inputs.Script }}
PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
run: |
# ${{ inputs.Name }}
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
$actionPath = $env:PSMODULE_GITHUB_ACTION_PATH
$scriptToRun = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Script
try {
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1
${{ inputs.Script }}
${{ github.action_path }}/src/outputs.ps1
& (Join-Path $actionPath 'src/init.ps1')
& (Join-Path $actionPath 'src/info.ps1')
if ($scriptToRun) {
Invoke-Expression $scriptToRun
}
& (Join-Path $actionPath 'src/outputs.ps1')
}
finally {
${{ github.action_path }}/src/clean.ps1
& (Join-Path $actionPath 'src/clean.ps1')
}
Copilot is powered by AI and may make mistakes. Always verify output.
}
finally {
${{ github.action_path }}/scripts/clean.ps1
${{ github.action_path }}/src/clean.ps1

Check warning

Code scanning / CodeQL

Code injection

Potential code injection in [${{ github.action_path }}](1), which may be controlled by an external user.

Copilot Autofix

AI 10 months ago

In general, to fix this type of issue in GitHub Actions, any value coming from a GitHub expression (${{ ... }}), whether or not it is attacker-controlled, should be assigned to an environment variable and then referenced using the shell’s native syntax ($VAR in PowerShell) inside the run: block. This avoids the risk of expression-based code injection inside scripts.

For this file, the safest, minimal-change fix is:

  1. Define an environment variable (for example, ACTION_PATH) in the env: section with the value ${{ github.action_path }}.
  2. Replace all usages of ${{ github.action_path }} in the run: script with $env:ACTION_PATH, which is standard PowerShell syntax for environment variables.
  3. Leave ${{ inputs.Script }} as-is, because that is the intended script content input to the action; the CodeQL report specifically targets the github.action_path expression.

Concretely, within action.yml:

  • Under env: for the RunGitHubScript step, add a line ACTION_PATH: ${{ github.action_path }} (or similarly named variable).
  • In the run: block, change:
    • ${{ github.action_path }}/src/init.ps1 → $env:ACTION_PATH/src/init.ps1
    • ${{ github.action_path }}/src/info.ps1 → $env:ACTION_PATH/src/info.ps1
    • ${{ github.action_path }}/src/outputs.ps1 → $env:ACTION_PATH/src/outputs.ps1
    • ${{ github.action_path }}/src/clean.ps1 → $env:ACTION_PATH/src/clean.ps1

No additional imports or external libraries are needed; this is purely a YAML and PowerShell syntax adjustment.

Suggested changeset 1
action.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/action.yml b/action.yml
--- a/action.yml
+++ b/action.yml
@@ -93,17 +93,18 @@
         PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
         PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
         PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
+        ACTION_PATH: ${{ github.action_path }}
       run: |
         # ${{ inputs.Name }}
         $ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
         $DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
         $VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
         try {
-          ${{ github.action_path }}/src/init.ps1
-          ${{ github.action_path }}/src/info.ps1
+          $env:ACTION_PATH/src/init.ps1
+          $env:ACTION_PATH/src/info.ps1
           ${{ inputs.Script }}
-          ${{ github.action_path }}/src/outputs.ps1
+          $env:ACTION_PATH/src/outputs.ps1
         }
         finally {
-          ${{ github.action_path }}/src/clean.ps1
+          $env:ACTION_PATH/src/clean.ps1
         }
EOF
@@ -93,17 +93,18 @@
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
ACTION_PATH: ${{ github.action_path }}
run: |
# ${{ inputs.Name }}
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
try {
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1
$env:ACTION_PATH/src/init.ps1
$env:ACTION_PATH/src/info.ps1
${{ inputs.Script }}
${{ github.action_path }}/src/outputs.ps1
$env:ACTION_PATH/src/outputs.ps1
}
finally {
${{ github.action_path }}/src/clean.ps1
$env:ACTION_PATH/src/clean.ps1
}
Copilot is powered by AI and may make mistakes. Always verify output.
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.