Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#append_entitlements(path, entitlements_hash) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/entitlements.rb', line 11

def append_entitlements(path, entitlements_hash)
	index = 0
	Dir.glob(path) do |file|
		entitlements = `codesign -d --entitlements :- "#{file}" 2>&1`
		plist_entitlements = Plist::parse_xml(entitlements)
		if (plist_entitlements)
			application_identifier = plist_entitlements["application-identifier"] ? plist_entitlements["application-identifier"] : index.to_s
			entitlements_hash[application_identifier] = plist_entitlements
			index = index + 1
		end
	end
end

#contained_binary_extensionsObject



1
2
3
4
# File 'lib/contained_binaries_definition.rb', line 1

def contained_binary_extensions
	return ["appex",
			"app"]
end

#extract_zip(file, destination) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/extract_zip.rb', line 3

def extract_zip(file, destination)
  FileUtils.mkdir_p(destination)

  Zip::File.open(file) do |zip_file|
    zip_file.each do |f|
      fpath = File.join(destination, f.name)
      zip_file.extract(f, fpath) unless File.exist?(fpath)
    end
  end
end

#get_entitlements(tempdir_path) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/entitlements.rb', line 24

def get_entitlements(tempdir_path)
	entitlements_hash = Hash.new

	contained_binary_extensions().each { |extension|
		append_entitlements("#{tempdir_path}/**/*.#{extension}", entitlements_hash)
	}

	if (entitlements_hash.length == 0)
		abort "No entitlements found on contained binaries"
	end

	return entitlements_hash.to_plist
end

#get_profiles(tempdir_path, only_expiration) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/profiles.rb', line 7

def get_profiles(tempdir_path, only_expiration)
	path = "#{tempdir_path}/**/*.mobileprovision"
	profiles = Hash.new
	index = 0
	Dir.glob(path) do |file|
		profile = `security cms -D -i "#{file}" 2>&1`
		plist_profile = Plist::parse_xml(profile)
		if plist_profile
			app_id = plist_profile["AppIDName"] ? plist_profile["AppIDName"] : index.to_s
			if only_expiration
				profiles[app_id] = plist_profile["ExpirationDate"]
			else
				profiles[app_id] = plist_profile
			end
			index = index + 1
		end
	end

	if (profiles.length == 0)
		abort "No embedded provisioning profiles found"
	end
	return profiles.to_plist
end

#validate_ipa(file) ⇒ Object



1
2
3
4
# File 'lib/validate_ipa.rb', line 1

def validate_ipa(file)
	puts "Missing or unspecified .ipa file" and abort unless file and ::File.exist?(file)
	return file
end

#verify_binaries(path) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/verify.rb', line 8

def verify_binaries(path)
	Dir.glob(path) do |file|
		codesign = `codesign --verify "#{file}" 2>&1`
		if (!codesign.to_s.empty?)
			puts codesign
		end
	end
end

#write_plist_to_path(plist, path) ⇒ Object



9
10
11
# File 'lib/compare.rb', line 9

def write_plist_to_path(plist, path)
	File.write(path, plist)
end