fix(tools): use execFile instead of exec to avoid shell injection#5197
fix(tools): use execFile instead of exec to avoid shell injection#5197marcoscaceres wants to merge 9 commits intomainfrom
Conversation
|
@copilot see the CI error about the commit message. Can you fix that please? |
Fixed in commits 593763c and c81e958. Two issues were addressed:
Note: the PR title still shows the original non-conventional text. Since I can't update the PR title directly, you may need to edit it manually to something like |
…m environment values Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Agent-Logs-Url: https://github.com/speced/respec/sessions/cf64d910-0bb6-4b8e-8a7b-e6ebd7300833 Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Agent-Logs-Url: https://github.com/speced/respec/sessions/cf64d910-0bb6-4b8e-8a7b-e6ebd7300833 Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Replace the hand-rolled splitArgs regex parser with direct array construction. The regex failed on paths with spaces (e.g. vnu-jar path) and was unnecessary complexity for static command strings.
ea33e47 to
3460e17
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the tools/release.cjs release script to avoid shell injection by switching from child_process.exec() (shell command string) to child_process.execFile() (explicit executable + argv array).
Changes:
- Replace
execwithexecFileintools/release.cjs. - Refactor
commandRunner()to build an argv array and calltoExecFilePromise()instead of interpolating a shell command string. - Update the HTML validator invocation to run
javawith-jaras explicit args.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…h spaces Agent-Logs-Url: https://github.com/speced/respec/sessions/5d94d008-6cad-43d1-89d6-8907cf192c39 Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Agent-Logs-Url: https://github.com/speced/respec/sessions/5d94d008-6cad-43d1-89d6-8907cf192c39 Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
|
@copilot can you check ci and fix the issue? |
The CI failure is in |
All call sites now pass arrays. The string split path was dead code that could silently break on spaced arguments.
Potential fix for https://github.com/speced/respec/security/code-scanning/47
Use
child_process.execFile()(orspawn) with an explicit executable and argument array, instead ofexec()with a single interpolated shell command string.Best minimal fix in this file:
execimport withexecFile.commandRunner(program)so it tokenizes the staticprogramonce (e.g.,"java -jar <path>"), then combines those tokens with parsedcmdtokens, and calls a newtoExecFilePromise(file, args, options).toExecPromise(cmd, ...)withtoExecFilePromise(file, args, ...)that callsexecFile(file, args, ...).This removes shell interpretation while preserving current functionality in
tools/release.cjs.Suggested fixes powered by Copilot Autofix. Review carefully before merging.