fix(security): require approved bot patch artifacts#28178
Conversation
Summary of ChangesHello, 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 security gate for the Gemini CLI bot's patch publishing process. By requiring an explicit approval marker, the system ensures that only validated changes are consumed by the publish job. Additionally, the changes improve the reliability of the bot by ensuring that rejected critique runs clean up any stale artifacts, maintaining a secure and predictable state. Highlights
Ignored Files
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 the 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 counterproductive. 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. Footnotes
|
|
📊 PR Size: size/M
|
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request introduces a new test suite, gemini-cli-bot-brain-workflow.test.ts, to validate the behavior of the gemini-cli-bot-brain.yml GitHub workflow. The tests cover scenarios such as removing stale patch artifacts on rejection, creating publishable patch markers on approval, and verifying approval requirements. The feedback recommends normalizing CRLF line endings to LF when reading the workflow file to ensure the tests run reliably on Windows environments.
| const workflow = fs.readFileSync(workflowPath, 'utf8'); | ||
| const match = workflow.match( | ||
| /^[ ]{6}- name: 'Generate Patch'[\s\S]*?^[ ]{8}run: \|\n([\s\S]*?)\n\n^[ ]{6}- name: 'Archive Brain Data'/m, | ||
| ); |
There was a problem hiding this comment.
The workflow file regex match and line splitting can fail on Windows environments if the repository is checked out with CRLF (\r\n) line endings. Normalizing the file content to use LF (\n) before matching ensures the test is robust and cross-platform.
| const workflow = fs.readFileSync(workflowPath, 'utf8'); | |
| const match = workflow.match( | |
| /^[ ]{6}- name: 'Generate Patch'[\s\S]*?^[ ]{8}run: \|\n([\s\S]*?)\n\n^[ ]{6}- name: 'Archive Brain Data'/m, | |
| ); | |
| const workflow = fs.readFileSync(workflowPath, 'utf8').replace(/\r\n/g, '\n'); | |
| const match = workflow.match( | |
| /^[ ]{6}- name: 'Generate Patch'[\s\S]*?^[ ]{8}run: \|\n([\s\S]*?)\n\n^[ ]{6}- name: 'Archive Brain Data'/m, | |
| ); |
There was a problem hiding this comment.
Addressed in cfd0a59 by normalizing CRLF to LF before matching and extracting the workflow script. I also validated the CRLF extraction path locally.
d24ea4c to
7251fdc
Compare
7251fdc to
cfd0a59
Compare
Summary
Require an explicit approval marker before the Gemini CLI bot publish job consumes
bot-changes.patch.This keeps the reasoning-to-publish boundary fail-closed: rejected critique runs now remove stale PR artifacts, and the publish job only applies a non-empty patch when it is paired with a marker generated after approval.
Testing
node ./node_modules/prettier/bin/prettier.cjs --check .github/workflows/gemini-cli-bot-brain.yml scripts/tests/gemini-cli-bot-brain-workflow.test.tsnode ./node_modules/eslint/bin/eslint.js scripts/tests/gemini-cli-bot-brain-workflow.test.tsnode ./node_modules/vitest/vitest.mjs run --config ./scripts/tests/vitest.config.ts scripts/tests/gemini-cli-bot-brain-workflow.test.ts --pool forks --poolOptions.forks.singleForknode scripts/lint.js --actionlint