├── .gitignore ├── LICENSING ├── AUTHORS ├── fileheader.txt ├── Package.resolved ├── LICENSE ├── Package.swift ├── README.md └── Sources └── cgjprofile └── main.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | .swiftpm 6 | -------------------------------------------------------------------------------- /LICENSING: -------------------------------------------------------------------------------- 1 | cgjprofile 2 | (c) 2019 Alexander von Below, Deutsche Telekom AG 3 | 4 | All files of this project are licensed under the MIT license. For details see file 'LICENSE' 5 | 6 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | cgjprofile 2 | 3 | (c) Alexander von Below, Deutsche Telekom AG 4 | 5 | Authors / Contributors of the project cgjprofile are 6 | 7 | * Alexander von Below (main author and initiator) 8 | * Karsten Reincke (project initializer in accordance to the wishes of A. von Below) 9 | -------------------------------------------------------------------------------- /fileheader.txt: -------------------------------------------------------------------------------- 1 | cgjprofile : command line tool for macOS to analyze the validity of mobile provisions files. 2 | Copyright (c) 2019 Alexander von Below, Deutsche Telekom AG 3 | contact: opensource@telekom.de 4 | This files is distributed under the terms of the MIT license. 5 | For details see the file LICENSE on the toplevel. 6 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "cgjprofileLib", 6 | "repositoryURL": "https://github.com/below/cgjProfileLib", 7 | "state": { 8 | "branch": null, 9 | "revision": "d0f6998e2d7335b6491af82e98d38376fbb497ba", 10 | "version": "1.0.0" 11 | } 12 | }, 13 | { 14 | "package": "swift-argument-parser", 15 | "repositoryURL": "https://github.com/apple/swift-argument-parser", 16 | "state": { 17 | "branch": null, 18 | "revision": "15351c1cd009eba0b6e438bfef55ea9847a8dc4a", 19 | "version": "0.3.0" 20 | } 21 | } 22 | ] 23 | }, 24 | "version": 1 25 | } 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Alexander von Below, Deutsche Telekom AG 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:4.2 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | /* 5 | * cgjprofile :- A tool to analyze the validity of iOS mobileprovision 6 | * files and associated certificates 7 | * Copyright (c) 2019, Alexander von Below, Deutsche Telekom AG 8 | * contact: opensource@telekom.de 9 | * This file is distributed under the conditions of the MIT license. 10 | * For details see the file LICENSE on the toplevel. 11 | */ 12 | 13 | import PackageDescription 14 | 15 | let package = Package( 16 | name: "cgjprofile", 17 | products: [ 18 | .executable(name: "cgjprofile", targets: ["cgjprofile"]), 19 | ], 20 | dependencies: [ 21 | // Dependencies declare other packages that this package depends on. 22 | .package(url: "https://github.com/apple/swift-argument-parser", from: "0.3.0"), 23 | .package(url: "https://github.com/below/cgjProfileLib", from: "1.0.0") 24 | ], 25 | targets: [ 26 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 27 | // Targets can depend on other targets in this package, and on products in packages which this package depends on. 28 | .target( 29 | name: "cgjprofile", 30 | dependencies: ["cgjprofileLib", "ArgumentParser"]), 31 | ] 32 | ) 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cgjprofile 2 | 3 | Command Line Tool for macOS to analyse the validity of mobile provision files and the corresponding certificates. The software is well suited to be used in automated setups. 4 | 5 | To facilitate reuse, the source code has been split into the tool, and the core functionality. The later is now a dependeny of the former. 6 | 7 | Let me know if this is useful, I am looking forward to your comments! 8 | 9 | 10 | 11 | ## Building 12 | 13 | This is a Swift Package Manager project. To build, simply execute `swift build -c release`. To create an Xcode project for debugging, execute `swift package generate-xcodeproj`. 14 | 15 | For more information, see the [Package Manager documentation](https://swift.org/package-manager/) 16 | 17 | ## Usage 18 | 19 | Once built, the tool can be invoked like this: 20 | 21 | `cgjprofile [--format="format string"] [--warn-expiration days] [--quiet] [path]` 22 | 23 | ### The Format String 24 | 25 | The format string takes c-style placeholders: 26 | 27 | * %e ExpirationDate 28 | * %c CreationDate 29 | * %u UUID 30 | * %a AppIDName 31 | * %t TeamName 32 | * %n Name 33 | 34 | Minimum width specifiers can be used, such as "%40u", adding spaces until the minimum length is met. 35 | 36 | If no format string is provided, the default is "%u %t %n" 37 | 38 | ### Expiration Warning 39 | 40 | If provided, a warning will be given if the profile will expire in the given number of days 41 | 42 | ### Quiet 43 | 44 | What you expect it would do. No output other than errors and the return value 45 | 46 | ### Path 47 | 48 | If provided, the path to the profile to be checked. Otherwise, all installed profiles are checked. 49 | 50 | ### Return Value 51 | 52 | * 0 on success 53 | * 1 if any profile was invalid 54 | 55 | -------------------------------------------------------------------------------- /Sources/cgjprofile/main.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * cgjprofile :- A tool to analyze the validity of iOS mobileprovision 3 | * files and associated certificates 4 | * Copyright (c) 2019, Alexander von Below, Deutsche Telekom AG 5 | * contact: opensource@telekom.de 6 | * This file is distributed under the conditions of the MIT license. 7 | * For details see the file LICENSE on the toplevel. 8 | */ 9 | 10 | import Darwin 11 | import ArgumentParser 12 | import cgjprofileLib 13 | 14 | internal func allowDeletion(items: [String]) -> Bool { 15 | 16 | fputs("The following files will be deleted:\n", stdout) 17 | for item in items { 18 | fputs("- " + item + "\n", stdout) 19 | } 20 | fputs("\nDo you want to proceed (Y/n)?", stdout) 21 | let result = readLine() 22 | if result?.prefix(1) == "Y" { 23 | return true 24 | } 25 | return false 26 | } 27 | 28 | 29 | struct Cgjprofile: ParsableCommand { 30 | static let configuration = CommandConfiguration( 31 | abstract: "Lists all mobileprovision files, or a single one") 32 | 33 | @Option(name: [.short, .customLong("warnExpiration")], help: "Set days to warn about expiration") 34 | var warnExpiration: Int = 0 35 | 36 | @Option(name: [.short, .long], help: "%e ExpirationDate\n%c CreationDate\n%u UUID\n%a AppIDName\n%t TeamName\n%n Name") 37 | var format: String = "%u %t %n" 38 | 39 | @Flag(name: [.short, .long], help: "Don't print any output (only errors") 40 | var quiet = false 41 | 42 | @Flag(name: [.customLong("r", withSingleDash: true)], help: "Delete expired files after confirmation") 43 | var delete = false 44 | 45 | @Argument(help: "Optional paths to, or UDIDs of, mobileprovision files") 46 | var paths = [String]() 47 | 48 | func run() throws { 49 | do { 50 | _ = try CgjProfileCore.analyzeMobileProfiles(format: format, pathsUDIDsOrNames: (paths.count > 0) ? paths:nil, regEx: nil, warnDays: warnExpiration, quiet: quiet, deletionHandler: delete ? allowDeletion:nil) 51 | } catch { 52 | fputs("Whoops! An error occurred: \(error)", stderr) 53 | throw error 54 | } 55 | 56 | } 57 | } 58 | 59 | Cgjprofile.main() 60 | --------------------------------------------------------------------------------