app-info 2.8.5 → 3.0.0.beta1

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -7
  3. data/.github/workflows/ci.yml +3 -1
  4. data/.rubocop.yml +31 -11
  5. data/CHANGELOG.md +22 -0
  6. data/Gemfile +7 -1
  7. data/README.md +64 -9
  8. data/Rakefile +11 -0
  9. data/app_info.gemspec +12 -3
  10. data/lib/app_info/aab.rb +58 -39
  11. data/lib/app_info/android/signature.rb +114 -0
  12. data/lib/app_info/android/signatures/base.rb +49 -0
  13. data/lib/app_info/android/signatures/info.rb +152 -0
  14. data/lib/app_info/android/signatures/v1.rb +59 -0
  15. data/lib/app_info/android/signatures/v2.rb +117 -0
  16. data/lib/app_info/android/signatures/v3.rb +127 -0
  17. data/lib/app_info/android/signatures/v4.rb +14 -0
  18. data/lib/app_info/apk.rb +43 -46
  19. data/lib/app_info/certificate.rb +181 -0
  20. data/lib/app_info/const.rb +41 -0
  21. data/lib/app_info/core_ext/object/try.rb +3 -1
  22. data/lib/app_info/core_ext/string/inflector.rb +2 -0
  23. data/lib/app_info/dsym/debug_info.rb +72 -0
  24. data/lib/app_info/dsym/macho.rb +55 -0
  25. data/lib/app_info/dsym.rb +27 -134
  26. data/lib/app_info/error.rb +7 -1
  27. data/lib/app_info/file.rb +23 -0
  28. data/lib/app_info/helper/archive.rb +37 -0
  29. data/lib/app_info/helper/file_size.rb +25 -0
  30. data/lib/app_info/helper/generate_class.rb +29 -0
  31. data/lib/app_info/helper/protobuf.rb +12 -0
  32. data/lib/app_info/helper/signatures.rb +229 -0
  33. data/lib/app_info/helper.rb +5 -126
  34. data/lib/app_info/info_plist.rb +14 -6
  35. data/lib/app_info/ipa/framework.rb +4 -4
  36. data/lib/app_info/ipa.rb +41 -36
  37. data/lib/app_info/macos.rb +34 -26
  38. data/lib/app_info/mobile_provision.rb +19 -30
  39. data/lib/app_info/pe.rb +226 -0
  40. data/lib/app_info/png_uncrush.rb +5 -4
  41. data/lib/app_info/proguard.rb +11 -17
  42. data/lib/app_info/protobuf/manifest.rb +1 -2
  43. data/lib/app_info/protobuf/models/Configuration_pb.rb +1 -0
  44. data/lib/app_info/protobuf/models/README.md +7 -0
  45. data/lib/app_info/protobuf/models/Resources_pb.rb +2 -0
  46. data/lib/app_info/protobuf/resources.rb +5 -5
  47. data/lib/app_info/version.rb +1 -1
  48. data/lib/app_info.rb +88 -45
  49. metadata +46 -35
data/lib/app_info.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'app_info/version'
4
- require 'app_info/error'
5
4
  require 'app_info/core_ext'
5
+ require 'app_info/const'
6
+ require 'app_info/certificate'
6
7
  require 'app_info/helper'
8
+ require 'app_info/error'
7
9
 
10
+ require 'app_info/file'
8
11
  require 'app_info/info_plist'
9
12
  require 'app_info/mobile_provision'
10
13
 
@@ -12,6 +15,7 @@ require 'app_info/ipa'
12
15
  require 'app_info/ipa/plugin'
13
16
  require 'app_info/ipa/framework'
14
17
 
18
+ require 'app_info/android/signature'
15
19
  require 'app_info/apk'
16
20
  require 'app_info/aab'
17
21
 
@@ -19,6 +23,7 @@ require 'app_info/proguard'
19
23
  require 'app_info/dsym'
20
24
 
21
25
  require 'app_info/macos'
26
+ require 'app_info/pe'
22
27
 
23
28
  # fix invaild date format warnings
24
29
  Zip.warn_invalid_date = false
@@ -26,44 +31,58 @@ Zip.warn_invalid_date = false
26
31
  # AppInfo Module
27
32
  module AppInfo
28
33
  class << self
29
- UNKNOWN_FORMAT = :unkown
30
-
31
34
  # Get a new parser for automatic
32
35
  def parse(file)
33
- raise NotFoundError, file unless File.exist?(file)
34
-
35
- case file_type(file)
36
- when :ipa then IPA.new(file)
37
- when :apk then APK.new(file)
38
- when :aab then AAB.new(file)
39
- when :mobileprovision then MobileProvision.new(file)
40
- when :dsym then DSYM.new(file)
41
- when :proguard then Proguard.new(file)
42
- when :macos then Macos.new(file)
43
- else
44
- raise UnkownFileTypeError, "Do not detect file type: #{file}"
45
- end
36
+ raise NotFoundError, file unless ::File.exist?(file)
37
+
38
+ parser = case file_type(file)
39
+ when Format::IPA then IPA.new(file)
40
+ when Format::APK then APK.new(file)
41
+ when Format::AAB then AAB.new(file)
42
+ when Format::MOBILEPROVISION then MobileProvision.new(file)
43
+ when Format::DSYM then DSYM.new(file)
44
+ when Format::PROGUARD then Proguard.new(file)
45
+ when Format::MACOS then Macos.new(file)
46
+ when Format::PE then PE.new(file)
47
+ else
48
+ raise UnknownFileTypeError, "Do not detect file type: #{file}"
49
+ end
50
+
51
+ return parser unless block_given?
52
+
53
+ # call block and clear!
54
+ yield parser
55
+ parser.clear!
46
56
  end
47
57
  alias dump parse
48
58
 
49
59
  def parse?(file)
50
- file_type(file) != UNKNOWN_FORMAT
60
+ file_type(file) != Format::UNKNOWN
51
61
  end
52
62
 
53
63
  # Detect file type by read file header
54
64
  #
55
65
  # TODO: This can be better solution, if anyone knows, tell me please.
56
66
  def file_type(file)
57
- header_hex = File.read(file, 100)
58
- type = if header_hex =~ /^\x50\x4b\x03\x04/
59
- detect_zip_file(file)
60
- else
61
- detect_mobileprovision(header_hex)
62
- end
63
-
64
- type || UNKNOWN_FORMAT
67
+ header_hex = ::File.read(file, 100)
68
+ case header_hex
69
+ when ZIP_RETGEX
70
+ detect_zip_file(file)
71
+ when PE_REGEX
72
+ Format::PE
73
+ when PLIST_REGEX, BPLIST_REGEX
74
+ Format::MOBILEPROVISION
75
+ else
76
+ Format::UNKNOWN
77
+ end
65
78
  end
66
79
 
80
+ def logger
81
+ @logger ||= Logger.new($stdout, level: :warn)
82
+ end
83
+
84
+ attr_writer :logger
85
+
67
86
  private
68
87
 
69
88
  # :nodoc:
@@ -71,35 +90,59 @@ module AppInfo
71
90
  Zip.warn_invalid_date = false
72
91
  zip_file = Zip::File.open(file)
73
92
 
74
- return :proguard unless zip_file.glob('*mapping*.txt').empty?
75
- return :apk if !zip_file.find_entry('AndroidManifest.xml').nil? &&
76
- !zip_file.find_entry('classes.dex').nil?
93
+ return Format::PROGUARD if proguard_clues?(zip_file)
94
+ return Format::APK if apk_clues?(zip_file)
95
+ return Format::AAB if aab_clues?(zip_file)
96
+ return Format::MACOS if macos_clues?(zip_file)
97
+ return Format::PE if pe_clues?(zip_file)
98
+ return Format::UNKNOWN unless clue = other_clues?(zip_file)
77
99
 
78
- return :aab if !zip_file.find_entry('base/manifest/AndroidManifest.xml').nil? &&
79
- !zip_file.find_entry('BundleConfig.pb').nil?
100
+ clue
101
+ ensure
102
+ zip_file.close
103
+ end
80
104
 
81
- return :macos if !zip_file.glob('*/Contents/MacOS/*').empty? &&
82
- !zip_file.glob('*/Contents/Info.plist').empty?
105
+ # :nodoc:
106
+ def proguard_clues?(zip_file)
107
+ !zip_file.glob('*mapping*.txt').empty?
108
+ end
83
109
 
84
- zip_file.each do |f|
85
- path = f.name
110
+ # :nodoc:
111
+ def apk_clues?(zip_file)
112
+ !zip_file.find_entry('AndroidManifest.xml').nil? &&
113
+ !zip_file.find_entry('classes.dex').nil?
114
+ end
86
115
 
87
- return :ipa if path.include?('Payload/') && path.end_with?('Info.plist')
88
- return :dsym if path.include?('Contents/Resources/DWARF/')
89
- end
90
- ensure
91
- zip_file.close
116
+ # :nodoc:
117
+ def aab_clues?(zip_file)
118
+ !zip_file.find_entry('base/manifest/AndroidManifest.xml').nil? &&
119
+ !zip_file.find_entry('BundleConfig.pb').nil?
92
120
  end
93
121
 
94
- PLIST_REGEX = /\x3C\x3F\x78\x6D\x6C/.freeze
95
- BPLIST_REGEX = /^\x62\x70\x6C\x69\x73\x74/.freeze
122
+ # :nodoc:
123
+ def macos_clues?(zip_file)
124
+ !zip_file.glob('*/Contents/MacOS/*').empty? &&
125
+ !zip_file.glob('*/Contents/Info.plist').empty?
126
+ end
96
127
 
97
128
  # :nodoc:
98
- def detect_mobileprovision(hex)
99
- case hex
100
- when PLIST_REGEX, BPLIST_REGEX
101
- :mobileprovision
129
+ def pe_clues?(zip_file)
130
+ !zip_file.glob('*.exe').empty?
131
+ end
132
+
133
+ # :nodoc:
134
+ def other_clues?(zip_file)
135
+ zip_file.each do |f|
136
+ path = f.name
137
+
138
+ return Format::IPA if path.include?('Payload/') && path.end_with?('Info.plist')
139
+ return Format::DSYM if path.include?('Contents/Resources/DWARF/')
102
140
  end
103
141
  end
104
142
  end
143
+
144
+ ZIP_RETGEX = /^\x50\x4b\x03\x04/.freeze
145
+ PE_REGEX = /^MZ/.freeze
146
+ PLIST_REGEX = /\x3C\x3F\x78\x6D\x6C/.freeze
147
+ BPLIST_REGEX = /^\x62\x70\x6C\x69\x73\x74/.freeze
105
148
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.5
4
+ version: 3.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - icyleaf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: CFPropertyList
@@ -76,14 +76,14 @@ dependencies:
76
76
  requirements:
77
77
  - - "~>"
78
78
  - !ruby/object:Gem::Version
79
- version: 2.5.1
79
+ version: 2.6.0
80
80
  type: :runtime
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - "~>"
85
85
  - !ruby/object:Gem::Version
86
- version: 2.5.1
86
+ version: 2.6.0
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: rubyzip
89
89
  requirement: !ruby/object:Gem::Requirement
@@ -138,6 +138,20 @@ dependencies:
138
138
  - - "~>"
139
139
  - !ruby/object:Gem::Version
140
140
  version: 0.2.0
141
+ - !ruby/object:Gem::Dependency
142
+ name: pedump
143
+ requirement: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: 0.6.2
148
+ type: :runtime
149
+ prerelease: false
150
+ version_requirements: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - "~>"
153
+ - !ruby/object:Gem::Version
154
+ version: 0.6.2
141
155
  - !ruby/object:Gem::Dependency
142
156
  name: google-protobuf
143
157
  requirement: !ruby/object:Gem::Requirement
@@ -186,34 +200,6 @@ dependencies:
186
200
  - - ">="
187
201
  - !ruby/object:Gem::Version
188
202
  version: '10.0'
189
- - !ruby/object:Gem::Dependency
190
- name: rspec
191
- requirement: !ruby/object:Gem::Requirement
192
- requirements:
193
- - - "~>"
194
- - !ruby/object:Gem::Version
195
- version: '3.0'
196
- type: :development
197
- prerelease: false
198
- version_requirements: !ruby/object:Gem::Requirement
199
- requirements:
200
- - - "~>"
201
- - !ruby/object:Gem::Version
202
- version: '3.0'
203
- - !ruby/object:Gem::Dependency
204
- name: rubocop
205
- requirement: !ruby/object:Gem::Requirement
206
- requirements:
207
- - - "~>"
208
- - !ruby/object:Gem::Version
209
- version: '1.19'
210
- type: :development
211
- prerelease: false
212
- version_requirements: !ruby/object:Gem::Requirement
213
- requirements:
214
- - - "~>"
215
- - !ruby/object:Gem::Version
216
- version: '1.19'
217
203
  description: Teardown tool for ipa/apk files and dSYM file, even support for info.plist
218
204
  and .mobileprovision files
219
205
  email:
@@ -240,19 +226,37 @@ files:
240
226
  - lib/app-info.rb
241
227
  - lib/app_info.rb
242
228
  - lib/app_info/aab.rb
229
+ - lib/app_info/android/signature.rb
230
+ - lib/app_info/android/signatures/base.rb
231
+ - lib/app_info/android/signatures/info.rb
232
+ - lib/app_info/android/signatures/v1.rb
233
+ - lib/app_info/android/signatures/v2.rb
234
+ - lib/app_info/android/signatures/v3.rb
235
+ - lib/app_info/android/signatures/v4.rb
243
236
  - lib/app_info/apk.rb
237
+ - lib/app_info/certificate.rb
238
+ - lib/app_info/const.rb
244
239
  - lib/app_info/core_ext.rb
245
240
  - lib/app_info/core_ext/object/try.rb
246
241
  - lib/app_info/core_ext/string/inflector.rb
247
242
  - lib/app_info/dsym.rb
243
+ - lib/app_info/dsym/debug_info.rb
244
+ - lib/app_info/dsym/macho.rb
248
245
  - lib/app_info/error.rb
246
+ - lib/app_info/file.rb
249
247
  - lib/app_info/helper.rb
248
+ - lib/app_info/helper/archive.rb
249
+ - lib/app_info/helper/file_size.rb
250
+ - lib/app_info/helper/generate_class.rb
251
+ - lib/app_info/helper/protobuf.rb
252
+ - lib/app_info/helper/signatures.rb
250
253
  - lib/app_info/info_plist.rb
251
254
  - lib/app_info/ipa.rb
252
255
  - lib/app_info/ipa/framework.rb
253
256
  - lib/app_info/ipa/plugin.rb
254
257
  - lib/app_info/macos.rb
255
258
  - lib/app_info/mobile_provision.rb
259
+ - lib/app_info/pe.rb
256
260
  - lib/app_info/png_uncrush.rb
257
261
  - lib/app_info/proguard.rb
258
262
  - lib/app_info/protobuf/manifest.rb
@@ -268,7 +272,14 @@ homepage: http://github.com/icyleaf/app-info
268
272
  licenses:
269
273
  - MIT
270
274
  metadata: {}
271
- post_install_message:
275
+ post_install_message: |
276
+ AppInfo 3.0 is coming!
277
+ **********************
278
+ The public API of some AppInfo classes has been changed.
279
+
280
+ Please ensure that your Gemfiles and .gemspecs are suitably restrictive
281
+ to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.8.5).
282
+ See https://github.com/icyleaf/app_info for details.
272
283
  rdoc_options: []
273
284
  require_paths:
274
285
  - lib
@@ -279,9 +290,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
279
290
  version: '2.5'
280
291
  required_rubygems_version: !ruby/object:Gem::Requirement
281
292
  requirements:
282
- - - ">="
293
+ - - ">"
283
294
  - !ruby/object:Gem::Version
284
- version: '0'
295
+ version: 1.3.1
285
296
  requirements: []
286
297
  rubygems_version: 3.4.1
287
298
  signing_key: