Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
| contents="$(jq '.version = "${{ steps.semver.outputs.new_version }}"' package.json)" | ||
| echo -E "${contents}" > package.json | ||
| contents="$(jq '.version = "${{ steps.semver.outputs.new_version }}"' ${PACKAGE_PATH}package.json)" | ||
| echo -E "${contents}" > ${PACKAGE_PATH}package.json |
Check warning
Code scanning / CodeQL
Code injection Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
The best way to fix this problem is to avoid directly interpolating untrusted values (such as ${{ steps.semver.outputs.new_version }}) into shell scripts or commands, especially when using double quotes or here-documents. Instead, assign expressions like ${{ steps.semver.outputs.new_version }} to an environment variable using the env: block, and then reference that variable within your shell script using the shell's native syntax (e.g., $NEW_VERSION). This prevents shell interpretation of potentially malicious input and adheres to GitHub's safe usage guidelines.
Specifically, in file node-release/action.yml, edit the block for "Push New Version".
- In the step starting at line 107, update the
env:block to includeNEW_VERSION: ${{ steps.semver.outputs.new_version }}. - Then, update line 113 to reference
$NEW_VERSIONwithin single quotes in thejqcommand:jq '.version = "'$NEW_VERSION'"' ....
| @@ -109,17 +109,18 @@ | ||
| shell: bash | ||
| env: | ||
| PACKAGE_PATH: ${{ inputs.package_path }} | ||
| NEW_VERSION: ${{ steps.semver.outputs.new_version }} | ||
| run: | | ||
| contents="$(jq '.version = "${{ steps.semver.outputs.new_version }}"' ${PACKAGE_PATH}package.json)" | ||
| contents="$(jq '.version = "'$NEW_VERSION'"' ${PACKAGE_PATH}package.json)" | ||
| echo -E "${contents}" > ${PACKAGE_PATH}package.json | ||
|
|
||
| git add . | ||
| git config --global user.email "github-bot@pagopa.it" | ||
| git config --global user.name "pagopa-github-bot" | ||
| if [ "${{ inputs.skip_ci }}" = "true" ]; then | ||
| git commit -m "Bump to version ${{ steps.semver.outputs.new_version }} [skip ci]" || exit 0 | ||
| git commit -m "Bump to version $NEW_VERSION [skip ci]" || exit 0 | ||
| else | ||
| git commit -m "Bump to version ${{ steps.semver.outputs.new_version }}" || exit 0 | ||
| git commit -m "Bump to version $NEW_VERSION" || exit 0 | ||
| fi | ||
| git push origin ${{ github.ref_name}} | ||
|
|
|
🎉 This PR is included in version 2.3.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
List of Changes
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: