Skip to content
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

Don't use unsafe functions from SwiftCLI #227

Open
Cyberbeni opened this issue Nov 30, 2021 · 1 comment
Open

Don't use unsafe functions from SwiftCLI #227

Cyberbeni opened this issue Nov 30, 2021 · 1 comment

Comments

@Cyberbeni
Copy link

Cyberbeni commented Nov 30, 2021

For example this:

let tagOutput = try Task.capture(bash: "git ls-remote --tags --refs \(package.gitPath)")

Has a warning that it is unsafe: https://github.com/jakeheis/SwiftCLI/blob/2e949055d9797c1a6bddcda0e58dada16cc8e970/Sources/SwiftCLI/Task.swift#L262

And it could be written like this:

Task.capture("/usr/bin/git", "ls-remote", "--tags", "--refs", package.gitPath)

I don't know if any of the commands can be set up to do RCE but there is no reason to take any chances with it when there are functions that take arguments in a string array instead of in a single string separated by spaces. (The linked code probably doesn't even work if you have a space somewhere in the gitPath)

@Cyberbeni
Copy link
Author

Or if we want to prepare for different locations for git then Task.capture(bash: "which git") would be safe to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant