Repository navigation
sync gemini cli 0.1.15 - #175
Conversation
…ocessing the list directly ourselves. (#3600)
Co-authored-by: Scott Densmore <scottdensmore@mac.com>
Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com> Co-authored-by: Aryan Sawant <156219699+aryanjsawant@users.noreply.github.com> Co-authored-by: neo.alienson <neo@01man.com>
Co-authored-by: Jacob Richman <jacob314@gmail.com>
Co-authored-by: matt korwel <matt.korwel@gmail.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>
#3863) Co-authored-by: Ioannis Papapanagiotou <iduckhd@hotmail.com>
Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
Co-authored-by: matt korwel <matt.korwel@gmail.com> Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com>
Co-authored-by: matt korwel <matt.korwel@gmail.com>
Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
Co-authored-by: matt korwel <matt.korwel@gmail.com>
Co-authored-by: Your Name <you@example.com>
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
| // wrap command to append subprocess pids (via pgrep) to temporary file | ||
| let command = strippedCommand.trim(); | ||
| if (!command.endsWith('&')) command += ';'; | ||
| return `{ ${command} }; __code=$?; pgrep -g 0 >${tempFilePath} 2>&1; exit $__code;`; |
Check warning
Code scanning / CodeQL
Unsafe shell command constructed from library input
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI over 1 year ago
To fix the problem, we should ensure that any user-controlled input embedded in a shell command string is properly escaped or quoted to prevent shell injection. Since the shell command string must be interpreted by the shell (due to the use of pipes, redirection, and command grouping), we cannot switch to execFile with argument arrays. Instead, we should use a library like shell-quote to safely quote the strippedCommand before embedding it in the shell command string. This involves importing shell-quote, and replacing the direct embedding of command in line 210 with a safely quoted version. Only the region where the shell command string is constructed (lines 208–211) needs to be changed, along with the necessary import for shell-quote.
| @@ -10,2 +10,3 @@ | ||
| import crypto from 'crypto'; | ||
| import shellQuote from 'shell-quote'; | ||
| import { Config } from '../config/config.js'; | ||
| @@ -207,5 +208,5 @@ | ||
| // wrap command to append subprocess pids (via pgrep) to temporary file | ||
| let command = strippedCommand.trim(); | ||
| if (!command.endsWith('&')) command += ';'; | ||
| return `{ ${command} }; __code=$?; pgrep -g 0 >${tempFilePath} 2>&1; exit $__code;`; | ||
| // Safely quote the command to prevent shell injection | ||
| const quotedCommand = shellQuote.quote([strippedCommand.trim()]); | ||
| return `{ ${quotedCommand}; }; __code=$?; pgrep -g 0 >${tempFilePath} 2>&1; exit $__code;`; | ||
| })(); |
| let url = urls[0]; | ||
|
|
||
| // Convert GitHub blob URL to raw URL | ||
| if (url.includes('github.com') && url.includes('/blob/')) { |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI over 1 year ago
To fix the problem, we should parse the URL and check the hostname explicitly, rather than using a substring check. Specifically, we should use the URL constructor (built-in in Node.js and browsers) to parse the URL and then check if the hostname is exactly 'github.com' (or, if desired, allow specific subdomains). Only if the hostname matches should we perform the GitHub blob-to-raw URL conversion. This change should be made in the executeFallback method, specifically replacing the logic at lines 108–112. We will also need to handle the case where the URL is invalid and cannot be parsed.
| @@ -107,6 +107,12 @@ | ||
| // Convert GitHub blob URL to raw URL | ||
| if (url.includes('github.com') && url.includes('/blob/')) { | ||
| url = url | ||
| .replace('github.com', 'raw.githubusercontent.com') | ||
| .replace('/blob/', '/'); | ||
| try { | ||
| const parsedUrl = new URL(url); | ||
| if (parsedUrl.hostname === 'github.com' && parsedUrl.pathname.includes('/blob/')) { | ||
| // Convert to raw.githubusercontent.com URL | ||
| parsedUrl.hostname = 'raw.githubusercontent.com'; | ||
| parsedUrl.pathname = parsedUrl.pathname.replace('/blob/', '/'); | ||
| url = parsedUrl.toString(); | ||
| } | ||
| } catch (e) { | ||
| // If URL parsing fails, proceed without conversion | ||
| } |
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
…cli-0.1.15 sync gemini cli 0.1.15
TLDR
Dive Deeper
Reviewer Test Plan
Testing Matrix
Linked issues / bugs