Merge pull request #20470 from Homebrew/formulary_tighter_path_detection

formulary: tighter path rejection detection.
This commit is contained in:
Mike McQuaid 2025-08-15 07:36:32 +00:00 committed by GitHub
commit 166fa896bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -619,7 +619,8 @@ module Formulary
if Homebrew::EnvConfig.forbid_packages_from_paths?
path_realpath = path.realpath.to_s
path_string = path.to_s
unless path_realpath.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/", "#{HOMEBREW_CACHE}/")
if !path_realpath.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/", "#{HOMEBREW_CACHE}/") &&
!path_string.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/", "#{HOMEBREW_CACHE}/")
if path_string.include?("./") || path_string.end_with?(".rb") || path_string.count("/") != 2
raise <<~WARNING
Rejecting formula at #{path_string} because it's not in a tap.