Use plist main binary for Rosetta audit
Currently `brew audit` only audits the first binary in a cask. For example the cask `wiso-steuer-2024` contains multiple binaries in `Contents/MacOS`: - `btssysteminfo` - `whilfe` - `wmain24` The first binary (some telemetry tool) is not the main binary and not a universal binary, but the other two are. Given that `wmain24` is defined as the main binary in the `Contents/Info.plist`, brew probably should audit that binary rather than just checking the first one.
This commit is contained in:
		
							parent
							
								
									f827410798
								
							
						
					
					
						commit
						8814a492aa
					
				@ -574,7 +574,11 @@ module Cask
 | 
			
		||||
              File.executable?(f) && !File.directory?(f) && !f.end_with?(".dylib")
 | 
			
		||||
            end
 | 
			
		||||
            add_error "No binaries in App: #{artifact.source}", location: cask.url.location if files.empty?
 | 
			
		||||
            system_command("lipo", args: ["-archs", files.first], print_stderr: false)
 | 
			
		||||
 | 
			
		||||
            main_binary = get_plist_main_binary(path)
 | 
			
		||||
            main_binary ||= files.first
 | 
			
		||||
 | 
			
		||||
            system_command("lipo", args: ["-archs", main_binary], print_stderr: false)
 | 
			
		||||
          when Artifact::Binary
 | 
			
		||||
            binary_path = path.to_s.gsub(cask.appdir, tmpdir)
 | 
			
		||||
            system_command("lipo", args: ["-archs", binary_path], print_stderr: true)
 | 
			
		||||
@ -739,6 +743,17 @@ module Cask
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sig { params(path: Pathname).returns(T.nilable(String)) }
 | 
			
		||||
    def get_plist_main_binary(path)
 | 
			
		||||
      return unless online?
 | 
			
		||||
 | 
			
		||||
      plist_path = "#{path}/Contents/Info.plist"
 | 
			
		||||
      return unless File.exist?(plist_path)
 | 
			
		||||
 | 
			
		||||
      plist = system_command!("plutil", args: ["-convert", "xml1", "-o", "-", plist_path]).plist
 | 
			
		||||
      plist["CFBundleExecutable"].presence
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sig { void }
 | 
			
		||||
    def audit_github_prerelease_version
 | 
			
		||||
      odebug "Auditing GitHub prerelease"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user