fastlane 2.241.1 → 2.242.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.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +39 -39
  3. data/cert/lib/cert/runner.rb +1 -1
  4. data/credentials_manager/README.md +3 -3
  5. data/credentials_manager/lib/credentials_manager/account_manager.rb +13 -3
  6. data/deliver/lib/deliver/runner.rb +5 -0
  7. data/fastlane/lib/assets/certificates/AppleIncRootCertificate.cer +0 -0
  8. data/fastlane/lib/assets/certificates/AppleRootCA-G3.cer +0 -0
  9. data/fastlane/lib/fastlane/action.rb +8 -6
  10. data/fastlane/lib/fastlane/actions/app_store_connect_api_key.rb +1 -1
  11. data/fastlane/lib/fastlane/actions/changelog_from_git_commits.rb +0 -3
  12. data/fastlane/lib/fastlane/actions/clipboard.rb +1 -1
  13. data/fastlane/lib/fastlane/actions/commit_version_bump.rb +0 -1
  14. data/fastlane/lib/fastlane/actions/create_keychain.rb +20 -29
  15. data/fastlane/lib/fastlane/actions/delete_keychain.rb +5 -3
  16. data/fastlane/lib/fastlane/actions/docs/build_app.md +1 -1
  17. data/fastlane/lib/fastlane/actions/docs/create_app_online.md +1 -1
  18. data/fastlane/lib/fastlane/actions/docs/frame_screenshots.md +4 -4
  19. data/fastlane/lib/fastlane/actions/docs/get_provisioning_profile.md +1 -1
  20. data/fastlane/lib/fastlane/actions/docs/upload_to_app_store.md.erb +1 -1
  21. data/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md +12 -0
  22. data/fastlane/lib/fastlane/actions/download_app_privacy_details_from_app_store.rb +5 -4
  23. data/fastlane/lib/fastlane/actions/download_dsyms.rb +3 -1
  24. data/fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb +1 -0
  25. data/fastlane/lib/fastlane/actions/git_pull.rb +1 -1
  26. data/fastlane/lib/fastlane/actions/hg_commit_version_bump.rb +0 -1
  27. data/fastlane/lib/fastlane/actions/import_certificate.rb +18 -6
  28. data/fastlane/lib/fastlane/actions/import_from_gem.rb +70 -0
  29. data/fastlane/lib/fastlane/actions/jazzy.rb +1 -1
  30. data/fastlane/lib/fastlane/actions/lcov.rb +1 -1
  31. data/fastlane/lib/fastlane/actions/mailgun.rb +2 -2
  32. data/fastlane/lib/fastlane/actions/make_changelog_from_jenkins.rb +1 -1
  33. data/fastlane/lib/fastlane/actions/notarize.rb +55 -7
  34. data/fastlane/lib/fastlane/actions/prompt.rb +1 -1
  35. data/fastlane/lib/fastlane/actions/push_to_git_remote.rb +2 -2
  36. data/fastlane/lib/fastlane/actions/sh.rb +20 -2
  37. data/fastlane/lib/fastlane/actions/sourcedocs.rb +2 -2
  38. data/fastlane/lib/fastlane/actions/swiftlint.rb +5 -2
  39. data/fastlane/lib/fastlane/actions/unlock_keychain.rb +17 -29
  40. data/fastlane/lib/fastlane/actions/update_fastlane.rb +10 -3
  41. data/fastlane/lib/fastlane/actions/update_project_code_signing.rb +2 -1
  42. data/fastlane/lib/fastlane/actions/update_project_provisioning.rb +21 -18
  43. data/fastlane/lib/fastlane/actions/upload_app_privacy_details_to_app_store.rb +1 -1
  44. data/fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb +8 -2
  45. data/fastlane/lib/fastlane/actions/verify_build.rb +2 -1
  46. data/fastlane/lib/fastlane/actions/verify_pod_keys.rb +2 -1
  47. data/fastlane/lib/fastlane/actions/xcodebuild.rb +1 -1
  48. data/fastlane/lib/fastlane/cli_tools_distributor.rb +7 -0
  49. data/fastlane/lib/fastlane/commands_generator.rb +7 -1
  50. data/fastlane/lib/fastlane/environment_printer.rb +14 -14
  51. data/fastlane/lib/fastlane/fast_file.rb +35 -4
  52. data/fastlane/lib/fastlane/helper/sh_helper.rb +27 -45
  53. data/fastlane/lib/fastlane/lane_list.rb +1 -1
  54. data/fastlane/lib/fastlane/plugins/plugin_manager.rb +2 -2
  55. data/fastlane/lib/fastlane/plugins/template/.rubocop.yml +0 -2
  56. data/fastlane/lib/fastlane/runner.rb +4 -6
  57. data/fastlane/lib/fastlane/server/socket_server.rb +57 -7
  58. data/fastlane/lib/fastlane/server/socket_server_action_command_executor.rb +4 -4
  59. data/fastlane/lib/fastlane/swift_fastlane_api_generator.rb +3 -3
  60. data/fastlane/lib/fastlane/swift_lane_manager.rb +32 -11
  61. data/fastlane/lib/fastlane/version.rb +2 -1
  62. data/fastlane/swift/ArgumentProcessor.swift +10 -2
  63. data/fastlane/swift/Deliverfile.swift +1 -1
  64. data/fastlane/swift/DeliverfileProtocol.swift +1 -1
  65. data/fastlane/swift/Fastlane.swift +46 -152
  66. data/fastlane/swift/Gymfile.swift +1 -1
  67. data/fastlane/swift/GymfileProtocol.swift +1 -1
  68. data/fastlane/swift/MainProcess.swift +27 -0
  69. data/fastlane/swift/Matchfile.swift +1 -1
  70. data/fastlane/swift/MatchfileProtocol.swift +1 -1
  71. data/fastlane/swift/Precheckfile.swift +1 -1
  72. data/fastlane/swift/PrecheckfileProtocol.swift +1 -1
  73. data/fastlane/swift/RubyCommand.swift +1 -9
  74. data/fastlane/swift/RubyCommandable.swift +3 -2
  75. data/fastlane/swift/Runner.swift +1 -1
  76. data/fastlane/swift/Scanfile.swift +1 -1
  77. data/fastlane/swift/ScanfileProtocol.swift +1 -1
  78. data/fastlane/swift/Screengrabfile.swift +1 -1
  79. data/fastlane/swift/ScreengrabfileProtocol.swift +1 -1
  80. data/fastlane/swift/Snapshotfile.swift +1 -1
  81. data/fastlane/swift/SnapshotfileProtocol.swift +1 -1
  82. data/fastlane/swift/main.swift +1 -1
  83. data/fastlane_core/lib/fastlane_core/cert_checker.rb +40 -76
  84. data/fastlane_core/lib/fastlane_core/command_executor.rb +128 -7
  85. data/fastlane_core/lib/fastlane_core/configuration/config_item.rb +1 -1
  86. data/fastlane_core/lib/fastlane_core/configuration/configuration_file.rb +1 -1
  87. data/fastlane_core/lib/fastlane_core/device_manager.rb +14 -5
  88. data/fastlane_core/lib/fastlane_core/fastlane_pty.rb +25 -10
  89. data/fastlane_core/lib/fastlane_core/helper.rb +26 -2
  90. data/fastlane_core/lib/fastlane_core/ios_app_identifier_guesser.rb +1 -1
  91. data/fastlane_core/lib/fastlane_core/itunes_transporter.rb +41 -22
  92. data/fastlane_core/lib/fastlane_core/keychain_importer.rb +48 -71
  93. data/fastlane_core/lib/fastlane_core/pkg_file_analyser.rb +5 -1
  94. data/fastlane_core/lib/fastlane_core/print_table.rb +1 -1
  95. data/fastlane_core/lib/fastlane_core/queue_worker.rb +0 -2
  96. data/fastlane_core/lib/fastlane_core/stored_passwords.rb +29 -0
  97. data/fastlane_core/lib/fastlane_core/string_filters.rb +1 -2
  98. data/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb +8 -4
  99. data/fastlane_core/lib/fastlane_core/ui/github_issue_inspector_reporter.rb +2 -2
  100. data/fastlane_core/lib/fastlane_core/ui/implementations/shell.rb +1 -1
  101. data/frameit/lib/frameit/device_types.rb +11 -4
  102. data/frameit/lib/frameit/editor.rb +31 -12
  103. data/frameit/lib/frameit/frame_downloader.rb +4 -1
  104. data/gym/lib/gym/detect_values.rb +10 -10
  105. data/gym/lib/gym/options.rb +1 -7
  106. data/gym/lib/gym/runner.rb +6 -1
  107. data/match/lib/match/encryption/encryption.rb +6 -1
  108. data/match/lib/match/encryption/openssl.rb +8 -3
  109. data/match/lib/match/portal_fetcher.rb +12 -6
  110. data/match/lib/match/runner.rb +4 -1
  111. data/match/lib/match/storage/gitlab/secure_file.rb +2 -1
  112. data/match/lib/match/storage/google_cloud_storage.rb +1 -1
  113. data/match/lib/match/storage/interface.rb +10 -0
  114. data/match/lib/match/storage/s3_storage.rb +1 -1
  115. data/pem/lib/pem/manager.rb +3 -3
  116. data/precheck/lib/precheck/runner.rb +4 -2
  117. data/scan/lib/scan/detect_values.rb +0 -1
  118. data/scan/lib/scan/runner.rb +1 -0
  119. data/sigh/lib/assets/resign.sh +10 -3
  120. data/sigh/lib/sigh/manager.rb +5 -1
  121. data/sigh/lib/sigh/resign.rb +5 -21
  122. data/snapshot/lib/snapshot/reset_simulators.rb +5 -2
  123. data/snapshot/lib/snapshot/runner.rb +0 -1
  124. data/spaceship/lib/spaceship/base.rb +1 -1
  125. data/spaceship/lib/spaceship/client.rb +13 -4
  126. data/spaceship/lib/spaceship/connect_api/api_client.rb +12 -14
  127. data/spaceship/lib/spaceship/connect_api/models/bundle_id.rb +1 -1
  128. data/spaceship/lib/spaceship/connect_api/models/user.rb +7 -3
  129. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +9 -11
  130. data/spaceship/lib/spaceship/connect_api/token.rb +21 -1
  131. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +3 -1
  132. data/spaceship/lib/spaceship/helper/plist_middleware.rb +2 -2
  133. data/spaceship/lib/spaceship/portal/portal_client.rb +8 -8
  134. data/spaceship/lib/spaceship/test_flight/client.rb +1 -5
  135. data/supply/lib/supply/client.rb +1 -1
  136. data/supply/lib/supply/options.rb +6 -0
  137. data/supply/lib/supply/uploader.rb +28 -2
  138. metadata +28 -25
  139. data/fastlane/lib/fastlane/actions/hockey.rb +0 -400
  140. data/fastlane/lib/fastlane/actions/typetalk.rb +0 -93
@@ -31,7 +31,7 @@ module Frameit
31
31
  if @frame_path # Mac doesn't need a frame
32
32
  self.frame = MiniMagick::Image.open(@frame_path)
33
33
  # Rotate the frame according to the device orientation
34
- self.frame.rotate(self.rotation_for_device_orientation)
34
+ rotate_image(self.frame, self.rotation_for_device_orientation)
35
35
  elsif self.class == Editor
36
36
  # Couldn't find device frame (probably an iPhone 4, for which there are no images available any more)
37
37
  # Message is already shown elsewhere
@@ -86,8 +86,20 @@ module Frameit
86
86
  # only. Instead of doing the calculations ourselves, it's much easier to let
87
87
  # imagemagick do the hard lifting for landscape screenshots
88
88
  rotation = self.rotation_for_device_orientation
89
- frame.rotate(-rotation)
90
- @image.rotate(-rotation)
89
+ rotate_image(frame, -rotation)
90
+ rotate_image(@image, -rotation)
91
+
92
+ # Optional screen masks preserve asymmetric corners and camera cutouts.
93
+ # A portrait mask is applied after normalizing the screenshot orientation.
94
+ if offset['mask']
95
+ mask_path = File.join(FrameDownloader.templates_path, offset['mask'])
96
+ UI.user_error!("Could not find screen mask '#{mask_path}'") unless File.file?(mask_path)
97
+ mask = MiniMagick::Image.open(mask_path)
98
+ mask.resize("#{image.width}x#{image.height}!")
99
+ @image = image.composite(mask, "png") do |c|
100
+ c.compose("CopyOpacity")
101
+ end
102
+ end
91
103
 
92
104
  # Debug Mode: Add filename to frame
93
105
  if self.debug_mode
@@ -135,8 +147,14 @@ module Frameit
135
147
  end
136
148
 
137
149
  # Revert the rotation from above
138
- frame.rotate(rotation)
139
- @image.rotate(rotation)
150
+ rotate_image(frame, rotation)
151
+ rotate_image(@image, rotation)
152
+ end
153
+
154
+ # Portrait screenshots need no rotation. ImageMagick would still decode and
155
+ # re-encode the whole image to rotate it by 0 degrees, so skip that pass.
156
+ def rotate_image(image, degrees)
157
+ image.rotate(degrees) unless degrees.zero?
140
158
  end
141
159
 
142
160
  def offset
@@ -283,8 +301,10 @@ module Frameit
283
301
  left_space = (background.width / 2.0 - image.width / 2.0).round
284
302
 
285
303
  @image = background.composite(image, "png") do |c|
286
- colorspace = image.data["colorspace"]
287
- c.colorspace(colorspace) if colorspace
304
+ # Ask for the colorspace alone: `image.data` makes ImageMagick compute
305
+ # statistics over every pixel to print them all as JSON
306
+ colorspace = image["%[colorspace]"]
307
+ c.colorspace(colorspace) unless colorspace.to_s.empty?
288
308
 
289
309
  c.compose("Over")
290
310
  c.geometry("+#{left_space}+#{device_top(background)}")
@@ -431,10 +451,6 @@ module Frameit
431
451
  empty_path = File.join(Frameit::ROOT, "lib/assets/empty.png")
432
452
  text_image = MiniMagick::Image.open(empty_path)
433
453
  image_height = max_height # gets trimmed afterwards anyway, and on the iPad the `y` would get cut
434
- text_image.combine_options do |i|
435
- # Oversize as the text might be larger than the actual image. We're trimming afterwards anyway
436
- i.resize("#{max_width * 5.0}x#{image_height}!") # `!` says it should ignore the ratio
437
- end
438
454
 
439
455
  current_font = font(key)
440
456
  text = fetch_text(key)
@@ -446,8 +462,11 @@ module Frameit
446
462
 
447
463
  interline_spacing = @config['interline_spacing']
448
464
 
449
- # Add the actual title
465
+ # Size the canvas and add the actual title in a single pass, as every
466
+ # pass reads and writes the whole oversized canvas
450
467
  text_image.combine_options do |i|
468
+ # Oversize as the text might be larger than the actual image. We're trimming afterwards anyway
469
+ i.resize("#{max_width * 5.0}x#{image_height}!") # `!` says it should ignore the ratio
451
470
  i.font(current_font) if current_font
452
471
  i.weight(@config[key.to_s]['font_weight']) if @config[key.to_s]['font_weight']
453
472
  i.gravity("Center")
@@ -55,7 +55,7 @@ module Frameit
55
55
 
56
56
  def print_disclaimer
57
57
  UI.header("Device frames disclaimer")
58
- UI.important("All used device frames are available via Facebook Design: https://design.facebook.com/toolsandresources/devices/")
58
+ UI.important("Device frames include assets from Facebook Design: https://design.facebook.com/toolsandresources/devices/")
59
59
  UI.message("----------------------------------------")
60
60
  UI.message("While Facebook has redrawn and shares these assets for the benefit")
61
61
  UI.message("of the design community, Facebook does not own any of the underlying")
@@ -66,6 +66,9 @@ module Frameit
66
66
  UI.message("Facebook disclaims all express or implied warranties with respect to these assets, including")
67
67
  UI.message("non-infringement of intellectual property rights.")
68
68
  UI.message("----------------------------------------")
69
+ UI.important("iPhone Duo artwork is from Apple Design Resources: https://developer.apple.com/design/resources/")
70
+ UI.message("Apple artwork remains subject to Apple's license supplied with the original download.")
71
+ UI.message("----------------------------------------")
69
72
  end
70
73
 
71
74
  private
@@ -1,5 +1,6 @@
1
1
  require 'fastlane_core/core_ext/cfpropertylist'
2
2
  require 'fastlane_core/project'
3
+ require 'security'
3
4
  require_relative 'module'
4
5
  require_relative 'code_signing_mapping'
5
6
 
@@ -41,8 +42,7 @@ module Gym
41
42
 
42
43
  # Make sure the output name is valid and remove a trailing `.ipa` extension
43
44
  # as it will be added by gym for free
44
- config[:output_name].gsub!(".ipa", "")
45
- config[:output_name].gsub!(File::SEPARATOR, "_")
45
+ config[:output_name] = config[:output_name].gsub(".ipa", "").gsub(File::SEPARATOR, "_")
46
46
 
47
47
  return config
48
48
  end
@@ -117,16 +117,16 @@ module Gym
117
117
  return
118
118
  end
119
119
 
120
- output = Helper.backticks("security find-certificate -a -c \"#{prefix}\"", print: false)
121
-
122
- # Find matches, filter by team_id, prepend prefix for full cert name
123
- certs = output.scan(/"(?:#{prefix})(.*)"/)
124
- certs = certs.flatten.uniq.select do |cert|
125
- cert.include?(team_id)
126
- end.map do |cert|
127
- prefix + cert
120
+ names = begin
121
+ Security::Certificate.find(name: prefix).map(&:name)
122
+ rescue Security::Error => e
123
+ UI.error("Could not search for installer certificates: #{e.message}")
124
+ []
128
125
  end
129
126
 
127
+ # Filter by team_id, the part after the prefix
128
+ certs = names.uniq.select { |name| name.start_with?(prefix) && name.delete_prefix(prefix).include?(team_id) }
129
+
130
130
  if certs.first
131
131
  UI.verbose("Detected installer certificate to use: #{certs.first}")
132
132
  Gym.config[:installer_cert_name] = certs.first
@@ -124,17 +124,11 @@ module Gym
124
124
  description: "Path to an export options plist or a hash with export options. Use 'xcodebuild -help' to print the full set of available options",
125
125
  optional: true,
126
126
  type: Hash,
127
- skip_type_validation: true,
128
- conflict_block: proc do |value|
129
- UI.user_error!("'#{value.key}' must be false to use 'export_options'")
130
- end),
127
+ skip_type_validation: true),
131
128
  FastlaneCore::ConfigItem.new(key: :export_xcargs,
132
129
  env_name: "GYM_EXPORT_XCARGS",
133
130
  description: "Pass additional arguments to xcodebuild for the package phase. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS=\"-ObjC -lstdc++\"",
134
131
  optional: true,
135
- conflict_block: proc do |value|
136
- UI.user_error!("'#{value.key}' must be false to use 'export_xcargs'")
137
- end,
138
132
  type: :shell_string),
139
133
  FastlaneCore::ConfigItem.new(key: :skip_build_archive,
140
134
  env_name: "GYM_SKIP_BUILD_ARCHIVE",
@@ -224,7 +224,12 @@ module Gym
224
224
 
225
225
  output_path = File.expand_path(File.join(Gym.config[:output_directory], Gym.config[:output_name] + ".app.dSYM.zip"))
226
226
  command = "cd #{containing_directory.shellescape} && zip -r #{output_path.shellescape} *.dSYM"
227
- Helper.backticks(command, print: !Gym.config[:silent])
227
+ FastlaneCore::CommandExecutor.execute(command: command,
228
+ print_all: !Gym.config[:silent],
229
+ print_command: !Gym.config[:silent],
230
+ error: proc do |output|
231
+ UI.user_error!("Could not compress the dSYM(s) to '#{output_path}':\n#{output}")
232
+ end)
228
233
  puts("") # new line
229
234
 
230
235
  UI.success("Successfully exported and compressed dSYM file")
@@ -1,6 +1,7 @@
1
1
  require 'base64'
2
2
  require 'openssl'
3
3
  require 'securerandom'
4
+ require 'fastlane_core/helper'
4
5
 
5
6
  module Match
6
7
  module Encryption
@@ -147,7 +148,11 @@ module Match
147
148
  content = File.read(file_path)
148
149
  e = MatchDataEncryption.new
149
150
  decrypted_data = e.decrypt(base64encoded_encrypted: content, password: password)
150
- File.binwrite(output_path, decrypted_data)
151
+ if File.extname(output_path) == ".p12"
152
+ FastlaneCore::Helper.open_owner_only(output_path, "wb") { |file| file.write(decrypted_data) }
153
+ else
154
+ File.binwrite(output_path, decrypted_data)
155
+ end
151
156
  end
152
157
  end
153
158
  end
@@ -67,6 +67,7 @@ module Match
67
67
  end
68
68
 
69
69
  def store_password(password)
70
+ return unless FastlaneCore::StoredPasswords.store?
70
71
  Security::InternetPassword.add(server_name(self.keychain_name), "", password)
71
72
  end
72
73
 
@@ -95,7 +96,11 @@ module Match
95
96
  unless password
96
97
  begin
97
98
  item = Security::InternetPassword.find(server: server_name(self.keychain_name))
98
- password = item.password if item
99
+ if item
100
+ password = item.password
101
+ server = server_name(self.keychain_name)
102
+ FastlaneCore::StoredPasswords.read_warning(server, what: "the match passphrase", remove_with: "security delete-internet-password -s #{server}", instead: "provide it with the MATCH_PASSWORD environment variable")&.each { |line| UI.important(line) }
103
+ end
99
104
  rescue Security::Error => ex
100
105
  UI.important("Could not read the local keychain: #{ex.message}")
101
106
  end
@@ -105,10 +110,10 @@ module Match
105
110
  if !UI.interactive?
106
111
  UI.error("Neither the MATCH_PASSWORD environment variable nor the local keychain contained a password.")
107
112
  UI.error("Bailing out instead of asking for a password, since this is non-interactive mode.")
108
- UI.user_error!("Try setting the MATCH_PASSWORD environment variable, or temporarily enable interactive mode to store a password.")
113
+ UI.user_error!("Try setting the MATCH_PASSWORD environment variable.")
109
114
  else
110
115
  UI.important("Enter the passphrase that should be used to encrypt/decrypt your certificates")
111
- UI.important("This passphrase is specific per repository and will be stored in your local keychain")
116
+ UI.important(FastlaneCore::StoredPasswords.store? ? "This passphrase is specific per repository and will be stored in your local keychain" : "This passphrase is specific per repository")
112
117
  UI.important("Make sure to remember the password, as you'll need it when you run match on a different machine")
113
118
  password = FastlaneCore::Helper.ask_password(message: "Passphrase for Match storage: ", confirm: true)
114
119
  store_password(password)
@@ -58,14 +58,20 @@ module Match
58
58
  devices
59
59
  end
60
60
 
61
- def self.bundle_ids(bundle_id_identifiers: nil)
62
- filter = { identifier: bundle_id_identifiers.join(',') } if bundle_id_identifiers
61
+ # App Store Connect refuses a filter value longer than 5000 characters; fastlane#29783 saw failures below that.
62
+ MAX_BUNDLE_ID_FILTER_LENGTH = 3500
63
63
 
64
- bundle_ids = Spaceship::ConnectAPI::BundleId.all(
65
- filter: filter
66
- )
64
+ def self.bundle_ids(bundle_id_identifiers: nil, max_bundle_id_filter_length: MAX_BUNDLE_ID_FILTER_LENGTH)
65
+ return Spaceship::ConnectAPI::BundleId.all(filter: nil) unless bundle_id_identifiers
67
66
 
68
- bundle_ids
67
+ filters = bundle_id_identifiers.each_with_object([]) do |identifier, list|
68
+ if list.empty? || list.last.length + 1 + identifier.length > max_bundle_id_filter_length
69
+ list << identifier.dup
70
+ else
71
+ list.last << ",#{identifier}"
72
+ end
73
+ end
74
+ filters.flat_map { |filter| Spaceship::ConnectAPI::BundleId.all(filter: { identifier: filter }) }
69
75
  end
70
76
  end
71
77
  end
@@ -250,7 +250,8 @@ module Match
250
250
 
251
251
  if params[:output_path]
252
252
  FileUtils.cp(cert_path, params[:output_path])
253
- FileUtils.cp(select_cert_or_key(paths: keys, certificate_id: certificate_id), params[:output_path])
253
+ key_path = select_cert_or_key(paths: keys, certificate_id: certificate_id)
254
+ FastlaneCore::Helper.open_owner_only(File.join(params[:output_path], File.basename(key_path)), "wb") { |file| IO.copy_stream(key_path, file) }
254
255
  end
255
256
 
256
257
  # Get and print info of certificate
@@ -387,6 +388,8 @@ module Match
387
388
 
388
389
  if Helper.mac?
389
390
  installed_profile = FastlaneCore::ProvisioningProfile.install(stored_profile_path, keychain_path)
391
+ else
392
+ UI.message("Skipping installation of provisioning profile as it would not work on this operating system.")
390
393
  end
391
394
 
392
395
  if params[:output_path]
@@ -2,6 +2,7 @@ require 'open-uri'
2
2
  require 'ostruct'
3
3
 
4
4
  require_relative '../../module'
5
+ require_relative '../interface'
5
6
 
6
7
  module Match
7
8
  module Storage
@@ -36,7 +37,7 @@ module Match
36
37
  url = URI("#{file_url}/download")
37
38
 
38
39
  begin
39
- destination_file = "#{working_directory}/#{@file.name}"
40
+ destination_file = Storage.download_path(working_directory, @file.name)
40
41
 
41
42
  create_subfolders(working_directory)
42
43
  File.open(destination_file, "wb") do |saved_file|
@@ -158,7 +158,7 @@ module Match
158
158
 
159
159
  bucket.files.each do |current_file|
160
160
  file_path = current_file.name # e.g. "N8X438SEU2/certs/distribution/XD9G7QCACF.cer"
161
- download_path = File.join(self.working_directory, file_path)
161
+ download_path = Storage.download_path(self.working_directory, file_path)
162
162
 
163
163
  FileUtils.mkdir_p(File.expand_path("..", download_path))
164
164
  UI.verbose("Downloading file from Google Cloud Storage '#{file_path}' on bucket #{self.bucket_name}")
@@ -2,6 +2,16 @@ require_relative '../module'
2
2
 
3
3
  module Match
4
4
  module Storage
5
+ # Where a file named `remote_name` by the storage is written in `working_directory`.
6
+ # Fails when the name would place it outside, e.g. with `..` segments.
7
+ def self.download_path(working_directory, remote_name)
8
+ root = File.expand_path(working_directory)
9
+ path = File.expand_path(File.join(root, remote_name))
10
+ return path if path.start_with?(root + File::SEPARATOR)
11
+
12
+ UI.user_error!("Refusing to download #{remote_name.inspect}: it would be written outside #{root}")
13
+ end
14
+
5
15
  class Interface
6
16
  MATCH_VERSION_FILE_NAME = "match_version.txt"
7
17
  # The working directory in which we download all the profiles
@@ -114,7 +114,7 @@ module Match
114
114
  file_path = strip_s3_object_prefix(object.key) # :s3_object_prefix:team_id/path/to/file
115
115
 
116
116
  # strip s3_prefix from file_path
117
- download_path = File.join(self.working_directory, file_path)
117
+ download_path = Storage.download_path(self.working_directory, file_path)
118
118
 
119
119
  FileUtils.mkdir_p(File.expand_path("..", download_path))
120
120
  UI.verbose("Downloading file from S3 '#{file_path}' on bucket #{self.s3_bucket}")
@@ -73,7 +73,7 @@ module PEM
73
73
 
74
74
  if PEM.config[:save_private_key]
75
75
  private_key_path = File.join(output_path, "#{filename_base}.pkey")
76
- File.write(private_key_path, pkey.to_pem)
76
+ FastlaneCore::Helper.open_owner_only(private_key_path) { |file| file.write(pkey.to_pem) }
77
77
  UI.message("Private key: ".green + Pathname.new(private_key_path).realpath.to_s)
78
78
  end
79
79
 
@@ -81,12 +81,12 @@ module PEM
81
81
  p12_cert_path = File.join(output_path, "#{filename_base}.p12")
82
82
  p12_password = PEM.config[:p12_password] == "" ? nil : PEM.config[:p12_password]
83
83
  p12 = OpenSSL::PKCS12.create(p12_password, certificate_type, pkey, x509_certificate)
84
- File.write(p12_cert_path, p12.to_der.force_encoding("UTF-8"))
84
+ FastlaneCore::Helper.open_owner_only(p12_cert_path) { |file| file.write(p12.to_der.force_encoding("UTF-8")) }
85
85
  UI.message("p12 certificate: ".green + Pathname.new(p12_cert_path).realpath.to_s)
86
86
  end
87
87
 
88
88
  x509_cert_path = File.join(output_path, "#{filename_base}.pem")
89
- File.write(x509_cert_path, x509_certificate.to_pem + pkey.to_pem)
89
+ FastlaneCore::Helper.open_owner_only(x509_cert_path) { |file| file.write(x509_certificate.to_pem + pkey.to_pem) }
90
90
  UI.message("PEM: ".green + Pathname.new(x509_cert_path).realpath.to_s)
91
91
  return x509_cert_path
92
92
  end
@@ -8,6 +8,9 @@ require_relative 'options'
8
8
 
9
9
  module Precheck
10
10
  class Runner
11
+ class BlockingViolationError < FastlaneCore::Interface::FastlaneError
12
+ end
13
+
11
14
  attr_accessor :spaceship
12
15
 
13
16
  # Uses the spaceship to download app metadata and then run all rule checkers
@@ -67,8 +70,7 @@ module Precheck
67
70
  end
68
71
 
69
72
  if processor_result.should_trigger_user_error?
70
- UI.user_error!("precheck 👮‍♀️ 👮 found one or more potential problems that must be addressed before submitting to review")
71
- return false
73
+ raise BlockingViolationError, "precheck 👮‍♀️ 👮 found one or more potential problems that must be addressed before submitting to review"
72
74
  end
73
75
 
74
76
  if processor_result.has_errors_or_warnings?
@@ -1,7 +1,6 @@
1
1
  require 'fastlane_core/device_manager'
2
2
  require 'fastlane_core/project'
3
3
  require 'pathname'
4
- require 'set'
5
4
  require_relative 'module'
6
5
 
7
6
  module Scan
@@ -378,6 +378,7 @@ module Scan
378
378
  end
379
379
 
380
380
  def test_results
381
+ UI.deprecated("Scan::Runner#test_results is deprecated and will be removed in a future version of fastlane; scan no longer uses it. Read the test results from the result bundle with Trainer::TestParser.")
381
382
  temp_junit_report = Scan.cache[:temp_junit_report]
382
383
  return File.read(temp_junit_report) if temp_junit_report && File.file?(temp_junit_report)
383
384
 
@@ -383,10 +383,17 @@ function provision_for_bundle_id {
383
383
  done
384
384
  }
385
385
 
386
+ # Print the plist inside a provisioning profile. Unlike `security cms -D`, this imports no certificate
387
+ # into the default keychain (#30186). Like it, it does not check the signature.
388
+ function decode_provision {
389
+
390
+ /usr/bin/openssl smime -verify -noverify -nosigs -inform DER -in "$1" 2> >(grep -v '^Verification successful$' >&2)
391
+ }
392
+
386
393
  # Find the bundle identifier contained inside a provisioning profile
387
394
  function bundle_id_for_provision {
388
395
 
389
- local FULL_BUNDLE_ID=$(PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< "$(security cms -D -i "$1")")
396
+ local FULL_BUNDLE_ID=$(PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< "$(decode_provision "$1")")
390
397
  checkStatus
391
398
  echo "${FULL_BUNDLE_ID#*.}"
392
399
  }
@@ -502,7 +509,7 @@ function resign {
502
509
 
503
510
  # Replace the embedded mobile provisioning profile
504
511
  log "Validating the new provisioning profile: $NEW_PROVISION"
505
- security cms -D -i "$NEW_PROVISION" > "$TEMP_DIR/profile.plist"
512
+ decode_provision "$NEW_PROVISION" > "$TEMP_DIR/profile.plist"
506
513
  checkStatus
507
514
 
508
515
  APP_IDENTIFIER_PREFIX=$(PlistBuddy -c "Print :Entitlements:application-identifier" "$TEMP_DIR/profile.plist" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
@@ -681,7 +688,7 @@ function resign {
681
688
 
682
689
  # Get the old and the new team ID
683
690
  # Old team ID is not part of app entitlements, have to get it from old embedded provisioning profile
684
- security cms -D -i "$TEMP_DIR/old-embedded.mobileprovision" > "$TEMP_DIR/old-embedded-profile.plist"
691
+ decode_provision "$TEMP_DIR/old-embedded.mobileprovision" > "$TEMP_DIR/old-embedded-profile.plist"
685
692
  OLD_TEAM_ID=$(PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/old-embedded-profile.plist" 2>/dev/null)
686
693
  if [ "$OLD_TEAM_ID" == "" ]; then
687
694
  OLD_TEAM_ID="$OLD_APP_ID"
@@ -41,7 +41,11 @@ module Sigh
41
41
  ENV["SIGH_UDID"] = ENV["SIGH_UUID"] = uuid if uuid
42
42
  ENV["SIGH_NAME"] = name if name
43
43
 
44
- FastlaneCore::ProvisioningProfile.install(profile, keychain_path)
44
+ if Helper.mac?
45
+ FastlaneCore::ProvisioningProfile.install(profile, keychain_path)
46
+ else
47
+ UI.message("Skipping installation of provisioning profile as it would not work on this operating system.")
48
+ end
45
49
  end
46
50
  end
47
51
  end
@@ -1,4 +1,5 @@
1
1
  require 'shellwords'
2
+ require 'security'
2
3
  require 'fastlane_core/globals'
3
4
 
4
5
  require_relative 'module'
@@ -25,12 +26,11 @@ module Sigh
25
26
  if keychain_path
26
27
  keychain_path_absolute = File.expand_path(keychain_path)
27
28
 
28
- current_keychains = `security list-keychains`
29
- current_keychains.delete!("\n")
29
+ current_keychains = Security::Keychain.list(:user).map(&:filename)
30
30
 
31
31
  unless current_keychains.include?(keychain_path_absolute)
32
32
  previous_keychains = current_keychains
33
- `security list-keychains -s #{current_keychains} '#{keychain_path_absolute}'`
33
+ Security::Keychain.set_search_list(current_keychains + [keychain_path_absolute])
34
34
  end
35
35
  end
36
36
 
@@ -84,7 +84,7 @@ module Sigh
84
84
  false
85
85
  end
86
86
  ensure
87
- `security list-keychains -s #{previous_keychains}` if previous_keychains
87
+ Security::Keychain.set_search_list(previous_keychains) if previous_keychains
88
88
  end
89
89
 
90
90
  def get_inputs(options, args)
@@ -189,23 +189,7 @@ module Sigh
189
189
 
190
190
  # Hash of available signing identities
191
191
  def installed_identities
192
- available = request_valid_identities
193
- ids = {}
194
- available.split("\n").each do |current|
195
- begin
196
- sha1 = current.match(/[a-zA-Z0-9]{40}/).to_s
197
- name = current.match(/.*\"(.*)\"/)[1]
198
- ids[sha1] = name
199
- rescue
200
- nil
201
- end # the last line does not match
202
- end
203
-
204
- ids
205
- end
206
-
207
- def request_valid_identities
208
- `security find-identity -v -p codesigning`
192
+ Security::Identity.find.to_h { |identity| [identity.sha1, identity.name] }
209
193
  end
210
194
 
211
195
  def installed_identity_descriptions
@@ -18,6 +18,11 @@ module Snapshot
18
18
 
19
19
  UI.abort_with_message!("User cancelled action") unless sure
20
20
 
21
+ # Listed before deleting: with nothing listed, nothing would be created again
22
+ all_runtime_type = runtimes
23
+ all_device_types = `xcrun simctl list devicetypes`.scan(/(.*)\s\((.*)\)/)
24
+ UI.user_error!("`xcrun simctl list` returned no runtimes or no device types; no simulator was deleted") if all_runtime_type.empty? || all_device_types.empty?
25
+
21
26
  if ios_versions
22
27
  ios_versions.each do |version|
23
28
  FastlaneCore::Simulator.delete_all_by_version(os_version: version)
@@ -29,7 +34,6 @@ module Snapshot
29
34
  FastlaneCore::SimulatorTV.delete_all
30
35
  FastlaneCore::SimulatorWatch.delete_all
31
36
 
32
- all_runtime_type = runtimes
33
37
  # == Runtimes ==
34
38
  # iOS 9.3 (9.3 - 13E233) (com.apple.CoreSimulator.SimRuntime.iOS-9-3)
35
39
  # iOS 10.0 (10.0 - 14A345) (com.apple.CoreSimulator.SimRuntime.iOS-10-0)
@@ -47,7 +51,6 @@ module Snapshot
47
51
  tv_version_ids = filter_runtimes(all_runtime_type, 'tvOS')
48
52
  watch_versions_ids = filter_runtimes(all_runtime_type, 'watchOS')
49
53
 
50
- all_device_types = `xcrun simctl list devicetypes`.scan(/(.*)\s\((.*)\)/)
51
54
  # == Device Types ==
52
55
  # iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
53
56
  # iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
@@ -1,7 +1,6 @@
1
1
  require 'shellwords'
2
2
  require 'plist'
3
3
  require 'os'
4
- require 'thread'
5
4
  require 'terminal-table'
6
5
 
7
6
  require 'fastlane_core/print_table'
@@ -181,7 +181,7 @@ module Spaceship
181
181
  # ProvisioningProfile.some_other_method
182
182
  # #=> NoMethodError: undefined method `some_other_method' for ProvisioningProfile
183
183
  def method_missing(method_sym, *args, &block)
184
- module_name = method_sym.to_s
184
+ module_name = method_sym.to_s.dup
185
185
  module_name.sub!(/^[a-z\d]/) { $&.upcase }
186
186
  module_name.gsub!(%r{(?:_|(/))([a-z\d])}) { $2.upcase }
187
187
  if const_defined?(module_name)
@@ -252,6 +252,8 @@ module Spaceship
252
252
  else
253
253
  # Log to file by default
254
254
  path = File.join(Dir.tmpdir, "spaceship#{Time.now.to_i}_#{Process.pid}_#{Thread.current.object_id}.log")
255
+ # The log holds every request and response body: create it readable by its owner only
256
+ File.open(path, File::WRONLY | File::CREAT | File::APPEND, 0o600) {}
255
257
  @logger = Logger.new(path)
256
258
  end
257
259
 
@@ -279,10 +281,12 @@ module Spaceship
279
281
  def store_cookie(path: nil)
280
282
  path ||= persistent_cookie_path
281
283
  FileUtils.mkdir_p(File.expand_path("..", path))
284
+ File.chmod(0o700, File.expand_path("..", path))
282
285
 
283
286
  # really important to specify the session to true
284
287
  # otherwise myacinfo and more won't be stored
285
288
  @cookie.save(path, :yaml, session: true)
289
+ File.chmod(0o600, path)
286
290
  return File.read(path)
287
291
  end
288
292
 
@@ -880,6 +884,8 @@ module Spaceship
880
884
  begin
881
885
  if File.exist?(persistent_cookie_path)
882
886
  puts("Loading session from '#{persistent_cookie_path}'") if Spaceship::Globals.verbose?
887
+ File.chmod(0o700, File.expand_path("..", persistent_cookie_path))
888
+ File.chmod(0o600, persistent_cookie_path)
883
889
  @cookie.load(persistent_cookie_path)
884
890
  return true
885
891
  end
@@ -1144,7 +1150,7 @@ module Spaceship
1144
1150
 
1145
1151
  def log_response(method, url, response, headers = nil, &block)
1146
1152
  url ||= extract_key_from_block('url', &block)
1147
- body = response.body.kind_of?(String) ? response.body.force_encoding(Encoding::UTF_8) : response.body
1153
+ body = response.body.kind_of?(String) ? response.body.dup.force_encoding(Encoding::UTF_8) : response.body
1148
1154
  logger.debug("<< #{method.upcase} #{url}: #{response.status} #{body}")
1149
1155
  end
1150
1156
 
@@ -1183,15 +1189,18 @@ module Spaceship
1183
1189
 
1184
1190
  handle_error(response)
1185
1191
 
1186
- if response.body.to_s.include?("<title>302 Found</title>")
1192
+ # Error pages are HTML; converting a parsed JSON or plist body to a string for each check is slow on large responses
1193
+ body = response.body.kind_of?(String) ? response.body : ""
1194
+
1195
+ if body.include?("<title>302 Found</title>")
1187
1196
  raise AppleTimeoutError.new, "Apple 302 detected - this might be temporary server error, check https://developer.apple.com/system-status/ to see if there is a known downtime"
1188
1197
  end
1189
1198
 
1190
- if response.body.to_s.include?("<h3>Bad Gateway</h3>")
1199
+ if body.include?("<h3>Bad Gateway</h3>")
1191
1200
  raise BadGatewayError.new, "Apple 502 detected - this might be temporary server error, try again later"
1192
1201
  end
1193
1202
 
1194
- if response.body.to_s.include?("<title>503 Service Temporarily Unavailable</title>") || response.body.to_s.include?("<h1>503 Service Temporarily Unavailable</h1>")
1203
+ if body.include?("<title>503 Service Temporarily Unavailable</title>") || body.include?("<h1>503 Service Temporarily Unavailable</h1>")
1195
1204
  raise AppleTimeoutError.new, "Apple 503 detected - this might be temporary server error, check https://developer.apple.com/system-status/ to see if there is a known downtime"
1196
1205
  end
1197
1206