-
Notifications
You must be signed in to change notification settings - Fork 13
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
Work around Windows bug where arguments are not properly quoted #3389
Conversation
cmd/state-exec/cmd_windows.go
Outdated
func Command(name string, arg ...string) *exec.Cmd { | ||
cmd := exec.Command(name, arg...) | ||
|
||
// Go currently does not escape arguments properly on Windows, it account for spaces and tab characters, but not | ||
// other characters that need escaping such as `<` and `>`. | ||
// This can be dropped once we update to a Go version that fixes this bug: https://github.com/golang/go/issues/68313 | ||
cmd.SysProcAttr = &syscall.SysProcAttr{CmdLine: makeCmdLine(cmd.Args)} | ||
|
||
return cmd | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this is purposely duplicating logic in osutils, because a design principle behind executors is that we avoid reusing internal libraries so as to keep the executable as lightweight as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I've accidentally included things that blew up the exe size. Fortunately we have a test to catch it 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work, and nice digging!
// For this test we don't care about the svc communication. | ||
env := e2e.OptAppendEnv("ACTIVESTATE_CI=false") | ||
|
||
inputs := []string{"a<b", "b>a", "hello world", "&whoami", "imnot|apipe", "%NotAppData%", "^NotEscaped", "(NotAGroup)"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a nice set of test inputs!
This works around a Go bug, which was filed here: golang/go#68313, and marked as duplicate of golang/go#15566, which was first reported nearly a decade ago (!!!). So rather than wait for a fix we're just going to work around it.