├── .DS_Store ├── .gitignore ├── Jamf Protect ULF Uploader.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── swiftpm │ │ │ └── Package.resolved │ └── xcuserdata │ │ ├── richard.mallion.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── thijs.xhaflaire.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── richard.mallion.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── thijs.xhaflaire.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── Jamf Protect ULF Uploader ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon-1024.png │ │ ├── icon-128.png │ │ ├── icon-16.png │ │ ├── icon-256 1.png │ │ ├── icon-256.png │ │ ├── icon-32 1.png │ │ ├── icon-32.png │ │ ├── icon-512 1.png │ │ ├── icon-512.png │ │ └── icon-64.png │ └── Contents.json ├── ContentView.swift ├── JamfProtectAPI.swift ├── Jamf_Protect_ULF_Uploader.entitlements ├── Jamf_Protect_ULF_UploaderApp.swift ├── Keychain.swift ├── Logger.swift ├── Models.swift ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json └── SettingsView.swift └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FBACB3BA2A8435A90096312C /* Jamf_Protect_ULF_UploaderApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBACB3B92A8435A90096312C /* Jamf_Protect_ULF_UploaderApp.swift */; }; 11 | FBACB3BC2A8435A90096312C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBACB3BB2A8435A90096312C /* ContentView.swift */; }; 12 | FBACB3BE2A8435AA0096312C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FBACB3BD2A8435AA0096312C /* Assets.xcassets */; }; 13 | FBACB3C12A8435AA0096312C /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FBACB3C02A8435AA0096312C /* Preview Assets.xcassets */; }; 14 | FBACB3C92A8435CA0096312C /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBACB3C82A8435CA0096312C /* Models.swift */; }; 15 | FBACB3CC2A84362A0096312C /* Yams in Frameworks */ = {isa = PBXBuildFile; productRef = FBACB3CB2A84362A0096312C /* Yams */; }; 16 | FBACB3CE2A850FB90096312C /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBACB3CD2A850FB90096312C /* Logger.swift */; }; 17 | FBACB3D02A850FEB0096312C /* Keychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBACB3CF2A850FEB0096312C /* Keychain.swift */; }; 18 | FBACB3D22A8510410096312C /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBACB3D12A8510410096312C /* SettingsView.swift */; }; 19 | FBDA126E2A85789000A69778 /* JamfProtectAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBDA126D2A85789000A69778 /* JamfProtectAPI.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | FBACB3B62A8435A90096312C /* Jamf Protect ULF Uploader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Jamf Protect ULF Uploader.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | FBACB3B92A8435A90096312C /* Jamf_Protect_ULF_UploaderApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Jamf_Protect_ULF_UploaderApp.swift; sourceTree = ""; }; 25 | FBACB3BB2A8435A90096312C /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 26 | FBACB3BD2A8435AA0096312C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | FBACB3C02A8435AA0096312C /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 28 | FBACB3C22A8435AA0096312C /* Jamf_Protect_ULF_Uploader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Jamf_Protect_ULF_Uploader.entitlements; sourceTree = ""; }; 29 | FBACB3C82A8435CA0096312C /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = ""; }; 30 | FBACB3CD2A850FB90096312C /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = ""; }; 31 | FBACB3CF2A850FEB0096312C /* Keychain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keychain.swift; sourceTree = ""; }; 32 | FBACB3D12A8510410096312C /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; 33 | FBDA126D2A85789000A69778 /* JamfProtectAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JamfProtectAPI.swift; sourceTree = ""; }; 34 | /* End PBXFileReference section */ 35 | 36 | /* Begin PBXFrameworksBuildPhase section */ 37 | FBACB3B32A8435A90096312C /* Frameworks */ = { 38 | isa = PBXFrameworksBuildPhase; 39 | buildActionMask = 2147483647; 40 | files = ( 41 | FBACB3CC2A84362A0096312C /* Yams in Frameworks */, 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | FBACB3AD2A8435A90096312C = { 49 | isa = PBXGroup; 50 | children = ( 51 | FBACB3B82A8435A90096312C /* Jamf Protect ULF Uploader */, 52 | FBACB3B72A8435A90096312C /* Products */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | FBACB3B72A8435A90096312C /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | FBACB3B62A8435A90096312C /* Jamf Protect ULF Uploader.app */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | FBACB3B82A8435A90096312C /* Jamf Protect ULF Uploader */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | FBACB3B92A8435A90096312C /* Jamf_Protect_ULF_UploaderApp.swift */, 68 | FBACB3BB2A8435A90096312C /* ContentView.swift */, 69 | FBDA126D2A85789000A69778 /* JamfProtectAPI.swift */, 70 | FBACB3BD2A8435AA0096312C /* Assets.xcassets */, 71 | FBACB3C22A8435AA0096312C /* Jamf_Protect_ULF_Uploader.entitlements */, 72 | FBACB3BF2A8435AA0096312C /* Preview Content */, 73 | FBACB3C82A8435CA0096312C /* Models.swift */, 74 | FBACB3CD2A850FB90096312C /* Logger.swift */, 75 | FBACB3CF2A850FEB0096312C /* Keychain.swift */, 76 | FBACB3D12A8510410096312C /* SettingsView.swift */, 77 | ); 78 | path = "Jamf Protect ULF Uploader"; 79 | sourceTree = ""; 80 | }; 81 | FBACB3BF2A8435AA0096312C /* Preview Content */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | FBACB3C02A8435AA0096312C /* Preview Assets.xcassets */, 85 | ); 86 | path = "Preview Content"; 87 | sourceTree = ""; 88 | }; 89 | /* End PBXGroup section */ 90 | 91 | /* Begin PBXNativeTarget section */ 92 | FBACB3B52A8435A90096312C /* Jamf Protect ULF Uploader */ = { 93 | isa = PBXNativeTarget; 94 | buildConfigurationList = FBACB3C52A8435AA0096312C /* Build configuration list for PBXNativeTarget "Jamf Protect ULF Uploader" */; 95 | buildPhases = ( 96 | FBACB3B22A8435A90096312C /* Sources */, 97 | FBACB3B32A8435A90096312C /* Frameworks */, 98 | FBACB3B42A8435A90096312C /* Resources */, 99 | ); 100 | buildRules = ( 101 | ); 102 | dependencies = ( 103 | ); 104 | name = "Jamf Protect ULF Uploader"; 105 | packageProductDependencies = ( 106 | FBACB3CB2A84362A0096312C /* Yams */, 107 | ); 108 | productName = "Jamf Protect ULF Uploader"; 109 | productReference = FBACB3B62A8435A90096312C /* Jamf Protect ULF Uploader.app */; 110 | productType = "com.apple.product-type.application"; 111 | }; 112 | /* End PBXNativeTarget section */ 113 | 114 | /* Begin PBXProject section */ 115 | FBACB3AE2A8435A90096312C /* Project object */ = { 116 | isa = PBXProject; 117 | attributes = { 118 | BuildIndependentTargetsInParallel = 1; 119 | LastSwiftUpdateCheck = 1430; 120 | LastUpgradeCheck = 1510; 121 | TargetAttributes = { 122 | FBACB3B52A8435A90096312C = { 123 | CreatedOnToolsVersion = 14.3.1; 124 | }; 125 | }; 126 | }; 127 | buildConfigurationList = FBACB3B12A8435A90096312C /* Build configuration list for PBXProject "Jamf Protect ULF Uploader" */; 128 | compatibilityVersion = "Xcode 14.0"; 129 | developmentRegion = en; 130 | hasScannedForEncodings = 0; 131 | knownRegions = ( 132 | en, 133 | Base, 134 | ); 135 | mainGroup = FBACB3AD2A8435A90096312C; 136 | packageReferences = ( 137 | FBACB3CA2A84362A0096312C /* XCRemoteSwiftPackageReference "Yams" */, 138 | ); 139 | productRefGroup = FBACB3B72A8435A90096312C /* Products */; 140 | projectDirPath = ""; 141 | projectRoot = ""; 142 | targets = ( 143 | FBACB3B52A8435A90096312C /* Jamf Protect ULF Uploader */, 144 | ); 145 | }; 146 | /* End PBXProject section */ 147 | 148 | /* Begin PBXResourcesBuildPhase section */ 149 | FBACB3B42A8435A90096312C /* Resources */ = { 150 | isa = PBXResourcesBuildPhase; 151 | buildActionMask = 2147483647; 152 | files = ( 153 | FBACB3C12A8435AA0096312C /* Preview Assets.xcassets in Resources */, 154 | FBACB3BE2A8435AA0096312C /* Assets.xcassets in Resources */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXResourcesBuildPhase section */ 159 | 160 | /* Begin PBXSourcesBuildPhase section */ 161 | FBACB3B22A8435A90096312C /* Sources */ = { 162 | isa = PBXSourcesBuildPhase; 163 | buildActionMask = 2147483647; 164 | files = ( 165 | FBACB3C92A8435CA0096312C /* Models.swift in Sources */, 166 | FBDA126E2A85789000A69778 /* JamfProtectAPI.swift in Sources */, 167 | FBACB3BC2A8435A90096312C /* ContentView.swift in Sources */, 168 | FBACB3BA2A8435A90096312C /* Jamf_Protect_ULF_UploaderApp.swift in Sources */, 169 | FBACB3D22A8510410096312C /* SettingsView.swift in Sources */, 170 | FBACB3CE2A850FB90096312C /* Logger.swift in Sources */, 171 | FBACB3D02A850FEB0096312C /* Keychain.swift in Sources */, 172 | ); 173 | runOnlyForDeploymentPostprocessing = 0; 174 | }; 175 | /* End PBXSourcesBuildPhase section */ 176 | 177 | /* Begin XCBuildConfiguration section */ 178 | FBACB3C32A8435AA0096312C /* Debug */ = { 179 | isa = XCBuildConfiguration; 180 | buildSettings = { 181 | ALWAYS_SEARCH_USER_PATHS = NO; 182 | CLANG_ANALYZER_NONNULL = YES; 183 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 184 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 185 | CLANG_ENABLE_MODULES = YES; 186 | CLANG_ENABLE_OBJC_ARC = YES; 187 | CLANG_ENABLE_OBJC_WEAK = YES; 188 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 189 | CLANG_WARN_BOOL_CONVERSION = YES; 190 | CLANG_WARN_COMMA = YES; 191 | CLANG_WARN_CONSTANT_CONVERSION = YES; 192 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 193 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 194 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 195 | CLANG_WARN_EMPTY_BODY = YES; 196 | CLANG_WARN_ENUM_CONVERSION = YES; 197 | CLANG_WARN_INFINITE_RECURSION = YES; 198 | CLANG_WARN_INT_CONVERSION = YES; 199 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 200 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 201 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 202 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 203 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 204 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 205 | CLANG_WARN_STRICT_PROTOTYPES = YES; 206 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 207 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 208 | CLANG_WARN_UNREACHABLE_CODE = YES; 209 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 210 | COPY_PHASE_STRIP = NO; 211 | DEAD_CODE_STRIPPING = YES; 212 | DEBUG_INFORMATION_FORMAT = dwarf; 213 | ENABLE_STRICT_OBJC_MSGSEND = YES; 214 | ENABLE_TESTABILITY = YES; 215 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 216 | GCC_C_LANGUAGE_STANDARD = gnu11; 217 | GCC_DYNAMIC_NO_PIC = NO; 218 | GCC_NO_COMMON_BLOCKS = YES; 219 | GCC_OPTIMIZATION_LEVEL = 0; 220 | GCC_PREPROCESSOR_DEFINITIONS = ( 221 | "DEBUG=1", 222 | "$(inherited)", 223 | ); 224 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 225 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 226 | GCC_WARN_UNDECLARED_SELECTOR = YES; 227 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 228 | GCC_WARN_UNUSED_FUNCTION = YES; 229 | GCC_WARN_UNUSED_VARIABLE = YES; 230 | MACOSX_DEPLOYMENT_TARGET = 13.0; 231 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 232 | MTL_FAST_MATH = YES; 233 | ONLY_ACTIVE_ARCH = YES; 234 | SDKROOT = macosx; 235 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 236 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 237 | }; 238 | name = Debug; 239 | }; 240 | FBACB3C42A8435AA0096312C /* Release */ = { 241 | isa = XCBuildConfiguration; 242 | buildSettings = { 243 | ALWAYS_SEARCH_USER_PATHS = NO; 244 | CLANG_ANALYZER_NONNULL = YES; 245 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 246 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 247 | CLANG_ENABLE_MODULES = YES; 248 | CLANG_ENABLE_OBJC_ARC = YES; 249 | CLANG_ENABLE_OBJC_WEAK = YES; 250 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 251 | CLANG_WARN_BOOL_CONVERSION = YES; 252 | CLANG_WARN_COMMA = YES; 253 | CLANG_WARN_CONSTANT_CONVERSION = YES; 254 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 255 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 256 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 257 | CLANG_WARN_EMPTY_BODY = YES; 258 | CLANG_WARN_ENUM_CONVERSION = YES; 259 | CLANG_WARN_INFINITE_RECURSION = YES; 260 | CLANG_WARN_INT_CONVERSION = YES; 261 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 262 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 263 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 264 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 265 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 266 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 267 | CLANG_WARN_STRICT_PROTOTYPES = YES; 268 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 269 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 270 | CLANG_WARN_UNREACHABLE_CODE = YES; 271 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 272 | COPY_PHASE_STRIP = NO; 273 | DEAD_CODE_STRIPPING = YES; 274 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 275 | ENABLE_NS_ASSERTIONS = NO; 276 | ENABLE_STRICT_OBJC_MSGSEND = YES; 277 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 278 | GCC_C_LANGUAGE_STANDARD = gnu11; 279 | GCC_NO_COMMON_BLOCKS = YES; 280 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 281 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 282 | GCC_WARN_UNDECLARED_SELECTOR = YES; 283 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 284 | GCC_WARN_UNUSED_FUNCTION = YES; 285 | GCC_WARN_UNUSED_VARIABLE = YES; 286 | MACOSX_DEPLOYMENT_TARGET = 13.0; 287 | MTL_ENABLE_DEBUG_INFO = NO; 288 | MTL_FAST_MATH = YES; 289 | SDKROOT = macosx; 290 | SWIFT_COMPILATION_MODE = wholemodule; 291 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 292 | }; 293 | name = Release; 294 | }; 295 | FBACB3C62A8435AA0096312C /* Debug */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 299 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 300 | CODE_SIGN_ENTITLEMENTS = "Jamf Protect ULF Uploader/Jamf_Protect_ULF_Uploader.entitlements"; 301 | CODE_SIGN_STYLE = Automatic; 302 | COMBINE_HIDPI_IMAGES = YES; 303 | CURRENT_PROJECT_VERSION = 44; 304 | DEAD_CODE_STRIPPING = YES; 305 | DEVELOPMENT_ASSET_PATHS = "\"Jamf Protect ULF Uploader/Preview Content\""; 306 | DEVELOPMENT_TEAM = VR4GB7TBDP; 307 | ENABLE_HARDENED_RUNTIME = YES; 308 | ENABLE_PREVIEWS = YES; 309 | GENERATE_INFOPLIST_FILE = YES; 310 | INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; 311 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 312 | LD_RUNPATH_SEARCH_PATHS = ( 313 | "$(inherited)", 314 | "@executable_path/../Frameworks", 315 | ); 316 | MACOSX_DEPLOYMENT_TARGET = 13.0; 317 | MARKETING_VERSION = 1.1; 318 | PRODUCT_BUNDLE_IDENTIFIER = "uk.co.mallion.jamf-protect-ulf-uploader"; 319 | PRODUCT_NAME = "$(TARGET_NAME)"; 320 | SWIFT_EMIT_LOC_STRINGS = YES; 321 | SWIFT_VERSION = 5.0; 322 | }; 323 | name = Debug; 324 | }; 325 | FBACB3C72A8435AA0096312C /* Release */ = { 326 | isa = XCBuildConfiguration; 327 | buildSettings = { 328 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 329 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 330 | CODE_SIGN_ENTITLEMENTS = "Jamf Protect ULF Uploader/Jamf_Protect_ULF_Uploader.entitlements"; 331 | CODE_SIGN_STYLE = Automatic; 332 | COMBINE_HIDPI_IMAGES = YES; 333 | CURRENT_PROJECT_VERSION = 44; 334 | DEAD_CODE_STRIPPING = YES; 335 | DEVELOPMENT_ASSET_PATHS = "\"Jamf Protect ULF Uploader/Preview Content\""; 336 | DEVELOPMENT_TEAM = VR4GB7TBDP; 337 | ENABLE_HARDENED_RUNTIME = YES; 338 | ENABLE_PREVIEWS = YES; 339 | GENERATE_INFOPLIST_FILE = YES; 340 | INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; 341 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 342 | LD_RUNPATH_SEARCH_PATHS = ( 343 | "$(inherited)", 344 | "@executable_path/../Frameworks", 345 | ); 346 | MACOSX_DEPLOYMENT_TARGET = 13.0; 347 | MARKETING_VERSION = 1.1; 348 | PRODUCT_BUNDLE_IDENTIFIER = "uk.co.mallion.jamf-protect-ulf-uploader"; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | SWIFT_EMIT_LOC_STRINGS = YES; 351 | SWIFT_VERSION = 5.0; 352 | }; 353 | name = Release; 354 | }; 355 | /* End XCBuildConfiguration section */ 356 | 357 | /* Begin XCConfigurationList section */ 358 | FBACB3B12A8435A90096312C /* Build configuration list for PBXProject "Jamf Protect ULF Uploader" */ = { 359 | isa = XCConfigurationList; 360 | buildConfigurations = ( 361 | FBACB3C32A8435AA0096312C /* Debug */, 362 | FBACB3C42A8435AA0096312C /* Release */, 363 | ); 364 | defaultConfigurationIsVisible = 0; 365 | defaultConfigurationName = Release; 366 | }; 367 | FBACB3C52A8435AA0096312C /* Build configuration list for PBXNativeTarget "Jamf Protect ULF Uploader" */ = { 368 | isa = XCConfigurationList; 369 | buildConfigurations = ( 370 | FBACB3C62A8435AA0096312C /* Debug */, 371 | FBACB3C72A8435AA0096312C /* Release */, 372 | ); 373 | defaultConfigurationIsVisible = 0; 374 | defaultConfigurationName = Release; 375 | }; 376 | /* End XCConfigurationList section */ 377 | 378 | /* Begin XCRemoteSwiftPackageReference section */ 379 | FBACB3CA2A84362A0096312C /* XCRemoteSwiftPackageReference "Yams" */ = { 380 | isa = XCRemoteSwiftPackageReference; 381 | repositoryURL = "https://github.com/jpsim/Yams.git"; 382 | requirement = { 383 | kind = upToNextMajorVersion; 384 | minimumVersion = 5.0.0; 385 | }; 386 | }; 387 | /* End XCRemoteSwiftPackageReference section */ 388 | 389 | /* Begin XCSwiftPackageProductDependency section */ 390 | FBACB3CB2A84362A0096312C /* Yams */ = { 391 | isa = XCSwiftPackageProductDependency; 392 | package = FBACB3CA2A84362A0096312C /* XCRemoteSwiftPackageReference "Yams" */; 393 | productName = Yams; 394 | }; 395 | /* End XCSwiftPackageProductDependency section */ 396 | }; 397 | rootObject = FBACB3AE2A8435A90096312C /* Project object */; 398 | } 399 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "pins" : [ 3 | { 4 | "identity" : "yams", 5 | "kind" : "remoteSourceControl", 6 | "location" : "https://github.com/jpsim/Yams.git", 7 | "state" : { 8 | "revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3", 9 | "version" : "5.0.6" 10 | } 11 | } 12 | ], 13 | "version" : 2 14 | } 15 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader.xcodeproj/project.xcworkspace/xcuserdata/richard.mallion.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader.xcodeproj/project.xcworkspace/xcuserdata/richard.mallion.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader.xcodeproj/project.xcworkspace/xcuserdata/thijs.xhaflaire.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader.xcodeproj/project.xcworkspace/xcuserdata/thijs.xhaflaire.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader.xcodeproj/xcuserdata/richard.mallion.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Jamf Protect ULF Uploader.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader.xcodeproj/xcuserdata/thijs.xhaflaire.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Jamf Protect ULF Uploader.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "icon-16.png", 5 | "idiom" : "mac", 6 | "scale" : "1x", 7 | "size" : "16x16" 8 | }, 9 | { 10 | "filename" : "icon-32 1.png", 11 | "idiom" : "mac", 12 | "scale" : "2x", 13 | "size" : "16x16" 14 | }, 15 | { 16 | "filename" : "icon-32.png", 17 | "idiom" : "mac", 18 | "scale" : "1x", 19 | "size" : "32x32" 20 | }, 21 | { 22 | "filename" : "icon-64.png", 23 | "idiom" : "mac", 24 | "scale" : "2x", 25 | "size" : "32x32" 26 | }, 27 | { 28 | "filename" : "icon-128.png", 29 | "idiom" : "mac", 30 | "scale" : "1x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "filename" : "icon-256 1.png", 35 | "idiom" : "mac", 36 | "scale" : "2x", 37 | "size" : "128x128" 38 | }, 39 | { 40 | "filename" : "icon-256.png", 41 | "idiom" : "mac", 42 | "scale" : "1x", 43 | "size" : "256x256" 44 | }, 45 | { 46 | "filename" : "icon-512 1.png", 47 | "idiom" : "mac", 48 | "scale" : "2x", 49 | "size" : "256x256" 50 | }, 51 | { 52 | "filename" : "icon-512.png", 53 | "idiom" : "mac", 54 | "scale" : "1x", 55 | "size" : "512x512" 56 | }, 57 | { 58 | "filename" : "icon-1024.png", 59 | "idiom" : "mac", 60 | "scale" : "2x", 61 | "size" : "512x512" 62 | } 63 | ], 64 | "info" : { 65 | "author" : "xcode", 66 | "version" : 1 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-1024.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-128.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-16.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-256 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-256 1.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-256.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-32 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-32 1.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-32.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-512 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-512 1.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-512.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red5coder/jamf-protect-ulf-uploader/001ab6bfa33bb261f5c6fd6b2903f307ce75e35f/Jamf Protect ULF Uploader/Assets.xcassets/AppIcon.appiconset/icon-64.png -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // Jamf Protect ULF Uploader 4 | // 5 | // Created by Richard Mallion on 09/08/2023. 6 | // 7 | 8 | import SwiftUI 9 | import Yams 10 | import os.log 11 | 12 | struct ContentView: View { 13 | @State private var protectURL = "" 14 | @State private var clientID = "" 15 | @State private var password = "" 16 | 17 | @State private var showAlert = false 18 | @State private var alertMessage = "" 19 | @State private var alertTitle = "" 20 | 21 | @State private var showActivity = false 22 | 23 | @State private var ulfilters = [ULFilter]() 24 | 25 | @State private var uploadButtonDisabled = true 26 | 27 | @State private var sortOrder = [KeyPathComparator(\ULFilter.name)] 28 | @State private var searchTerm = "" 29 | 30 | private var searchResults: [ULFilter] { 31 | if searchTerm.isEmpty { 32 | return ulfilters.filter { _ in true } 33 | } else { 34 | return ulfilters.filter { 35 | $0.name.lowercased().contains(searchTerm.lowercased()) || 36 | $0.description.lowercased().contains(searchTerm.lowercased()) || 37 | $0.tagsDiplay.lowercased().contains(searchTerm.lowercased()) 38 | } 39 | } 40 | } 41 | 42 | var body: some View { 43 | VStack { 44 | Table(searchResults, sortOrder: $sortOrder) { 45 | TableColumn("Include") { item in 46 | Toggle("", isOn: Binding( 47 | get: { return item.include }, 48 | set: { 49 | if let index = ulfilters.firstIndex(where: { $0.id == item.id }) { 50 | ulfilters[index].include = $0 51 | } 52 | var disableupload = true 53 | ulfilters.forEach { 54 | if $0.include { 55 | disableupload = false 56 | } 57 | uploadButtonDisabled = disableupload 58 | } 59 | } 60 | )) 61 | } 62 | .width(45) 63 | TableColumn("Filter Name") { logfilter in 64 | Text(logfilter.name) 65 | .lineLimit(nil) 66 | .fixedSize(horizontal: false, vertical: true) 67 | } 68 | .width(ideal: 200) 69 | TableColumn("Description") { logfilter in 70 | Text(logfilter.description) 71 | .lineLimit(nil) // Allow multiple lines 72 | .fixedSize(horizontal: false, vertical: true) 73 | } 74 | .width(ideal: 650) 75 | TableColumn("Tags") { logfilter in 76 | Text(logfilter.tagsDiplay) 77 | .lineLimit(nil) // Allow multiple lines 78 | .fixedSize(horizontal: false, vertical: true) 79 | } 80 | } 81 | .onChange(of: sortOrder) { newOrder in 82 | ulfilters.sort(using: newOrder) 83 | } 84 | .searchable(text: $searchTerm, prompt: "Search in name, description or tag") 85 | HStack { 86 | Button("Fetch Filters") { 87 | Task { 88 | if let unifiedLogsURL = await getBranch(branchname: "unified_log_filters") { 89 | var branchYamlFiles = await getBranchContent(branchURL: unifiedLogsURL, type: "blob") 90 | let branchSubDirectories = await getBranchContent(branchURL: unifiedLogsURL, type: "tree") 91 | if let branchSubDirectories = branchSubDirectories { 92 | for directory in branchSubDirectories { 93 | let extraYAML = await getBranchContent(branchURL: directory, type: "blob") 94 | branchYamlFiles?.append(contentsOf: extraYAML ?? []) 95 | } 96 | } 97 | if let branchYamlFiles = branchYamlFiles { 98 | if let fetchedulfilters = try? await getYamlFiles(fileURLS: branchYamlFiles) { 99 | ulfilters = fetchedulfilters.sorted { $0.name < $1.name } 100 | Logger.github.info("Found \(fetchedulfilters.count, privacy: .public) filters") 101 | } 102 | } else { 103 | Logger.github.error("No filters found") 104 | } 105 | } 106 | } 107 | } 108 | .padding(.trailing) 109 | Button("Upload") { 110 | Task { 111 | await uploadFilters() 112 | } 113 | } 114 | .disabled(uploadButtonDisabled) 115 | ProgressView() 116 | .scaleEffect(0.5) 117 | .opacity(showActivity ? 1 : 0) 118 | } 119 | } 120 | .padding() 121 | .alert(isPresented: self.$showAlert, 122 | content: { 123 | self.showCustomAlert() 124 | }) 125 | .task { 126 | let defaults = UserDefaults.standard 127 | protectURL = defaults.string(forKey: "protectURL") ?? "" 128 | if protectURL.isEmpty { 129 | NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil) 130 | } 131 | } 132 | } 133 | 134 | func showCustomAlert() -> Alert { 135 | return Alert( 136 | title: Text(alertTitle), 137 | message: Text(alertMessage), 138 | dismissButton: .default(Text("OK")) 139 | ) 140 | } 141 | 142 | 143 | // MARK: - UploadFilters 144 | func uploadFilters() async { 145 | Logger.protect.info("About to upload selected filters") 146 | showActivity = true 147 | var succesfullUploadCount = 0 148 | for filter in ulfilters { 149 | if filter.include { 150 | if let responseCode = await uploadFilter(filter: filter), responseCode == 200 { 151 | succesfullUploadCount = succesfullUploadCount + 1 152 | } 153 | } 154 | } 155 | Logger.protect.info("\(succesfullUploadCount, privacy: .public) filters where selected for upload") 156 | showActivity = false 157 | alertMessage = "\(succesfullUploadCount) Unified Logging Filters Uploaded." 158 | alertTitle = "Upload Results" 159 | showAlert = true 160 | 161 | } 162 | 163 | func uploadFilter(filter: ULFilter) async -> Int? { 164 | Logger.protect.info("About to upload filter \(filter.name, privacy: .public)") 165 | let defaults = UserDefaults.standard 166 | clientID = defaults.string(forKey: "clientID") ?? "" 167 | protectURL = defaults.string(forKey: "protectURL") ?? "" 168 | let credentialsArray = Keychain().retrieve(service: "uk.co.mallion.jamf-protect-ulf-uploader") 169 | if credentialsArray.count == 2 { 170 | password = credentialsArray[1] 171 | } 172 | let jamfProtect = JamfProtectAPI() 173 | let (authToken, httpRespoonse) = await jamfProtect.getToken(protectURL: protectURL, clientID: clientID, password: password) 174 | if let httpResponse = httpRespoonse { 175 | Logger.protect.info("HTTP Response \(httpResponse) to authenticating to \(protectURL , privacy: .public)") 176 | } 177 | guard let authToken else { 178 | Logger.protect.error("Could not authenticate to \(protectURL , privacy: .public)") 179 | alertMessage = "Could not authenticate. Please check the url and authentication details" 180 | alertTitle = "Authentication Error" 181 | showAlert = true 182 | return nil 183 | } 184 | Logger.protect.info("Sucessfully authenticated to \(protectURL , privacy: .public)") 185 | let responseCode = await jamfProtect.createFilter(protectURL: protectURL, access_token: authToken.access_token, ulfilter: filter) 186 | return responseCode 187 | } 188 | 189 | // MARK: - Github 190 | func getBranch(branchname: String) async -> String? { 191 | Logger.github.info("About to get the contents of the main branch") 192 | guard var branchesEndPoint = URLComponents(string: "https://api.github.com") else { 193 | return nil 194 | } 195 | branchesEndPoint.path="/repos/jamf/jamfprotect/contents" 196 | let queryItems = [URLQueryItem(name: "ref", value: "main")] 197 | branchesEndPoint.queryItems = queryItems 198 | guard let url = branchesEndPoint.url else { return nil } 199 | var branchRequest = URLRequest(url: url) 200 | branchRequest.httpMethod = "GET" 201 | branchRequest.setValue("application/vnd.github.v3+json", forHTTPHeaderField: "Accept") 202 | guard let (data, response) = try? await URLSession.shared.data(for: branchRequest) else { 203 | Logger.github.error("Failed to connect to main branch") 204 | return nil 205 | } 206 | 207 | if let httpResponse = response as? HTTPURLResponse { 208 | Logger.github.info("HTTP Response \(httpResponse.statusCode) to connecting to https://api.github.com/repos/jamf/jamfprotect/contents?ref=main: \(httpResponse.statusCode , privacy: .public)") 209 | } 210 | do { 211 | let contents = try JSONDecoder().decode(GitMainBranchContents.self, from: data) 212 | for content in contents { 213 | if content.name.lowercased() == "unified_log_filters" && content.type.lowercased() == "dir" { 214 | Logger.github.info("Found unified_log_filters \(content.git_url , privacy: .public)") 215 | return content.git_url 216 | } 217 | } 218 | Logger.github.error("No content was retrieved from the main branch") 219 | return nil 220 | 221 | } catch { 222 | Logger.github.error("Could not decode contents from the main brnch, \(error.localizedDescription)") 223 | return nil 224 | } 225 | } 226 | 227 | func getBranchContent(branchURL: String , type: String) async -> [String]? { 228 | guard let url = URL(string: branchURL) else { return nil} 229 | var branchRequest = URLRequest(url: url) 230 | branchRequest.httpMethod = "GET" 231 | guard let (data, response) = try? await URLSession.shared.data(for: branchRequest) 232 | else { 233 | Logger.github.error("Failed to retrieve branch dertails for \(branchURL , privacy: .public)") 234 | return nil 235 | } 236 | do { 237 | let unifiedLoggingBranch = try JSONDecoder().decode(UnifiedLoggingBranch.self, from: data) 238 | var files = [String]() 239 | for file in unifiedLoggingBranch.tree { 240 | if file.path.lowercased().hasSuffix(".yaml") && file.type.lowercased() == type { 241 | files.append(file.url) 242 | } else if file.type.lowercased() == type && type == "tree"{ 243 | files.append(file.url) 244 | } 245 | } 246 | if files.count > 0 { 247 | return files 248 | } 249 | return nil 250 | } catch _ { 251 | Logger.github.error("Could not decode content for \(branchURL, privacy: .public)") 252 | return nil 253 | } 254 | } 255 | 256 | func getYamlFiles (fileURLS: [String]) async throws-> [ULFilter] { 257 | Logger.github.info("About to retrive the unified log filters") 258 | var ulfilters = [ULFilter]() 259 | try await withThrowingTaskGroup(of: (ULFilter?).self) { group in 260 | for file in fileURLS { 261 | group.addTask { 262 | return (try await getYamlFile(fileURL: file)) 263 | } 264 | } 265 | for try await (ulfilter) in group { 266 | if let ulfilter = ulfilter { 267 | ulfilters.append(ulfilter) 268 | } 269 | } 270 | } 271 | return ulfilters 272 | } 273 | 274 | func getYamlFile (fileURL: String) async throws -> ULFilter? { 275 | Logger.github.info("Fetching filter \(fileURL , privacy: .public)") 276 | guard let url = URL(string: fileURL) else { throw ThumbnailError.invalidURL } 277 | let result: (data: Data, response: URLResponse) = try await URLSession.shared.data(from: url) 278 | if let httpResponse = result.response as? HTTPURLResponse { 279 | Logger.github.info("HTTP Response \(httpResponse.statusCode , privacy: .public) to connecting to \(fileURL , privacy: .public)") 280 | } 281 | let decoder = YAMLDecoder() 282 | let encodedString = String(decoding: result.data, as: UTF8.self) 283 | do { 284 | let encodedulfilter = try decoder.decode(EncodedULFilter.self, from: encodedString, userInfo: [:]) 285 | let decodedContents = try Data.decodeUrlSafeBase64(encodedulfilter.content) 286 | let decodedContentsString = String(decoding: decodedContents, as: UTF8.self) 287 | let decodedContentsStringQuotes = handleQuotes(string: decodedContentsString) 288 | do { 289 | let ulfilter = try decoder.decode(ULFilter.self, from: decodedContentsStringQuotes, userInfo: [:]) 290 | Logger.github.info("Successfully retrieved filter \(ulfilter.name,privacy: .public)") 291 | return ulfilter 292 | } catch { 293 | Logger.github.error("Failed to decode \(fileURL,privacy: .public) , \(error.localizedDescription, privacy: .public)") 294 | } 295 | return nil 296 | } catch { 297 | Logger.github.error("Failed to decode \(error.localizedDescription, privacy: .public)") 298 | } 299 | return nil 300 | } 301 | 302 | 303 | func handleQuotes(string: String) -> String { 304 | let array = string.components(separatedBy: "predicate:") 305 | let subsection = array[1].components(separatedBy: "tags:") 306 | var predicate = subsection[0] 307 | predicate = predicate.replacingOccurrences(of: "\"", with: "'") 308 | if let range = predicate.range(of: String("'")) { 309 | predicate.replaceSubrange(range, with: String("\"")) 310 | } 311 | if let range = predicate.range(of: String("'"), options: .backwards) { 312 | predicate.replaceSubrange(range, with: String("\"")) 313 | } 314 | var finalString = array[0] 315 | finalString = finalString + "predicate:" 316 | finalString = finalString + predicate 317 | finalString = finalString + "tags:" 318 | finalString = finalString + subsection[1] 319 | return finalString 320 | } 321 | 322 | 323 | 324 | enum ThumbnailError: Error { 325 | case invalidURL 326 | case missingData 327 | } 328 | 329 | } 330 | 331 | 332 | struct ContentView_Previews: PreviewProvider { 333 | static var previews: some View { 334 | ContentView() 335 | } 336 | } 337 | 338 | 339 | 340 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/JamfProtectAPI.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JamfProtectAPI.swift 3 | // Jamf Protect ULF Uploader 4 | // 5 | // Created by Richard Mallion on 10/08/2023. 6 | // 7 | 8 | import Foundation 9 | import os.log 10 | 11 | // MARK: - Jamf Protect Auth Model 12 | struct JamfAuth: Decodable { 13 | let access_token: String 14 | let expires_in: Int 15 | let token_type: String 16 | } 17 | 18 | 19 | struct JamfProtectAPI { 20 | 21 | func createFilter(protectURL: String, access_token: String, ulfilter: ULFilter) async -> Int? { 22 | Logger.protect.info("About to upload filter \(ulfilter.name, privacy: .public).") 23 | guard var jamfAuthEndpoint = URLComponents(string: protectURL) else { 24 | Logger.protect.error("Protect URL seems invalid.") 25 | return nil 26 | } 27 | jamfAuthEndpoint.path="/graphql" 28 | guard let url = jamfAuthEndpoint.url else { 29 | Logger.protect.error("Protect URL seems invalid.") 30 | return nil 31 | } 32 | var request = URLRequest(url: url) 33 | request.httpMethod = "POST" 34 | request.setValue("\(access_token)", forHTTPHeaderField: "Authorization") 35 | var predicate = ulfilter.predicate 36 | predicate = predicate.replacingOccurrences(of: "'", with: "\\\"") 37 | var enabled = "false" 38 | if ulfilter.enabled { 39 | enabled = "true" 40 | } 41 | var tags = "" 42 | for tag in ulfilter.tags { 43 | tags = tags + "\"\(tag)\"," 44 | } 45 | let createFilter = """ 46 | mutation createFilter { 47 | createUnifiedLoggingFilter( 48 | input: { 49 | name: "\(ulfilter.name)" 50 | description: "\(ulfilter.description)" 51 | filter: "\(predicate)" 52 | enabled: \(enabled) 53 | tags: [\(tags)] 54 | } 55 | ) { 56 | uuid 57 | name 58 | created 59 | updated 60 | filter 61 | tags 62 | enabled 63 | } 64 | } 65 | """ 66 | let json: [String: Any] = ["query": createFilter ] 67 | let jsonData = try? JSONSerialization.data(withJSONObject: json) 68 | if let jsonData = jsonData { 69 | request.httpBody = jsonData 70 | } 71 | guard let (data, response) = try? await URLSession.shared.data(for: request) 72 | else { 73 | Logger.protect.error("Could not initiate connection to \(url, privacy: .public).") 74 | return nil 75 | } 76 | if let httpResponse = response as? HTTPURLResponse { 77 | Logger.protect.info("HTTP Response \(httpResponse.statusCode, privacy: .public) to uplaoding filter \(ulfilter.name , privacy: .public)") 78 | } 79 | 80 | let httpResponse = response as? HTTPURLResponse 81 | return httpResponse?.statusCode 82 | } 83 | 84 | func getToken(protectURL: String , clientID: String, password: String) async -> (JamfAuth?,Int?) { 85 | Logger.protect.info("Fetching authentication token.") 86 | guard var jamfAuthEndpoint = URLComponents(string: protectURL) else { 87 | Logger.protect.error("Protect URL seems invalid.") 88 | return (nil, nil) 89 | } 90 | jamfAuthEndpoint.path="/token" 91 | guard let url = jamfAuthEndpoint.url else { 92 | Logger.protect.error("Protect URL seems invalid.") 93 | return (nil, nil) 94 | } 95 | var authRequest = URLRequest(url: url) 96 | authRequest.httpMethod = "POST" 97 | let json: [String: Any] = ["client_id": clientID, 98 | "password": password] 99 | let jsonData = try? JSONSerialization.data(withJSONObject: json) 100 | if let jsonData = jsonData { 101 | authRequest.httpBody = jsonData 102 | } 103 | guard let (data, response) = try? await URLSession.shared.data(for: authRequest) 104 | else { 105 | Logger.protect.error("Could not initiate connection to \(url, privacy: .public).") 106 | return (nil, nil) 107 | } 108 | let httpResponse = response as? HTTPURLResponse 109 | do { 110 | let protectToken = try JSONDecoder().decode(JamfAuth.self, from: data) 111 | Logger.protect.info("Authentication token decoded.") 112 | return (protectToken, httpResponse?.statusCode) 113 | } catch _ { 114 | Logger.protect.error("Could not decode authentication token.") 115 | return (nil, httpResponse?.statusCode) 116 | } 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Jamf_Protect_ULF_Uploader.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | com.apple.security.network.client 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Jamf_Protect_ULF_UploaderApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Jamf_Protect_ULF_UploaderApp.swift 3 | // Jamf Protect ULF Uploader 4 | // 5 | // Created by Richard Mallion on 09/08/2023. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct Jamf_Protect_ULF_UploaderApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | Settings { 17 | SettingsView() 18 | .frame( 19 | minWidth: 500, maxWidth: 500, 20 | minHeight: 175, maxHeight: 175) 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Keychain.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Keychain.swift 3 | // Jamf Protect ULF Uploader 4 | // 5 | // Created by Richard Mallion on 10/08/2023. 6 | // 7 | 8 | import Foundation 9 | import Security 10 | 11 | let kSecAttrAccountString = NSString(format: kSecAttrAccount) 12 | let kSecValueDataString = NSString(format: kSecValueData) 13 | let kSecClassGenericPasswordString = NSString(format: kSecClassGenericPassword) 14 | 15 | class Keychain { 16 | 17 | func save(service: String, account: String, data: String) { 18 | 19 | if let password = data.data(using: String.Encoding.utf8) { 20 | var keychainQuery: [String: Any] = [kSecClass as String: kSecClassGenericPassword, 21 | kSecAttrService as String: service, 22 | kSecAttrAccount as String: account, 23 | kSecValueData as String: password] 24 | 25 | // see if credentials already exist for server 26 | let accountCheck = retrieve(service: service) 27 | if accountCheck.count == 0 { 28 | // try to add new credentials, if account exists we'll try updating it 29 | let addStatus = SecItemAdd(keychainQuery as CFDictionary, nil) 30 | if (addStatus != errSecSuccess) { 31 | if let addErr = SecCopyErrorMessageString(addStatus, nil) { 32 | print("[addStatus] Write failed for new credentials: \(addErr)") 33 | } 34 | } 35 | } else { 36 | // credentials already exist, try to update 37 | keychainQuery = [kSecClass as String: kSecClassGenericPasswordString, 38 | kSecAttrService as String: service, 39 | kSecMatchLimit as String: kSecMatchLimitOne, 40 | kSecReturnAttributes as String: true] 41 | let updateStatus = SecItemUpdate(keychainQuery as CFDictionary, [kSecAttrAccountString:account,kSecValueDataString:password] as CFDictionary) 42 | if (updateStatus != errSecSuccess) { 43 | if let updateErr = SecCopyErrorMessageString(updateStatus, nil) { 44 | print("[updateStatus] Update failed for existing credentials: \(updateErr)") 45 | } 46 | } 47 | } 48 | } 49 | } 50 | 51 | func retrieve(service: String) -> [String] { 52 | 53 | var storedCreds = [String]() 54 | 55 | let keychainQuery: [String: Any] = [kSecClass as String: kSecClassGenericPasswordString, 56 | kSecAttrService as String: service, 57 | kSecMatchLimit as String: kSecMatchLimitOne, 58 | kSecReturnAttributes as String: true, 59 | kSecReturnData as String: true] 60 | var item: CFTypeRef? 61 | let status = SecItemCopyMatching(keychainQuery as CFDictionary, &item) 62 | guard status != errSecItemNotFound else { return [] } 63 | guard status == errSecSuccess else { return [] } 64 | 65 | guard let existingItem = item as? [String : Any], 66 | let passwordData = existingItem[kSecValueData as String] as? Data, 67 | let account = existingItem[kSecAttrAccount as String] as? String, 68 | let password = String(data: passwordData, encoding: String.Encoding.utf8) 69 | else { 70 | return [] 71 | } 72 | storedCreds.append(account) 73 | storedCreds.append(password) 74 | return storedCreds 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Logger.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Logger.swift 3 | // Jamf Protect ULF Uploader 4 | // 5 | // Created by Richard Mallion on 10/08/2023. 6 | // 7 | 8 | import Foundation 9 | import os.log 10 | 11 | extension Logger { 12 | private static var subsystem = Bundle.main.bundleIdentifier! 13 | 14 | //Categories 15 | static let protect = Logger(subsystem: subsystem, category: "protect") 16 | static let github = Logger(subsystem: subsystem, category: "github") 17 | } 18 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Models.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Models.swift 3 | // Jamf Protect ULF Uploader 4 | // 5 | // Created by Richard Mallion on 09/08/2023. 6 | // 7 | 8 | import Foundation 9 | 10 | 11 | // MARK: - GitBranch 12 | struct GitMainBranch : Codable { 13 | let name: String 14 | let git_url: String 15 | let type: String 16 | } 17 | typealias GitMainBranchContents = [GitMainBranch] 18 | 19 | 20 | // MARK: - RawULFilter 21 | struct EncodedULFilter : Codable { 22 | let url: String 23 | let content: String 24 | let encoding: String 25 | enum CodingKeys: String, CodingKey { 26 | case url 27 | case content 28 | case encoding 29 | } 30 | } 31 | 32 | // MARK: - ULFilter 33 | struct ULFilter : Codable, Identifiable { 34 | let id = UUID() 35 | var include = false 36 | let name: String 37 | let description: String 38 | let predicate: String 39 | let tags: [String] 40 | var tagsDiplay: String { return tags.joined(separator: ", ")} 41 | let enabled: Bool 42 | enum CodingKeys: String, CodingKey { 43 | case name,description,predicate 44 | case tags 45 | case enabled 46 | } 47 | } 48 | 49 | // MARK: - UnifiedLoggingBranch 50 | struct UnifiedLoggingBranch: Codable { 51 | let tree: [File] 52 | enum CodingKeys: String, CodingKey { 53 | case tree 54 | } 55 | } 56 | 57 | // MARK: - File 58 | struct File: Codable { 59 | let path, url: String 60 | let type: String 61 | enum CodingKeys: String, CodingKey { 62 | case path, url 63 | case type 64 | } 65 | } 66 | 67 | 68 | extension Data { 69 | static func decodeUrlSafeBase64(_ value: String) throws -> Data { 70 | var stringtoDecode: String = value.replacingOccurrences(of: "-", with: "+") 71 | stringtoDecode = stringtoDecode.replacingOccurrences(of: "_", with: "/") 72 | // switch (stringtoDecode.utf8.count % 4) { 73 | // case 2: 74 | // stringtoDecode += "==" 75 | // case 3: 76 | // stringtoDecode += "=" 77 | // default: 78 | // break 79 | // } 80 | guard let data = Data(base64Encoded: stringtoDecode, options: [.ignoreUnknownCharacters]) else { 81 | throw NSError(domain: "decodeUrlSafeBase64", code: 1, 82 | userInfo: [NSLocalizedDescriptionKey: "Can't decode base64 string"]) 83 | } 84 | return data 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Jamf Protect ULF Uploader/SettingsView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SettingsView.swift 3 | // Jamf Protect ULF Uploader 4 | // 5 | // Created by Richard Mallion on 10/08/2023. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct SettingsView: View { 11 | @AppStorage("protectURL") var protectURL: String = "" 12 | @AppStorage("clientID") var clientID: String = "" 13 | 14 | @State private var verifyButtonDisabled = true 15 | @State private var password = "" 16 | 17 | @State private var showAlert = false 18 | @State private var alertMessage = "" 19 | @State private var alertTitle = "" 20 | 21 | var body: some View { 22 | VStack(alignment: .trailing){ 23 | HStack(alignment: .center) { 24 | VStack(alignment: .trailing, spacing: 12.0) { 25 | Text("Jamf Protect URL:") 26 | Text("Client ID:") 27 | Text("Password:") 28 | } 29 | VStack(alignment: .leading, spacing: 7.0) { 30 | TextField("https://your-jamf-protect-server.com" , text: $protectURL) 31 | .textFieldStyle(.roundedBorder) 32 | .onChange(of: protectURL) { newValue in 33 | if protectURL.isEmpty { 34 | verifyButtonDisabled = true 35 | } else { 36 | verifyButtonDisabled = false 37 | } 38 | } 39 | TextField("Your Jamf Protect Client ID" , text: $clientID) 40 | .textFieldStyle(.roundedBorder) 41 | .onChange(of: clientID) { newValue in 42 | if clientID.isEmpty { 43 | verifyButtonDisabled = true 44 | } else { 45 | verifyButtonDisabled = false 46 | } 47 | } 48 | SecureField("Your Jamf Protect API Password" , text: $password) 49 | .textFieldStyle(.roundedBorder) 50 | .onChange(of: password) { newValue in 51 | savePasswordToKeychain() 52 | if password.isEmpty { 53 | verifyButtonDisabled = true 54 | } else { 55 | verifyButtonDisabled = false 56 | } 57 | } 58 | } 59 | } 60 | .padding() 61 | HStack(alignment: .center) { 62 | Spacer() 63 | Button("Verify") { 64 | Task { 65 | await verifyCredentials() 66 | } 67 | } 68 | .disabled(verifyButtonDisabled) 69 | Spacer() 70 | } 71 | .alert(isPresented: self.$showAlert, 72 | content: { 73 | self.showCustomAlert() 74 | }) 75 | } 76 | .onAppear { 77 | let defaults = UserDefaults.standard 78 | clientID = defaults.string(forKey: "clientID") ?? "" 79 | protectURL = defaults.string(forKey: "protectURL") ?? "" 80 | let credentialsArray = Keychain().retrieve(service: "uk.co.mallion.jamf-protect-ulf-uploader") 81 | if credentialsArray.count == 2 { 82 | password = credentialsArray[1] 83 | } 84 | if clientID.isEmpty || protectURL.isEmpty || password.isEmpty { 85 | verifyButtonDisabled = true 86 | } else { 87 | verifyButtonDisabled = false 88 | } 89 | } 90 | } 91 | 92 | func showCustomAlert() -> Alert { 93 | return Alert( 94 | title: Text(alertTitle), 95 | message: Text(alertMessage), 96 | dismissButton: .default(Text("OK")) 97 | ) 98 | } 99 | 100 | func verifyCredentials() async { 101 | let jamfProtect = JamfProtectAPI() 102 | let (authToken, httpRespoonse) = await jamfProtect.getToken(protectURL: protectURL, clientID: clientID, password: password) 103 | if let httpRespoonse = httpRespoonse, httpRespoonse == 200 { 104 | alertTitle = "Authentication" 105 | alertMessage = "Successfully Authenticated." 106 | } else { 107 | alertTitle = "Authentication" 108 | alertMessage = "Failed to Authenticate." 109 | } 110 | showAlert = true 111 | } 112 | 113 | func savePasswordToKeychain() { 114 | DispatchQueue.global(qos: .background).async { 115 | Keychain().save(service: "uk.co.mallion.jamf-protect-ulf-uploader", account: "apiclient", data: password) 116 | } 117 | } 118 | } 119 | 120 | struct SettingsView_Previews: PreviewProvider { 121 | static var previews: some View { 122 | SettingsView() 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Jamf Protect Unified Logging Filter Uploader 2 | 3 | The "Jamf Protect Unified Logging Filter Uploader" is a macOS app that allows you to batch upload Unified Logging Filters from the [Jamf Protect Repo](https://github.com/jamf/jamfprotect/tree/main/unified_log_filters) to a Jamf Protect tenant. 4 | 5 | ### Requirements 6 | 7 | - A Mac running macOS Ventura (13.0) or higher 8 | - A Jamf Protect Tenant 9 | - A Jamf Protect API client needs to be created with the following permissions. 10 | - Read and Write for Unified Logging 11 | 12 | ### Usage 13 | The app will require the credentials to access your Jamf Protect Tenant. This includes: 14 | - Your Jamf Protect URL 15 | - The Client ID for the API Client you created 16 | - The password for the API client you created 17 | 18 | Click the "Fetch Filters" button, this will retrieve the available filters. 19 | 20 | Select the ones you wish to upload by selecting the checkbox by each one. 21 | 22 | Click Upload 23 | 24 | The app does log to Unified Logging. You can view the logs like this: 25 | 26 | `log stream --predicate 'subsystem == "uk.co.mallion.jamf-protect-ulf-uploader"' --level info` 27 | 28 | mainscreen 29 | 30 | 31 | --------------------------------------------------------------------------------