Class: Headdesk::Ipa

Inherits:
Object
  • Object
show all
Defined in:
lib/headdesk/ipa.rb

Overview

Representation of an unzipped IPA file

Defined Under Namespace

Classes: Entitlements

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Ipa

Returns a new instance of Ipa.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/headdesk/ipa.rb', line 19

def initialize(path)
  @path = path

  apktool_yml = File.join(@path, 'apktool.yml').freeze
  was_unpacked_by_apktool = File.exist?(apktool_yml)

  @path = File.join(@path, 'unknown') if was_unpacked_by_apktool
  @path = Dir[File.join(@path, 'Payload','*.app')].first

  throw CliError.new('Path did not contain Info.plist') unless @path && Dir.exist?(@path)

  info_plist_path = File.join(@path, 'Info.plist').freeze

  throw CliError.new('Path did not contain Info.plist') unless File.exist?(info_plist_path)

  @info_plist = Plist.parse_xml(info_plist_path)

  @url_schemes = []
  @info_plist['CFBundleURLTypes'].each do |url_type|
    url_type['CFBundleURLSchemes'].each do |url_scheme|
      @url_schemes << url_scheme
    end
  end

  entitlements = Plist.parse_xml(`codesign -d --entitlements :- #{@path}`)
  @entitlements = Entitlements.new(
    entitlements['application-identifier'],
    entitlements['aps-environment'],
    entitlements['com.apple.developer.associated-domains'],
    entitlements['com.apple.developer.team-identifier'],
    entitlements['get-task-allow']
  )
end

Instance Attribute Details

#entitlementsObject (readonly)

Returns the value of attribute entitlements.



15
16
17
# File 'lib/headdesk/ipa.rb', line 15

def entitlements
  @entitlements
end

#info_plistObject (readonly)

Returns the value of attribute info_plist.



15
16
17
# File 'lib/headdesk/ipa.rb', line 15

def info_plist
  @info_plist
end

#url_schemesObject (readonly)

Returns the value of attribute url_schemes.



15
16
17
# File 'lib/headdesk/ipa.rb', line 15

def url_schemes
  @url_schemes
end

Instance Method Details

#analyzeObject



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/headdesk/ipa.rb', line 53

def analyze
  report = Headdesk::IPAReport.new(self)

  Headdesk::Check.for_ipa.each do |check_type|
    check = check_type.new(self)
    report << check.process
  end

  # TODO: Associated domains
  report
end