-
Notifications
You must be signed in to change notification settings - Fork 0
fix(crab-pf): replace broken verify with smoke+session test, add session handling #32
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
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
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
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
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
Unsafe shell command constructed from library input Medium
Copilot Autofix
AI about 13 hours ago
In general, to fix this kind of issue you should avoid invoking a shell with a dynamically constructed command string containing untrusted data. Instead, use the
child_processAPIs that accept a command and an argument array (execFile,spawn, orexecSyncwith thecmdandargsform) and pass the untrusted value as an argument or configuration option (likecwd) that is not interpreted by the shell. If you truly must use a shell, you need to robustly escape the untrusted value with a library such asshell-quote, but the safer approach here is to eliminate the shell usage.The single best way to fix this specific case without changing the intended behavior is to stop constructing and executing
cd "${outputDir}" && npm install --silent 2>&1as a shell command string. Instead, we can runnpmdirectly and let Node handle the working directory via thecwdoption. For synchronous execution,execSyncalready supports an argument-array form:execSync(command, args?, options?). We can replace the existing call withexecSync('npm', ['install', '--silent'], { cwd: outputDir, timeout: 60000, encoding: 'utf-8' });. This preserves the same effect—runningnpm install --silentinoutputDirwith the same timeout and encoding settings—while ensuring thatoutputDiris only used as a directory path, not as part of a shell command. No additional imports are necessary, asexecSyncis already imported fromnode:child_process. The change is localized to theexecuteToolfunction around line 290 inplugins/promptfoo/src/agent/loop.ts.Concretely:
plugins/promptfoo/src/agent/loop.ts, locate theexecSynccall on lines 290–293.outputDirwith the safer argument-array form and passoutputDirthrough thecwdoption.try/catchstructure and behavior (ignore install errors) unchanged.