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

sandbox: sandbox all taps by default. #2898

Merged
merged 1 commit into from Jul 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions Library/Homebrew/sandbox.rb
Expand Up @@ -3,18 +3,14 @@

class Sandbox
SANDBOX_EXEC = "/usr/bin/sandbox-exec".freeze
SANDBOXED_TAPS = %w[
homebrew/core
].freeze

def self.available?
OS.mac? && OS::Mac.version >= "10.6" && File.executable?(SANDBOX_EXEC)
end

def self.formula?(formula)
def self.formula?(_formula)
return false unless available?
return false if ARGV.no_sandbox?
ARGV.sandbox? || SANDBOXED_TAPS.include?(formula.tap.to_s)
!ARGV.no_sandbox?
end

def self.test?
Expand Down
10 changes: 1 addition & 9 deletions Library/Homebrew/test/sandbox_spec.rb
Expand Up @@ -12,15 +12,7 @@

specify "#formula?" do
f = formula { url "foo-1.0" }
f2 = formula { url "bar-1.0" }
allow(f2).to receive(:tap).and_return(Tap.fetch("test/tap"))

ENV["HOMEBREW_SANDBOX"] = "1"
expect(described_class).to be_formula(f), "Formulae should be sandboxed if --sandbox was passed."

ENV.delete("HOMEBREW_SANDBOX")
expect(described_class).to be_formula(f), "Formulae should be sandboxed if in a sandboxed tap."
expect(described_class).not_to be_formula(f2), "Formulae should not be sandboxed if not in a sandboxed tap."
expect(described_class).to be_formula(f), "Formulae should be sandboxed."
end

specify "#test?" do
Expand Down