device_api-ios 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +3 -10
- data/device_api-ios.gemspec +1 -1
- data/lib/device_api/ios/plistutil.rb +13 -7
- data/lib/device_api/ios/signing.rb +41 -5
- data/spec/ios_signing_spec.rb +51 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f131af055b0b58b5ef4378fed43b28e7b67d028a
|
4
|
+
data.tar.gz: 353f90a18052442c2213db25ee7007defb8a27af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 437802096cbf0dec1d15c350d3d74189d6bb299f0a3fb3bd4bd208ebc5e11742949bcae4b24a722d96b744903f74ac57fd177105e02bc149e9d66e0e97dfa728
|
7
|
+
data.tar.gz: 4477c6442a539b7a8bda12e1657c931e763d481aa98e8e9d45c081dfa5cf412ba5c520bd893d991e4270aa74a4df5c571b2a164eddd967cddede98bdb4056064
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,16 +1,9 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
coderay (1.1.0)
|
5
4
|
device_api (1.0.1)
|
6
5
|
diff-lcs (1.2.5)
|
7
6
|
ios-devices (0.2.1)
|
8
|
-
method_source (0.8.2)
|
9
|
-
ox (2.2.1)
|
10
|
-
pry (0.10.2)
|
11
|
-
coderay (~> 1.1.0)
|
12
|
-
method_source (~> 0.8.1)
|
13
|
-
slop (~> 3.4)
|
14
7
|
rspec (3.3.0)
|
15
8
|
rspec-core (~> 3.3.0)
|
16
9
|
rspec-expectations (~> 3.3.0)
|
@@ -24,7 +17,6 @@ GEM
|
|
24
17
|
diff-lcs (>= 1.2.0, < 2.0)
|
25
18
|
rspec-support (~> 3.3.0)
|
26
19
|
rspec-support (3.3.0)
|
27
|
-
slop (3.6.0)
|
28
20
|
|
29
21
|
PLATFORMS
|
30
22
|
ruby
|
@@ -32,6 +24,7 @@ PLATFORMS
|
|
32
24
|
DEPENDENCIES
|
33
25
|
device_api (>= 1.0.0)
|
34
26
|
ios-devices
|
35
|
-
ox
|
36
|
-
pry
|
37
27
|
rspec
|
28
|
+
|
29
|
+
BUNDLED WITH
|
30
|
+
1.10.5
|
data/device_api-ios.gemspec
CHANGED
@@ -31,17 +31,23 @@ module DeviceAPI
|
|
31
31
|
raise PlistutilCommandError.new('plistutil not found') unless plistutil_available?
|
32
32
|
result = execute("plistutil -i #{plist}")
|
33
33
|
raise PlistutilCommandError.new(result.stderr) if result.exit != 0
|
34
|
-
|
34
|
+
parse_xml(result.stdout)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.parse_xml(xml)
|
38
|
+
info = Ox.parse(xml)
|
35
39
|
nodes = info.locate('*/dict')
|
36
40
|
values = {}
|
37
41
|
last_key = nil
|
38
|
-
nodes.each do |
|
39
|
-
|
40
|
-
if child.
|
41
|
-
|
42
|
-
|
43
|
-
values[last_key] = child.nodes.first
|
42
|
+
nodes.first.nodes.each do |child|
|
43
|
+
if child.value == 'key'
|
44
|
+
if child.nodes.first == 'get-task-allow'
|
45
|
+
values['get-task-allow'] = nodes.first.nodes[nodes.first.nodes.index(child)+1].value
|
46
|
+
next
|
44
47
|
end
|
48
|
+
last_key = child.nodes.first
|
49
|
+
elsif child.value == 'string'
|
50
|
+
values[last_key] = child.nodes.first
|
45
51
|
end
|
46
52
|
end
|
47
53
|
values
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'device_api/execution'
|
2
|
+
require 'device_api/ios/plistutil'
|
2
3
|
|
3
4
|
# DeviceAPI - an interface to allow for automation of devices
|
4
5
|
module DeviceAPI
|
@@ -42,11 +43,33 @@ module DeviceAPI
|
|
42
43
|
cert = options[:cert]
|
43
44
|
entitlements = options[:entitlements]
|
44
45
|
app = options[:app]
|
46
|
+
original_app = nil
|
45
47
|
|
46
|
-
|
48
|
+
if is_ipa?(app)
|
49
|
+
original_app = app
|
50
|
+
app = unpack_ipa(app)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Check to see if the entitlements passed in is a file or the XML
|
54
|
+
unless File.exists?(entitlements)
|
55
|
+
file = Tempfile.new('entitlements')
|
56
|
+
file.write(entitlements)
|
57
|
+
file.close
|
58
|
+
entitlements = file.path
|
59
|
+
end
|
60
|
+
|
61
|
+
result = execute("codesign --force --sign '#{cert}' --entitlements #{entitlements} '#{app}'")
|
47
62
|
|
48
63
|
raise SigningCommandError.new(result.stderr) if result.exit != 0
|
49
64
|
|
65
|
+
zip_app(app, original_app) if original_app
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.zip_app(payload_path, ipa_path)
|
69
|
+
result = execute("cd #{File.dirname(payload_path)}; zip -r #{ipa_path} ../Payload ")
|
70
|
+
raise SigningCommandError.new(result.stderr) if result.exit != 0
|
71
|
+
|
72
|
+
true
|
50
73
|
end
|
51
74
|
|
52
75
|
def self.get_signing_certs
|
@@ -63,16 +86,29 @@ module DeviceAPI
|
|
63
86
|
certs
|
64
87
|
end
|
65
88
|
|
66
|
-
def self.get_entitlements(app_path)
|
89
|
+
def self.get_entitlements(app_path, raw = false)
|
67
90
|
app_path = unpack_ipa(app_path) if is_ipa?(app_path)
|
68
91
|
result = execute("codesign -d --entitlements - #{app_path}")
|
69
92
|
|
70
|
-
require 'pry'
|
71
|
-
binding.pry
|
72
93
|
if result.exit != 0
|
73
94
|
raise SigningCommandError.new(result.stderr)
|
74
95
|
end
|
75
|
-
|
96
|
+
|
97
|
+
# Clean up the result as it occasionally contains invalid UTF-8 characters
|
98
|
+
xml = result.stdout.to_s.encode('UTF-8', 'UTF-8', invalid: :replace)
|
99
|
+
xml = xml[xml.index('<')..xml.length]
|
100
|
+
|
101
|
+
return xml if raw
|
102
|
+
entitlements = Plistutil.parse_xml(xml)
|
103
|
+
return entitlements
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.enable_get_tasks(app_path)
|
107
|
+
entitlements = get_entitlements(app_path, raw: true)
|
108
|
+
|
109
|
+
return entitlements if entitlements.scan(/<key>get-task-allow<\/key>\\n.*<true\/>/).count > 0
|
110
|
+
|
111
|
+
entitlements.gsub('<false/>', '<true/>') if entitlements.scan(/<key>get-task-allow<\/key>\\n.*<false\/>/)
|
76
112
|
end
|
77
113
|
end
|
78
114
|
|
data/spec/ios_signing_spec.rb
CHANGED
@@ -43,20 +43,61 @@ describe DeviceAPI::IOS::Signing do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "entitlements" do
|
46
|
+
plist = <<-eos
|
47
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
48
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
49
|
+
<plist version="1.0">
|
50
|
+
<dict>
|
51
|
+
<key>application-identifier</key>
|
52
|
+
<string>uk.co.bbc.test</string>
|
53
|
+
<key>com.apple.developer.team-identifier</key>
|
54
|
+
<string>ABC1DE2345</string>
|
55
|
+
<key>get-task-allow</key>
|
56
|
+
<false/>
|
57
|
+
<key>keychain-access-groups</key>
|
58
|
+
<array>
|
59
|
+
<string>uk.co.bbc.iplayer.test</string>
|
60
|
+
</array>
|
61
|
+
</dict>
|
62
|
+
</plist>
|
63
|
+
eos
|
64
|
+
|
46
65
|
it 'returns a list of entitlements for an app' do
|
47
|
-
out = <<-eos
|
48
|
-
<dict>
|
49
|
-
<key>application-identifier</key>
|
50
|
-
<string>uk.co.bbc.test</string>
|
51
|
-
<key>get-task-allow</key>
|
52
|
-
<false/>
|
53
|
-
</dict>
|
54
|
-
eos
|
55
66
|
allow(Open3).to receive(:capture3) {
|
56
|
-
[
|
67
|
+
[plist, '', (Struct.new(:exitstatus)).new(0)]
|
68
|
+
}
|
69
|
+
|
70
|
+
expected_result = {
|
71
|
+
'application-identifier' => 'uk.co.bbc.test',
|
72
|
+
'com.apple.developer.team-identifier' => 'ABC1DE2345',
|
73
|
+
'get-task-allow' => 'false'
|
57
74
|
}
|
75
|
+
expect(DeviceAPI::IOS::Signing.get_entitlements('')).to eq(expected_result)
|
76
|
+
end
|
58
77
|
|
59
|
-
|
78
|
+
it 'should replace the entitlements for an app' do
|
79
|
+
expected = <<-eos
|
80
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
81
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
82
|
+
<plist version="1.0">
|
83
|
+
<dict>
|
84
|
+
<key>application-identifier</key>
|
85
|
+
<string>uk.co.bbc.test</string>
|
86
|
+
<key>com.apple.developer.team-identifier</key>
|
87
|
+
<string>ABC1DE2345</string>
|
88
|
+
<key>get-task-allow</key>
|
89
|
+
<true/>
|
90
|
+
<key>keychain-access-groups</key>
|
91
|
+
<array>
|
92
|
+
<string>uk.co.bbc.iplayer.test</string>
|
93
|
+
</array>
|
94
|
+
</dict>
|
95
|
+
</plist>
|
96
|
+
eos
|
97
|
+
allow(Open3).to receive(:capture3) {
|
98
|
+
[plist, '', (Struct.new(:exitstatus)).new(0)]
|
99
|
+
}
|
100
|
+
expect(DeviceAPI::IOS::Signing.enable_get_tasks('test.ipa')).to eq(expected)
|
60
101
|
end
|
61
102
|
end
|
62
103
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: device_api-ios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BBC
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-02-
|
13
|
+
date: 2016-02-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: device_api
|