fastlane-plugin-wpmreleasetoolkit 15.3.0 → 15.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 821f365e32e08a05230fbc5ae16760f128ff39eca6b8b8c99459751bc6299120
4
- data.tar.gz: f67252ac27be73b6d8d0f54c8679d11d5c71a1f52042caa8ab97362451ff8abe
3
+ metadata.gz: dd6cd903b356f44324f711012ffa75b7814adb1e31e1a4631e4e616bf77518d2
4
+ data.tar.gz: 95a989ce4d3e8a88855eb30d52f2c320573957d1321c5c15edd0d0f8b1695368
5
5
  SHA512:
6
- metadata.gz: 214447b137397d1b1ed813320370eb6a2e06c15d6a7a9d8d28d063d55b9c7dd39c751d6700d537d253e222808ac132c179eec87ee893db87c430323dabee8d9a
7
- data.tar.gz: 9eb8cef1bb2a5cd5fc96df1aa7aa5500ebc2f9eb49beb6dd345da1011741b1d823c2fc76fdc8faf14c66f94673c6b77bd526fcf2c8a470da590731756e70d6af
6
+ metadata.gz: bdc7407060feede6dd035952dee8f90edfd28a435727a5656f9dbd8e70e968caecbfdbad1ec60c8777543568ed4ef6d1efdc2b9dc7ca3e50f3cd570535afd6b7
7
+ data.tar.gz: 5c9eeaa224d8af92149421f6591bfc8cc8fa983fabeb26ad300e358fac418e4e536d5a7864dce84f5cc9d9cd46531b5a155845fd206bcb629252616803c6299b
@@ -15,22 +15,34 @@ module Fastlane
15
15
 
16
16
  UI.message("Verifying #{path}")
17
17
 
18
- case File.extname(path).downcase
19
- when '.app'
20
- verify_app_bundle(path: path, expected_authority: params[:expected_authority], verify_notarization: params[:verify_notarization])
21
- when '.dmg'
18
+ extension = File.extname(path).downcase
19
+ if mach_o?(path)
20
+ verify_binary(path: path, expected_authority: params[:expected_authority], verify_hardened_runtime: params[:verify_hardened_runtime], verify_notarization: params[:verify_notarization])
21
+ elsif extension == '.app'
22
+ verify_app_bundle(path: path, expected_authority: params[:expected_authority], verify_hardened_runtime: params[:verify_hardened_runtime], verify_notarization: params[:verify_notarization])
23
+ elsif extension == '.dmg'
24
+ UI.message("Skipping the hardened runtime check for #{path}: it only applies to code, not to a disk image.") if params[:verify_hardened_runtime]
22
25
  verify_disk_image(path: path, expected_authority: params[:expected_authority], verify_notarization: params[:verify_notarization])
23
26
  else
24
- UI.user_error!("Don't know how to verify #{path}. Supported artifacts are `.app` bundles and `.dmg` disk images")
27
+ UI.user_error!("Don't know how to verify #{path}. Supported artifacts are `.app` bundles, `.dmg` disk images and Mach-O binaries")
25
28
  end
26
29
  end
27
30
 
28
31
  UI.success("Verified #{paths.length} artifact(s)")
29
32
  end
30
33
 
31
- def self.verify_app_bundle(path:, expected_authority:, verify_notarization:)
34
+ # Thin 32- and 64-bit, then universal, in both byte orders.
35
+ MACH_O_MAGIC_NUMBERS = %w[feedface feedfacf cefaedfe cffaedfe cafebabe cafebabf bebafeca bfbafeca].freeze
36
+
37
+ # Recognizes a bare binary by its content, because its name can look like it has an extension, e.g. `tool-v1.2.3`.
38
+ #
39
+ def self.mach_o?(path)
40
+ File.file?(path) && MACH_O_MAGIC_NUMBERS.include?(File.binread(path, 4).to_s.unpack1('H*'))
41
+ end
42
+
43
+ def self.verify_app_bundle(path:, expected_authority:, verify_hardened_runtime:, verify_notarization:)
32
44
  UI.user_error!("#{path} is not signed at all") unless signed?(path, deep: true)
33
- verify_authority!(path: path, expected_authority: expected_authority) unless expected_authority.nil?
45
+ verify_signature_details!(path: path, expected_authority: expected_authority, verify_hardened_runtime: verify_hardened_runtime)
34
46
 
35
47
  return unless verify_notarization
36
48
 
@@ -49,7 +61,7 @@ module Fastlane
49
61
  UI.message("Checking whether #{path} is signed. Disk images usually aren't, so a `codesign` failure due to the image being unsigned is expected and tolerated (other signature failures will still fail).")
50
62
 
51
63
  if signed?(path)
52
- verify_authority!(path: path, expected_authority: expected_authority) unless expected_authority.nil?
64
+ verify_signature_details!(path: path, expected_authority: expected_authority, verify_hardened_runtime: false)
53
65
  verify!("#{path} was rejected by Gatekeeper", 'spctl', '--assess', '--type', 'open', '--context', 'context:primary-signature', '--verbose=2', path) if verify_notarization
54
66
  else
55
67
  UI.important("#{path} is not signed — skipping its signature checks. We expect that the app it contains is the one carrying the signature.")
@@ -58,6 +70,14 @@ module Fastlane
58
70
  verify!("#{path} has no notarization ticket stapled to it", 'xcrun', 'stapler', 'validate', path) if verify_notarization
59
71
  end
60
72
 
73
+ def self.verify_binary(path:, expected_authority:, verify_hardened_runtime:, verify_notarization:)
74
+ UI.user_error!("#{path} is not signed at all") unless signed?(path)
75
+ verify_signature_details!(path: path, expected_authority: expected_authority, verify_hardened_runtime: verify_hardened_runtime)
76
+
77
+ # `--type execute` rejects any bare binary, notarized or not, as `does not seem to be an app`.
78
+ verify!("#{path} was rejected by Gatekeeper", 'spctl', '--assess', '--type', 'open', '--context', 'context:primary-signature', '--verbose=2', path) if verify_notarization
79
+ end
80
+
61
81
  # Distinguishes an artifact that carries no signature at all from one whose signature is
62
82
  # broken: the former is expected for a disk image, the latter always a failure.
63
83
  #
@@ -80,11 +100,33 @@ module Fastlane
80
100
  sh(*command, error_callback: ->(_) { UI.user_error!(error_message) })
81
101
  end
82
102
 
83
- def self.verify_authority!(path:, expected_authority:)
103
+ def self.verify_signature_details!(path:, expected_authority:, verify_hardened_runtime:)
104
+ return if expected_authority.nil? && !verify_hardened_runtime
105
+
106
+ signature_details(path).each do |details|
107
+ UI.user_error!("#{path} is not signed by '#{expected_authority}':\n#{details}") unless expected_authority.nil? || details.lines(chomp: true).include?("Authority=#{expected_authority}")
108
+ UI.user_error!("#{path} is not signed with the hardened runtime:\n#{details}") if verify_hardened_runtime && !code_directory_flags(details).include?('runtime')
109
+ end
110
+ end
111
+
112
+ # Each architecture of universal code carries its own signature, but `codesign --display`
113
+ # only shows the one matching this Mac's, so the others are displayed one at a time.
114
+ #
115
+ # @return [Array<String>] The `codesign --display` output for each architecture.
116
+ #
117
+ def self.signature_details(path)
84
118
  details = sh('codesign', '--display', '--verbose=2', path)
85
- return if details.include?("Authority=#{expected_authority}")
119
+ architectures = details[/^Format=.*Mach-O universal \(([^)]+)\)/, 1]&.split
120
+ return [details] if architectures.nil?
121
+
122
+ architectures.map { |architecture| sh('codesign', '--display', '--verbose=2', '--arch', architecture, path) }
123
+ end
86
124
 
87
- UI.user_error!("#{path} is not signed by '#{expected_authority}':\n#{details}")
125
+ # The flags of the CodeDirectory line, e.g. `%w[adhoc runtime]` for `flags=0x10002(adhoc,runtime)`.
126
+ # The `Executable=` line can contain `flags=` too, as part of the path.
127
+ #
128
+ def self.code_directory_flags(details)
129
+ details[/^CodeDirectory\b.*?\bflags=0x\h+\(([^)]*)\)/, 1]&.split(',') || []
88
130
  end
89
131
 
90
132
  #####################################################
@@ -99,11 +141,16 @@ module Fastlane
99
141
  <<~DETAILS
100
142
  Verify that the given macOS artifacts are signed, and optionally notarized.
101
143
 
102
- The checks that apply are picked from the artifact's extension:
144
+ The checks that apply are picked from the kind of artifact:
103
145
 
104
146
  - `.app` — the signature is valid and satisfies its designated requirement, Gatekeeper accepts
105
147
  the bundle for execution, and a notarization ticket is stapled to it.
106
148
  - `.dmg` — if the image is signed, the signature is valid (and can be checked against the expected authority) and Gatekeeper accepts opening it; when `verify_notarization` is true, a notarization ticket is stapled to the image.
149
+ - a bare Mach-O binary, whatever its name — the signature is valid and can be checked against the expected authority, and Gatekeeper accepts it as notarized. A bare binary can't be stapled, so that acceptance relies on an online lookup that can lag a fresh submission.
150
+
151
+ `verify_hardened_runtime` checks that app bundles and bare binaries are signed with the hardened runtime.
152
+ Notarization requires it, so `verify_notarization` already covers it implicitly. Use this option to catch a missing hardened runtime before submitting for notarization.
153
+ It doesn't apply to disk images.
107
154
  DETAILS
108
155
  end
109
156
 
@@ -111,7 +158,7 @@ module Fastlane
111
158
  [
112
159
  FastlaneCore::ConfigItem.new(
113
160
  key: :artifact_path,
114
- description: 'The path, or list of paths, to the `.app` bundle(s) or `.dmg` disk image(s) to verify',
161
+ description: 'The path, or list of paths, to the `.app` bundle(s), `.dmg` disk image(s) or bare binaries to verify',
115
162
  type: Array,
116
163
  verify_block: proc do |value|
117
164
  UI.user_error!('`artifact_path` must be a String or an Array of Strings') unless value.all?(String)
@@ -125,9 +172,15 @@ module Fastlane
125
172
  optional: true,
126
173
  default_value: nil
127
174
  ),
175
+ FastlaneCore::ConfigItem.new(
176
+ key: :verify_hardened_runtime,
177
+ description: 'Whether to also assert that app bundles and bare binaries are signed with the hardened runtime. Disk images are skipped',
178
+ type: Boolean,
179
+ default_value: false
180
+ ),
128
181
  FastlaneCore::ConfigItem.new(
129
182
  key: :verify_notarization,
130
- description: 'Whether to also assert that the artifact is accepted by Gatekeeper and has a notarization ticket stapled to it',
183
+ description: 'Whether to also assert that the artifact is accepted by Gatekeeper and, unless it is a bare binary, has a notarization ticket stapled to it',
131
184
  type: Boolean,
132
185
  default_value: true
133
186
  ),
@@ -3,6 +3,6 @@
3
3
  module Fastlane
4
4
  module Wpmreleasetoolkit
5
5
  NAME = 'fastlane-plugin-wpmreleasetoolkit'
6
- VERSION = '15.3.0'
6
+ VERSION = '15.4.0'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-wpmreleasetoolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.3.0
4
+ version: 15.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
@@ -130,7 +130,7 @@ dependencies:
130
130
  version: '1.19'
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: 1.19.4
133
+ version: 1.19.5
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -140,7 +140,7 @@ dependencies:
140
140
  version: '1.19'
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
- version: 1.19.4
143
+ version: 1.19.5
144
144
  - !ruby/object:Gem::Dependency
145
145
  name: octokit
146
146
  requirement: !ruby/object:Gem::Requirement