Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replace Runtime.exec with ProcessBuilder to prevent shell metacharacter expansion#307

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge2 commits intomaster
base:master
Choose a base branch
Loading
fromcopilot/fix-cmdshell-escaping-issue

Conversation

Copy link
Contributor

CopilotAI commentedNov 9, 2025
edited
Loading

Shell implementations (CmdShell, BourneShell, CommandShell) cannot escape metacharacters like*,?,[] in arguments. Passing a passwordS8p3r*S3cr3t causes the shell to expand the asterisk, making it impossible to pass literal wildcards.

Changes

Core execution path

  • ModifiedCommandline.execute() to useProcessBuilder instead ofRuntime.getRuntime().exec()
  • Changed from shell-wrapped command line to direct execution viagetRawCommandline()
  • Environment variables now set viaProcessBuilder.environment() map
  • Working directory set viaProcessBuilder.directory()

Test coverage

  • Added tests verifying asterisk and question mark arguments are preserved literally

Impact

Commands execute directly without shell interpretation. Shell features (pipes, redirects, glob expansion) no longer work through this API.

// Before: asterisk expanded by shellCommandlinecmd =newCommandline();cmd.setExecutable("echo");cmd.createArg().setValue("S8p3r*S3cr3t");// Would list matching files// After: asterisk preserved literallycmd.execute();// Outputs: S8p3r*S3cr3t

Fixes SCM-763.

Original prompt

This section details on the original issue you should resolve

<issue_title>CmdShell does not escape asterisk arg value (SCM-763)</issue_title>
<issue_description>This was found during SCM-763.

Consider your want to pass a password (on Windows) with asterisk:S8p3r*S3cr3t. The escaped outcome isS8p3r*S3cr3t. No change, but to pass an asterisk you need to quote the entire string otherwise the shell will expand the asterisk. Correct value would be:"S8p3r*S3cr3t"

Currently, this is impossible in Plexus Utils.</issue_description>

Comments on the Issue (you are @copilot in this section)

@michael-oYes, it is. The entire process execution suffers from one serious flaw that it executes a local shell rather than providing it to the system directory. The shell will do its own replacement which hasn't been espaced by this implementation.@slachiewiczIs it worth keeping the issue open? Any idea how this should be fixed?@michael-o> Is it worth keeping the issue open? Any idea how this should be fixed?

Yes, because the shell invocation needs to be dropped altogether.</comment_new>
<comment_new>@slachiewicz
Should be fixed here or deprecated here CmdShell and fix it properly on SCM?</comment_new>
<comment_new>@michael-o

Should be fixed here or deprecated here CmdShell and fix it properly on SCM?

Completely here replace all shell impls with ProcessBuilder </comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.

CopilotAI self-assigned thisNov 9, 2025
…xpansionCo-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
CopilotAI changed the title[WIP] Fix asterisk argument escaping in CmdShellReplace Runtime.exec with ProcessBuilder to prevent shell metacharacter expansionNov 9, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@slachiewiczslachiewiczAwaiting requested review from slachiewicz

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

CmdShell does not escape asterisk arg value (SCM-763)

1 participant

@slachiewicz

[8]ページ先頭

©2009-2025 Movatter.jp