mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

When the file isn't world-readable, `brew audit` prints a failure message including a suggestion to `chmod +r` the file. Unfortunately, this isn't quite right: with both macOS and coreutils, leaving out the "who" in a chmod only affects bits which would be set in the umask. So, if the umask doesn't allow world-readable (which might be why the file wasn't world-readable in the first place), the suggested chmod command does nothing. Change to print `chmod a+r` instead; that does have the intended effect. No other `chmod` suggestions in this file have the same problem.
24 lines
660 B
Ruby
24 lines
660 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rubocops/files"
|
|
|
|
RSpec.describe RuboCop::Cop::FormulaAudit::Files do
|
|
subject(:cop) { described_class.new }
|
|
|
|
context "when auditing files" do
|
|
it "reports an offense when the permissions are invalid" do
|
|
filename = Formulary.core_path("test_formula")
|
|
File.open(filename, "w") do |file|
|
|
FileUtils.chmod "-rwx", filename
|
|
|
|
expect_offense(<<~RUBY, file)
|
|
class Foo < Formula
|
|
^^^^^^^^^^^^^^^^^^^ FormulaAudit/Files: Incorrect file permissions (000): chmod a+r #{filename}
|
|
url "https://brew.sh/foo-1.0.tgz"
|
|
end
|
|
RUBY
|
|
end
|
|
end
|
|
end
|
|
end
|