fastlane-plugin-ipa_info 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4760b3932e7e1b06973ec7bba3af813b0e73d126fc07735b7a5f851c31d8c5e
4
- data.tar.gz: 933a353918805cb565d01652b76675923780f982de0587919569869d137c0a2d
3
+ metadata.gz: 01742d4f12328334684ce676dd4d347a8728c00d66cbdb5868cd493a275d0947
4
+ data.tar.gz: 95ef95fa5b756e0b4242c608eb1d467aed2525a2379b5597b8bb89b13a7a91b6
5
5
  SHA512:
6
- metadata.gz: 684a77ae2d2876dc5c00a07718684d899d8ee71dd09903afe675b7e7e19e69b15c8f78afd3372ef378489637e8db6428c658d0116bf41dcce804cfcf6599cea3
7
- data.tar.gz: 9e2b92e2f584f35e14fad54117ac2bb39e81f9abbe72015e5744fde542924f77bebc3834f22c38cf920d5d84ed055f379c4566a5664467ee7c700399e3c10db9
6
+ metadata.gz: 8e54eebcf53a0885e570df99541156fd3dc43549abfca176879a96c7e8ad13903890db463aae1f6d0ded0e95cfe155b6a1b83e5b1cc0441b9253842543882791
7
+ data.tar.gz: 95aedea9818581710484f8d3cece34c54d7390ad1d37b1803768c64fc1dbaaf51c26d6fbb35968d2ebf0d9da45fab3fd2492355691dd506d74905ee6a84014ef
@@ -4,32 +4,27 @@ require 'fileutils'
4
4
  require 'plist'
5
5
  require 'open3'
6
6
  require 'fastlane_core/ui/ui'
7
+ require "securerandom"
7
8
 
8
9
  module Fastlane
9
10
  module Helper
10
11
  class IpaAnalyzeHelper
11
12
  def self.analyze(ipa_path)
12
- app_folder_path = find_app_folder_path_in_ipa(ipa_path)
13
- plist_data = self.fetch_file_with_unzip(ipa_path, "#{app_folder_path}/Info.plist")
14
- mobileprovisioning_data = self.fetch_file_with_unzip(ipa_path, "#{app_folder_path}/embedded.mobileprovision")
15
-
16
13
  return {
17
- provisiong_info: self.analyze_mobileprovisioning(mobileprovisioning_data),
18
- plist_info: self.analyze_info_plist(plist_data),
19
- certificate_info: self.codesigned(ipa_path, app_folder_path)
14
+ provisiong_info: self.analyze_file_with_unzip(ipa_path, "embedded.mobileprovision"),
15
+ plist_info: self.analyze_file_with_unzip(ipa_path, "Info.plist"),
16
+ certificate_info: analyze_file_with_unzip(ipa_path, "")
20
17
  }
21
18
  end
22
19
 
23
20
  # Info plist
24
- def self.analyze_info_plist(data)
25
- tempfile = Tempfile.new(::File.basename("infoplist"))
21
+ def self.analyze_info_plist(tempfile)
26
22
  result = {}
27
23
 
28
24
  begin
29
- File.binwrite(tempfile.path, data)
30
- UI.user_error!("Failed to convert binary Plist to XML") unless system("plutil -convert xml1 '#{tempfile.path}'")
25
+ UI.user_error!("Failed to convert binary Plist to XML") unless system("plutil -convert xml1 '#{tempfile}'")
31
26
 
32
- plist = Plist.parse_xml(tempfile.path)
27
+ plist = Plist.parse_xml(tempfile)
33
28
  plist.each do |key, value|
34
29
  parse_value = value.class == Hash || value.class == Array ? value : value.to_s
35
30
 
@@ -38,20 +33,18 @@ module Fastlane
38
33
  rescue StandardError => e
39
34
  UI.user_error!(e.message)
40
35
  ensure
41
- tempfile.close && tempfile.unlink
36
+ FileUtils.rm_r(tempfile)
42
37
  end
43
38
 
44
39
  result
45
40
  end
46
41
 
47
42
  # mobileprovisioning
48
- def self.analyze_mobileprovisioning(data)
49
- tempfile = Tempfile.new(::File.basename("mobileprovisioning"))
43
+ def self.analyze_mobileprovisioning(tempfile)
50
44
  result = {}
51
45
 
52
46
  begin
53
- File.binwrite(tempfile.path, data)
54
- mobileprovisioning = Plist.parse_xml(`security cms -D -i #{tempfile.path}`)
47
+ mobileprovisioning = Plist.parse_xml(`security cms -D -i #{tempfile}`)
55
48
  mobileprovisioning.each do |key, value|
56
49
  next if key == 'DeveloperCertificates'
57
50
 
@@ -62,49 +55,61 @@ module Fastlane
62
55
  rescue StandardError => e
63
56
  UI.user_error!(e.message)
64
57
  ensure
65
- tempfile.close && tempfile.unlink
58
+ FileUtils.rm_r(tempfile)
66
59
  end
67
60
 
68
61
  result
69
62
  end
70
63
 
71
64
  # certificate
72
- def self.codesigned(ipa_path, app_folder_path)
73
- tempdir = Dir.pwd + "/tmp"
65
+ def self.codesigned(temp_file_path)
74
66
  result = {}
75
67
 
68
+ cmd = "codesign -dv #{temp_file_path}"
69
+ _stdout, stderr, _status = Open3.capture3(cmd)
70
+ codesigned_flag = stderr.include?("Signed Time")
71
+ result["CodeSigned"] = codesigned_flag
72
+
73
+ return result
74
+ end
75
+
76
+ # unzip ipa file and analyze file
77
+ def self.analyze_file_with_unzip(ipa_path, target_file_name)
78
+ tempdir = Dir.pwd + "/tmp-#{SecureRandom.hex(10)}"
79
+ target_file_path = find_app_folder_path_in_ipa(ipa_path) + "/#{target_file_name}"
80
+ temp_file_path = "#{tempdir}/#{target_file_name}"
81
+
76
82
  begin
77
- _, error, = Open3.capture3("unzip -d #{tempdir} #{ipa_path}")
83
+ _, error, = Open3.capture3("unzip -o -d #{tempdir} #{ipa_path}")
78
84
  UI.user_error!(error) unless error.empty?
79
85
 
80
- cmd = "codesign -dv #{tempdir}/#{app_folder_path}"
81
- _stdout, stderr, _status = Open3.capture3(cmd)
82
- codesigned_flag = stderr.include?("Signed Time")
83
- result["CodeSigned"] = codesigned_flag
86
+ copy_cmd = "#{tempdir}/#{target_file_path} #{temp_file_path}"
87
+
88
+ case target_file_name
89
+ when "Info.plist" then
90
+ self.copy_file(copy_cmd)
91
+ return self.analyze_info_plist(temp_file_path)
92
+ when "embedded.mobileprovision" then
93
+ self.copy_file(copy_cmd)
94
+ return self.analyze_mobileprovisioning(temp_file_path)
95
+ when "" then
96
+ return self.codesigned(target_file_path)
97
+ end
84
98
  rescue StandardError => e
99
+ FileUtils.rm_r(tempdir)
85
100
  UI.user_error!(e.message)
86
101
  ensure
87
102
  FileUtils.rm_r(tempdir)
88
103
  end
89
104
 
90
- return result
105
+ return nil
91
106
  end
92
107
 
93
- # extract file
94
- def self.fetch_file_with_unzip(path, target_file)
95
- list, error, = Open3.capture3("unzip", "-Z", "-1", path)
108
+ # copy
109
+ def self.copy_file(cmd)
110
+ cmd = "cp #{cmd}"
111
+ _, error, = Open3.capture3(cmd)
96
112
  UI.user_error!(error) unless error.empty?
97
-
98
- return nil if list.empty?
99
- entry = list.chomp.split("\n").find do |e|
100
- File.fnmatch(target_file, e, File::FNM_PATHNAME)
101
- end
102
-
103
- data, error, = Open3.capture3("unzip", "-p", path, entry)
104
- UI.user_error!(error) unless error.empty?
105
- UI.user_error!("not exits data for #{target_file}") if data.empty?
106
-
107
- data
108
113
  end
109
114
 
110
115
  # return app folder path
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module IpaInfo
3
- VERSION = "0.8.1"
3
+ VERSION = "0.8.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-ipa_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tarappo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-11 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plist