app-info 3.0.0.beta1 → 3.0.0.beta3
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 +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +29 -3
- data/README.md +4 -4
- data/lib/app_info/aab.rb +57 -114
- data/lib/app_info/android/signature.rb +5 -5
- data/lib/app_info/android/signatures/base.rb +41 -37
- data/lib/app_info/android/signatures/info.rb +135 -129
- data/lib/app_info/android/signatures/v1.rb +56 -52
- data/lib/app_info/android/signatures/v2.rb +114 -110
- data/lib/app_info/android/signatures/v3.rb +124 -120
- data/lib/app_info/android/signatures/v4.rb +13 -9
- data/lib/app_info/android.rb +181 -0
- data/lib/app_info/apk.rb +68 -100
- data/lib/app_info/apple.rb +192 -0
- data/lib/app_info/certificate.rb +14 -19
- data/lib/app_info/const.rb +48 -13
- data/lib/app_info/dsym.rb +6 -3
- data/lib/app_info/error.rb +1 -7
- data/lib/app_info/file.rb +30 -4
- data/lib/app_info/helper/file_size.rb +1 -1
- data/lib/app_info/info_plist.rb +54 -25
- data/lib/app_info/ipa.rb +39 -118
- data/lib/app_info/macos.rb +38 -94
- data/lib/app_info/mobile_provision.rb +49 -20
- data/lib/app_info/pe.rb +103 -7
- data/lib/app_info/png_uncrush.rb +19 -0
- data/lib/app_info/proguard.rb +21 -2
- data/lib/app_info/protobuf/manifest.rb +5 -1
- data/lib/app_info/version.rb +1 -1
- data/lib/app_info.rb +4 -3
- metadata +4 -2
data/lib/app_info/pe.rb
CHANGED
@@ -24,14 +24,21 @@ module AppInfo
|
|
24
24
|
0x5128 => 'RISC-v 128'
|
25
25
|
}.freeze
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
# @return [Symbol] {Manufacturer}
|
28
|
+
def manufacturer
|
29
|
+
Manufacturer::MICROSOFT
|
29
30
|
end
|
30
31
|
|
32
|
+
# @return [Symbol] {Platform}
|
31
33
|
def platform
|
32
34
|
Platform::WINDOWS
|
33
35
|
end
|
34
36
|
|
37
|
+
# @return [Symbol] {Device}
|
38
|
+
def device
|
39
|
+
Device::WINDOWS
|
40
|
+
end
|
41
|
+
|
35
42
|
# return file size
|
36
43
|
# @example Read file size in integer
|
37
44
|
# aab.size # => 3618865
|
@@ -49,23 +56,75 @@ module AppInfo
|
|
49
56
|
file_to_human_size(binary_file, human_size: human_size)
|
50
57
|
end
|
51
58
|
|
52
|
-
|
59
|
+
# @!method product_name
|
60
|
+
# @see VersionInfo#product_name
|
61
|
+
# @return [String]
|
62
|
+
# @!method product_version
|
63
|
+
# @see VersionInfo#product_version
|
64
|
+
# @return [String]
|
65
|
+
# @!method company_name
|
66
|
+
# @see VersionInfo#company_name
|
67
|
+
# @return [String]
|
68
|
+
# @!method assembly_version
|
69
|
+
# @see VersionInfo#assembly_version
|
70
|
+
# @return [String]
|
71
|
+
# @!method file_version
|
72
|
+
# @see VersionInfo#file_version
|
73
|
+
# @return [String]
|
74
|
+
# @!method file_description
|
75
|
+
# @see VersionInfo#file_description
|
76
|
+
# @return [String]
|
77
|
+
# @!method copyright
|
78
|
+
# @see VersionInfo#copyright
|
79
|
+
# @return [String]
|
80
|
+
# @return [String]
|
81
|
+
# @!method special_build
|
82
|
+
# @see VersionInfo#special_build
|
83
|
+
# @return [String]
|
84
|
+
# @!method private_build
|
85
|
+
# @see VersionInfo#private_build
|
86
|
+
# @return [String]
|
87
|
+
# @!method original_filename
|
88
|
+
# @see VersionInfo#original_filename
|
89
|
+
# @return [String]
|
90
|
+
# @!method internal_name
|
91
|
+
# @see VersionInfo#internal_name
|
92
|
+
# @return [String]
|
93
|
+
# @!method legal_trademarks
|
94
|
+
# @see VersionInfo#legal_trademarks
|
95
|
+
# @return [String]
|
96
|
+
def_delegators :version_info, :product_name, :product_version, :company_name, :assembly_version,
|
97
|
+
:file_version, :file_description, :copyright, :special_build, :private_build,
|
98
|
+
:original_filename, :internal_name, :legal_trademarks
|
53
99
|
|
54
100
|
alias name product_name
|
55
|
-
alias release_version product_version
|
56
|
-
alias build_version assembly_version
|
57
101
|
|
102
|
+
# Find {#product_version} then fallback to {#file_version}
|
103
|
+
# @return [String, nil]
|
104
|
+
def release_version
|
105
|
+
product_version || file_version
|
106
|
+
end
|
107
|
+
|
108
|
+
# Find {#special_build}, {#private_build} then fallback to {#assembly_version}
|
109
|
+
# @return [String, nil]
|
110
|
+
def build_version
|
111
|
+
special_build || private_build || assembly_version
|
112
|
+
end
|
113
|
+
|
114
|
+
# @return [String]
|
58
115
|
def archs
|
59
116
|
ARCH[image_file_header.Machine] || 'unknown'
|
60
117
|
end
|
61
118
|
alias architectures archs
|
62
119
|
|
120
|
+
# @return [Hash{String => String}] imports imports of libraries
|
63
121
|
def imports
|
64
122
|
@imports ||= pe.imports.each_with_object({}) do |import, obj|
|
65
123
|
obj[import.module_name] = import.first_thunk.map(&:name).compact
|
66
124
|
end
|
67
125
|
end
|
68
126
|
|
127
|
+
# @return [Array{String}] icons paths of bmp image icons
|
69
128
|
def icons
|
70
129
|
@icons ||= lambda {
|
71
130
|
# Fetch the largest size icon
|
@@ -105,6 +164,7 @@ module AppInfo
|
|
105
164
|
}.call
|
106
165
|
end
|
107
166
|
|
167
|
+
# @return [PEdump]
|
108
168
|
def pe
|
109
169
|
@pe ||= lambda {
|
110
170
|
pe = PEdump.new(io)
|
@@ -113,6 +173,7 @@ module AppInfo
|
|
113
173
|
}.call
|
114
174
|
end
|
115
175
|
|
176
|
+
# @return [VersionInfo]
|
116
177
|
def version_info
|
117
178
|
@version_info ||= VersionInfo.new(pe.version_info)
|
118
179
|
end
|
@@ -124,6 +185,7 @@ module AppInfo
|
|
124
185
|
@imports = nil
|
125
186
|
end
|
126
187
|
|
188
|
+
# @return [String] binary_file path
|
127
189
|
def binary_file
|
128
190
|
@binary_file ||= lambda {
|
129
191
|
file_io = ::File.open(@file, 'rb')
|
@@ -131,7 +193,7 @@ module AppInfo
|
|
131
193
|
|
132
194
|
zip_file = Zip::File.open(@file)
|
133
195
|
zip_entry = zip_file.glob('*.exe').first
|
134
|
-
raise
|
196
|
+
raise NotFoundError, 'Not found .exe file in archive file' if zip_entry.nil?
|
135
197
|
|
136
198
|
exe_file = tempdir(zip_entry.name, prefix: 'pe-exe', system: true)
|
137
199
|
zip_entry.extract(exe_file)
|
@@ -147,6 +209,7 @@ module AppInfo
|
|
147
209
|
@image_file_header ||= pe.pe.image_file_header
|
148
210
|
end
|
149
211
|
|
212
|
+
# @return [Hash{Symbol => String}]
|
150
213
|
def icon_metadata(file, mask_file: nil)
|
151
214
|
{
|
152
215
|
name: ::File.basename(file),
|
@@ -156,42 +219,75 @@ module AppInfo
|
|
156
219
|
}
|
157
220
|
end
|
158
221
|
|
222
|
+
# @return [File]
|
159
223
|
def io
|
160
224
|
@io ||= ::File.open(binary_file, 'rb')
|
161
225
|
end
|
162
226
|
|
163
227
|
# VersionInfo class
|
164
228
|
#
|
165
|
-
#
|
229
|
+
# @see https://learn.microsoft.com/zh-cn/windows/win32/menurc/versioninfo-resource
|
166
230
|
class VersionInfo
|
167
231
|
def initialize(raw)
|
168
232
|
@raw = raw
|
169
233
|
end
|
170
234
|
|
235
|
+
# @return [String]
|
171
236
|
def company_name
|
172
237
|
@company_name ||= value_of('CompanyName')
|
173
238
|
end
|
174
239
|
|
240
|
+
# @return [String]
|
175
241
|
def product_name
|
176
242
|
@product_name ||= value_of('ProductName')
|
177
243
|
end
|
178
244
|
|
245
|
+
# @return [String]
|
179
246
|
def product_version
|
180
247
|
@product_version ||= value_of('ProductVersion')
|
181
248
|
end
|
182
249
|
|
250
|
+
# @return [String]
|
183
251
|
def assembly_version
|
184
252
|
@assembly_version ||= value_of('Assembly Version')
|
185
253
|
end
|
186
254
|
|
255
|
+
# @return [String]
|
187
256
|
def file_version
|
188
257
|
@file_version ||= value_of('FileVersion')
|
189
258
|
end
|
190
259
|
|
260
|
+
# @return [String, nil]
|
191
261
|
def file_description
|
192
262
|
@file_description ||= value_of('FileDescription')
|
193
263
|
end
|
194
264
|
|
265
|
+
# @return [String, nil]
|
266
|
+
def special_build
|
267
|
+
@special_build ||= value_of('SpecialBuild')
|
268
|
+
end
|
269
|
+
|
270
|
+
# @return [String, nil]
|
271
|
+
def private_build
|
272
|
+
@private_build ||= value_of('PrivateBuild')
|
273
|
+
end
|
274
|
+
|
275
|
+
# @return [String]
|
276
|
+
def original_filename
|
277
|
+
@original_filename ||= value_of('OriginalFilename')
|
278
|
+
end
|
279
|
+
|
280
|
+
# @return [String]
|
281
|
+
def internal_name
|
282
|
+
@internal_name ||= value_of('InternalName')
|
283
|
+
end
|
284
|
+
|
285
|
+
# @return [String]
|
286
|
+
def legal_trademarks
|
287
|
+
@legal_trademarks ||= value_of('LegalTrademarks')
|
288
|
+
end
|
289
|
+
|
290
|
+
# @return [String]
|
195
291
|
def copyright
|
196
292
|
@copyright ||= value_of('LegalCopyright')
|
197
293
|
end
|
data/lib/app_info/png_uncrush.rb
CHANGED
@@ -32,18 +32,24 @@ module AppInfo
|
|
32
32
|
@data = String.new
|
33
33
|
end
|
34
34
|
|
35
|
+
# @return [Integer]
|
35
36
|
def size
|
36
37
|
@io.size
|
37
38
|
end
|
38
39
|
|
40
|
+
# @param [String] format
|
41
|
+
# @return [String]
|
42
|
+
# @see IO package data
|
39
43
|
def unpack(format)
|
40
44
|
@io.unpack(format)
|
41
45
|
end
|
42
46
|
|
47
|
+
# @return [String]
|
43
48
|
def header
|
44
49
|
@header ||= self[0, 8]
|
45
50
|
end
|
46
51
|
|
52
|
+
# @return [Boolean]
|
47
53
|
def png?
|
48
54
|
header.bytes == PNG_HEADER
|
49
55
|
end
|
@@ -61,10 +67,17 @@ module AppInfo
|
|
61
67
|
end
|
62
68
|
end
|
63
69
|
|
70
|
+
# Decompress crushed png file.
|
71
|
+
# @param [String] input path of png file
|
72
|
+
# @param [String] output path of output file
|
73
|
+
# @return [Boolean] result whether decompress successfully
|
64
74
|
def self.decompress(input, output)
|
65
75
|
new(input).decompress(output)
|
66
76
|
end
|
67
77
|
|
78
|
+
# get png dimensions
|
79
|
+
# @param [String] input path of png file
|
80
|
+
# @return [Array<Integer>] dimensions width, height value of png file
|
68
81
|
def self.dimensions(input)
|
69
82
|
new(input).dimensions
|
70
83
|
end
|
@@ -74,10 +87,16 @@ module AppInfo
|
|
74
87
|
raise FormatError, 'not a png file' unless @io.png?
|
75
88
|
end
|
76
89
|
|
90
|
+
# get png dimensions
|
91
|
+
# @param [String] input path of png file
|
92
|
+
# @return [Array<Integer>] dimensions width, height value of png file
|
77
93
|
def dimensions
|
78
94
|
_dump_sections(dimensions: true)
|
79
95
|
end
|
80
96
|
|
97
|
+
# Decompress crushed png file.
|
98
|
+
# @param [String] output path of output file
|
99
|
+
# @return [Boolean] result whether decompress successfully
|
81
100
|
def decompress(output)
|
82
101
|
content = _remap(_dump_sections)
|
83
102
|
return false unless content
|
data/lib/app_info/proguard.rb
CHANGED
@@ -10,41 +10,54 @@ module AppInfo
|
|
10
10
|
|
11
11
|
NAMESPACE = UUIDTools::UUID.sha1_create(UUIDTools::UUID_DNS_NAMESPACE, 'icyleaf.com')
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
# @return [Symbol] {Manufacturer}
|
14
|
+
def manufacturer
|
15
|
+
Manufacturer::GOOGLE
|
15
16
|
end
|
16
17
|
|
18
|
+
# @return [Symbol] {Platform}
|
19
|
+
def platform
|
20
|
+
Platform::ANDROID
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [String]
|
17
24
|
def uuid
|
18
25
|
# Similar to https://docs.sentry.io/workflow/debug-files/#proguard-uuids
|
19
26
|
UUIDTools::UUID.sha1_create(NAMESPACE, ::File.read(mapping_path)).to_s
|
20
27
|
end
|
21
28
|
alias debug_id uuid
|
22
29
|
|
30
|
+
# @return [Boolean]
|
23
31
|
def mapping?
|
24
32
|
::File.exist?(mapping_path)
|
25
33
|
end
|
26
34
|
|
35
|
+
# @return [Boolean]
|
27
36
|
def manifest?
|
28
37
|
::File.exist?(manifest_path)
|
29
38
|
end
|
30
39
|
|
40
|
+
# @return [Boolean]
|
31
41
|
def symbol?
|
32
42
|
::File.exist?(symbol_path)
|
33
43
|
end
|
34
44
|
alias resource? symbol?
|
35
45
|
|
46
|
+
# @return [String, nil]
|
36
47
|
def package_name
|
37
48
|
return unless manifest?
|
38
49
|
|
39
50
|
manifest.root.attributes['package']
|
40
51
|
end
|
41
52
|
|
53
|
+
# @return [String, nil]
|
42
54
|
def releasd_version
|
43
55
|
return unless manifest?
|
44
56
|
|
45
57
|
manifest.root.attributes['package']
|
46
58
|
end
|
47
59
|
|
60
|
+
# @return [String, nil]
|
48
61
|
def version_name
|
49
62
|
return unless manifest?
|
50
63
|
|
@@ -52,6 +65,7 @@ module AppInfo
|
|
52
65
|
end
|
53
66
|
alias release_version version_name
|
54
67
|
|
68
|
+
# @return [String, nil]
|
55
69
|
def version_code
|
56
70
|
return unless manifest?
|
57
71
|
|
@@ -59,25 +73,30 @@ module AppInfo
|
|
59
73
|
end
|
60
74
|
alias build_version version_code
|
61
75
|
|
76
|
+
# @return [REXML::Document]
|
62
77
|
def manifest
|
63
78
|
return unless manifest?
|
64
79
|
|
65
80
|
@manifest ||= REXML::Document.new(::File.new(manifest_path))
|
66
81
|
end
|
67
82
|
|
83
|
+
# @return [String]
|
68
84
|
def mapping_path
|
69
85
|
@mapping_path ||= Dir.glob(::File.join(contents, '*mapping*.txt')).first
|
70
86
|
end
|
71
87
|
|
88
|
+
# @return [String]
|
72
89
|
def manifest_path
|
73
90
|
@manifest_path ||= ::File.join(contents, 'AndroidManifest.xml')
|
74
91
|
end
|
75
92
|
|
93
|
+
# @return [String]
|
76
94
|
def symbol_path
|
77
95
|
@symbol_path ||= ::File.join(contents, 'R.txt')
|
78
96
|
end
|
79
97
|
alias resource_path symbol_path
|
80
98
|
|
99
|
+
# @return [String] contents path of contents
|
81
100
|
def contents
|
82
101
|
@contents ||= unarchive(@file, prefix: 'proguard')
|
83
102
|
end
|
@@ -6,6 +6,7 @@ require 'app_info/core_ext'
|
|
6
6
|
|
7
7
|
module AppInfo
|
8
8
|
module Protobuf
|
9
|
+
# AAB Protobuf Base class
|
9
10
|
class Base
|
10
11
|
include Helper::GenerateClass
|
11
12
|
|
@@ -21,6 +22,7 @@ module AppInfo
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
25
|
+
# AAB Protobuf Attribute
|
24
26
|
class Attribute < Base
|
25
27
|
attr_reader :namespace, :name, :value, :resource_id
|
26
28
|
|
@@ -47,6 +49,8 @@ module AppInfo
|
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
52
|
+
# AAB Protobuf Node class.
|
53
|
+
# example: manifest,activity, activity-alias, service, receiver, provider, application
|
50
54
|
class Node < Base
|
51
55
|
attr_reader :name, :attributes, :children
|
52
56
|
|
@@ -106,6 +110,7 @@ module AppInfo
|
|
106
110
|
end
|
107
111
|
end
|
108
112
|
|
113
|
+
# AAB Protobuf Manifest
|
109
114
|
class Manifest < Node
|
110
115
|
def self.parse(io, resources = nil)
|
111
116
|
doc = Aapt::Pb::XmlNode.decode(io)
|
@@ -170,7 +175,6 @@ module AppInfo
|
|
170
175
|
end.flatten.uniq
|
171
176
|
end
|
172
177
|
|
173
|
-
# :nodoc:
|
174
178
|
# Workaround ruby always return true by called `Object.const_defined?(Data)`
|
175
179
|
class Data < Node; end
|
176
180
|
|
data/lib/app_info/version.rb
CHANGED
data/lib/app_info.rb
CHANGED
@@ -11,18 +11,19 @@ require 'app_info/file'
|
|
11
11
|
require 'app_info/info_plist'
|
12
12
|
require 'app_info/mobile_provision'
|
13
13
|
|
14
|
+
require 'app_info/apple'
|
15
|
+
require 'app_info/macos'
|
14
16
|
require 'app_info/ipa'
|
15
17
|
require 'app_info/ipa/plugin'
|
16
18
|
require 'app_info/ipa/framework'
|
17
19
|
|
18
|
-
require 'app_info/android
|
20
|
+
require 'app_info/android'
|
19
21
|
require 'app_info/apk'
|
20
22
|
require 'app_info/aab'
|
21
23
|
|
22
24
|
require 'app_info/proguard'
|
23
25
|
require 'app_info/dsym'
|
24
26
|
|
25
|
-
require 'app_info/macos'
|
26
27
|
require 'app_info/pe'
|
27
28
|
|
28
29
|
# fix invaild date format warnings
|
@@ -45,7 +46,7 @@ module AppInfo
|
|
45
46
|
when Format::MACOS then Macos.new(file)
|
46
47
|
when Format::PE then PE.new(file)
|
47
48
|
else
|
48
|
-
raise
|
49
|
+
raise UnknownFormatError, "Do not detect file format: #{file}"
|
49
50
|
end
|
50
51
|
|
51
52
|
return parser unless block_given?
|
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: 3.0.0.
|
4
|
+
version: 3.0.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icyleaf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: CFPropertyList
|
@@ -226,6 +226,7 @@ files:
|
|
226
226
|
- lib/app-info.rb
|
227
227
|
- lib/app_info.rb
|
228
228
|
- lib/app_info/aab.rb
|
229
|
+
- lib/app_info/android.rb
|
229
230
|
- lib/app_info/android/signature.rb
|
230
231
|
- lib/app_info/android/signatures/base.rb
|
231
232
|
- lib/app_info/android/signatures/info.rb
|
@@ -234,6 +235,7 @@ files:
|
|
234
235
|
- lib/app_info/android/signatures/v3.rb
|
235
236
|
- lib/app_info/android/signatures/v4.rb
|
236
237
|
- lib/app_info/apk.rb
|
238
|
+
- lib/app_info/apple.rb
|
237
239
|
- lib/app_info/certificate.rb
|
238
240
|
- lib/app_info/const.rb
|
239
241
|
- lib/app_info/core_ext.rb
|