diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2487277..140414b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,8 @@ name: Build on: - [push] + push: + pull_request_target: + types: [labeled] jobs: build: name: Build and Test @@ -26,7 +28,7 @@ jobs: name: artifacts path: target/*.jar - name: Create Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: prerelease: true diff --git a/.github/workflows/dependency-check.yml b/.github/workflows/dependency-check.yml index c0b2327..1bacff2 100644 --- a/.github/workflows/dependency-check.yml +++ b/.github/workflows/dependency-check.yml @@ -10,54 +10,11 @@ on: jobs: check-dependencies: - name: Check dependencies - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - with: - show-progress: false - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - cache: 'maven' - - name: Cache NVD DB - uses: actions/cache@v4 - with: - path: ~/.m2/repository/org/owasp/dependency-check-data/ - key: dependency-check-${{ github.run_id }} - restore-keys: | - dependency-check - env: - SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5 - - name: Run org.owasp:dependency-check plugin - id: dependency-check - continue-on-error: true - run: mvn -B validate -Pdependency-check - env: - NVD_API_KEY: ${{ secrets.NVD_API_KEY }} - - name: Upload report on failure - if: steps.dependency-check.outcome == 'failure' - uses: actions/upload-artifact@v4 - with: - name: dependency-check-report - path: target/dependency-check-report.html - if-no-files-found: error - - name: Slack Notification on regular check - if: github.event_name == 'schedule' && steps.dependency-check.outcome == 'failure' - uses: rtCamp/action-slack-notify@v2 - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_USERNAME: 'Cryptobot' - SLACK_ICON: false - SLACK_ICON_EMOJI: ':bot:' - SLACK_CHANNEL: 'cryptomator-desktop' - SLACK_TITLE: "Vulnerabilities in ${{ github.event.repository.name }} detected." - SLACK_MESSAGE: "Download the for more details." - SLACK_FOOTER: false - MSG_MINIMAL: true - - name: Failing workflow on release branch - if: github.event_name == 'push' && steps.dependency-check.outcome == 'failure' - shell: bash - run: exit 1 + uses: skymatic/workflows/.github/workflows/run-dependency-check.yml@v1 + with: + runner-os: 'macos-latest' + java-distribution: 'temurin' + java-version: 21 + secrets: + nvd-api-key: ${{ secrets.NVD_API_KEY }} + slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3bdc7f8..cb18016 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.cryptomator integrations-mac - 1.2.3 + 1.2.4 Cryptomator Integrations for macOS Provides optional macOS services used by Cryptomator @@ -30,16 +30,16 @@ 17 - 1.3.0 - 2.0.11 + 1.3.1 + 2.0.13 - 5.10.1 - 5.10.0 + 5.10.2 + 5.12.0 - 9.0.9 - 1.6.13 + 9.2.0 + 1.6.14 @@ -104,7 +104,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.1 + 3.13.0 -h @@ -116,7 +116,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.1 + 3.5.0 check-preconditions @@ -145,7 +145,7 @@ org.codehaus.mojo exec-maven-plugin - 3.1.1 + 3.3.0 @@ -203,7 +203,7 @@ maven-source-plugin - 3.3.0 + 3.3.1 attach-sources @@ -215,7 +215,7 @@ maven-javadoc-plugin - 3.6.3 + 3.7.0 attach-javadocs @@ -307,7 +307,7 @@ maven-gpg-plugin - 3.1.0 + 3.2.4 sign-artifacts @@ -368,7 +368,7 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.1 + 3.1.2 diff --git a/src/main/native/Integrations.xcodeproj/project.pbxproj b/src/main/native/Integrations.xcodeproj/project.pbxproj index 32103e4..a1c46cb 100644 --- a/src/main/native/Integrations.xcodeproj/project.pbxproj +++ b/src/main/native/Integrations.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 74BEF1852C0384FB006731AC /* SKYLaunchService.m in Sources */ = {isa = PBXBuildFile; fileRef = 74BEF1842C0384FB006731AC /* SKYLaunchService.m */; }; + 74BEF1862C0384FB006731AC /* SKYLaunchService.h in Headers */ = {isa = PBXBuildFile; fileRef = 74BEF1832C0384FB006731AC /* SKYLaunchService.h */; }; 74CF2E7B254C295A006266D6 /* org_cryptomator_macos_autostart_MacLaunchServices_Native.m in Sources */ = {isa = PBXBuildFile; fileRef = 74CF2E7A254C295A006266D6 /* org_cryptomator_macos_autostart_MacLaunchServices_Native.m */; }; 9E0819C91D75CABC000C89E6 /* org_cryptomator_macos_keychain_MacKeychain_Native.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E0819C71D75CABC000C89E6 /* org_cryptomator_macos_keychain_MacKeychain_Native.m */; }; 9E21340025542735006EA872 /* org_cryptomator_macos_uiappearance_AppAppearance_Native.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E2133FF25542735006EA872 /* org_cryptomator_macos_uiappearance_AppAppearance_Native.m */; }; @@ -19,6 +21,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 74BEF1832C0384FB006731AC /* SKYLaunchService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SKYLaunchService.h; sourceTree = ""; }; + 74BEF1842C0384FB006731AC /* SKYLaunchService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SKYLaunchService.m; sourceTree = ""; }; 74CF2E7A254C295A006266D6 /* org_cryptomator_macos_autostart_MacLaunchServices_Native.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = org_cryptomator_macos_autostart_MacLaunchServices_Native.m; sourceTree = ""; }; 9E0819B71D748ECC000C89E6 /* libIntegrations.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libIntegrations.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 9E0819C71D75CABC000C89E6 /* org_cryptomator_macos_keychain_MacKeychain_Native.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = org_cryptomator_macos_keychain_MacKeychain_Native.m; sourceTree = ""; }; @@ -54,6 +58,8 @@ 9E21341025542ECE006EA872 /* SKYAppearanceNotifier.m */, 9E213409255429CA006EA872 /* SKYAppearanceObserver.h */, 9E21340A255429CA006EA872 /* SKYAppearanceObserver.m */, + 74BEF1832C0384FB006731AC /* SKYLaunchService.h */, + 74BEF1842C0384FB006731AC /* SKYLaunchService.m */, 9E0819B81D748ECC000C89E6 /* Products */, ); sourceTree = ""; @@ -74,6 +80,7 @@ buildActionMask = 2147483647; files = ( 9E21341125542ECE006EA872 /* SKYAppearanceNotifier.h in Headers */, + 74BEF1862C0384FB006731AC /* SKYLaunchService.h in Headers */, 9E21340B255429CA006EA872 /* SKYAppearanceObserver.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -135,6 +142,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 74BEF1852C0384FB006731AC /* SKYLaunchService.m in Sources */, 9EACB1B425557865000F3214 /* org_cryptomator_macos_tray_ActivationPolicy_Native.m in Sources */, 74CF2E7B254C295A006266D6 /* org_cryptomator_macos_autostart_MacLaunchServices_Native.m in Sources */, 9E21340C255429CA006EA872 /* SKYAppearanceObserver.m in Sources */, diff --git a/src/main/native/SKYLaunchService.h b/src/main/native/SKYLaunchService.h new file mode 100644 index 0000000..bffb7e0 --- /dev/null +++ b/src/main/native/SKYLaunchService.h @@ -0,0 +1,17 @@ +// +// SKYLaunchService.h +// Integrations +// +// Created by Tobias Hagemann on 26.05.24. +// Copyright © 2024 Cryptomator. All rights reserved. +// + +#import + +@interface SKYLaunchService : NSObject + ++ (BOOL)isLoginItemEnabled; ++ (BOOL)enableLoginItem; ++ (BOOL)disableLoginItem; + +@end diff --git a/src/main/native/SKYLaunchService.m b/src/main/native/SKYLaunchService.m new file mode 100644 index 0000000..a2fb2f2 --- /dev/null +++ b/src/main/native/SKYLaunchService.m @@ -0,0 +1,128 @@ +// +// SKYLaunchService.m +// Integrations +// +// Created by Tobias Hagemann on 26.05.24. +// Copyright © 2024 Cryptomator. All rights reserved. +// + +#import "SKYLaunchService.h" +#import + +@implementation SKYLaunchService + ++ (BOOL)isLoginItemEnabled { + if (@available(macOS 13, *)) { + if (SMAppService.mainAppService.status == SMAppServiceStatusEnabled) { + return YES; + } else if ([self isLegacyLoginItemEnabled]) { + // migrate legacy login item + [self disableLegacyLoginItem]; + return [self enableLoginItem]; + } else { + return NO; + } + } else { // macOS < 13 + return [self isLegacyLoginItemEnabled]; + } +} + ++ (BOOL)enableLoginItem { + if (@available(macOS 13, *)) { + NSError *error; + if ([SMAppService.mainAppService registerAndReturnError:&error]) { + return YES; + } else { + NSLog(@"Failed to register login item: %@", error.localizedDescription); + return NO; + } + } else { // macOS < 13 + return [self enableLegacyLoginItem]; + } +} + ++ (BOOL)disableLoginItem { + if (@available(macOS 13, *)) { + NSError *error; + if ([SMAppService.mainAppService unregisterAndReturnError:&error]) { + return YES; + } else { + NSLog(@"Failed to unregister login item: %@", error.localizedDescription); + return NO; + } + } else { // macOS < 13 + return [self disableLegacyLoginItem]; + } +} + +#pragma mark - Legacy + ++ (BOOL)isLegacyLoginItemEnabled { + LSSharedFileListRef sharedFileList = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); + NSString *applicationPath = NSBundle.mainBundle.bundlePath; + if (sharedFileList) { + UInt32 seedValue; + NSArray *sharedFileListArray = CFBridgingRelease(LSSharedFileListCopySnapshot(sharedFileList, &seedValue)); + for (id sharedFile in sharedFileListArray) { + LSSharedFileListItemRef sharedFileListItem = (__bridge LSSharedFileListItemRef)sharedFile; + CFURLRef applicationPathURL = NULL; + LSSharedFileListItemResolve(sharedFileListItem, 0, (CFURLRef *)&applicationPathURL, NULL); + if (applicationPathURL != NULL) { + NSString *resolvedApplicationPath = [(__bridge NSURL *)applicationPathURL path]; + CFRelease(applicationPathURL); + if ([resolvedApplicationPath compare:applicationPath] == NSOrderedSame) { + CFRelease(sharedFileList); + return YES; + } + } + } + CFRelease(sharedFileList); + } else { + NSLog(@"Unable to create the shared file list."); + } + return NO; +} + ++ (BOOL)enableLegacyLoginItem { + LSSharedFileListRef sharedFileList = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); + NSString *applicationPath = NSBundle.mainBundle.bundlePath; + NSURL *applicationPathURL = [NSURL fileURLWithPath:applicationPath]; + if (sharedFileList) { + LSSharedFileListItemRef sharedFileListItem = LSSharedFileListInsertItemURL(sharedFileList, kLSSharedFileListItemLast, NULL, NULL, (__bridge CFURLRef)applicationPathURL, NULL, NULL); + if (sharedFileListItem) { + CFRelease(sharedFileListItem); + } + CFRelease(sharedFileList); + return YES; + } else { + NSLog(@"Unable to create the shared file list."); + return NO; + } +} + ++ (BOOL)disableLegacyLoginItem { + LSSharedFileListRef sharedFileList = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); + NSString *applicationPath = NSBundle.mainBundle.bundlePath; + if (sharedFileList) { + UInt32 seedValue; + NSArray *sharedFileListArray = CFBridgingRelease(LSSharedFileListCopySnapshot(sharedFileList, &seedValue)); + for (id sharedFile in sharedFileListArray) { + LSSharedFileListItemRef sharedFileListItem = (__bridge LSSharedFileListItemRef)sharedFile; + CFURLRef applicationPathURL; + if (LSSharedFileListItemResolve(sharedFileListItem, 0, &applicationPathURL, NULL) == noErr) { + NSString *resolvedApplicationPath = [(__bridge NSURL *)applicationPathURL path]; + if ([resolvedApplicationPath compare:applicationPath] == NSOrderedSame) { + LSSharedFileListItemRemove(sharedFileList, sharedFileListItem); + } + CFRelease(applicationPathURL); + } + } + CFRelease(sharedFileList); + return YES; + } else { + NSLog(@"Unable to create the shared file list."); + return NO; + } +} + +@end diff --git a/src/main/native/org_cryptomator_macos_autostart_MacLaunchServices_Native.m b/src/main/native/org_cryptomator_macos_autostart_MacLaunchServices_Native.m index 8e07f45..2c22932 100644 --- a/src/main/native/org_cryptomator_macos_autostart_MacLaunchServices_Native.m +++ b/src/main/native/org_cryptomator_macos_autostart_MacLaunchServices_Native.m @@ -7,72 +7,16 @@ // #import "org_cryptomator_macos_autostart_MacLaunchServices_Native.h" -#import +#import "SKYLaunchService.h" JNIEXPORT jboolean JNICALL Java_org_cryptomator_macos_autostart_MacLaunchServices_00024Native_isLoginItemEnabled(JNIEnv *env, jobject thisObj) { - LSSharedFileListRef sharedFileList = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); - NSString *applicationPath = NSBundle.mainBundle.bundlePath; - if (sharedFileList) { - UInt32 seedValue; - NSArray *sharedFileListArray = CFBridgingRelease(LSSharedFileListCopySnapshot(sharedFileList, &seedValue)); - for (id sharedFile in sharedFileListArray) { - LSSharedFileListItemRef sharedFileListItem = (__bridge LSSharedFileListItemRef)sharedFile; - CFURLRef applicationPathURL = NULL; - LSSharedFileListItemResolve(sharedFileListItem, 0, (CFURLRef *)&applicationPathURL, NULL); - if (applicationPathURL != NULL) { - NSString *resolvedApplicationPath = [(__bridge NSURL *)applicationPathURL path]; - CFRelease(applicationPathURL); - if ([resolvedApplicationPath compare:applicationPath] == NSOrderedSame) { - CFRelease(sharedFileList); - return YES; - } - } - } - CFRelease(sharedFileList); - } else { - NSLog(@"Unable to create the shared file list."); - } - return NO; + return [SKYLaunchService isLoginItemEnabled]; } JNIEXPORT jboolean JNICALL Java_org_cryptomator_macos_autostart_MacLaunchServices_00024Native_enableLoginItem(JNIEnv *env, jobject thisObj) { - LSSharedFileListRef sharedFileList = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); - NSString *applicationPath = NSBundle.mainBundle.bundlePath; - NSURL *applicationPathURL = [NSURL fileURLWithPath:applicationPath]; - if (sharedFileList) { - LSSharedFileListItemRef sharedFileListItem = LSSharedFileListInsertItemURL(sharedFileList, kLSSharedFileListItemLast, NULL, NULL, (__bridge CFURLRef)applicationPathURL, NULL, NULL); - if (sharedFileListItem) { - CFRelease(sharedFileListItem); - } - CFRelease(sharedFileList); - return YES; - } else { - NSLog(@"Unable to create the shared file list."); - return NO; - } + return [SKYLaunchService enableLoginItem]; } JNIEXPORT jboolean JNICALL Java_org_cryptomator_macos_autostart_MacLaunchServices_00024Native_disableLoginItem(JNIEnv *env, jobject thisObj) { - LSSharedFileListRef sharedFileList = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); - NSString *applicationPath = NSBundle.mainBundle.bundlePath; - if (sharedFileList) { - UInt32 seedValue; - NSArray *sharedFileListArray = CFBridgingRelease(LSSharedFileListCopySnapshot(sharedFileList, &seedValue)); - for (id sharedFile in sharedFileListArray) { - LSSharedFileListItemRef sharedFileListItem = (__bridge LSSharedFileListItemRef)sharedFile; - CFURLRef applicationPathURL; - if (LSSharedFileListItemResolve(sharedFileListItem, 0, &applicationPathURL, NULL) == noErr) { - NSString *resolvedApplicationPath = [(__bridge NSURL *)applicationPathURL path]; - if ([resolvedApplicationPath compare:applicationPath] == NSOrderedSame) { - LSSharedFileListItemRemove(sharedFileList, sharedFileListItem); - } - CFRelease(applicationPathURL); - } - } - CFRelease(sharedFileList); - return YES; - } else { - NSLog(@"Unable to create the shared file list."); - return NO; - } + return [SKYLaunchService disableLoginItem]; } diff --git a/src/main/resources/MacIntegrationsBundle_pt_BR.properties b/src/main/resources/MacIntegrationsBundle_pt_BR.properties index 9c36c16..9ca8fdb 100644 --- a/src/main/resources/MacIntegrationsBundle_pt_BR.properties +++ b/src/main/resources/MacIntegrationsBundle_pt_BR.properties @@ -1 +1 @@ -org.cryptomator.macos.keychain.displayName=macOS chaveiro \ No newline at end of file +org.cryptomator.macos.keychain.displayName=Chaveiro macOS \ No newline at end of file diff --git a/src/main/resources/MacIntegrationsBundle_sl.properties b/src/main/resources/MacIntegrationsBundle_sl.properties index e69de29..bc2eb19 100644 --- a/src/main/resources/MacIntegrationsBundle_sl.properties +++ b/src/main/resources/MacIntegrationsBundle_sl.properties @@ -0,0 +1 @@ +org.cryptomator.macos.keychain.displayName=macOS Keychain \ No newline at end of file