Parsing quarantine info
This commit is contained in:
parent
07ece653e9
commit
d093d9662e
@ -19,6 +19,7 @@
|
|||||||
7AF0C51A29EF43C2008D4084 /* OutlineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF0C51929EF43C2008D4084 /* OutlineView.swift */; };
|
7AF0C51A29EF43C2008D4084 /* OutlineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF0C51929EF43C2008D4084 /* OutlineView.swift */; };
|
||||||
7AF0C51C29EF43CD008D4084 /* TreeItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF0C51B29EF43CD008D4084 /* TreeItem.swift */; };
|
7AF0C51C29EF43CD008D4084 /* TreeItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF0C51B29EF43CD008D4084 /* TreeItem.swift */; };
|
||||||
7AF0C53B29F72151008D4084 /* PlistView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF0C53A29F72151008D4084 /* PlistView.swift */; };
|
7AF0C53B29F72151008D4084 /* PlistView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF0C53A29F72151008D4084 /* PlistView.swift */; };
|
||||||
|
7AF0C53D29F9B7FE008D4084 /* Quarantine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF0C53C29F9B7FE008D4084 /* Quarantine.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@ -36,6 +37,7 @@
|
|||||||
7AF0C51929EF43C2008D4084 /* OutlineView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OutlineView.swift; sourceTree = "<group>"; };
|
7AF0C51929EF43C2008D4084 /* OutlineView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OutlineView.swift; sourceTree = "<group>"; };
|
||||||
7AF0C51B29EF43CD008D4084 /* TreeItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TreeItem.swift; sourceTree = "<group>"; };
|
7AF0C51B29EF43CD008D4084 /* TreeItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TreeItem.swift; sourceTree = "<group>"; };
|
||||||
7AF0C53A29F72151008D4084 /* PlistView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlistView.swift; sourceTree = "<group>"; };
|
7AF0C53A29F72151008D4084 /* PlistView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlistView.swift; sourceTree = "<group>"; };
|
||||||
|
7AF0C53C29F9B7FE008D4084 /* Quarantine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Quarantine.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -94,6 +96,7 @@
|
|||||||
7A72231429DCABE400503F78 /* ContentView.swift */,
|
7A72231429DCABE400503F78 /* ContentView.swift */,
|
||||||
7A064BEA29DF5BB800C5D978 /* AppPackage.swift */,
|
7A064BEA29DF5BB800C5D978 /* AppPackage.swift */,
|
||||||
7A064BEC29E2C91D00C5D978 /* Certificate.swift */,
|
7A064BEC29E2C91D00C5D978 /* Certificate.swift */,
|
||||||
|
7AF0C53C29F9B7FE008D4084 /* Quarantine.swift */,
|
||||||
7A72231629DCABE500503F78 /* Assets.xcassets */,
|
7A72231629DCABE500503F78 /* Assets.xcassets */,
|
||||||
7A72231B29DCABE500503F78 /* reSign.entitlements */,
|
7A72231B29DCABE500503F78 /* reSign.entitlements */,
|
||||||
7A72231829DCABE500503F78 /* Preview Content */,
|
7A72231829DCABE500503F78 /* Preview Content */,
|
||||||
@ -195,6 +198,7 @@
|
|||||||
7A064BE929DE18C700C5D978 /* SignInfoView.swift in Sources */,
|
7A064BE929DE18C700C5D978 /* SignInfoView.swift in Sources */,
|
||||||
7A064BED29E2C91D00C5D978 /* Certificate.swift in Sources */,
|
7A064BED29E2C91D00C5D978 /* Certificate.swift in Sources */,
|
||||||
7A72231329DCABE400503F78 /* reSignApp.swift in Sources */,
|
7A72231329DCABE400503F78 /* reSignApp.swift in Sources */,
|
||||||
|
7AF0C53D29F9B7FE008D4084 /* Quarantine.swift in Sources */,
|
||||||
7A064BE429DE107000C5D978 /* Category.swift in Sources */,
|
7A064BE429DE107000C5D978 /* Category.swift in Sources */,
|
||||||
7AF0C51A29EF43C2008D4084 /* OutlineView.swift in Sources */,
|
7AF0C51A29EF43C2008D4084 /* OutlineView.swift in Sources */,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -48,6 +48,7 @@ class AppPackage {
|
|||||||
var certificates: [Certificate]?
|
var certificates: [Certificate]?
|
||||||
var infoPlist: [String: Any] = [:]
|
var infoPlist: [String: Any] = [:]
|
||||||
var entitlements: [String: Any] = [:]
|
var entitlements: [String: Any] = [:]
|
||||||
|
var quarantine: Quarantine?
|
||||||
|
|
||||||
init(url: URL) {
|
init(url: URL) {
|
||||||
|
|
||||||
@ -74,25 +75,24 @@ class AppPackage {
|
|||||||
|
|
||||||
func getAppInfo() throws {
|
func getAppInfo() throws {
|
||||||
|
|
||||||
let pStaticCode: UnsafeMutablePointer<SecStaticCode?> = .allocate(capacity: 1)
|
var staticCode: SecStaticCode? = nil
|
||||||
defer { pStaticCode.deallocate() }
|
var status = SecStaticCodeCreateWithPath(url as CFURL, [], &staticCode)
|
||||||
var status = SecStaticCodeCreateWithPath(url as CFURL, [], pStaticCode)
|
|
||||||
try checkResult(status)
|
try checkResult(status)
|
||||||
|
|
||||||
guard let staticCode = pStaticCode.pointee else {
|
guard let staticCode else {
|
||||||
throw SecError.staticCodeNil
|
throw SecError.staticCodeNil
|
||||||
}
|
}
|
||||||
|
|
||||||
let pSigningInfo: UnsafeMutablePointer<CFDictionary?> = .allocate(capacity: 1)
|
var signingInfo: CFDictionary?
|
||||||
defer { pSigningInfo.deallocate() }
|
|
||||||
let signInfoFlags: SecCSFlags = [
|
let signInfoFlags: SecCSFlags = [
|
||||||
SecCSFlags(rawValue: kSecCSRequirementInformation),
|
SecCSFlags(rawValue: kSecCSRequirementInformation),
|
||||||
SecCSFlags(rawValue: kSecCSSigningInformation),
|
SecCSFlags(rawValue: kSecCSSigningInformation),
|
||||||
]
|
]
|
||||||
status = SecCodeCopySigningInformation(staticCode, signInfoFlags, pSigningInfo)
|
|
||||||
|
status = SecCodeCopySigningInformation(staticCode, signInfoFlags, &signingInfo)
|
||||||
try checkResult(status)
|
try checkResult(status)
|
||||||
|
|
||||||
if let signingInfo = pSigningInfo.pointee as? [String: Any] {
|
if let signingInfo = signingInfo as? [String: Any] {
|
||||||
|
|
||||||
bundleId = signingInfo[kSecCodeInfoIdentifier as String] as? String
|
bundleId = signingInfo[kSecCodeInfoIdentifier as String] as? String
|
||||||
mainExecutable = (signingInfo[kSecCodeInfoMainExecutable as String] as? URL)?.path()
|
mainExecutable = (signingInfo[kSecCodeInfoMainExecutable as String] as? URL)?.path()
|
||||||
@ -110,6 +110,8 @@ class AppPackage {
|
|||||||
infoPlist = signingInfo[kSecCodeInfoPList as String] as? [String: Any] ?? [:]
|
infoPlist = signingInfo[kSecCodeInfoPList as String] as? [String: Any] ?? [:]
|
||||||
entitlements = signingInfo[kSecCodeInfoEntitlementsDict as String] as? [String: Any] ?? [:]
|
entitlements = signingInfo[kSecCodeInfoEntitlementsDict as String] as? [String: Any] ?? [:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quarantine = Quarantine(url: url)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDigestAlgorithm(from dict: [String: Any]) -> String? {
|
func getDigestAlgorithm(from dict: [String: Any]) -> String? {
|
||||||
|
|||||||
33
reSign/Quarantine.swift
Normal file
33
reSign/Quarantine.swift
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// Quarantine.swift
|
||||||
|
// reSign
|
||||||
|
//
|
||||||
|
// Created by Мустафаев Селим Мустафаевич on 26.04.2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class Quarantine {
|
||||||
|
|
||||||
|
var flags: Int
|
||||||
|
var date: Date
|
||||||
|
var agent: String
|
||||||
|
var uuid: String
|
||||||
|
|
||||||
|
init?(url: URL) {
|
||||||
|
guard let data = try? url.extendedAttribute(forName: "com.apple.quarantine"),
|
||||||
|
let stringData = String(data: data, encoding: .utf8)
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
let parts = stringData.split(separator: ";")
|
||||||
|
|
||||||
|
self.flags = Int(parts[0]) ?? 0
|
||||||
|
self.date = Date(timeIntervalSince1970: TimeInterval(UInt32(parts[1], radix: 16) ?? 0))
|
||||||
|
self.agent = String(parts[2])
|
||||||
|
self.uuid = String(parts[3])
|
||||||
|
|
||||||
|
print(parts)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -51,6 +51,21 @@ struct FormTextItem: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct FormToggleItem: View {
|
||||||
|
|
||||||
|
let name: String
|
||||||
|
let value: Bool
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
Text(name)
|
||||||
|
Spacer()
|
||||||
|
Toggle("", isOn: .constant(value))
|
||||||
|
.disabled(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct SignInfoView: View {
|
struct SignInfoView: View {
|
||||||
|
|
||||||
let appPackage: AppPackage
|
let appPackage: AppPackage
|
||||||
@ -58,18 +73,31 @@ struct SignInfoView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
Section(header: Text("General info")) {
|
Section(header: Text("General info")) {
|
||||||
FormTextItem(name: "Main executable path", value: appPackage.mainExecutable)
|
FormTextItem(name: "Bundle ID", value: appPackage.bundleId)
|
||||||
|
FormTextItem(name: "Team ID", value: appPackage.teamId)
|
||||||
|
FormToggleItem(name: "Quarantine", value: appPackage.quarantine != nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
Section(header: Text("Details")) {
|
||||||
FormTextItem(name: "Format", value: appPackage.format)
|
FormTextItem(name: "Format", value: appPackage.format)
|
||||||
|
FormTextItem(name: "Main executable path", value: appPackage.mainExecutable)
|
||||||
FormTextItem(name: "Code signature source", value: appPackage.source)
|
FormTextItem(name: "Code signature source", value: appPackage.source)
|
||||||
FormTextItem(name: "Runtime version", value: appPackage.runtimeVersion)
|
FormTextItem(name: "Runtime version", value: appPackage.runtimeVersion)
|
||||||
FormTextItem(name: "Flags", array: appPackage.flags)
|
FormTextItem(name: "Flags", array: appPackage.flags)
|
||||||
FormTextItem(name: "Digest algorithm", value: appPackage.digestAlgorithm)
|
FormTextItem(name: "Digest algorithm", value: appPackage.digestAlgorithm)
|
||||||
FormTextItem(name: "Bundle ID", value: appPackage.bundleId)
|
|
||||||
FormTextItem(name: "Team ID", value: appPackage.teamId)
|
|
||||||
FormTextItem(name: "Signing date", date: appPackage.signingDate)
|
FormTextItem(name: "Signing date", date: appPackage.signingDate)
|
||||||
FormTextItem(name: "Signing date (actual)", date: appPackage.signingDateActual)
|
FormTextItem(name: "Signing date (actual)", date: appPackage.signingDateActual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let quarantine = appPackage.quarantine {
|
||||||
|
Section("Quarantine") {
|
||||||
|
FormTextItem(name: "Flags", value: quarantine.flags)
|
||||||
|
FormTextItem(name: "Date", date: quarantine.date)
|
||||||
|
FormTextItem(name: "Agent", value: quarantine.agent)
|
||||||
|
FormTextItem(name: "UUID", value: quarantine.uuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Section(header: Text("Requirements")) {
|
Section(header: Text("Requirements")) {
|
||||||
FormTextItem(name: "Designated requirements", value: appPackage.designatedRequirements)
|
FormTextItem(name: "Designated requirements", value: appPackage.designatedRequirements)
|
||||||
FormTextItem(name: "Implicit requirements", value: appPackage.implicitRequirements)
|
FormTextItem(name: "Implicit requirements", value: appPackage.implicitRequirements)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user