[brew audit] fix "Incorrect file permissions" message

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.
This commit is contained in:
Jade Elizabeth Sailor 2024-02-20 16:06:36 -05:00
parent 14ba271533
commit 94aeabfc8a
2 changed files with 2 additions and 2 deletions

View File

@ -22,7 +22,7 @@ module RuboCop
if actual_mode & 0444 != 0444 if actual_mode & 0444 != 0444
problem format("Incorrect file permissions (%03<actual>o): chmod %<wanted>s %<path>s", problem format("Incorrect file permissions (%03<actual>o): chmod %<wanted>s %<path>s",
actual: actual_mode & 0777, actual: actual_mode & 0777,
wanted: "+r", wanted: "a+r",
path: file_path) path: file_path)
end end
# Check that the file is user-writeable. # Check that the file is user-writeable.

View File

@ -13,7 +13,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::Files do
expect_offense(<<~RUBY, file) expect_offense(<<~RUBY, file)
class Foo < Formula class Foo < Formula
^^^^^^^^^^^^^^^^^^^ FormulaAudit/Files: Incorrect file permissions (000): chmod +r #{filename} ^^^^^^^^^^^^^^^^^^^ FormulaAudit/Files: Incorrect file permissions (000): chmod a+r #{filename}
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
end end
RUBY RUBY