From e0d12bea5aa9129a3ca785d3fe9f740912c23995 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Tue, 25 Jun 2019 12:59:51 +0200 Subject: [PATCH 1/7] Added setup to store a copy of the plugin.json inside Macpass and use that as fallback as well as if the user denies access to remote systems --- MacPass.xcodeproj/project.pbxproj | 4 ++ MacPass/MPPluginRepository.m | 99 +++++++++++++++++++---------- MacPass/MPSettingsHelper.h | 2 + MacPass/MPSettingsHelper.m | 1 + MacPass/Resources/plugins.json | 26 ++++++++ scripts/update_plugin_repository.sh | 6 ++ 6 files changed, 105 insertions(+), 33 deletions(-) create mode 100644 MacPass/Resources/plugins.json create mode 100755 scripts/update_plugin_repository.sh diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 8ff06f6e..cebb6f77 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -203,6 +203,7 @@ 4C8B36AB17A6ED4B005E1FF1 /* MPOutlineContextMenuDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8B36AA17A6ED4B005E1FF1 /* MPOutlineContextMenuDelegate.m */; }; 4C8DEAA21C314D2C00D24C32 /* MPTestAutotypeDelay.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8DEAA11C314D2C00D24C32 /* MPTestAutotypeDelay.m */; }; 4C8E889222C223620002C7C8 /* createdTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C8E889122C223620002C7C8 /* createdTemplate.pdf */; }; + 4C8E889422C227270002C7C8 /* plugins.json in Resources */ = {isa = PBXBuildFile; fileRef = 4C8E889322C227270002C7C8 /* plugins.json */; }; 4C8F0C6E1FCEE9B900BE157F /* MPPluginConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8F0C6D1FCEE9B900BE157F /* MPPluginConstants.m */; }; 4C8F0C711FCEF91400BE157F /* MPPickcharsParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8F0C701FCEF91400BE157F /* MPPickcharsParser.m */; }; 4C8F0C731FCF1B7A00BE157F /* MPTestPickcharsParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8F0C721FCF1B7A00BE157F /* MPTestPickcharsParser.m */; }; @@ -720,6 +721,7 @@ 4C8C10061FC489D8003DDD5E /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/PluginPreferences.strings; sourceTree = ""; }; 4C8DEAA11C314D2C00D24C32 /* MPTestAutotypeDelay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTestAutotypeDelay.m; sourceTree = ""; }; 4C8E889122C223620002C7C8 /* createdTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = createdTemplate.pdf; sourceTree = ""; }; + 4C8E889322C227270002C7C8 /* plugins.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = plugins.json; path = Resources/plugins.json; sourceTree = ""; }; 4C8F0C6C1FCEE98900BE157F /* MPPluginConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPluginConstants.h; sourceTree = ""; }; 4C8F0C6D1FCEE9B900BE157F /* MPPluginConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPPluginConstants.m; sourceTree = ""; }; 4C8F0C6F1FCEF91400BE157F /* MPPickcharsParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPickcharsParser.h; sourceTree = ""; }; @@ -1485,6 +1487,7 @@ 4C77E36D15B84A240093A587 /* Supporting Files */ = { isa = PBXGroup; children = ( + 4C8E889322C227270002C7C8 /* plugins.json */, FA13910A1F9CD9EB0033D256 /* Localizable.stringsdict */, 4C888C8E16EB6C91003D34A1 /* Localizable.strings */, 4CB9339716D3A0DD00A13B5D /* Credits.rtf */, @@ -1924,6 +1927,7 @@ 6021FE4B18E13F1D00C3BC51 /* GroupInspectorView.xib in Resources */, 4C3826BF1AD04D8E007D7D67 /* 52_EncryptedTemplate.pdf in Resources */, 4C3826BD1AD04D8E007D7D67 /* 50_FolderTarTemplate.pdf in Resources */, + 4C8E889422C227270002C7C8 /* plugins.json in Resources */, 6021FE3B18E1341900C3BC51 /* EntryInspectorView.xib in Resources */, 4C3826AD1AD04D8E007D7D67 /* 32_FileSystemViewTemplate.pdf in Resources */, 6021FE6118E15D9100C3BC51 /* WorkflowPreferences.xib in Resources */, diff --git a/MacPass/MPPluginRepository.m b/MacPass/MPPluginRepository.m index 09268b09..e272837f 100644 --- a/MacPass/MPPluginRepository.m +++ b/MacPass/MPPluginRepository.m @@ -23,6 +23,7 @@ #import "MPPluginRepository.h" #import "MPConstants.h" #import "MPPluginRepositoryItem.h" +#import "MPSettingsHelper.h" NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com.hicknhack.macpass.MPPluginRepositoryDidInitializeAvailablePluginsNotification"; @@ -56,7 +57,7 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com. if(self) { _isInitialized = NO; _lastDataFetchTime = NSDate.distantPast.timeIntervalSinceReferenceDate; - [self fetchRepositoryDataCompletionHandler:^(NSArray * _Nonnull availablePlugins) { + [self _fetchRepositoryDataCompletionHandler:^(NSArray * _Nonnull availablePlugins) { self.availablePlugins = availablePlugins; self.isInitialized = YES; }]; @@ -68,7 +69,7 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com. /* update cache on every read if it's older than 5 minutes */ if((NSDate.timeIntervalSinceReferenceDate - self.lastDataFetchTime) > 60*5 ) { NSLog(@"%@: updating available plugins cache.", self.className); - [self fetchRepositoryDataCompletionHandler:^(NSArray * _Nonnull availablePlugins) { + [self _fetchRepositoryDataCompletionHandler:^(NSArray * _Nonnull availablePlugins) { self.availablePlugins = availablePlugins; }]; } @@ -87,59 +88,91 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com. } } -- (void)fetchRepositoryDataCompletionHandler:(void (^)(NSArray * _Nonnull))completionHandler { +- (void)_fetchRepositoryDataCompletionHandler:(void (^)(NSArray * _Nonnull))completionHandler { + BOOL allowRemoteConnection = [self _askForPluginRepositoryPermission]; + if(!allowRemoteConnection) { + [self _fetchLocalFallbackRepositoryData:completionHandler]; + return; + } NSString *urlString = NSBundle.mainBundle.infoDictionary[MPBundlePluginRepositoryURLKey]; if(!urlString) { - if(completionHandler) { - completionHandler(@[]); - } + [self _fetchLocalFallbackRepositoryData:completionHandler]; return; } NSURL *jsonURL = [NSURL URLWithString:urlString]; if(!jsonURL) { - if(completionHandler) { - completionHandler(@[]); - } + [self _fetchLocalFallbackRepositoryData:completionHandler]; return; } NSURLSessionTask *downloadTask = [NSURLSession.sharedSession dataTaskWithURL:jsonURL completionHandler:^(NSData * _Nullable jsonData, NSURLResponse * _Nullable response, NSError * _Nullable error) { if(![response isKindOfClass:NSHTTPURLResponse.class]) { - if(completionHandler) { - completionHandler(@[]); - } + [self _fetchLocalFallbackRepositoryData:completionHandler]; return; } NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; if(httpResponse.statusCode != 200 || jsonData.length == 0) { - if(completionHandler) { - completionHandler(@[]); - } + [self _fetchLocalFallbackRepositoryData:completionHandler]; return; } - id jsonRoot = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; - if(!jsonRoot || ![jsonRoot isKindOfClass:NSArray.class]) { - if(completionHandler) { - completionHandler(@[]); - } - return; - } - NSMutableArray *items = [[NSMutableArray alloc] init]; - for(id item in jsonRoot) { - if(![item isKindOfClass:NSDictionary.class]) { - continue; - } - MPPluginRepositoryItem *pluginItem = [MPPluginRepositoryItem pluginItemFromDictionary:item]; - if(pluginItem.isVaid) { - [items addObject:pluginItem]; - } - } + + NSArray *items = [self _parseJSONData:jsonData]; + if(completionHandler) { completionHandler([items copy]); } }]; - [downloadTask resume]; } +- (void)_fetchLocalFallbackRepositoryData:(void (^)(NSArray * _Nonnull))completionHandler { + NSURL *jsonURL = [NSBundle.mainBundle URLForResource:@"plugins" withExtension:@"json"]; + NSData *localJsonData = [NSData dataWithContentsOfURL:jsonURL]; + if(!localJsonData) { + if(completionHandler) { + completionHandler(@[]); + } + } + NSArray *items = [self _parseJSONData:localJsonData]; + if(completionHandler) { + completionHandler(items); + } +} + +- (NSArray *)_parseJSONData:(NSData *)jsonData { + NSError *error; + id jsonRoot = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; + if(!jsonRoot || ![jsonRoot isKindOfClass:NSArray.class]) { + return @[]; + } + NSMutableArray *items = [[NSMutableArray alloc] init]; + for(id item in jsonRoot) { + if(![item isKindOfClass:NSDictionary.class]) { + continue; + } + MPPluginRepositoryItem *pluginItem = [MPPluginRepositoryItem pluginItemFromDictionary:item]; + if(pluginItem.isVaid) { + [items addObject:pluginItem]; + } + } + return [items copy]; +} + +- (BOOL)_askForPluginRepositoryPermission { + if(![NSUserDefaults.standardUserDefaults objectForKey:kMPSettingsKeyAllowRemoteFetchOfPluginRepository]) { + NSAlert *alert = [[NSAlert alloc] init]; + alert.alertStyle = NSAlertStyleWarning; + alert.informativeText = NSLocalizedString(@"ALERT_ASK_FOR_PLUGIN_REPOSITORY_CONNECTION_PERMISSION_INFORMATIVE_TEXT", @"Informative text displayed on the alert that shows up when MacPass asks for permssion to download the plugin repository JSON file"); + alert.messageText = NSLocalizedString(@"ALERT_ASK_FOR_PLUGIN_REPOSITORY_CONNECTION_PERMISSION_MESSAGE", @"Message displayed on the alert that askf for permission to download the plugin repository JSON file"); + alert.showsSuppressionButton = YES; + [alert addButtonWithTitle:NSLocalizedString(@"ALERT_ASK_FOR_PLUGIN_REPOSITORY_DISALLOW_DOWNLOAD", @"Disallow the download of the plugin repository file")]; + [alert addButtonWithTitle:NSLocalizedString(@"ALERT_ASK_FOR_PLUGIN_REPOSITORY_ALLOW_DOWNLOAD", @"Allow the download of the plugin repository file")]; + NSModalResponse repsonse = [alert runModal]; + BOOL allow = (repsonse == NSAlertFirstButtonReturn); + [NSUserDefaults.standardUserDefaults setBool:allow forKey:kMPSettingsKeyAllowRemoteFetchOfPluginRepository]; + return allow; + } + return [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyAllowRemoteFetchOfPluginRepository]; +} + @end diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h index 52d70470..a5d68a0a 100644 --- a/MacPass/MPSettingsHelper.h +++ b/MacPass/MPSettingsHelper.h @@ -87,6 +87,8 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyLoadUnsecurePlugins; // I APPKIT_EXTERN NSString *const kMPSettingsKeyDisabledPlugins; // NSArray of bundle identifiers of disabled plugins APPKIT_EXTERN NSString *const kMPSettingsKeyLoadIncompatiblePlugins; // If set to YES incompatible plugins (no version info, marked as incompatible, etc) will be loaded regardless APPKIT_EXTERN NSString *const kMPSettingsKeyHideIncopatiblePluginsWarning; // Do not show an alert, when MacPass encounteres incompatible plugins +APPKIT_EXTERN NSString *const kMPSettingsKeyAllowRemoteFetchOfPluginRepository; // Allow the download of the plugin repository file +APPKIT_EXTERN NSString *const kMPSettingsKeyPluginHideAksForRemoveConnectionPermission; typedef NS_ENUM(NSUInteger, MPFileChangeStrategy) { MPFileChangeStrategyAsk, diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index eccbb4e2..7a473bcd 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -84,6 +84,7 @@ NSString *const kMPSettingsKeyLoadUnsecurePlugins = @"LoadUn NSString *const kMPSettingsKeyLoadIncompatiblePlugins = @"LoadIncompatiblePlugins"; NSString *const kMPSettingsKeyDisabledPlugins = @"DisabledPlugins"; NSString *const kMPSettingsKeyHideIncopatiblePluginsWarning = @"HideIncopatiblePluginsWarning"; +NSString *const kMPSettingsKeyAllowRemoteFetchOfPluginRepository = @"AllowRemoteFetchOfPluginRepository"; /* Deprecated */ NSString *const kMPDeprecatedSettingsKeyRememberKeyFilesForDatabases = @"kMPSettingsKeyRememberKeyFilesForDatabases"; diff --git a/MacPass/Resources/plugins.json b/MacPass/Resources/plugins.json new file mode 100644 index 00000000..ca5ba69a --- /dev/null +++ b/MacPass/Resources/plugins.json @@ -0,0 +1,26 @@ +[ + { + "name": "MacPassHTTP", + "description": "KeePassHTTP support for MacPass", + "download": "https://github.com/MacPass/MacPassHTTP/releases/download/0.3.1/MacPassHTTP.mpplugin-0.3.1.zip", + "source": "https://github.com/MacPass/MacPassHTTP", + "currentVersion": "0.3.1", + "bundleIdentifier": "com.hicknhacksoftware.MacPassHTTP", + "compatibilty" : [ + { + "pluginVersion": "0.2.*", + "minimumHostVersion" : "0.6.1", + "maximumHostVersion" : "0.6.2" + }, + { + "pluginVersion": "0.3", + "minimumHostVersion" : "0.7", + "maximumHostVersion" : "0.7.3" + }, + { + "pluginVersion": "0.3.1", + "minimumHostVersion" : "0.7.4" + } + ] + } +] diff --git a/scripts/update_plugin_repository.sh b/scripts/update_plugin_repository.sh new file mode 100755 index 00000000..6c15a54f --- /dev/null +++ b/scripts/update_plugin_repository.sh @@ -0,0 +1,6 @@ +#!/bin/bash +URL="https://macpassapp.org/data/plugins.json" +MY_FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +DOWNLOAD_FOLDER="${MY_FOLDER}/../MacPass/Resources/" +cd "${DOWNLOAD_FOLDER}" +wget "${URL}" From 4a33a7ece2ba4ccda57a8ce98f12086759253705 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Wed, 26 Jun 2019 12:33:38 +0200 Subject: [PATCH 2/7] ignore updated localizations helper file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8cdf8669..49cec965 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ Docs/Acknowlegements/*.fls Docs/Acknowlegements/*.log Docs/Acknowlegements/*.synctex.gz docs/acknowledgement/*.lb +MacPass/en.lproj/Localizable.strings.updated From 972f775ab37c2eee52f60da355f8fcc9d20e3ead Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Wed, 26 Jun 2019 12:33:49 +0200 Subject: [PATCH 3/7] added load external content ui for settings --- MacPass/Base.lproj/PluginPreferences.xib | 53 +++++++++++++++++------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/MacPass/Base.lproj/PluginPreferences.xib b/MacPass/Base.lproj/PluginPreferences.xib index 706563df..b79f7c31 100644 --- a/MacPass/Base.lproj/PluginPreferences.xib +++ b/MacPass/Base.lproj/PluginPreferences.xib @@ -1,8 +1,8 @@ - + - + @@ -21,19 +21,19 @@ - + - + - + - + - + @@ -58,14 +58,14 @@ - + If enabled, Plugins without proper signatures will be allowed to load. Keep in mind, that Plugins have full access to your data! Changes take affect on restart. @@ -74,13 +74,13 @@ - + - + - + @@ -167,7 +167,7 @@ + + + + + + + + + - + + + + + + + @@ -208,7 +229,7 @@ - + From 28817b6c802719cd2e547e395c6719ef89802e87 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Wed, 26 Jun 2019 13:05:40 +0200 Subject: [PATCH 4/7] wired plugin repository download settings and fixed crash when initializing plugin host --- MacPass/Base.lproj/PluginPreferences.xib | 3 ++- MacPass/MPPluginPreferencesController.m | 5 +++++ MacPass/MPPluginRepository.m | 20 +++++++++++++------- MacPass/de.lproj/Localizable.strings | 12 ++++++++++++ MacPass/en.lproj/Localizable.strings | 12 ++++++++++++ 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/MacPass/Base.lproj/PluginPreferences.xib b/MacPass/Base.lproj/PluginPreferences.xib index b79f7c31..1b2c6e0e 100644 --- a/MacPass/Base.lproj/PluginPreferences.xib +++ b/MacPass/Base.lproj/PluginPreferences.xib @@ -9,6 +9,7 @@ + @@ -229,7 +230,7 @@ - + diff --git a/MacPass/MPPluginPreferencesController.m b/MacPass/MPPluginPreferencesController.m index 02c71f9e..eb07bebc 100644 --- a/MacPass/MPPluginPreferencesController.m +++ b/MacPass/MPPluginPreferencesController.m @@ -42,6 +42,7 @@ typedef NS_ENUM(NSUInteger, MPPluginSegmentType) { @interface MPPluginPreferencesController () +@property (strong) IBOutlet NSButton *allowRemoteConnectionCheckButton; @property (strong) IBOutlet NSTableView *pluginTableView; @property (strong) IBOutlet NSView *settingsView; @property (strong) IBOutlet NSView *fallbackSettingsView; @@ -83,6 +84,10 @@ typedef NS_ENUM(NSUInteger, MPPluginSegmentType) { toObject:NSUserDefaultsController.sharedUserDefaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyLoadIncompatiblePlugins] options:nil]; + [self.allowRemoteConnectionCheckButton bind:NSValueBinding + toObject:NSUserDefaultsController.sharedUserDefaultsController + withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyAllowRemoteFetchOfPluginRepository] + options:nil]; [self.pluginTableView registerForDraggedTypes:@[(NSString *)kUTTypeFileURL]]; } diff --git a/MacPass/MPPluginRepository.m b/MacPass/MPPluginRepository.m index e272837f..ff40ad20 100644 --- a/MacPass/MPPluginRepository.m +++ b/MacPass/MPPluginRepository.m @@ -57,7 +57,7 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com. if(self) { _isInitialized = NO; _lastDataFetchTime = NSDate.distantPast.timeIntervalSinceReferenceDate; - [self _fetchRepositoryDataCompletionHandler:^(NSArray * _Nonnull availablePlugins) { + [self _fetchAppropriateRepositoryDataCompletionHandler:^(NSArray * _Nonnull availablePlugins) { self.availablePlugins = availablePlugins; self.isInitialized = YES; }]; @@ -69,7 +69,7 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com. /* update cache on every read if it's older than 5 minutes */ if((NSDate.timeIntervalSinceReferenceDate - self.lastDataFetchTime) > 60*5 ) { NSLog(@"%@: updating available plugins cache.", self.className); - [self _fetchRepositoryDataCompletionHandler:^(NSArray * _Nonnull availablePlugins) { + [self _fetchAppropriateRepositoryDataCompletionHandler:^(NSArray * _Nonnull availablePlugins) { self.availablePlugins = availablePlugins; }]; } @@ -88,12 +88,18 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com. } } +- (void)_fetchAppropriateRepositoryDataCompletionHandler:(void (^)(NSArray * _Nonnull))completionHandler { + /* dispatch the call to allow for direct return and handle resutl later on */ + dispatch_async(dispatch_get_main_queue(), ^{ + BOOL allowRemoteConnection = [self _askForPluginRepositoryPermission]; + if(!allowRemoteConnection) { + [self _fetchLocalFallbackRepositoryData:completionHandler]; + } + [self _fetchRepositoryDataCompletionHandler:completionHandler]; + }); +} + - (void)_fetchRepositoryDataCompletionHandler:(void (^)(NSArray * _Nonnull))completionHandler { - BOOL allowRemoteConnection = [self _askForPluginRepositoryPermission]; - if(!allowRemoteConnection) { - [self _fetchLocalFallbackRepositoryData:completionHandler]; - return; - } NSString *urlString = NSBundle.mainBundle.infoDictionary[MPBundlePluginRepositoryURLKey]; if(!urlString) { [self _fetchLocalFallbackRepositoryData:completionHandler]; diff --git a/MacPass/de.lproj/Localizable.strings b/MacPass/de.lproj/Localizable.strings index 9aaf7d11..8894679c 100644 --- a/MacPass/de.lproj/Localizable.strings +++ b/MacPass/de.lproj/Localizable.strings @@ -37,6 +37,18 @@ /* Action to add an entry via template */ "ADD_TREMPLATE_ENTRY" = "Vorgabeeintrag erstellen"; +/* Allow the download of the plugin repository file */ +"ALERT_ASK_FOR_PLUGIN_REPOSITORY_ALLOW_DOWNLOAD" = "Keine Daten herunterladen."; + +/* Informative text displayed on the alert that shows up when MacPass asks for permssion to download the plugin repository JSON file */ +"ALERT_ASK_FOR_PLUGIN_REPOSITORY_CONNECTION_PERMISSION_INFORMATIVE_TEXT" = "Das Verzeichnis ist auf https://macpassapp.org hinterlegt. MacPass verbindet lädt die Defintionen herunter um sicher zu stellen, dass alle Daten auf dem neusten Stand sind."; + +/* Message displayed on the alert that askf for permission to download the plugin repository JSON file */ +"ALERT_ASK_FOR_PLUGIN_REPOSITORY_CONNECTION_PERMISSION_MESSAGE" = "MacPass möchte das Pluginverzeichnis aktualisieren."; + +/* Disallow the download of the plugin repository file */ +"ALERT_ASK_FOR_PLUGIN_REPOSITORY_DISALLOW_DOWNLOAD" = "Aktualisiere Daten online."; + /* Button in dialog to leave autotype disabled and continiue! */ "ALERT_AUTOTYPE_MISSING_ACCESSIBILTY_PERMISSIONS_BUTTON_OK" = "Autotype deaktiviert lassen."; diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index 403fa1bf..4e211e67 100644 --- a/MacPass/en.lproj/Localizable.strings +++ b/MacPass/en.lproj/Localizable.strings @@ -37,6 +37,18 @@ /* Action to add an entry via template */ "ADD_TREMPLATE_ENTRY" = "Create Template Entry"; +/* Allow the download of the plugin repository file */ +"ALERT_ASK_FOR_PLUGIN_REPOSITORY_ALLOW_DOWNLOAD" = "Do not update defintions"; + +/* Informative text displayed on the alert that shows up when MacPass asks for permssion to download the plugin repository JSON file */ +"ALERT_ASK_FOR_PLUGIN_REPOSITORY_CONNECTION_PERMISSION_INFORMATIVE_TEXT" = "The plugin defintions are hosted online at https://macpassapp.org. MacPass would like to download those files to ensure the data is up to date."; + +/* Message displayed on the alert that askf for permission to download the plugin repository JSON file */ +"ALERT_ASK_FOR_PLUGIN_REPOSITORY_CONNECTION_PERMISSION_MESSAGE" = "MacPass would like to check for updates of plugin defintions online"; + +/* Disallow the download of the plugin repository file */ +"ALERT_ASK_FOR_PLUGIN_REPOSITORY_DISALLOW_DOWNLOAD" = "Update definitions online"; + /* Button in dialog to leave autotype disabled and continiue! */ "ALERT_AUTOTYPE_MISSING_ACCESSIBILTY_PERMISSIONS_BUTTON_OK" = "Keep Autotype disabled."; From 024131de350c9f98d9b8e233dd7c31caf387f9b1 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Fri, 12 Jul 2019 17:01:22 +0200 Subject: [PATCH 5/7] Fixed typo in comment --- MacPass/MPPluginRepository.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MacPass/MPPluginRepository.m b/MacPass/MPPluginRepository.m index ff40ad20..098e7529 100644 --- a/MacPass/MPPluginRepository.m +++ b/MacPass/MPPluginRepository.m @@ -89,7 +89,7 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com. } - (void)_fetchAppropriateRepositoryDataCompletionHandler:(void (^)(NSArray * _Nonnull))completionHandler { - /* dispatch the call to allow for direct return and handle resutl later on */ + /* dispatch the call to allow for direct return and handle result later on */ dispatch_async(dispatch_get_main_queue(), ^{ BOOL allowRemoteConnection = [self _askForPluginRepositoryPermission]; if(!allowRemoteConnection) { From 53b807788a88da8187b27dad8bf243ea93800e8f Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Fri, 12 Jul 2019 17:07:30 +0200 Subject: [PATCH 6/7] Fixed issue where remove connection would be used despite the user not consenting to it. --- MacPass/MPPluginRepository.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MacPass/MPPluginRepository.m b/MacPass/MPPluginRepository.m index 098e7529..923c3bc0 100644 --- a/MacPass/MPPluginRepository.m +++ b/MacPass/MPPluginRepository.m @@ -95,7 +95,9 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com. if(!allowRemoteConnection) { [self _fetchLocalFallbackRepositoryData:completionHandler]; } - [self _fetchRepositoryDataCompletionHandler:completionHandler]; + else { + [self _fetchRepositoryDataCompletionHandler:completionHandler]; + } }); } From fc21257173b0b3953b4d4b872028b065a57800b5 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Mon, 15 Jul 2019 12:22:07 +0200 Subject: [PATCH 7/7] Minor style fixes --- MacPass/MPPluginHost.m | 1 + MacPass/MPPluginRepository.m | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MacPass/MPPluginHost.m b/MacPass/MPPluginHost.m index 761ff632..e85366e7 100644 --- a/MacPass/MPPluginHost.m +++ b/MacPass/MPPluginHost.m @@ -464,6 +464,7 @@ NSString *const MPImportPluginUTIKey = @"MPImportPluginUTIKey"; - (NSArray *)importPlugins { return [self _pluginsConformingToProtocoll:@protocol(MPImportPlugin)]; } + @end @implementation MPPluginHost (MPWindowTitleResolverSupport) diff --git a/MacPass/MPPluginRepository.m b/MacPass/MPPluginRepository.m index 923c3bc0..b737d290 100644 --- a/MacPass/MPPluginRepository.m +++ b/MacPass/MPPluginRepository.m @@ -66,7 +66,9 @@ NSString *const MPPluginRepositoryDidUpdateAvailablePluginsNotification = @"com. } - (NSArray *)availablePlugins { - /* update cache on every read if it's older than 5 minutes */ + /* FIXME: Invalidate fetch when settings have changed! + update cache on every read if it's older than 5 minutes + */ if((NSDate.timeIntervalSinceReferenceDate - self.lastDataFetchTime) > 60*5 ) { NSLog(@"%@: updating available plugins cache.", self.className); [self _fetchAppropriateRepositoryDataCompletionHandler:^(NSArray * _Nonnull availablePlugins) {