Skip to content

Commit

Permalink
Merge branch 'release/1.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Jun 21, 2024
2 parents c163245 + 3b64db2 commit 19d9923
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 128 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build
on:
[push]
push:
pull_request_target:
types: [labeled]
jobs:
build:
name: Build and Test
Expand All @@ -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
Expand Down
59 changes: 8 additions & 51 deletions .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/${{ github.repository }}/actions/run/${{ github.run_id }}|report> 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 }}
28 changes: 14 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.cryptomator</groupId>
<artifactId>integrations-mac</artifactId>
<version>1.2.3</version>
<version>1.2.4</version>

<name>Cryptomator Integrations for macOS</name>
<description>Provides optional macOS services used by Cryptomator</description>
Expand All @@ -30,16 +30,16 @@
<project.jdk.version>17</project.jdk.version>

<!-- runtime dependencies -->
<api.version>1.3.0</api.version>
<slf4j.version>2.0.11</slf4j.version>
<api.version>1.3.1</api.version>
<slf4j.version>2.0.13</slf4j.version>

<!-- test dependencies -->
<junit.jupiter.version>5.10.1</junit.jupiter.version>
<mockito.version>5.10.0</mockito.version>
<junit.jupiter.version>5.10.2</junit.jupiter.version>
<mockito.version>5.12.0</mockito.version>

<!-- build plugin dependencies -->
<dependency-check.version>9.0.9</dependency-check.version>
<nexus-staging.version>1.6.13</nexus-staging.version>
<dependency-check.version>9.2.0</dependency-check.version>
<nexus-staging.version>1.6.14</nexus-staging.version>
</properties>

<licenses>
Expand Down Expand Up @@ -104,7 +104,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
<configuration>
<compilerArgs>
<arg>-h</arg>
Expand All @@ -116,7 +116,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
<executions>
<execution>
<id>check-preconditions</id>
Expand Down Expand Up @@ -145,7 +145,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<version>3.3.0</version>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -203,7 +203,7 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -215,7 +215,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<version>3.7.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -307,7 +307,7 @@
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down Expand Up @@ -368,7 +368,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.2</version>
</plugin>
</plugins>
</build>
Expand Down
8 changes: 8 additions & 0 deletions src/main/native/Integrations.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -19,6 +21,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
74BEF1832C0384FB006731AC /* SKYLaunchService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SKYLaunchService.h; sourceTree = "<group>"; };
74BEF1842C0384FB006731AC /* SKYLaunchService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SKYLaunchService.m; sourceTree = "<group>"; };
74CF2E7A254C295A006266D6 /* org_cryptomator_macos_autostart_MacLaunchServices_Native.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = org_cryptomator_macos_autostart_MacLaunchServices_Native.m; sourceTree = "<group>"; };
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 = "<group>"; };
Expand Down Expand Up @@ -54,6 +58,8 @@
9E21341025542ECE006EA872 /* SKYAppearanceNotifier.m */,
9E213409255429CA006EA872 /* SKYAppearanceObserver.h */,
9E21340A255429CA006EA872 /* SKYAppearanceObserver.m */,
74BEF1832C0384FB006731AC /* SKYLaunchService.h */,
74BEF1842C0384FB006731AC /* SKYLaunchService.m */,
9E0819B81D748ECC000C89E6 /* Products */,
);
sourceTree = "<group>";
Expand All @@ -74,6 +80,7 @@
buildActionMask = 2147483647;
files = (
9E21341125542ECE006EA872 /* SKYAppearanceNotifier.h in Headers */,
74BEF1862C0384FB006731AC /* SKYLaunchService.h in Headers */,
9E21340B255429CA006EA872 /* SKYAppearanceObserver.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -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 */,
Expand Down
17 changes: 17 additions & 0 deletions src/main/native/SKYLaunchService.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// SKYLaunchService.h
// Integrations
//
// Created by Tobias Hagemann on 26.05.24.
// Copyright © 2024 Cryptomator. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface SKYLaunchService : NSObject

+ (BOOL)isLoginItemEnabled;
+ (BOOL)enableLoginItem;
+ (BOOL)disableLoginItem;

@end
128 changes: 128 additions & 0 deletions src/main/native/SKYLaunchService.m
Original file line number Diff line number Diff line change
@@ -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 <ServiceManagement/ServiceManagement.h>

@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
Loading

0 comments on commit 19d9923

Please sign in to comment.