A big messy commit. Sorry about that

This commit is contained in:
Greg Neagle
2025-05-15 14:28:47 -07:00
parent 73abde1414
commit 119e277ec8
12 changed files with 86 additions and 413 deletions

View File

@@ -1,8 +0,0 @@
//
// MiddlewareFactory.swift
// munki
//
// Created by Greg Neagle on 5/10/25.
//
import Foundation

View File

@@ -1,8 +0,0 @@
//
// MiddleWareProtocol.swift
// munki
//
// Created by Greg Neagle on 5/10/25.
//
import Foundation

View File

@@ -167,6 +167,14 @@
C058EF712DCE9C1B002775E0 /* pkginfoOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C030A99E2C3B4F04007F0B34 /* pkginfoOptions.swift */; };
C058EF722DCE9C3E002775E0 /* admincommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = C013643E2C2DCA5C008DB215 /* admincommon.swift */; };
C058EF742DCE9CAE002775E0 /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = C058EF732DCE9CAE002775E0 /* ArgumentParser */; };
C058EF7C2DCF9FB0002775E0 /* MiddlewareProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C058EF7B2DCF9FB0002775E0 /* MiddlewareProtocol.swift */; };
C058EF7D2DCF9FB0002775E0 /* MiddlewareProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C058EF7B2DCF9FB0002775E0 /* MiddlewareProtocol.swift */; };
C058EF7E2DCF9FB0002775E0 /* MiddlewareProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C058EF7B2DCF9FB0002775E0 /* MiddlewareProtocol.swift */; };
C058EF7F2DCF9FB0002775E0 /* MiddlewareProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C058EF7B2DCF9FB0002775E0 /* MiddlewareProtocol.swift */; };
C058EF9A2DCFA4B2002775E0 /* MiddlewareFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C058EF992DCFA4B2002775E0 /* MiddlewareFactory.swift */; };
C058EF9B2DCFA4B2002775E0 /* MiddlewareFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C058EF992DCFA4B2002775E0 /* MiddlewareFactory.swift */; };
C058EF9C2DCFA4B2002775E0 /* MiddlewareFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C058EF992DCFA4B2002775E0 /* MiddlewareFactory.swift */; };
C058EF9D2DCFA4B2002775E0 /* MiddlewareFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C058EF992DCFA4B2002775E0 /* MiddlewareFactory.swift */; };
C05DB20C2DAC62530081FACD /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = C05DB20B2DAC62530081FACD /* ArgumentParser */; };
C05DB20D2DAC66810081FACD /* version.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D00FAF2C458EAA0021DA9C /* version.swift */; };
C05DB20E2DAC66E50081FACD /* readline.swift in Sources */ = {isa = PBXBuildFile; fileRef = C030A9F52C435183007F0B34 /* readline.swift */; };
@@ -684,8 +692,15 @@
C030A9F52C435183007F0B34 /* readline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = readline.swift; sourceTree = "<group>"; };
C043ED1E2C4822C70047C025 /* sqlite3.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = sqlite3.swift; sourceTree = "<group>"; };
C043ED222C483EEE0047C025 /* rmpkgs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = rmpkgs.swift; sourceTree = "<group>"; };
C05764AB2DD57C4800FEF66A /* managedsoftwareupdate.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = managedsoftwareupdate.entitlements; sourceTree = "<group>"; };
C05764AE2DD57CF500FEF66A /* repoclean.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = repoclean.entitlements; sourceTree = "<group>"; };
C05764AF2DD57CF800FEF66A /* iconimporter.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = iconimporter.entitlements; sourceTree = "<group>"; };
C05764B02DD57CFF00FEF66A /* munkiimport.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = munkiimport.entitlements; sourceTree = "<group>"; };
C05764B12DD57D0800FEF66A /* makecatalogs.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = makecatalogs.entitlements; sourceTree = "<group>"; };
C058EF1D2DCD041A002775E0 /* RepoProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepoProtocol.swift; sourceTree = "<group>"; };
C058EF282DCD11E1002775E0 /* tempfileutils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = tempfileutils.swift; sourceTree = "<group>"; };
C058EF7B2DCF9FB0002775E0 /* MiddlewareProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MiddlewareProtocol.swift; sourceTree = "<group>"; };
C058EF992DCFA4B2002775E0 /* MiddlewareFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MiddlewareFactory.swift; sourceTree = "<group>"; };
C05DB2022DAC53150081FACD /* manifestutil */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = manifestutil; sourceTree = BUILT_PRODUCTS_DIR; };
C05DB2122DAC67760081FACD /* manifestutil-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "manifestutil-Bridging-Header.h"; sourceTree = "<group>"; };
C0684DD12DBFDBD20091E774 /* precache_agent */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = precache_agent; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -982,6 +997,7 @@
C030A9CE2C41F798007F0B34 /* munkiimport */ = {
isa = PBXGroup;
children = (
C05764B02DD57CFF00FEF66A /* munkiimport.entitlements */,
C030A9CF2C41F798007F0B34 /* munkiimport.swift */,
);
path = munkiimport;
@@ -998,6 +1014,15 @@
path = installer;
sourceTree = "<group>";
};
C058EF7A2DCF9F6E002775E0 /* middleware */ = {
isa = PBXGroup;
children = (
C058EF7B2DCF9FB0002775E0 /* MiddlewareProtocol.swift */,
C058EF992DCFA4B2002775E0 /* MiddlewareFactory.swift */,
);
path = middleware;
sourceTree = "<group>";
};
C0684E462DC586250091E774 /* osinstaller */ = {
isa = PBXGroup;
children = (
@@ -1062,6 +1087,7 @@
C07A6FA72C2A82B400090743 /* managedsoftwareupdate */ = {
isa = PBXGroup;
children = (
C05764AB2DD57C4800FEF66A /* managedsoftwareupdate.entitlements */,
C07A6FA82C2A82B400090743 /* managedsoftwareupdate.swift */,
C0011CB42C7EC5B60004ED70 /* msuutils.swift */,
C0011CB72C7F86480004ED70 /* distributednotifications.swift */,
@@ -1082,6 +1108,7 @@
C07A6FC52C2B5C0700090743 /* makecatalogs */ = {
isa = PBXGroup;
children = (
C05764B12DD57D0800FEF66A /* makecatalogs.entitlements */,
C07A6FC62C2B5C0700090743 /* makecatalogs.swift */,
);
path = makecatalogs;
@@ -1174,6 +1201,7 @@
C07AED6D2C67DF4F00DE6119 /* network */ = {
isa = PBXGroup;
children = (
C058EF7A2DCF9F6E002775E0 /* middleware */,
C07AED6E2C67DF6B00DE6119 /* gurl.swift */,
C07AED712C67F77000DE6119 /* sslerrors.swift */,
C01792D22C6BC81B008CBC22 /* fetch.swift */,
@@ -1186,6 +1214,7 @@
C0848D182C94D1840008B463 /* iconimporter */ = {
isa = PBXGroup;
children = (
C05764AF2DD57CF800FEF66A /* iconimporter.entitlements */,
C0848D192C94D1840008B463 /* iconimporter.swift */,
);
path = iconimporter;
@@ -1194,6 +1223,7 @@
C0BF62CE2CEC00E90030885D /* repoclean */ = {
isa = PBXGroup;
children = (
C05764AE2DD57CF500FEF66A /* repoclean.entitlements */,
C0BF62CF2CEC00E90030885D /* repoclean.swift */,
);
path = repoclean;
@@ -1868,6 +1898,7 @@
C0684DE02DBFDD530091E774 /* munkistatus.swift in Sources */,
C0684DEC2DBFDF470091E774 /* cliutils.swift in Sources */,
C0684DDD2DBFDD0C0091E774 /* stderrout.swift in Sources */,
C058EF9A2DCFA4B2002775E0 /* MiddlewareFactory.swift in Sources */,
C0684DF52DBFE2580091E774 /* dmgutils.swift in Sources */,
C0684DE22DBFDD930091E774 /* fetch.swift in Sources */,
C0684DEA2DBFDF0D0091E774 /* munkihash.swift in Sources */,
@@ -1886,6 +1917,7 @@
C0684DED2DBFDF5C0091E774 /* keychain.swift in Sources */,
C0684DDE2DBFDD190091E774 /* constants.swift in Sources */,
C058EF302DCD18D3002775E0 /* tempfileutils.swift in Sources */,
C058EF7E2DCF9FB0002775E0 /* MiddlewareProtocol.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1921,6 +1953,7 @@
files = (
C0684E9B2DC7E5700091E774 /* manifests.swift in Sources */,
C0684E6C2DC73C150091E774 /* plistutils.swift in Sources */,
C058EF7F2DCF9FB0002775E0 /* MiddlewareProtocol.swift in Sources */,
C058EF242DCD041A002775E0 /* RepoProtocol.swift in Sources */,
C0684E792DC7BF2F0091E774 /* prefs.swift in Sources */,
C0684E8E2DC7E2D10091E774 /* dateutils.swift in Sources */,
@@ -1950,6 +1983,7 @@
C0684E9E2DC7E59B0091E774 /* stoprequested.swift in Sources */,
C0684E892DC7E2470091E774 /* gurl.swift in Sources */,
C0684E8A2DC7E2470091E774 /* clientcerts.swift in Sources */,
C058EF9D2DCFA4B2002775E0 /* MiddlewareFactory.swift in Sources */,
C0684EA92DC83B9A0091E774 /* appleupdates.swift in Sources */,
C0684E852DC7C6220091E774 /* download.swift in Sources */,
C0684E942DC7E3BC0091E774 /* dmgutils.swift in Sources */,
@@ -1997,6 +2031,8 @@
C07A6FDA2C2CF19600090743 /* cliutils.swift in Sources */,
C0D9C2A02C6175A10019A067 /* processes.swift in Sources */,
C01364432C2DD1BA008DB215 /* plistutils.swift in Sources */,
C058EF9C2DCFA4B2002775E0 /* MiddlewareFactory.swift in Sources */,
C058EF7C2DCF9FB0002775E0 /* MiddlewareProtocol.swift in Sources */,
C00519A92D2A5C180060DDB6 /* authrestartclient.swift in Sources */,
C01792D32C6BC81B008CBC22 /* fetch.swift in Sources */,
C0684E3D2DC19C7A0091E774 /* BlockingApplications.swift in Sources */,
@@ -2065,6 +2101,7 @@
C01792EC2C75089F008CBC22 /* licensing.swift in Sources */,
C0D00FB72C45BCB90021DA9C /* errors.swift in Sources */,
C07A9D9E2C86CB3A00D5D4B2 /* msuoptions.swift in Sources */,
C058EF7D2DCF9FB0002775E0 /* MiddlewareProtocol.swift in Sources */,
C0B7FA022D288C2700CC14F0 /* authrestart.swift in Sources */,
C030A9C82C41F32E007F0B34 /* munkiimportOptions.swift in Sources */,
C030A9C02C409738007F0B34 /* iconutils.swift in Sources */,
@@ -2118,6 +2155,7 @@
C030A9C12C419565007F0B34 /* osinstaller.swift in Sources */,
C06C21352C8793720023E9D9 /* bootstrapping.swift in Sources */,
C0D9C2B12C62D4120019A067 /* powermanager.swift in Sources */,
C058EF9B2DCFA4B2002775E0 /* MiddlewareFactory.swift in Sources */,
C0D9C2982C6012C80019A067 /* dmg.swift in Sources */,
C030A9C22C41B556007F0B34 /* pkginfolib.swift in Sources */,
C058EF232DCD041A002775E0 /* RepoProtocol.swift in Sources */,
@@ -2416,6 +2454,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = munkiimport/munkiimport.entitlements;
CODE_SIGN_STYLE = Manual;
CREATE_INFOPLIST_SECTION_IN_BINARY = NO;
DEAD_CODE_STRIPPING = YES;
@@ -2437,6 +2476,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = munkiimport/munkiimport.entitlements;
CODE_SIGN_STYLE = Manual;
CREATE_INFOPLIST_SECTION_IN_BINARY = NO;
DEAD_CODE_STRIPPING = YES;
@@ -2456,6 +2496,7 @@
C05DB2062DAC53150081FACD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = manifestutil/manifestutil.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
@@ -2472,6 +2513,7 @@
C05DB2072DAC53150081FACD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = manifestutil/manifestutil.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
@@ -2488,6 +2530,7 @@
C0684DD62DBFDBD20091E774 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = precache_agent/precache_agent.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
@@ -2503,6 +2546,7 @@
C0684DD72DBFDBD20091E774 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = precache_agent/precache_agent.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
@@ -2731,6 +2775,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = managedsoftwareupdate/managedsoftwareupdate.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
@@ -2750,6 +2795,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = managedsoftwareupdate/managedsoftwareupdate.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
@@ -2804,6 +2850,7 @@
C07A6FC92C2B5C0700090743 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = makecatalogs/makecatalogs.entitlements;
CODE_SIGN_STYLE = Manual;
CREATE_INFOPLIST_SECTION_IN_BINARY = NO;
DEAD_CODE_STRIPPING = YES;
@@ -2823,6 +2870,7 @@
C07A6FCA2C2B5C0700090743 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = makecatalogs/makecatalogs.entitlements;
CODE_SIGN_STYLE = Manual;
CREATE_INFOPLIST_SECTION_IN_BINARY = NO;
DEAD_CODE_STRIPPING = YES;
@@ -2842,6 +2890,7 @@
C0848D1B2C94D1840008B463 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = iconimporter/iconimporter.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
@@ -2858,6 +2907,7 @@
C0848D1C2C94D1840008B463 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = iconimporter/iconimporter.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
@@ -2874,6 +2924,7 @@
C0BF62D12CEC00E90030885D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = repoclean/repoclean.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";
@@ -2890,6 +2941,7 @@
C0BF62D22CEC00E90030885D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = repoclean/repoclean.entitlements;
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "";

View File

@@ -23,7 +23,7 @@ import Foundation
/// Loads a Repo plugin from a dylib
/// implementation lifted from
/// https://theswiftdev.com/building-and-loading-dynamic-libraries-at-runtime-in-swift/
func loadRepoPlugin(at path: String) throws -> RepoPluginBuilder {
private func loadRepoPlugin(at path: String) throws -> RepoPluginBuilder {
typealias InitFunction = @convention(c) () -> UnsafeMutableRawPointer
let openRes = dlopen(path, RTLD_NOW | RTLD_LOCAL)

View File

@@ -141,9 +141,22 @@ func headerDictFromList(_ strList: [String]?) -> [String: String] {
return headerDict
}
func runMiddleware(options: GurlOptions, pkginfo _: PlistDict?) -> GurlOptions {
// placeholder function
return options
/// Attempts to process our request via a middleware plugin, if one is found
func runMiddleware(_ request: MunkiMiddlewareRequest) -> MunkiMiddlewareRequest {
let display = DisplayAndLog.main
do {
if let middleware = try loadMiddlewarePlugin() {
display.debug2("Running middleware plugin")
display.debug2("Input: \(request)")
let modifiedRequest = middleware.processRequest(request)
display.debug2("Output: \(modifiedRequest)")
return modifiedRequest
}
} catch {
display.error("Could not load middleware plugin: \(error.localizedDescription)")
}
// no plugin found, or error loading plugin -- just return unmodified request
return request
}
/// Gets an HTTP or HTTPS URL and stores it in
@@ -171,6 +184,15 @@ func getURL(
if pathExists(tempDownloadPath), !resume {
try? FileManager.default.removeItem(atPath: tempDownloadPath)
}
let headers = headerDictFromList(customHeaders)
// Run middleware
var request = MunkiMiddlewareRequest(
url: url,
headers: headers
)
request = runMiddleware(request)
var cacheData: [String: String]?
if onlyIfNewer, pathExists(destinationPath) {
@@ -184,9 +206,9 @@ func getURL(
let ignoreSystemProxy = pref("IgnoreSystemProxies") as? Bool ?? false
var options = GurlOptions(
url: url,
url: request.url,
destinationPath: tempDownloadPath,
additionalHeaders: headerDictFromList(customHeaders),
additionalHeaders: request.headers,
followRedirects: followRedirects,
ignoreSystemProxy: ignoreSystemProxy,
canResume: resume,
@@ -195,9 +217,6 @@ func getURL(
log: DisplayAndLog.main.debug2
)
// TODO: middleware support
options = runMiddleware(options: options, pkginfo: pkginfo)
let display = DisplayAndLog.main
let session = Gurl(options: options)
var displayMessage = message

View File

@@ -20,8 +20,13 @@
import Foundation
public struct MunkiMiddlewareRequest {
var url: String
var headers: [String: String]
}
public protocol MunkiMiddleware {
func processRequest(_ request: URLRequest) -> URLRequest
func processRequest(_ request: MunkiMiddlewareRequest) -> MunkiMiddlewareRequest
}
open class MiddlewarePluginBuilder {

View File

@@ -1,298 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 77;
objects = {
/* Begin PBXFileReference section */
C058EF892DCFA10A002775E0 /* libs3Middleware.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libs3Middleware.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedRootGroup section */
C058EF8B2DCFA10A002775E0 /* s3Middleware */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = s3Middleware;
sourceTree = "<group>";
};
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
C058EF872DCFA10A002775E0 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
C058EF802DCFA10A002775E0 = {
isa = PBXGroup;
children = (
C058EF8B2DCFA10A002775E0 /* s3Middleware */,
C058EF8A2DCFA10A002775E0 /* Products */,
);
sourceTree = "<group>";
};
C058EF8A2DCFA10A002775E0 /* Products */ = {
isa = PBXGroup;
children = (
C058EF892DCFA10A002775E0 /* libs3Middleware.dylib */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
C058EF852DCFA10A002775E0 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
C058EF882DCFA10A002775E0 /* s3Middleware */ = {
isa = PBXNativeTarget;
buildConfigurationList = C058EF922DCFA10A002775E0 /* Build configuration list for PBXNativeTarget "s3Middleware" */;
buildPhases = (
C058EF852DCFA10A002775E0 /* Headers */,
C058EF862DCFA10A002775E0 /* Sources */,
C058EF872DCFA10A002775E0 /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
fileSystemSynchronizedGroups = (
C058EF8B2DCFA10A002775E0 /* s3Middleware */,
);
name = s3Middleware;
packageProductDependencies = (
);
productName = s3Middleware;
productReference = C058EF892DCFA10A002775E0 /* libs3Middleware.dylib */;
productType = "com.apple.product-type.library.dynamic";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
C058EF812DCFA10A002775E0 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1630;
TargetAttributes = {
C058EF882DCFA10A002775E0 = {
CreatedOnToolsVersion = 16.3;
LastSwiftMigration = 1630;
};
};
};
buildConfigurationList = C058EF842DCFA10A002775E0 /* Build configuration list for PBXProject "s3Middleware" */;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = C058EF802DCFA10A002775E0;
minimizedProjectReferenceProxies = 1;
preferredProjectObjectVersion = 77;
productRefGroup = C058EF8A2DCFA10A002775E0 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
C058EF882DCFA10A002775E0 /* s3Middleware */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
C058EF862DCFA10A002775E0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
C058EF902DCFA10A002775E0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 15.4;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
C058EF912DCFA10A002775E0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 15.4;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
};
name = Release;
};
C058EF932DCFA10A002775E0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
EXECUTABLE_PREFIX = lib;
MACOSX_DEPLOYMENT_TARGET = 10.15;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 6.0;
};
name = Debug;
};
C058EF942DCFA10A002775E0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
EXECUTABLE_PREFIX = lib;
MACOSX_DEPLOYMENT_TARGET = 10.15;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 6.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
C058EF842DCFA10A002775E0 /* Build configuration list for PBXProject "s3Middleware" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C058EF902DCFA10A002775E0 /* Debug */,
C058EF912DCFA10A002775E0 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C058EF922DCFA10A002775E0 /* Build configuration list for PBXNativeTarget "s3Middleware" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C058EF932DCFA10A002775E0 /* Debug */,
C058EF942DCFA10A002775E0 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = C058EF812DCFA10A002775E0 /* Project object */;
}

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>s3Middleware.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>

View File

@@ -1,30 +0,0 @@
//
// s3Middleware.swift
// s3Middleware
//
// Created by Greg Neagle on 5/10/25.
//
import Foundation
class s3Middleware: MunkiMiddleware {
func processRequest(_ request: MunkiMiddlewareRequest) -> MunkiMiddlewareRequest {
var modifiedRequest = request
modifiedRequest.headers["X-Custom-Header-Hello"] = "Hello, World!"
return modifiedRequest
}
}
// MARK: dylib "interface"
/// Function with C calling style for our dylib. We use it to instantiate the Repo object and return an instance
@_cdecl("createPlugin")
public func createPlugin() -> UnsafeMutableRawPointer {
return Unmanaged.passRetained(MWA2APIRepoBuilder()).toOpaque()
}
final class MWA2APIRepoBuilder: MiddlewarePluginBuilder {
override func create() -> MunkiMiddleware {
return s3Middleware()
}
}

View File

@@ -1,38 +0,0 @@
//
// MiddlewareProtocol.swift
// munki
//
// Created by Greg Neagle on 5/10/25.
//
// Copyright 2025 Greg Neagle.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import Foundation
public struct MunkiMiddlewareRequest {
var url: String
var headers: [String: String]
}
public protocol MunkiMiddleware {
func processRequest(_ request: MunkiMiddlewareRequest) -> MunkiMiddlewareRequest
}
open class MiddlewarePluginBuilder {
// public init() {}
open func create() -> MunkiMiddleware {
fatalError("You have to override this method.")
}
}