Class: Cask::Audit Private
- Includes:
- SystemCommand::Mixin, Utils::Curl, Utils::Output::Mixin
- Defined in:
- cask/audit.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Audit a cask for various problems.
Constant Summary collapse
- Error =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.type_alias do { message: T.nilable(String), location: T.nilable(Homebrew::SourceLocation), corrected: T::Boolean, } end
Instance Attribute Summary collapse
- #cask ⇒ Cask readonly private
- #download ⇒ Download? readonly private
- #livecheck_result ⇒ void writeonly private
Instance Method Summary collapse
- #add_error(message, location: nil, strict_only: false, corrected: false) ⇒ void private
- #audit_appimage_versioned_target ⇒ void private
- #audit_artifact_case ⇒ void private
- #audit_bitbucket_repository ⇒ void private
- #audit_cask_path ⇒ void private
- #audit_conflicts_with ⇒ void private
- #audit_denylist ⇒ void private
- #audit_deprecate_disable ⇒ void private
- #audit_description ⇒ void private
- #audit_download ⇒ void private
- #audit_download_url_format ⇒ void private
- #audit_download_url_is_osdn ⇒ void private
- #audit_forgejo_prerelease_version ⇒ void private
- #audit_forgejo_repository ⇒ void private
- #audit_forgejo_repository_archived ⇒ void private
- #audit_generic_artifacts ⇒ void private
- #audit_github_prerelease_version ⇒ void private
- #audit_github_repository ⇒ void private
- #audit_github_repository_archived ⇒ void private
- #audit_gitlab_prerelease_version ⇒ void private
- #audit_gitlab_repository ⇒ void private
- #audit_gitlab_repository_archived ⇒ void private
- #audit_homepage_domain_age ⇒ void private
- #audit_homepage_https_availability ⇒ void private
- #audit_hosting_with_livecheck ⇒ void private
- #audit_languages ⇒ void private
- #audit_latest_with_auto_updates ⇒ void private
- #audit_latest_with_livecheck ⇒ void private
- #audit_livecheck_https_availability ⇒ void private
- #audit_livecheck_unneeded_long_version ⇒ void private
- #audit_livecheck_version ⇒ Boolean, ... private
- #audit_min_os ⇒ void private
- #audit_no_string_version_latest ⇒ void private
- #audit_required_stanzas ⇒ void private
- #audit_reverse_migration ⇒ void private
- #audit_rosetta ⇒ void private
- #audit_sha256_actually_256 ⇒ void private
- #audit_sha256_invalid ⇒ void private
- #audit_sha256_no_check_if_latest ⇒ void private
- #audit_sha256_no_check_if_unversioned ⇒ void private
- #audit_signing ⇒ void private
- #audit_single_zap ⇒ void private
- #audit_stanza_requires_uninstall ⇒ void private
- #audit_token ⇒ void private
- #audit_token_bad_words ⇒ void private
- #audit_token_conflicts ⇒ void private
- #audit_url_https_availability ⇒ void private
- #audit_version_special_characters ⇒ void private
- #errors ⇒ Array<Error> private
- #errors? ⇒ Boolean private
- #extract_artifacts(include_manual_installers: false, &_block) {|artifacts, @tmpdir| ... } ⇒ void private
- #fix? ⇒ Boolean private
- #initialize(cask, download: false, online: nil, strict: nil, signing: nil, new_cask: nil, fix: nil, only: [], except: []) ⇒ void constructor private
- #new_cask? ⇒ Boolean private
- #normalize_min_os(min_os) ⇒ MacOSVersion? private
- #online? ⇒ Boolean private
- #result ⇒ String? private
- #run! ⇒ ::Cask::Audit private
- #signing? ⇒ Boolean private
- #strict? ⇒ Boolean private
- #success? ⇒ Boolean private
- #summary ⇒ String? 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_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Methods included from Utils::Curl
clear_path_cache, curl, curl_args, curl_check_http_content, curl_download, curl_executable, curl_headers, curl_http_content_headers_and_checksum, curl_output, curl_path, curl_response_follow_redirections, curl_response_last_location, curl_supports_fail_with_body?, curl_supports_tls13?, curl_version, curl_with_workarounds, http_status_ok?, https_redirect_curl_args, insecure_redirect?, no_insecure_redirect_curl_args, parse_curl_output, parse_curl_response, strip_progress_bar, url_protected_by_cloudflare?, url_protected_by_incapsula?
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Constructor Details
#initialize(cask, download: false, online: nil, strict: nil, signing: nil, new_cask: nil, fix: nil, only: [], except: []) ⇒ 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.
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 |
# File 'cask/audit.rb', line 56 def initialize( cask, download: false, online: nil, strict: nil, signing: nil, new_cask: nil, fix: nil, only: [], except: [] ) # `new_cask` implies `online`, `strict` and `signing` online = new_cask if online.nil? strict = new_cask if strict.nil? signing = new_cask if signing.nil? # `online` and `signing` imply `download` download ||= online || signing @cask = cask @download = T.let(nil, T.nilable(Download)) @download = Download.new(cask) if download @online = online @strict = strict @signing = signing @new_cask = new_cask @fix = fix @only = only @except = except @livecheck_result = T.let(nil, T.nilable(T.any(T::Boolean, Symbol))) end |
Instance Attribute Details
#cask ⇒ Cask (readonly)
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.
40 41 42 |
# File 'cask/audit.rb', line 40 def cask @cask end |
#download ⇒ Download? (readonly)
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.
43 44 45 |
# File 'cask/audit.rb', line 43 def download @download end |
#livecheck_result=(value) ⇒ void (writeonly)
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.
46 47 48 |
# File 'cask/audit.rb', line 46 def livecheck_result=(value) @livecheck_result = value end |
Instance Method Details
#add_error(message, location: nil, strict_only: false, corrected: false) ⇒ 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.
141 142 143 144 145 146 |
# File 'cask/audit.rb', line 141 def add_error(, location: nil, strict_only: false, corrected: false) # Only raise non-critical audits if the user specified `--strict`. return if strict_only && !@strict errors << { message:, location:, corrected: } end |
#audit_appimage_versioned_target ⇒ 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.
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'cask/audit.rb', line 338 def audit_appimage_versioned_target # `app_image` artifacts live inside `on_linux` blocks, # so an audit running on another OS would not materialize them. # Evaluate every tag (restoring the default afterwards) # so the check runs regardless of the audit host. basenames = if cask.on_system_blocks_exist? begin OnSystem::VALID_OS_ARCH_TAGS.flat_map do |tag| cask.refresh_for_tag(tag) { appimage_target_basenames } || [] end ensure cask.refresh end else appimage_target_basenames end basenames.uniq.each do |basename| # electron-updater renames the AppImage on self-update # if its basename contains an `X.Y.Z` version, # which leaves the Caskroom back-symlink dangling. # A version-less target is overwritten in place instead. next unless basename.match?(/\d+\.\d+\.\d+/) add_error "app_image target '#{basename}' should not embed a version; " \ "use a version-less `target:` so self-updaters overwrite it in place" end end |
#audit_artifact_case ⇒ 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.
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
# File 'cask/audit.rb', line 682 def audit_artifact_case return if (url = cask.url).nil? return unless online? odebug "Auditing artifact case" extract_artifacts(include_manual_installers: true) do |artifacts, tmpdir| artifacts.each do |artifact| source = case artifact when Artifact::Pkg, Artifact::Installer artifact.path else artifact.source end source = if source.to_s.start_with?("#{cask.appdir}/") Pathname(source.to_s.delete_prefix("#{cask.appdir}/")) elsif source.absolute? source.relative_path_from(cask.staged_path) else source end components = source.each_filename.to_a current = tmpdir on_disk = [] components.each do |component| break unless current.directory? children = current.children.map { |child| child.basename.to_s } match = children.find { |name| name == component } || children.find { |name| name.casecmp?(component) } break if match.nil? on_disk << match current /= match end next if on_disk.length != components.length next if on_disk == components = "Artifact #{source} does not match the case of the extracted " \ "#{File.join(on_disk)}; this fails on case-sensitive filesystems" dsl_key = artifact.class.dsl_key fixed = correct_error("#{}; corrected the `#{dsl_key}` stanza", location: url.location) do |cask_ast| cask_ast.replace_stanza_value(dsl_key, source.to_s, File.join(on_disk)).positive? end next if fixed add_error "#{}.", location: url.location end end end |
#audit_bitbucket_repository ⇒ 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.
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 |
# File 'cask/audit.rb', line 1047 def audit_bitbucket_repository return unless new_cask? return if (url = cask.url).nil? user, repo = get_repo_data(%r{https?://bitbucket\.org/([^/]+)/([^/]+)/?.*}) return if user.nil? || repo.nil? odebug "Auditing Bitbucket repo" self_submission = self_submission?(user) error = SharedAudits.bitbucket(user, repo, self_submission:) add_error error, location: url.location if error end |
#audit_cask_path ⇒ 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.
1175 1176 1177 1178 1179 1180 1181 1182 1183 |
# File 'cask/audit.rb', line 1175 def audit_cask_path return unless (tap = cask.tap)&.core_cask_tap? expected_path = tap.new_cask_path(cask.token) return if cask.sourcefile_path.to_s.end_with?(expected_path.to_s) add_error "Cask should be located in '#{expected_path}'" end |
#audit_conflicts_with ⇒ 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.
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 |
# File 'cask/audit.rb', line 1077 def audit_conflicts_with return if !cask.tap&.official? || cask.conflicts_with.nil? Homebrew::API.with_no_api_env do nonexisting_conflicting_casks = cask.conflicts_with.fetch(:cask, Set.new) - core_cask_tokens nonexisting_conflicting_casks.each do |c| add_error("cask conflicts with non-existing cask `#{c}`") end end end |
#audit_denylist ⇒ 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.
1089 1090 1091 1092 1093 1094 |
# File 'cask/audit.rb', line 1089 def audit_denylist return unless cask.tap&.official? return unless (reason = Denylist.reason(cask.token)) add_error "#{cask.token} is not allowed: #{reason}" end |
#audit_deprecate_disable ⇒ 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.
1186 1187 1188 1189 |
# File 'cask/audit.rb', line 1186 def audit_deprecate_disable error = SharedAudits.check_deprecate_disable_reason(cask) add_error error if error end |
#audit_description ⇒ 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.
317 318 319 320 321 322 323 |
# File 'cask/audit.rb', line 317 def audit_description # Fonts seldom benefit from descriptions and requiring them disproportionately # increases the maintenance burden. return if cask.tap == "homebrew/cask" && cask.token.include?("font-") add_error("Cask should have a description. Please add a `desc` stanza.", strict_only: true) if cask.desc.blank? end |
#audit_download ⇒ 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.
548 549 550 551 552 553 554 555 556 |
# File 'cask/audit.rb', line 548 def audit_download return if (download = self.download).blank? || (url = cask.url).nil? begin download.fetch rescue => e add_error "download not possible: #{e}", location: url.location end end |
#audit_download_url_format ⇒ 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.
465 466 467 468 469 470 471 472 473 |
# File 'cask/audit.rb', line 465 def audit_download_url_format return if (url = cask.url).nil? odebug "Auditing URL format" return unless bad_sourceforge_url? add_error "SourceForge URL format incorrect. See #{Formatter.url(SOURCEFORGE_REFERENCE_URL)}", location: url.location end |
#audit_download_url_is_osdn ⇒ 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.
476 477 478 479 480 481 |
# File 'cask/audit.rb', line 476 def audit_download_url_is_osdn return if (url = cask.url).nil? return unless bad_osdn_url? add_error "OSDN download urls are disabled.", location: url.location, strict_only: true end |
#audit_forgejo_prerelease_version ⇒ 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.
954 955 956 957 958 959 960 961 962 963 964 965 |
# File 'cask/audit.rb', line 954 def audit_forgejo_prerelease_version return if (url = cask.url).nil? odebug "Auditing Forgejo prerelease" user, repo = get_repo_data(%r{https?://codeberg\.org/([^/]+)/([^/]+)/?.*}) if online? return if user.nil? || repo.nil? tag = SharedAudits.forgejo_tag_from_url(url.to_s) tag ||= cask.version error = SharedAudits.forgejo_release(user, repo, tag, cask:) add_error error, location: url.location if error end |
#audit_forgejo_repository ⇒ 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.
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
# File 'cask/audit.rb', line 1062 def audit_forgejo_repository return unless new_cask? return if (url = cask.url).nil? user, repo = get_repo_data(%r{https?://codeberg\.org/([^/]+)/([^/]+)/?.*}) return if user.nil? || repo.nil? odebug "Auditing Forgejo repo" self_submission = self_submission?(user) error = SharedAudits.forgejo(user, repo, self_submission:) add_error error, location: url.location if error end |
#audit_forgejo_repository_archived ⇒ 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.
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
# File 'cask/audit.rb', line 1000 def audit_forgejo_repository_archived return if cask.deprecated? || cask.disabled? return if (url = cask.url).nil? user, repo = get_repo_data(%r{https?://codeberg\.org/([^/]+)/([^/]+)/?.*}) if online? return if user.nil? || repo.nil? = SharedAudits.forgejo_repo_data(user, repo) return if .nil? return unless ["archived"] add_error "Forgejo repository is archived since #{["archived_at"]}", location: url.location end |
#audit_generic_artifacts ⇒ 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.
484 485 486 487 488 489 490 |
# File 'cask/audit.rb', line 484 def audit_generic_artifacts cask.artifacts.grep(Artifact::Artifact).each do |artifact| unless artifact.target.absolute? add_error "target must be absolute path for #{artifact.class.english_name} #{artifact.source}" end end end |
#audit_github_prerelease_version ⇒ 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.
925 926 927 928 929 930 931 932 933 934 935 936 |
# File 'cask/audit.rb', line 925 def audit_github_prerelease_version return if (url = cask.url).nil? odebug "Auditing GitHub prerelease" user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online? return if user.nil? || repo.nil? tag = SharedAudits.github_tag_from_url(url.to_s) tag ||= cask.version error = SharedAudits.github_release(user, repo, tag, cask:) add_error error, location: url.location if error end |
#audit_github_repository ⇒ 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.
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 |
# File 'cask/audit.rb', line 1017 def audit_github_repository return unless new_cask? return if (url = cask.url).nil? user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) return if user.nil? || repo.nil? odebug "Auditing GitHub repo" self_submission = self_submission?(user) error = SharedAudits.github(user, repo, self_submission:) add_error error, location: url.location if error end |
#audit_github_repository_archived ⇒ 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.
968 969 970 971 972 973 974 975 976 977 978 979 980 |
# File 'cask/audit.rb', line 968 def audit_github_repository_archived # Deprecated/disabled casks may have an archived repository. return if cask.deprecated? || cask.disabled? return if (url = cask.url).nil? user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online? return if user.nil? || repo.nil? = SharedAudits.github_repo_data(user, repo) return if .nil? add_error "GitHub repo is archived", location: url.location if ["archived"] end |
#audit_gitlab_prerelease_version ⇒ 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.
939 940 941 942 943 944 945 946 947 948 949 950 951 |
# File 'cask/audit.rb', line 939 def audit_gitlab_prerelease_version return if (url = cask.url).nil? user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online? return if user.nil? || repo.nil? odebug "Auditing GitLab prerelease" tag = SharedAudits.gitlab_tag_from_url(url.to_s) tag ||= cask.version error = SharedAudits.gitlab_release(user, repo, tag, cask:) add_error error, location: url.location if error end |
#audit_gitlab_repository ⇒ 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.
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
# File 'cask/audit.rb', line 1032 def audit_gitlab_repository return unless new_cask? return if (url = cask.url).nil? user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) return if user.nil? || repo.nil? odebug "Auditing GitLab repo" self_submission = self_submission?(user) error = SharedAudits.gitlab(user, repo, self_submission:) add_error error, location: url.location if error end |
#audit_gitlab_repository_archived ⇒ 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.
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 |
# File 'cask/audit.rb', line 983 def audit_gitlab_repository_archived # Deprecated/disabled casks may have an archived repository. return if cask.deprecated? || cask.disabled? return if (url = cask.url).nil? user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online? return if user.nil? || repo.nil? odebug "Auditing GitLab repo archived" = SharedAudits.gitlab_repo_data(user, repo) return if .nil? add_error "GitLab repo is archived", location: url.location if ["archived"] end |
#audit_homepage_domain_age ⇒ 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.
1126 1127 1128 1129 1130 1131 1132 1133 |
# File 'cask/audit.rb', line 1126 def audit_homepage_domain_age return unless new_cask? return unless cask.tap&.official? return unless (homepage = cask.homepage) new_domain_problem = SharedAudits.new_domain_problem(homepage) add_error new_domain_problem if new_domain_problem end |
#audit_homepage_https_availability ⇒ 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.
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 |
# File 'cask/audit.rb', line 1106 def audit_homepage_https_availability return unless online? return unless (homepage = cask.homepage) return if SharedAudits.homepage_browsed_recently?(cask.homepage_browsed) user_agents = if cask.tap&.audit_exception(:simple_user_agent_for_homepage, cask.token) ["curl"] else [:browser, :default] end validate_url_for_https_availability( homepage, SharedAudits::URL_TYPE_HOMEPAGE, user_agents:, check_content: true, strict: strict? ) end |
#audit_hosting_with_livecheck ⇒ 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.
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'cask/audit.rb', line 442 def audit_hosting_with_livecheck return if cask.deprecated? || cask.disabled? return if cask.version&.latest? return if (url = cask.url).nil? return if cask.livecheck_defined? return if audit_livecheck_version == :auto_detected add_livecheck = "please add a livecheck. See #{Formatter.url(LIVECHECK_REFERENCE_URL)}" case url.uri.host when /(?:\A|\.)sourceforge\.net\z/ return unless online? add_error "Download is hosted on SourceForge, #{add_livecheck}", location: url.location when "dl.devmate.com" add_error "Download is hosted on DevMate, #{add_livecheck}", location: url.location end end |
#audit_languages ⇒ 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.
493 494 495 496 497 498 499 |
# File 'cask/audit.rb', line 493 def audit_languages @cask.languages.each do |language| Locale.parse(language) rescue Locale::ParserError add_error "Locale '#{language}' is invalid." end end |
#audit_latest_with_auto_updates ⇒ 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.
431 432 433 434 435 436 |
# File 'cask/audit.rb', line 431 def audit_latest_with_auto_updates return unless cask.version&.latest? return unless cask.auto_updates add_error "Casks with `version :latest` should not use `auto_updates`." end |
#audit_latest_with_livecheck ⇒ 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.
422 423 424 425 426 427 428 |
# File 'cask/audit.rb', line 422 def audit_latest_with_livecheck return unless cask.version&.latest? return unless cask.livecheck_defined? return if cask.livecheck.skip? add_error "Casks with a `livecheck` should not use `version :latest`." end |
#audit_livecheck_https_availability ⇒ 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.
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 |
# File 'cask/audit.rb', line 1150 def audit_livecheck_https_availability return unless online? return unless cask.livecheck_defined? return unless (url = cask.livecheck.url) return if url.is_a?(Symbol) = cask.livecheck. return if .post_form || .post_json # Validating HTTPS availability is unnecessary if the check uses HTTPS # and does not fail. if url.start_with?("https:") && audit_livecheck_version != false odebug "Skipping livecheck_https_availability audit (working HTTPS livecheck)" return end odebug "Auditing livecheck HTTPS availability" validate_url_for_https_availability( url, "livecheck URL", check_content: true, user_agents: [:default, :browser] ) end |
#audit_livecheck_unneeded_long_version ⇒ 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.
559 560 561 562 563 564 565 566 567 568 569 |
# File 'cask/audit.rb', line 559 def audit_livecheck_unneeded_long_version return if cask.version.nil? || (url = cask.url).nil? return if cask.livecheck.strategy != :sparkle return unless cask.version.csv.second return if cask.url.to_s.include? cask.version.csv.second return if cask.version.csv.third.present? && cask.url.to_s.include?(cask.version.csv.third) add_error "Download does not require additional version components. Use `&:short_version` in the livecheck", location: url.location, strict_only: true end |
#audit_livecheck_version ⇒ 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.
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 |
# File 'cask/audit.rb', line 813 def audit_livecheck_version return @livecheck_result unless @livecheck_result.nil? return unless online? return unless cask.version odebug "Auditing livecheck version" referenced_cask, = Homebrew::Livecheck.resolve_livecheck_reference(cask) # Respect skip conditions for a referenced cask if referenced_cask skip_info = Homebrew::Livecheck::SkipConditions.referenced_skip_information( referenced_cask, Homebrew::Livecheck.package_or_resource_name(cask), ) end # Respect cask skip conditions (e.g. deprecated, disabled, latest, unversioned) skip_info ||= Homebrew::Livecheck::SkipConditions.skip_information(cask) if skip_info.present? @livecheck_result = :skip return @livecheck_result end result = Homebrew::Livecheck.latest_version( cask, referenced_formula_or_cask: referenced_cask, ) if result throttle = cask.livecheck.throttle throttle_days = cask.livecheck.throttle_days if referenced_cask throttle ||= referenced_cask.livecheck.throttle throttle_days ||= referenced_cask.livecheck.throttle_days end latest_version = (throttle || throttle_days) ? result[:latest_throttled] : result[:latest] end if latest_version && (cask.version.to_s == latest_version.to_s) @livecheck_result = :auto_detected return @livecheck_result end add_error "Version '#{cask.version}' differs from '#{latest_version}' retrieved by livecheck." @livecheck_result = false end |
#audit_min_os ⇒ 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.
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 |
# File 'cask/audit.rb', line 863 def audit_min_os return unless online? odebug "Auditing minimum macOS version" bundle_min_os = cask_bundle_min_os sparkle_min_os = cask_sparkle_min_os app_min_os = [bundle_min_os, sparkle_min_os].compact.max = [] << "from artifact: #{bundle_min_os.to_sym}" if bundle_min_os << "from upstream: #{sparkle_min_os.to_sym}" if sparkle_min_os odebug "Detected minimum macOS: #{app_min_os.to_sym} (#{.join(" | ")})" if app_min_os return if app_min_os.nil? || app_min_os <= HOMEBREW_MACOS_OLDEST_ALLOWED on_system_block_min_os = cask.on_system_block_min_os depends_on_min_os = cask.depends_on.macos&.minimum_version cask_min_os = [on_system_block_min_os, depends_on_min_os].compact.max = [] << "from on_system block: #{on_system_block_min_os.to_sym}" if on_system_block_min_os if depends_on_min_os && depends_on_min_os > HOMEBREW_MACOS_OLDEST_ALLOWED << "from depends_on stanza: #{depends_on_min_os.to_sym}" end odebug "Declared minimum macOS: #{cask_min_os&.to_sym} (#{.join(" | ").presence || "default"})" return if cask_min_os&.to_sym == app_min_os.to_sym # ignore declared minimum OS < 11.x when auditing as ARM a cask with arch-specific artifacts return if OnSystem.arch_condition_met?(:arm) && cask.on_system_blocks_exist? && cask_min_os.present? && app_min_os < MacOSVersion.new("11") && app_min_os < cask_min_os min_os_definition = if cask_min_os && cask_min_os > HOMEBREW_MACOS_OLDEST_ALLOWED definition = if on_system_block_min_os.to_s > depends_on_min_os.to_s "an on_system block" else "a depends_on stanza" end "#{definition} with a minimum macOS version of #{cask_min_os.to_sym.inspect}" else "no minimum macOS version" end source = (bundle_min_os.to_s > sparkle_min_os.to_s) ? "Artifact" : "Upstream" = "#{source} defined #{app_min_os.to_sym.inspect} as the minimum macOS version " \ "but the cask declared #{min_os_definition}" # A cask with `on_system` blocks may have a different minimum per OS or # arch, so a top-level `depends_on macos:` stanza would be wrong. maximum_macos = cask.depends_on.maximum_macos&.maximum_version unsatisfiable_minimum = maximum_macos.present? && app_min_os > maximum_macos if !cask.on_system_blocks_exist? && !unsatisfiable_minimum fixed = correct_error("#{}; set `depends_on macos:` to #{app_min_os.to_sym.inspect}") do |cask_ast| cask_ast.update_depends_on_macos_minimum!(app_min_os.to_sym) end return if fixed end add_error end |
#audit_no_string_version_latest ⇒ 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.
368 369 370 371 372 373 374 375 |
# File 'cask/audit.rb', line 368 def audit_no_string_version_latest return unless cask.version odebug "Auditing version :latest does not appear as a string ('latest')" return if cask.version.raw_version != "latest" add_error "you should use version :latest instead of version 'latest'" end |
#audit_required_stanzas ⇒ 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.
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'cask/audit.rb', line 295 def audit_required_stanzas odebug "Auditing required stanzas" [:version, :sha256, :url, :homepage].each do |sym| add_error "a #{sym} stanza is required" unless cask.public_send(sym) end add_error "at least one name stanza is required" if cask.name.empty? installable_artifact = if cask.on_system_blocks_exist? begin OnSystem::VALID_OS_ARCH_TAGS.any? do |tag| cask.refresh_for_tag(tag) { cask.installable_artifact? } end ensure cask.refresh end else cask.installable_artifact? end add_error "at least one installable artifact stanza is required" unless installable_artifact end |
#audit_reverse_migration ⇒ 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.
1097 1098 1099 1100 1101 1102 1103 |
# File 'cask/audit.rb', line 1097 def audit_reverse_migration return unless new_cask? return unless cask.tap&.official? return unless cask.tap&.tap_migrations&.key?(cask.token) add_error "#{cask.token} is listed in tap_migrations.json" end |
#audit_rosetta ⇒ 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.
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 |
# File 'cask/audit.rb', line 738 def audit_rosetta return if (url = cask.url).nil? return unless online? # Rosetta 2 is only for ARM-capable macOS versions, which are Big Sur (11.x) and later return if Homebrew::SimulateSystem.current_arch != :arm return if MacOSVersion::SYMBOLS.fetch(Homebrew::SimulateSystem.current_os, "10") < "11" return if cask.depends_on.macos&.maximum_version.to_s < "11" odebug "Auditing Rosetta 2 requirement" extract_artifacts do |artifacts, tmpdir| is_container = artifacts.any? { |a| a.is_a?(Artifact::App) || a.is_a?(Artifact::Pkg) } mentions_rosetta = cask.caveats_object.invoked?(:requires_rosetta) || cask.caveats.include?("requires Rosetta 2") requires_intel = cask.depends_on.arch&.any? { |arch| arch[:type] == :intel } artifacts_to_test = artifacts.filter do |artifact| next false if !artifact.is_a?(Artifact::App) && !artifact.is_a?(Artifact::Binary) next false if artifact.is_a?(Artifact::Binary) && is_container true end next if artifacts_to_test.blank? any_requires_rosetta = artifacts_to_test.any? do |artifact| artifact = T.cast(artifact, T.any(Artifact::App, Artifact::Binary)) path = tmpdir/artifact.source.relative_path_from(cask.staged_path) result = case artifact when Artifact::App files = Dir[path/"Contents/MacOS/*"].select do |f| File.executable?(f) && !File.directory?(f) && !f.end_with?(".dylib") end add_error "No binaries in App: #{artifact.source}", location: url.location if files.empty? main_binary = get_plist_main_binary(path) main_binary ||= files.fetch(0) system_command("lipo", args: ["-archs", main_binary], print_stderr: false) when Artifact::Binary binary_path = path.to_s.gsub(cask.appdir, tmpdir.to_s) system_command("lipo", args: ["-archs", binary_path], print_stderr: true) else T.absurd(artifact) end # binary stanza can contain shell scripts, so we just continue if lipo fails. next false unless result.success? odebug "Architectures: #{result.merged_output}" unless /arm64|x86_64/.match?(result.merged_output) add_error "Artifacts architecture is no longer supported by macOS!", location: url.location next end result.merged_output.exclude?("arm64") && result.merged_output.include?("x86_64") end if any_requires_rosetta if !mentions_rosetta && !requires_intel add_error "At least one artifact requires Rosetta 2 but this is not indicated by the caveats!", location: url.location end elsif mentions_rosetta add_error "No artifacts require Rosetta 2 but the caveats say otherwise!", location: url.location end end end |
#audit_sha256_actually_256 ⇒ 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.
400 401 402 403 404 405 406 407 408 |
# File 'cask/audit.rb', line 400 def audit_sha256_actually_256 return unless cask.sha256 odebug "Auditing sha256 string is a legal SHA-256 digest" return unless cask.sha256.is_a?(Checksum) return if cask.sha256.to_s.match?(/\A[0-9a-f]{64}\z/i) add_error "sha256 string must be of 64 hexadecimal characters" end |
#audit_sha256_invalid ⇒ 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.
411 412 413 414 415 416 417 418 419 |
# File 'cask/audit.rb', line 411 def audit_sha256_invalid return unless cask.sha256 odebug "Auditing sha256 is not a known invalid value" empty_sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" return if cask.sha256 != empty_sha256 add_error "cannot use the sha256 for an empty string: #{empty_sha256}" end |
#audit_sha256_no_check_if_latest ⇒ 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.
378 379 380 381 382 383 384 385 386 387 |
# File 'cask/audit.rb', line 378 def audit_sha256_no_check_if_latest return unless cask.sha256 return unless cask.version odebug "Auditing sha256 :no_check with version :latest" return unless cask.version.latest? return if cask.sha256 == :no_check add_error "you should use sha256 :no_check when version is :latest" end |
#audit_sha256_no_check_if_unversioned ⇒ 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.
390 391 392 393 394 395 396 397 |
# File 'cask/audit.rb', line 390 def audit_sha256_no_check_if_unversioned return unless cask.sha256 return if cask.sha256 == :no_check return unless cask.url&.unversioned? add_error "Use `sha256 :no_check` when URL is unversioned." end |
#audit_signing ⇒ 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.
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
# File 'cask/audit.rb', line 572 def audit_signing return if download.blank? url = cask.url return if url.nil? return if !cask.tap&.official? && !signing? deprecated_or_disabled = cask.deprecated? || cask.disabled? deprecate_disable_reason = cask.disabled? ? cask.disable_reason : cask.deprecation_reason gatekeeper_failure_expected = deprecate_disable_reason == :fails_gatekeeper_check return if deprecated_or_disabled && !gatekeeper_failure_expected unless Quarantine.available? odebug "Quarantine support is not available, skipping signing audit" return end odebug "Auditing signing" is_in_skiplist = cask.tap&.audit_exception(:signing_audit_skiplist, cask.token, Homebrew::SimulateSystem.current_arch.to_s) || cask.tap&.audit_exception(:signing_audit_skiplist, cask.token, "all") extract_artifacts(include_manual_installers: true) do |artifacts, tmpdir| is_container = artifacts.any? do |artifact| artifact.is_a?(Artifact::App) || artifact.is_a?(Artifact::Pkg) || (artifact.is_a?(Artifact::Installer) && [".app", ".pkg"].include?(artifact.path.extname.downcase)) end any_signing_failure = artifacts.any? do |artifact| next false if artifact.is_a?(Artifact::Binary) && is_container == true artifact_path = case artifact when Artifact::Pkg, Artifact::Installer artifact.path else artifact.source end artifact_path = artifact_path.relative_path_from(cask.staged_path) if artifact_path.absolute? path = tmpdir/artifact_path unless Quarantine.detect(path) odebug "#{path} does not have quarantine attributes, skipping signing audit" next false end result = case artifact when Artifact::Pkg system_command("spctl", args: ["--assess", "--type", "install", path], print_stderr: false) when Artifact::App next opoo "gktool not found, skipping app signing audit" unless which("gktool") system_command("gktool", args: ["scan", path], print_stderr: false) when Artifact::Installer if artifact.path.extname.downcase == ".app" next opoo "gktool not found, skipping app signing audit" unless which("gktool") system_command("gktool", args: ["scan", path], print_stderr: false) elsif artifact.path.extname.downcase == ".pkg" system_command("spctl", args: ["--assess", "--type", "install", path], print_stderr: false) else next false end when Artifact::Binary # Shell scripts cannot be signed, so we skip them next false if ::Utils::Path.text_executable?(path) system_command("codesign", args: ["--verify", "-R=notarized", "--check-notarization", path], print_stderr: false) else add_error "Unknown artifact type: #{artifact.class}", location: url.location next end next false if result.success? next true if gatekeeper_failure_expected next true if is_in_skiplist = <<~EOS Signature verification failed: #{result.merged_output} EOS if cask.tap&.official? += <<~EOS The homebrew/cask tap requires all casks to be signed and notarized by Apple. Please contact the upstream developer and ask them to sign and notarize their software. EOS end add_error true end return if any_signing_failure add_error "Cask is in the signing audit skiplist, but does not need to be skipped!" if is_in_skiplist return unless gatekeeper_failure_expected add_error <<~EOS Cask is deprecated/disabled because it failed Gatekeeper checks but all artifacts now pass! Remove the deprecate/disable stanza or update the deprecate/disable reason. EOS end end |
#audit_single_zap ⇒ 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.
287 288 289 290 291 292 |
# File 'cask/audit.rb', line 287 def audit_single_zap odebug "Auditing single zap stanzas" return if cask.artifacts.count { |k| k.is_a?(Artifact::Zap) } <= 1 add_error "only a single zap stanza is allowed" end |
#audit_stanza_requires_uninstall ⇒ 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.
277 278 279 280 281 282 283 284 |
# File 'cask/audit.rb', line 277 def audit_stanza_requires_uninstall odebug "Auditing stanzas which require an uninstall" return if cask.artifacts.none? { |k| k.is_a?(Artifact::Pkg) || k.is_a?(Artifact::Installer) } return if cask.artifacts.any?(Artifact::Uninstall) add_error "installer and pkg stanzas require an uninstall stanza" end |
#audit_token ⇒ 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.
502 503 504 505 506 507 508 |
# File 'cask/audit.rb', line 502 def audit_token token_auditor = Homebrew::FormulaNameCaskTokenAuditor.new(cask.token) return if (errors = token_auditor.errors).none? add_error "Cask token '#{cask.token}' must not contain " \ "#{::Utils::Text.to_sentence(errors, conjunction: "or")}." end |
#audit_token_bad_words ⇒ 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.
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
# File 'cask/audit.rb', line 520 def audit_token_bad_words return unless new_cask? token = cask.token add_error "cask token contains .app" if token.end_with? ".app" match_data = /-(?<designation>alpha|beta|rc|release-candidate)$/.match(cask.token) if match_data && cask.tap&.official? add_error "cask token contains version designation '#{match_data[:designation]}'" end add_error("cask token mentions launcher", strict_only: true) if token.end_with? "launcher" add_error("cask token mentions desktop", strict_only: true) if token.end_with? "desktop" add_error("cask token mentions platform", strict_only: true) if token.end_with? "mac", "osx", "macos" add_error("cask token mentions architecture", strict_only: true) if token.end_with? "x86", "32_bit", "x86_64", "64_bit" frameworks = %w[cocoa qt gtk wx java] return if frameworks.include?(token) || !token.end_with?(*frameworks) add_error("cask token mentions framework", strict_only: true) end |
#audit_token_conflicts ⇒ 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.
511 512 513 514 515 516 517 |
# File 'cask/audit.rb', line 511 def audit_token_conflicts Homebrew::API.with_no_api_env do return unless core_formula_names.include?(cask.token) add_error("cask token conflicts with an existing homebrew/core formula: #{Formatter.url(core_formula_url)}") end end |
#audit_url_https_availability ⇒ 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.
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 |
# File 'cask/audit.rb', line 1136 def audit_url_https_availability return unless online? return unless (url = cask.url) return if url.using validate_url_for_https_availability( url, "binary URL", location: url.location, user_agents: [url.user_agent], referer: url.referer ) end |
#audit_version_special_characters ⇒ 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.
326 327 328 329 330 331 332 333 334 335 |
# File 'cask/audit.rb', line 326 def audit_version_special_characters return unless cask.version return if cask.version.latest? raw_version = cask.version.raw_version return if raw_version.exclude?(":") && raw_version.exclude?("/") add_error "version should not contain colons or slashes" end |
#errors ⇒ Array<Error>
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.
119 120 121 |
# File 'cask/audit.rb', line 119 def errors @errors ||= T.let([], T.nilable(T::Array[Error])) end |
#errors? ⇒ 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.
124 125 126 |
# File 'cask/audit.rb', line 124 def errors? errors.any? end |
#extract_artifacts(include_manual_installers: false, &_block) {|artifacts, @tmpdir| ... } ⇒ 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.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'cask/audit.rb', line 175 def extract_artifacts(include_manual_installers: false, &_block) return unless online? return if (download = self.download).nil? artifacts = cask.artifacts.select do |artifact| artifact.is_a?(Artifact::Pkg) || artifact.is_a?(Artifact::App) || artifact.is_a?(Artifact::Binary) || (include_manual_installers && artifact.is_a?(Artifact::Installer) && artifact.manual_install && [".app", ".pkg"].include?(artifact.path.extname.downcase)) end if @artifacts_extracted && @tmpdir yield artifacts, @tmpdir if block_given? return end return if artifacts.empty? @tmpdir ||= T.let(Pathname(Dir.mktmpdir("cask-audit", HOMEBREW_TEMP)), T.nilable(Pathname)) # Clean up tmp dir when @tmpdir object is destroyed ObjectSpace.define_finalizer( @tmpdir, proc { FileUtils.remove_entry(@tmpdir) }, ) ohai "Downloading and extracting artifacts" downloaded_path = download.fetch primary_container = UnpackStrategy.detect(downloaded_path, type: @cask.container&.type, merge_xattrs: true) return if primary_container.nil? # If the container has any dependencies we need to install them or unpacking will fail. if primary_container.dependencies.any? = { show_header: true, installed_on_request: false, verbose: false, }.compact Homebrew::Install.perform_preinstall_checks_once formula_installers = primary_container.dependencies.filter_map do |dep| next unless dep.is_a?(Formula) next if dep.linked? FormulaInstaller.new( dep, **, ) end valid_formula_installers = Homebrew::Install.fetch_formulae(formula_installers) formula_installers.each do |fi| next unless valid_formula_installers.include?(fi) fi.install fi.finish end end # Extract the container to the temporary directory. primary_container.extract_nestedly(to: @tmpdir, basename: downloaded_path.basename, verbose: false) if (nested_container = @cask.container&.nested) FileUtils.chmod_R "+rw", @tmpdir/nested_container, force: true, verbose: false UnpackStrategy.detect(@tmpdir/nested_container, merge_xattrs: true) .extract_nestedly(to: @tmpdir, verbose: false) end # Propagate quarantine attributes from the downloaded file to extracted contents. # This is necessary because some extraction tools (like 7zr) don't preserve xattrs. Quarantine.propagate(from: downloaded_path, to: @tmpdir) # Process rename operations after extraction # Create a temporary installer to process renames in the audit directory temp_installer = Installer.new(@cask) temp_installer.process_rename_operations(target_dir: @tmpdir) # Set the flag to indicate that extraction has occurred. @artifacts_extracted = T.let(true, T.nilable(TrueClass)) # Yield the artifacts and temp directory to the block if provided. yield artifacts, @tmpdir if block_given? end |
#fix? ⇒ 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.
96 |
# File 'cask/audit.rb', line 96 def fix? = !!@fix |
#new_cask? ⇒ 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.
84 |
# File 'cask/audit.rb', line 84 def new_cask? = !!@new_cask |
#normalize_min_os(min_os) ⇒ MacOSVersion?
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.
266 267 268 269 270 271 272 273 274 |
# File 'cask/audit.rb', line 266 def normalize_min_os(min_os) return if min_os.nil? return if min_os.is_a?(String) && min_os.blank? min_os = MacOSVersion.new(min_os) unless min_os.is_a?(MacOSVersion) MacOSVersion.new(min_os.release_version) rescue MacOSVersion::Error nil end |
#online? ⇒ 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.
87 |
# File 'cask/audit.rb', line 87 def online? =!!@online |
#result ⇒ String?
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.
149 150 151 |
# File 'cask/audit.rb', line 149 def result Formatter.error("failed") if errors? end |
#run! ⇒ ::Cask::Audit
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.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'cask/audit.rb', line 99 def run! only_audits = @only except_audits = @except public_methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name| name = audit_method_name.delete_prefix("audit_") next if !only_audits.empty? && only_audits.exclude?(name) next if except_audits.include?(name) public_send(audit_method_name) end self rescue => e odebug e, ::Utils::Backtrace.clean(e) add_error "exception while auditing #{cask}: #{e.}" self end |
#signing? ⇒ 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.
90 |
# File 'cask/audit.rb', line 90 def signing? = !!@signing |
#strict? ⇒ 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.
93 |
# File 'cask/audit.rb', line 93 def strict? = !!@strict |
#success? ⇒ 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.
129 130 131 |
# File 'cask/audit.rb', line 129 def success? !errors? end |
#summary ⇒ String?
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.
154 155 156 157 158 159 160 161 162 163 164 |
# File 'cask/audit.rb', line 154 def summary return if success? summary = ["audit for #{cask}: #{result}"] errors.each do |error| summary << " #{Formatter.error("-")} #{error[:message]}" end summary.join("\n") end |