From 94aeabfc8a887d58d5e17a438cc54659ec6f7b43 Mon Sep 17 00:00:00 2001 From: Jade Elizabeth Sailor Date: Tue, 20 Feb 2024 16:06:36 -0500 Subject: [PATCH] [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. --- Library/Homebrew/rubocops/files.rb | 2 +- Library/Homebrew/test/rubocops/files_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/rubocops/files.rb b/Library/Homebrew/rubocops/files.rb index a27a37b6c0..33443232de 100644 --- a/Library/Homebrew/rubocops/files.rb +++ b/Library/Homebrew/rubocops/files.rb @@ -22,7 +22,7 @@ module RuboCop if actual_mode & 0444 != 0444 problem format("Incorrect file permissions (%03o): chmod %s %s", actual: actual_mode & 0777, - wanted: "+r", + wanted: "a+r", path: file_path) end # Check that the file is user-writeable. diff --git a/Library/Homebrew/test/rubocops/files_spec.rb b/Library/Homebrew/test/rubocops/files_spec.rb index 52071477fa..d6f9505fb5 100644 --- a/Library/Homebrew/test/rubocops/files_spec.rb +++ b/Library/Homebrew/test/rubocops/files_spec.rb @@ -13,7 +13,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::Files do expect_offense(<<~RUBY, file) 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" end RUBY