pprof 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/lib/pprof/output_formatter.rb +45 -38
- data/lib/pprof/provisioning_profile.rb +19 -12
- data/lib/pprof/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe023fb6399ea85e9aafbd5fe04e359134b37880148ab6796538db8a98bbfca9
|
4
|
+
data.tar.gz: 558e2fc9027127c7aeb87ffb7e80b85ef80439bc6ec4c2301e478b342fb767a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 825fa827ec95e13c0e18af1a4159d0c32a66e73f18d74e303018db47c4cc770eb500fcebe75537457045bc659a1128a13b7d7e24a42a46a9eb0ffa0d1d391d15
|
7
|
+
data.tar.gz: 34ac09512ae66a156695d8ed273b7c54b8b0381a03b02e4396fbd71f8bcbe880e7464a2c45dc7e1096e145eb05da9c66b6a06f5685d64c346c4770aaccc23a44
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ It also supports printing the output in JSON format so you can pipe the result o
|
|
18
18
|
$ gem install pprof
|
19
19
|
```
|
20
20
|
|
21
|
-
_(You might need to run this command with `sudo` if your gem home is a system directory)_
|
21
|
+
_(You might need to run this command with `sudo` if your gem home is a system directory. Alternatively, we recommend to use a Ruby Version Manager like `rbenv`.)_
|
22
22
|
|
23
23
|
### Build from source
|
24
24
|
|
@@ -129,11 +129,13 @@ File.open('certs.txt', 'w') do |file|
|
|
129
129
|
end
|
130
130
|
|
131
131
|
# And you can easily loop on all provisioning profiles and manipulate each
|
132
|
-
|
132
|
+
profiles_dirs = PProf::ProvisioningProfile::DEFAULT_DIRS
|
133
133
|
# `*.mobileprovision` are typically for iOS profiles, `*.provisionprofile` for Mac profiles
|
134
|
-
|
135
|
-
|
136
|
-
|
134
|
+
profiles_dirs.each do |dir|
|
135
|
+
Dir["#{dir}/*.{mobileprovision,provisionprofile}"].each do |file|
|
136
|
+
p = PProf::ProvisioningProfile.new(file)
|
137
|
+
puts p.name
|
138
|
+
end
|
137
139
|
end
|
138
140
|
```
|
139
141
|
|
@@ -149,7 +151,7 @@ That plist payload itself contains various data, including some textual informat
|
|
149
151
|
|
150
152
|
```ruby
|
151
153
|
PProf::ProvisioningProfile
|
152
|
-
::
|
154
|
+
::DEFAULT_DIRS
|
153
155
|
new(file) => PProf::ProvisioningProfile
|
154
156
|
to_hash => Hash<String, Any>
|
155
157
|
|
@@ -7,7 +7,7 @@ module PProf
|
|
7
7
|
# A helper tool to pretty-print Provisioning Profile informations
|
8
8
|
class OutputFormatter
|
9
9
|
# List of properties of a `PProf::ProvisioningProfile` to print when using the `-i` flag
|
10
|
-
MAIN_PROFILE_KEYS = %i[name uuid app_id_name app_id_prefix creation_date expiration_date ttl team_ids team_name].freeze
|
10
|
+
MAIN_PROFILE_KEYS = %i[path name uuid app_id_name app_id_prefix creation_date expiration_date ttl team_ids team_name].freeze
|
11
11
|
|
12
12
|
# Initialize a new OutputFormatter
|
13
13
|
#
|
@@ -110,6 +110,7 @@ module PProf
|
|
110
110
|
#
|
111
111
|
def as_json(profile, options = {})
|
112
112
|
hash = profile.to_hash.dup
|
113
|
+
hash['path'] = profile.path
|
113
114
|
hash.delete 'DER-Encoded-Profile'
|
114
115
|
hash.delete 'ProvisionedDevices' unless options[:devices]
|
115
116
|
if options[:certs]
|
@@ -164,15 +165,15 @@ module PProf
|
|
164
165
|
|
165
166
|
# Prints the filtered list as a table
|
166
167
|
#
|
167
|
-
# @param [String]
|
168
|
-
# The
|
169
|
-
# Defaults to '~/Library/MobileDevice/Provisioning Profiles'
|
168
|
+
# @param [String] dirs
|
169
|
+
# The directories containing the mobileprovision/provisionprofile files to list.
|
170
|
+
# Defaults to ['~/Library/MobileDevice/Provisioning Profiles', '~/Library/Developer/Xcode/UserData/Provisioning Profiles']
|
170
171
|
#
|
171
172
|
# @yield each provisioning provile for filtering/validation
|
172
173
|
# The block is given ProvisioningProfile object and should
|
173
174
|
# return true to display the row, false to filter it out
|
174
175
|
#
|
175
|
-
def print_table(
|
176
|
+
def print_table(dirs: PProf::ProvisioningProfile::DEFAULT_DIRS)
|
176
177
|
count = 0
|
177
178
|
errors = []
|
178
179
|
|
@@ -181,19 +182,21 @@ module PProf
|
|
181
182
|
@output.puts table.row('UUID', 'Name', 'AppID', 'Expiration Date', ' ', 'Team Name')
|
182
183
|
@output.puts table.separator
|
183
184
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
185
|
+
dirs.each do |dir|
|
186
|
+
Dir['*.{mobileprovision,provisionprofile}', base: dir].each do |file_name|
|
187
|
+
file = File.join(dir, file_name)
|
188
|
+
begin
|
189
|
+
p = PProf::ProvisioningProfile.new(file)
|
188
190
|
|
189
|
-
|
191
|
+
next if block_given? && !yield(p)
|
190
192
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
193
|
+
state = DateTime.now < p.expiration_date ? "\u{2705}" : "\u{274c}" # 2705=checkmark, 274C=red X
|
194
|
+
@output.puts table.row(p.uuid, p.name, p.entitlements.app_id, p.expiration_date.to_time, state, p.team_name)
|
195
|
+
rescue StandardError => e
|
196
|
+
errors << { message: e, file: file }
|
197
|
+
end
|
198
|
+
count += 1
|
195
199
|
end
|
196
|
-
count += 1
|
197
200
|
end
|
198
201
|
|
199
202
|
@output.puts table.separator
|
@@ -208,25 +211,27 @@ module PProf
|
|
208
211
|
# The options hash typically filled while parsing the command line arguments.
|
209
212
|
# - :mode: will print the UUIDs if set to `:list`, the file path otherwise
|
210
213
|
# - :zero: will concatenate the entries with `\0` instead of `\n` if set
|
211
|
-
# @param [String]
|
212
|
-
# The
|
213
|
-
# Defaults to '~/Library/MobileDevice/Provisioning Profiles'
|
214
|
+
# @param [String] dirs
|
215
|
+
# The directories containing the mobileprovision/provisionprofile files to list.
|
216
|
+
# Defaults to ['~/Library/MobileDevice/Provisioning Profiles', '~/Library/Developer/Xcode/UserData/Provisioning Profiles']
|
214
217
|
#
|
215
218
|
# @yield each provisioning profile for filtering/validation
|
216
219
|
# The block is given ProvisioningProfile object and should
|
217
220
|
# return true to display the row, false to filter it out
|
218
221
|
#
|
219
|
-
def print_list(options:,
|
222
|
+
def print_list(options:, dirs: PProf::ProvisioningProfile::DEFAULT_DIRS)
|
220
223
|
errors = []
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
224
|
+
dirs.each do |dir|
|
225
|
+
Dir['*.{mobileprovision,provisionprofile}', base: dir].each do |file_name|
|
226
|
+
file = File.join(dir, file_name)
|
227
|
+
p = PProf::ProvisioningProfile.new(file)
|
228
|
+
next if block_given? && !yield(p)
|
225
229
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
+
@output.print options[:mode] == :list ? p.uuid.chomp : file.chomp
|
231
|
+
@output.print options[:zero] ? "\0" : "\n"
|
232
|
+
rescue StandardError => e
|
233
|
+
errors << { message: e, file: file }
|
234
|
+
end
|
230
235
|
end
|
231
236
|
errors.each { |e| print_error(e[:message], e[:file]) } unless errors.empty?
|
232
237
|
end
|
@@ -237,22 +242,24 @@ module PProf
|
|
237
242
|
# The options hash typically filled while parsing the command line arguments.
|
238
243
|
# - :certs: will print the UUIDs if set to `:list`, the file path otherwise
|
239
244
|
# - :devices: will concatenate the entries with `\0` instead of `\n` if set
|
240
|
-
# @param [String]
|
241
|
-
# The
|
242
|
-
# Defaults to '~/Library/MobileDevice/Provisioning Profiles'
|
245
|
+
# @param [String] dirs
|
246
|
+
# The directories containing the mobileprovision/provisionprofile files to list.
|
247
|
+
# Defaults to ['~/Library/MobileDevice/Provisioning Profiles', '~/Library/Developer/Xcode/UserData/Provisioning Profiles']
|
243
248
|
#
|
244
249
|
# @yield each provisioning profile for filtering/validation
|
245
250
|
# The block is given ProvisioningProfile object and should
|
246
251
|
# return true to display the row, false to filter it out
|
247
252
|
#
|
248
|
-
def print_json_list(options:,
|
253
|
+
def print_json_list(options:, dirs: PProf::ProvisioningProfile::DEFAULT_DIRS)
|
249
254
|
errors = []
|
250
|
-
profiles =
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
255
|
+
profiles = dirs.flat_map do |dir|
|
256
|
+
Dir['*.{mobileprovision,provisionprofile}', base: dir].map do |file_name|
|
257
|
+
file = File.join(dir, file_name)
|
258
|
+
p = PProf::ProvisioningProfile.new(file)
|
259
|
+
as_json(p, options) unless block_given? && !yield(p)
|
260
|
+
rescue StandardError => e
|
261
|
+
errors << { message: e, file: file }
|
262
|
+
end
|
256
263
|
end.compact
|
257
264
|
errors.each { |e| print_error(e[:message], e[:file]) } unless errors.empty?
|
258
265
|
@output.puts JSON.pretty_generate(profiles)
|
@@ -262,7 +269,7 @@ module PProf
|
|
262
269
|
return false if actual.nil? # false if no Push entitlements
|
263
270
|
return true if expected == true # true if Push present but we don't filter on specific env
|
264
271
|
|
265
|
-
actual =~ expected
|
272
|
+
actual =~ expected # true if Push present and we filter on specific env
|
266
273
|
end
|
267
274
|
end
|
268
275
|
end
|
@@ -9,28 +9,35 @@ module PProf
|
|
9
9
|
# Represents the content of a Provisioning Profile file
|
10
10
|
class ProvisioningProfile
|
11
11
|
# The default location where all the Provisioning Profiles are stored on a Mac
|
12
|
-
|
12
|
+
DEFAULT_DIRS = [
|
13
|
+
File.join(Dir.home, 'Library', 'MobileDevice', 'Provisioning Profiles'),
|
14
|
+
File.join(Dir.home, 'Library', 'Developer', 'Xcode', 'UserData', 'Provisioning Profiles')
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
attr_reader :path
|
13
18
|
|
14
19
|
# Create a new ProvisioningProfile object from a file path or UUID
|
15
20
|
#
|
16
21
|
# - If the parameter given has the form of an UUID, a file named with this UUID
|
17
|
-
# and a `.mobileprovision` is searched in the default
|
22
|
+
# and a `.mobileprovision` is searched in the default directories `DEFAULT_DIRS`
|
18
23
|
# - Otherwise, the parameter is interpreted as a file path
|
19
24
|
#
|
20
25
|
# @param [String] file
|
21
26
|
# File path or UUID of the ProvisioningProfile
|
22
27
|
#
|
23
28
|
def initialize(file)
|
24
|
-
path = if file.match?(/^[0-9A-F-]*$/i)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
@path = if file.match?(/^[0-9A-F-]*$/i)
|
30
|
+
PProf::ProvisioningProfile::DEFAULT_DIRS.flat_map do |dir|
|
31
|
+
Dir["#{dir}/#{file}.{mobileprovision,provisionprofile}"]
|
32
|
+
end.compact.first
|
33
|
+
else
|
34
|
+
file
|
35
|
+
end
|
36
|
+
raise "Unable to find Provisioning Profile with UUID #{file}." if @path.nil?
|
30
37
|
|
31
38
|
xml = nil
|
32
39
|
begin
|
33
|
-
pkcs7 = OpenSSL::PKCS7.new(File.read(path))
|
40
|
+
pkcs7 = OpenSSL::PKCS7.new(File.read(@path))
|
34
41
|
pkcs7.verify([], OpenSSL::X509::Store.new)
|
35
42
|
xml = pkcs7.data
|
36
43
|
raise 'Empty PKCS7 payload' if xml.nil? || xml.empty?
|
@@ -40,10 +47,10 @@ module PProf
|
|
40
47
|
# So as a fallback, we run the `security` command line.
|
41
48
|
# (We could use `security` everytime, but invoking a command line is generally less
|
42
49
|
# efficient than calling the OpenSSL gem if available, so for now it's just used as fallback)
|
43
|
-
xml = `security cms -D -i "#{path}" 2> /dev/null`
|
50
|
+
xml = `security cms -D -i "#{@path}" 2> /dev/null`
|
44
51
|
end
|
45
52
|
@plist = Plist.parse_xml(xml)
|
46
|
-
raise "Unable to parse file #{path}." if @plist.nil?
|
53
|
+
raise "Unable to parse file #{@path}." if @plist.nil?
|
47
54
|
end
|
48
55
|
|
49
56
|
# The name of the Provisioning Profile
|
@@ -164,7 +171,7 @@ module PProf
|
|
164
171
|
#
|
165
172
|
# @return [String]
|
166
173
|
def to_s
|
167
|
-
lines = %i[name uuid app_id_name app_id_prefix creation_date expiration_date ttl team_ids team_name].map do |key|
|
174
|
+
lines = %i[path name uuid app_id_name app_id_prefix creation_date expiration_date ttl team_ids team_name].map do |key|
|
168
175
|
"- #{key}: #{send(key.to_sym)}"
|
169
176
|
end +
|
170
177
|
[
|
data/lib/pprof/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pprof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier Halligon
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: plist
|
@@ -44,7 +43,6 @@ licenses:
|
|
44
43
|
- MIT
|
45
44
|
metadata:
|
46
45
|
rubygems_mfa_required: 'true'
|
47
|
-
post_install_message:
|
48
46
|
rdoc_options: []
|
49
47
|
require_paths:
|
50
48
|
- lib
|
@@ -59,8 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
57
|
- !ruby/object:Gem::Version
|
60
58
|
version: '0'
|
61
59
|
requirements: []
|
62
|
-
rubygems_version: 3.
|
63
|
-
signing_key:
|
60
|
+
rubygems_version: 3.6.8
|
64
61
|
specification_version: 4
|
65
62
|
summary: A Provisioning Profiles library
|
66
63
|
test_files: []
|