Module: OS::Mac::Cask::Quarantine::ClassMethods Private
- Extended by:
- T::Helpers
- Includes:
- Kernel, Utils::Output::Mixin
- Defined in:
- extend/os/mac/cask/quarantine.rb
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Constant Summary
Constants included from Kernel
Kernel::IGNORE_INTERRUPTS_MUTEX
Instance Method Summary collapse
- #cask!(cask: nil, download_path: nil, action: true) ⇒ void private
- #check_quarantine_support ⇒ Array<(Symbol, [String, nil])> private
- #copy_xattrs(from, to, command:) ⇒ void private
- #signing_identity(file) ⇒ ::Cask::Quarantine::SigningIdentity? private
- #signing_identity_match(file, identity) ⇒ Boolean? private
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Methods included from Kernel
#ensure_executable!, #exec_browser, #exec_editor, #ignore_interrupts, #interactive_shell, #quiet_system, #redirect_stdout, #safe_system, #which, #which_editor, #with_env, #with_homebrew_path
Instance Method Details
#cask!(cask: nil, download_path: nil, action: true) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'extend/os/mac/cask/quarantine.rb', line 55 def cask!(cask: nil, download_path: nil, action: true) return if cask.nil? || download_path.nil? return if ::Cask::Quarantine.detect(download_path) odebug "Quarantining #{download_path}" path_cf_string = MacOS::FFI::CoreFoundation.string_create(download_path.to_s) if path_cf_string.null? Kernel.raise ::Cask::CaskQuarantineError.new(download_path, "Failed to create CFString for path") end path_cf_url = MacOS::FFI::CoreFoundation.url_create_with_file_system_path(path_cf_string) if path_cf_url.null? Kernel.raise ::Cask::CaskQuarantineError.new(download_path, "Failed to create CFURL for path") end quarantine_agent_name = MacOS::FFI::CoreFoundation.string_create("Homebrew Cask") quarantine_data_url = MacOS::FFI::CoreFoundation.string_create(cask.url.to_s) quarantine_origin_url = MacOS::FFI::CoreFoundation.string_create(cask.homepage.to_s) if quarantine_agent_name.null? || quarantine_data_url.null? || quarantine_origin_url.null? Kernel.raise ::Cask::CaskQuarantineError.new(download_path, "Failed to create CFString for quarantine properties") end quarantine_dictionary = MacOS::FFI::CoreFoundation.dictionary_create( MacOS::FFI::LaunchServices.quarantine_agent_name_key => quarantine_agent_name, MacOS::FFI::LaunchServices.quarantine_type_key => MacOS::FFI::LaunchServices.quarantine_type_web_download, MacOS::FFI::LaunchServices.quarantine_data_url_key => quarantine_data_url, MacOS::FFI::LaunchServices.quarantine_origin_url_key => quarantine_origin_url, ) if quarantine_dictionary.null? Kernel.raise ::Cask::CaskQuarantineError.new(download_path, "Failed to create quarantine dictionary") end success = MacOS::FFI::CoreFoundation.url_set_resource_property_for_key( path_cf_url, MacOS::FFI::CoreFoundation.url_quarantine_properties_key, quarantine_dictionary, ) return if success Kernel.raise ::Cask::CaskQuarantineError.new(download_path, "Failed to set quarantine properties for URL") end |
#check_quarantine_support ⇒ Array<(Symbol, [String, nil])>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'extend/os/mac/cask/quarantine.rb', line 20 def check_quarantine_support odebug "Checking quarantine support" status = if ::Cask::Quarantine.xattr_available? odebug "Quarantine is available via FFI." :quarantine_available else odebug "There's no working version of `xattr` on this system." :xattr_broken end [status, nil] end |
#copy_xattrs(from, to, command:) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'extend/os/mac/cask/quarantine.rb', line 104 def copy_xattrs(from, to, command:) odebug "Copying xattrs from #{from} to #{to}" if to.writable? MacOS::FFI.copy_xattrs(from.to_s, to.to_s) return end ruby, *args = HOMEBREW_RUBY_EXEC_ARGS command.run!( ruby, args: args + [ "-I", $LOAD_PATH.join(File::PATH_SEPARATOR), COPY_XATTRS_SCRIPT, from, to, ], sudo: true, ) end |
#signing_identity(file) ⇒ ::Cask::Quarantine::SigningIdentity?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
37 38 39 40 41 42 |
# File 'extend/os/mac/cask/quarantine.rb', line 37 def signing_identity(file) requirement = MacOS::FFI::Security.designated_requirement(file.to_s) return if requirement.nil? ::Cask::Quarantine::SigningIdentity.new(requirement:) end |
#signing_identity_match(file, identity) ⇒ Boolean?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
50 51 52 |
# File 'extend/os/mac/cask/quarantine.rb', line 50 def signing_identity_match(file, identity) MacOS::FFI::Security.requirement_match(file.to_s, identity.requirement) end |