match/lib/match/storage/s3_storage.rb in fastlane-2.223.1 vs match/lib/match/storage/s3_storage.rb in fastlane-2.224.0

- old
+ new

@@ -99,12 +99,15 @@ return if @working_directory && Dir.exist?(@working_directory) # No existing working directory, creating a new one now self.working_directory = Dir.mktmpdir - s3_client.find_bucket!(s3_bucket).objects(prefix: s3_object_prefix).each do |object| + # If team_id is defined, use `:team/` as a prefix (appending it at the end of the `s3_object_prefix` if one provided by the user), + # so that we limit the download to only files that are specific to this team, and avoid downloads + decryption of unnecessary files. + key_prefix = team_id.nil? ? s3_object_prefix : File.join(s3_object_prefix, team_id, '').delete_prefix('/') + s3_client.find_bucket!(s3_bucket).objects(prefix: key_prefix).each do |object| # Prevent download if the file path is a directory. # We need to check if string ends with "/" instead of using `File.directory?` because # the string represent a remote location, not a local file in disk. next if object.key.end_with?("/") @@ -179,10 +182,10 @@ s3_object_prefix + sanitized end def strip_s3_object_prefix(object_path) - object_path.gsub(/^#{s3_object_prefix}/, "") + object_path.delete_prefix(s3_object_prefix.to_s).delete_prefix('/') end def sanitize_file_name(file_name) file_name.gsub(self.working_directory + "/", "") end