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

Doubledash hygiene for external commands #2613

Merged
merged 13 commits into from
Feb 4, 2014

Conversation

rolandwalker
Copy link
Contributor

Many Unix utilities follow the convention of doubledash (--) to segregate
filenames/branchnames/usernames, etc from flags. For example, if you wish
to delete a file named -f, you can say

rm -- -f

Everything to the right side of doubledash is read by rm as a filename.
Using doudbledash is best practice whenever calling Unix utilities
programatically. It does lower the attack surface for malicious inputs, but
the main benefit is avoiding unintended consequences from legitimate inputs.

In cases where a flag takes an argument, eg tar -f <file>, there is no
ambiguity about <file>, and doubledash or other tricks are not needed.

For reference, here are various examples of command forms which
accept doubledash. This PR audits homebrew-cask for all of those listed,
though some of them may not have been present.

Other commands exist which do not support doubledash, for which a separate
PR will follow.

This is a followup to #2595, and is relevant to #2556, though it does not itself fix that bug.

rolandwalker added a commit that referenced this pull request Feb 4, 2014
Doubledash hygiene for external commands
@rolandwalker rolandwalker merged commit 15d1fe8 into Homebrew:master Feb 4, 2014
@rolandwalker rolandwalker deleted the double_dash branch February 4, 2014 01:00
rolandwalker added a commit to rolandwalker/homebrew-cask that referenced this pull request Feb 4, 2014
For external commands which do not support the doubledash convention
(Homebrew#2613), wrap file arguments in Pathname.new(file).realpath at the
very last minute.  This provides a guarantee against surprises caused
by unusual filenames which might be misinterpreted as flags.
@Homebrew Homebrew locked and limited conversation to collaborators May 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant