Refactor Github Action per b/485167538#19341
Conversation
|
Hi @google-admin, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this. We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines. Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed. Thank you for your understanding and for being a part of our community! |
|
Hi there! Thank you for your contribution to Gemini CLI. To improve our contribution process and better track changes, we now require all pull requests to be associated with an existing issue, as announced in our recent discussion and as detailed in our CONTRIBUTING.md. This pull request is being closed because it is not currently linked to an issue. Once you have updated the description of this PR to link an issue (e.g., by adding How to link an issue: Thank you for your understanding and for being a part of our community! |
Summary of ChangesHello @google-admin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a standardized refactoring across several custom GitHub Actions. The primary goal is to improve the robustness and security of these actions by modifying how input parameters are accessed within shell scripts. Instead of directly embedding input values, they are now explicitly passed as environment variables, aligning with best practices for GitHub Actions development and mitigating potential issues. Highlights
Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is an automated refactoring to improve the security of your GitHub Actions by replacing direct context access in run scripts with environment variables, a good practice to prevent shell injection. However, a critical issue has been identified: in several instances, the new environment variables are used unquoted within the shell scripts, which re-introduces potential command injection vulnerabilities if the inputs contain shell metacharacters. Additionally, one instance of incomplete refactoring was found, leaving direct input access in a script. Recommendations have been provided to properly quote variables and complete the refactoring.
| --workspace="${INPUTS_CORE_PACKAGE_NAME}" \ | ||
| --no-tag | ||
| npm dist-tag rm ${{ inputs.core-package-name }} false --silent | ||
| npm dist-tag rm ${INPUTS_CORE_PACKAGE_NAME} false --silent |
There was a problem hiding this comment.
The environment variable INPUTS_CORE_PACKAGE_NAME is used unquoted in a shell script. If the corresponding input contains shell metacharacters (e.g., ;, &, |), an attacker could execute arbitrary commands in the context of the GitHub Actions runner. Always wrap environment variables in double quotes when using them in shell scripts.
npm dist-tag rm "${INPUTS_CORE_PACKAGE_NAME}" false --silent| --workspace="${INPUTS_CLI_PACKAGE_NAME}" \ | ||
| --no-tag | ||
| npm dist-tag rm ${{ inputs.cli-package-name }} false --silent | ||
| npm dist-tag rm ${INPUTS_CLI_PACKAGE_NAME} false --silent |
| --workspace="${INPUTS_A2A_PACKAGE_NAME}" \ | ||
| --no-tag | ||
| npm dist-tag rm ${{ inputs.a2a-package-name }} false --silent | ||
| npm dist-tag rm ${INPUTS_A2A_PACKAGE_NAME} false --silent |
| run: |- | ||
| npm run build:sandbox -- \ | ||
| --image google/gemini-cli-sandbox:${{ steps.image_tag.outputs.FINAL_TAG }} \ | ||
| --image google/gemini-cli-sandbox:${STEPS_IMAGE_TAG_OUTPUTS_FINAL_TAG} \ |
| run: |- | ||
| echo ""@google-gemini:registry=https://npm.pkg.github.com"" > ~/.npmrc | ||
| echo ""//npm.pkg.github.com/:_authToken=${{ inputs.github-token }}"" >> ~/.npmrc | ||
| echo ""//npm.pkg.github.com/:_authToken=${INPUTS_GITHUB_TOKEN}"" >> ~/.npmrc |
There was a problem hiding this comment.
| working-directory: '${{ inputs.working-directory }}' | ||
| run: | | ||
| npm dist-tag add ${{ inputs.core-package-name }}@${{ inputs.version }} ${{ inputs.channel }} | ||
| npm dist-tag add ${INPUTS_CORE_PACKAGE_NAME}@${INPUTS_VERSION} ${INPUTS_CHANNEL} |
| working-directory: '${{ inputs.working-directory }}' | ||
| run: | | ||
| npm dist-tag add ${{ inputs.cli-package-name }}@${{ inputs.version }} ${{ inputs.channel }} | ||
| npm dist-tag add ${INPUTS_CLI_PACKAGE_NAME}@${INPUTS_VERSION} ${INPUTS_CHANNEL} |
| working-directory: '${{ inputs.working-directory }}' | ||
| run: | | ||
| npm dist-tag add ${{ inputs.a2a-package-name }}@${{ inputs.version }} ${{ inputs.channel }} | ||
| npm dist-tag add ${INPUTS_A2A_PACKAGE_NAME}@${INPUTS_VERSION} ${INPUTS_CHANNEL} |
| if: "${{ inputs.dry-run != 'true' && inputs.skip-github-release != 'true' && inputs.npm-tag != 'dev' && inputs.npm-registry-url != 'https://npm.pkg.github.com/' }}" | ||
| env: | ||
| GITHUB_TOKEN: '${{ inputs.github-token }}' | ||
| INPUTS_RELEASE_TAG: ${{ inputs.release-tag }} | ||
| STEPS_RELEASE_BRANCH_OUTPUTS_BRANCH_NAME: ${{ steps.release_branch.outputs.BRANCH_NAME }} | ||
| INPUTS_PREVIOUS_TAG: ${{ inputs.previous-tag }} | ||
| shell: 'bash' | ||
| run: | | ||
| gh release create "${{ inputs.release-tag }}" \ | ||
| gh release create "${INPUTS_RELEASE_TAG}" \ | ||
| bundle/gemini.js \ | ||
| --target "${{ steps.release_branch.outputs.BRANCH_NAME }}" \ | ||
| --title "Release ${{ inputs.release-tag }}" \ | ||
| --notes-start-tag "${{ inputs.previous-tag }}" \ | ||
| --target "${STEPS_RELEASE_BRANCH_OUTPUTS_BRANCH_NAME}" \ | ||
| --title "Release ${INPUTS_RELEASE_TAG}" \ | ||
| --notes-start-tag "${INPUTS_PREVIOUS_TAG}" \ | ||
| --generate-notes \ | ||
| ${{ inputs.npm-tag != 'latest' && '--prerelease' || '' }} |
There was a problem hiding this comment.
This automated refactoring to improve security by using environment variables for inputs is incomplete. The inputs.npm-tag is still used directly within the run script, which goes against the pattern being applied in this PR.
To complete the refactoring, you should pass inputs.npm-tag as an environment variable and use shell logic to conditionally add the --prerelease flag.
if: "${{ inputs.dry-run != 'true' && inputs.skip-github-release != 'true' && inputs.npm-tag != 'dev' && inputs.npm-registry-url != 'https://npm.pkg.github.com/' }}"
env:
GITHUB_TOKEN: '${{ inputs.github-token }}'
INPUTS_RELEASE_TAG: ${{ inputs.release-tag }}
STEPS_RELEASE_BRANCH_OUTPUTS_BRANCH_NAME: ${{ steps.release_branch.outputs.BRANCH_NAME }}
INPUTS_PREVIOUS_TAG: ${{ inputs.previous-tag }}
INPUTS_NPM_TAG: ${{ inputs.npm-tag }}
shell: 'bash'
run: |
PRERELEASE_ARG=""
if [[ "$INPUTS_NPM_TAG" != "latest" ]]; then
PRERELEASE_ARG="--prerelease"
fi
gh release create "${INPUTS_RELEASE_TAG}" \
bundle/gemini.js \
--target "${STEPS_RELEASE_BRANCH_OUTPUTS_BRANCH_NAME}" \
--title "Release ${INPUTS_RELEASE_TAG}" \
--notes-start-tag "${INPUTS_PREVIOUS_TAG}" \
--generate-notes \
$PRERELEASE_ARG
This is a http://go/LSC run by http://go/ghss to automatically refactor your Github Actions per http://b/485167538.
This is a PR to help you upgrade to the latest standards in Github Actions.
Please merge this PR to accept the changes. NOTE: if you do not accept this PR, it may be force merged by the GHSS team. See http://b/485167538 for more details.