-
Notifications
You must be signed in to change notification settings - Fork 1
fix: Node release custom package path #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7d965e5
parametrized package path
mamari90 7f654f0
parametrized package path
mamari90 c16d60a
updated readme
mamari90 01dcbbc
Potential fix for code scanning alert no. 135: Code injection
mamari90 663ab60
Potential fix for code scanning alert no. 135: Code injection
mamari90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,11 @@ | |
| type: boolean | ||
| description: True to create only the Tag without the Release | ||
| default: false | ||
| package_path: | ||
| required: false | ||
| type: string | ||
| description: Path leading to package.json file | ||
| default: "./" | ||
|
|
||
|
|
||
| outputs: | ||
|
|
@@ -69,11 +74,13 @@ | |
|
|
||
| - id: get_version | ||
| name: Get Version | ||
| env: | ||
| PACKAGE_PATH: ${{ inputs.package_path }} | ||
| run: | | ||
| PACKAGE_FILE="package.json" | ||
| PACKAGE_FILE="${PACKAGE_PATH}package.json" | ||
| if [[ -f "$PACKAGE_FILE" ]]; then | ||
| echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | ||
| echo "version=$(node -p "require('${PACKAGE_PATH}package.json').version")" >> $GITHUB_ENV | ||
| fi | ||
Check warningCode scanning / CodeQL Environment variable built from user-controlled sources Medium
Potential environment variable injection in
PACKAGE_FILE="${PACKAGE_PATH}package.json"if [[ -f "$PACKAGE_FILE" ]]; thenecho "version=$(node -p "require('${PACKAGE_PATH}package.json').version")" >> $GITHUB_ENVfi Error loading related location Loading |
||
| shell: bash | ||
|
|
||
| - name: Bump Package Version | ||
|
|
@@ -100,9 +107,11 @@ | |
| - name: Push New Version | ||
| if: ${{ inputs.semver != 'skip' }} | ||
| shell: bash | ||
| env: | ||
| PACKAGE_PATH: ${{ inputs.package_path }} | ||
| run: | | ||
| 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 | ||
|
|
||
| git add . | ||
| git config --global user.email "[email protected]" | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Code injection Medium
Copilot Autofix
AI 30 days 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 theenv: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".env:block to includeNEW_VERSION: ${{ steps.semver.outputs.new_version }}.$NEW_VERSIONwithin single quotes in thejqcommand:jq '.version = "'$NEW_VERSION'"' ....