provisinfo 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c085fa743d77df73e59ee42b73987675bbc18480
4
- data.tar.gz: 15a477681c5149f289e4797c9d506886b9a14f57
3
+ metadata.gz: 84c054f090b22dc5feecaf2bc9951589edf5fba4
4
+ data.tar.gz: 6279105bd9997ce3c9a4b9009d9b07b7868ffcb7
5
5
  SHA512:
6
- metadata.gz: 1b369a3e0588122af96126ca30e0a5da5915ed2b86666f350ca0694c8f21997309967d9c4468c9a2a831f2168920e40db7c312271b762f23cf693ab0a2e50a34
7
- data.tar.gz: 7d34953cee8f38db88618126e3cb65e6c9b39f5d8c4c9f2c0548c95b381a2563aeed94ff851b0cc11ca0b84e954bde959875923a6819ebaf21d769b3ccb61d9a
6
+ metadata.gz: 2c43fce6c23ec7d1e17cd57027f7f6adb9657fd6d2b956619ce195cecef29036636f72dbdd6d45c0cf8d61b8a970bf35f30aad1194d5d5cb1cf53bc2f0c3ed6c
7
+ data.tar.gz: 1816daafdcec1e08860b97cf8c4002b7de72633312d6b9746d6bbfcab2241dffc09bd53d30aed642ee4ccc94fb74410206f31e05d9cfdd2b50b7664d58ce3d74
data/README.md CHANGED
@@ -21,7 +21,9 @@ Or install it yourself as:
21
21
  ## Usage
22
22
  It can be used like a CLI client:
23
23
 
24
- provisinfo info --filepath p1.mobileprovision
24
+ provisinfo info --filename p1.mobileprovision
25
+
26
+ provisinfo validate --provisioning p1.mobileprovision --certificate cert.p12
25
27
 
26
28
  Or you can use in your code:
27
29
 
@@ -31,6 +33,7 @@ Or you can use in your code:
31
33
 
32
34
  #access to any property
33
35
  p1.appID
36
+ puts p1.expirationDate < DateTime.now ? "Expired" : "Active"
34
37
 
35
38
 
36
39
  ## Development
data/bin/provisinfo CHANGED
@@ -9,10 +9,12 @@ program :description, 'CLI for \'provisinfo\' - Provisioning for Human beings. E
9
9
  program :help, 'Author', 'Oswaldo Rubio <osrufung@gmail.com>'
10
10
  program :help, 'GitHub', 'https://github.com/osrufung/provisinfo'
11
11
 
12
+ default_command :info
13
+
12
14
  command :info do |c|
13
15
  c.syntax = 'provisinfo info [options]'
14
- c.summary = 'Extracts information from mobileprovision file'
15
- c.description = 'Show user friendly information from mobileprovision file'
16
+ c.summary = 'Show user friendly information from mobileprovision file'
17
+ c.description = c.summary
16
18
  c.example 'description', 'provisinfo info --filename prov1.mobileprovision'
17
19
  c.option '--filename STRING', 'String','.mobileprovision filepath'
18
20
  c.action do |args, options|
@@ -20,3 +22,16 @@ command :info do |c|
20
22
  Provisinfo.show_info(options.filename)
21
23
  end
22
24
  end
25
+
26
+ command :validate do |c|
27
+ c.syntax = 'provisinfo validate [options]'
28
+ c.summary = 'Validates that a provisioning profile was signed with a given developer certificate'
29
+ c.description = c.summary
30
+ c.example 'description', 'provisinfo validate --provisioning prov1.mobileprovision --certificate cert.p12'
31
+ c.option '--provisioning STRING', 'String','.mobileprovision filepath'
32
+ c.option '--certificate STRING', 'String','path to a p12 certificate.'
33
+ c.action do |args, options|
34
+ # Do something or c.when_called Provisioning info::Commands::Name
35
+ Provisinfo.validate(options.provisioning,options.certificate)
36
+ end
37
+ end
@@ -2,6 +2,15 @@ require 'plist'
2
2
  require 'json'
3
3
  require 'date'
4
4
 
5
+ require "openssl"
6
+ require "rexml/document"
7
+
8
+ RED = 31
9
+ GREEN = 32
10
+
11
+ def puts_message(color, code, text)
12
+ puts "[ \e[#{color}m#{code.upcase}\e[0m ] #{text}"
13
+ end
5
14
 
6
15
  class Provisioning
7
16
  attr_accessor :name
@@ -13,9 +22,10 @@ class Provisioning
13
22
  attr_accessor :expirationDate
14
23
 
15
24
  #by default, it will load the first .mobileprovision file in current directory
25
+
16
26
  def initialize(filename = nil)
17
27
  if filename.nil?
18
- @filename = self.class.list_files().first
28
+ @filename = self.class.list_provisioning_files().first
19
29
  else
20
30
  @filename = filename
21
31
  end
@@ -27,7 +37,9 @@ class Provisioning
27
37
  end
28
38
 
29
39
  end
30
-
40
+
41
+
42
+
31
43
  def load_from_file()
32
44
  xml_raw = `security cms -D -i #{@filename}`
33
45
  xml_parsed = Plist::parse_xml(xml_raw)
@@ -36,11 +48,10 @@ class Provisioning
36
48
  @uuid = xml_parsed['UUID']
37
49
  @appID = xml_parsed['Entitlements']['application-identifier']
38
50
  @expirationDate = xml_parsed['ExpirationDate']
39
-
40
51
 
41
52
  end
42
53
 
43
- def self.list_files()
54
+ def self.list_provisioning_files()
44
55
  provisioning_file_paths = []
45
56
  Dir.entries('.').each do |path|
46
57
  provisioning_file_paths << path if path=~ /.*\.mobileprovision$/
@@ -62,10 +73,54 @@ class Provisioning
62
73
 
63
74
  end
64
75
 
65
- end
76
+ def matches_certificate?(certificate_filename, password)
77
+
78
+ if certificate_filename.nil? or not File.exists?(certificate_filename)
79
+ abort("can't find the certificate file.")
80
+ end
81
+
82
+ profile = File.read(self.filename)
83
+ certificate = File.read(certificate_filename)
84
+ p7 = OpenSSL::PKCS7.new(profile)
85
+ cert = OpenSSL::PKCS12.new(certificate, password)
86
+ store = OpenSSL::X509::Store.new
87
+ p7.verify([], store)
88
+
89
+ plist = REXML::Document.new(p7.data)
90
+ plist.elements.each('/plist/dict/key') do |ele|
91
+ if ele.text == "DeveloperCertificates"
92
+ keys = ele.next_element
93
+ key = keys.get_elements('//array/data')[0].text
94
+
95
+ key = key.scan(/.{1,64}/).join("\n")
96
+
97
+ profile_cert = "-----BEGIN CERTIFICATE-----\n" + key.gsub(/\t/, "") + "\n-----END CERTIFICATE-----\n"
98
+
99
+ @provisioning_cert = OpenSSL::X509::Certificate.new(profile_cert)
100
+ end
101
+ end
102
+
103
+ return @provisioning_cert.to_s != cert.certificate.to_s
104
+ end
105
+
106
+ end
66
107
 
67
108
 
68
109
  if __FILE__ == $0
69
- p1 = Provisioning.new('failed.mobileprovision')
110
+
111
+ # failed test case
112
+ p1 = Provisioning.new('3WKJWX.mobileprovision')
70
113
  p1.show_info()
114
+ p p1.expirationDate < DateTime.now ? "Expired" : "Active"
115
+
116
+
117
+ # Validation case
118
+ p1 = Provisioning.new('3WKJWX.mobileprovision')
119
+
120
+ if p1.matches_certificate?('3WKJWX.p12','')
121
+ puts_message(RED, "error", "Provisioning profile was not signed with provided certificate.")
122
+ else
123
+ puts_message(GREEN, "passed", "Provisioning profile matches certificate file.")
124
+ end
125
+
71
126
  end
@@ -1,3 +1,3 @@
1
1
  module Provisinfo
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/provisinfo.rb CHANGED
@@ -2,8 +2,13 @@ require 'provisinfo/version'
2
2
  require 'provisinfo/provisioning'
3
3
 
4
4
  module Provisinfo
5
- def self.show_info(provisioninFileName)
6
- p1 = Provisioning.new(provisioninFileName)
5
+ def self.show_info(provisioningFileName)
6
+ p1 = Provisioning.new(provisionginFileName)
7
7
  p1.show_info()
8
8
  end
9
+
10
+ def self.validate(provisioningFileName,certificateFileName)
11
+ p1 = Provisioning.new(provisioningFileName)
12
+ p1.validate(certificateFileName)
13
+ end
9
14
  end
data/provisinfo.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["osrufung@gmail.com"]
11
11
 
12
12
  spec.summary = %q{A provisioning profile CLI inspector}
13
- spec.description = %q{A simple provisioning profile CLI inspector to extract metadata from .mobileprovision file.}
13
+ spec.description = %q{A simple provisioning profile CLI inspector to extract metadata from .mobileprovision file and validate iOS p12 certificates.}
14
14
  spec.homepage = "https://github.com/osrufung/provisinfo"
15
15
 
16
16
 
@@ -23,4 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_dependency 'commander', '~> 4.1'
25
25
  spec.add_dependency 'plist', '~> 3.1.0'
26
+
27
+
26
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: provisinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oswaldo Rubio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-21 00:00:00.000000000 Z
11
+ date: 2015-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.1.0
69
69
  description: A simple provisioning profile CLI inspector to extract metadata from
70
- .mobileprovision file.
70
+ .mobileprovision file and validate iOS p12 certificates.
71
71
  email:
72
72
  - osrufung@gmail.com
73
73
  executables: