-
Notifications
You must be signed in to change notification settings - Fork 5.6k
adds a windows-specific method to check if a command is safe #4119
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
Conversation
All contributors have signed the CLA ✍️ ✅ |
19aedc5
to
6561d4c
Compare
I have read the CLA Document and I hereby sign the CLA |
04aaa69
to
9c2223d
Compare
This reverts commit 7035522.
9c2223d
to
13f0876
Compare
#[test] | ||
fn everything_is_unsafe() { | ||
for cmd in [ | ||
vec_str(&["powershell.exe", "-NoLogo", "-Command", "echo hello"]), |
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.
I know this is a WIP, but wouldn't this be safe?
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, this is more just meant to test the current "everything is unsafe" behavior. It'll change shortly
return true; | ||
} | ||
} | ||
|
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.
This is making me question whether we should be doing is_safe_to_call_with_exec()
as it works today on Windows. Possibly only if you have Git Bash enabled or whatever it is on Windows and we're actually going to run the command through it? What do you think?
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.
I originally had a version where only the new windows function is called and nothing after it. But there are some tests that are depending on the other safety checks being called (ie, Windows tests that use commands such as "ls"
). I'm not sure if those tests are valid, but I left this for now to be conservative and not regress anything until I can learn more
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.
ls works in PowerShell by default, apparently. It works in cmd.exe on my machine, but probably due to Git Bash.
refactors command_safety files into its own package, so we can add platform-specific ones
Also creates a windows-specific of
is_known_safe_command
that just returns false always, since that is what happens today.