Skip to content

Commit d690d37

Browse files
lolgearlucasderraugh
authored andcommitted
Privacy: apple events permissions have been added. (#561)
* application: info plist privacy apple events usage description has been added. * application: apple script error handling has been added. * application: unused variable has been removed.
1 parent 3973ee4 commit d690d37

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

GitUp/Application/Document.m

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1954,9 +1954,31 @@ - (IBAction)openInFinder:(id)sender {
19541954
[[NSWorkspace sharedWorkspace] openURL:[NSURL fileURLWithPath:_repository.workingDirectoryPath isDirectory:YES]];
19551955
}
19561956

1957+
// NOTE: To reset permissions via terminal:
1958+
1959+
// reset permissions of all apps in category AppleEvents ( Automation )
1960+
// $ tccutil reset AppleEvents
1961+
1962+
// reset all permissions for all apps
1963+
// $ tccutil reset All
1964+
1965+
// reset all permissions for particular bundle identifier.
1966+
// $ tccutil reset All co.gitup.mac-debug
1967+
19571968
- (IBAction)openInTerminal:(id)sender {
19581969
NSString* script = [NSString stringWithFormat:@"tell application \"Terminal\" to do script \"cd \\\"%@\\\"\"", _repository.workingDirectoryPath];
1959-
[[[NSAppleScript alloc] initWithSource:script] executeAndReturnError:NULL];
1970+
NSDictionary *dictionary = nil;
1971+
[[[NSAppleScript alloc] initWithSource:script] executeAndReturnError:&dictionary];
1972+
if (dictionary != nil) {
1973+
NSString *message = (NSString *)dictionary[NSAppleScriptErrorMessage] ?: @"Unknown error!";
1974+
// show error?
1975+
NSInteger code = [dictionary[NSAppleScriptErrorNumber] integerValue];
1976+
NSString *key = @"NSAppleEventsUsageDescription";
1977+
NSString *recovery = [[NSBundle mainBundle] localizedStringForKey:key value:nil table:@"InfoPlist"];
1978+
NSDictionary *userInfo = @{NSLocalizedDescriptionKey : message, NSLocalizedRecoveryOptionsErrorKey : recovery};
1979+
NSError *error = [NSError errorWithDomain:@"com.apple.security.automation.appleEvents" code:code userInfo:userInfo];
1980+
[self presentError:error];
1981+
}
19601982
[[NSWorkspace sharedWorkspace] launchApplication:@"Terminal"];
19611983
}
19621984

GitUp/Application/Info.plist

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
<string>$(PRODUCT_NAME)</string>
3030
<key>CFBundlePackageType</key>
3131
<string>APPL</string>
32-
<key>CFBundleVersion</key>
33-
<string>${BUNDLE_VERSION}</string>
3432
<key>CFBundleShortVersionString</key>
3533
<string>${BUNDLE_VERSION_STRING}</string>
3634
<key>CFBundleURLTypes</key>
@@ -42,8 +40,12 @@
4240
</array>
4341
</dict>
4442
</array>
43+
<key>CFBundleVersion</key>
44+
<string>${BUNDLE_VERSION}</string>
4545
<key>LSMinimumSystemVersion</key>
4646
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
47+
<key>NSAppleEventsUsageDescription</key>
48+
<string>Please</string>
4749
<key>NSHumanReadableCopyright</key>
4850
<string>Copyright © 2015-2019 Pierre-Olivier Latour. All rights reserved.</string>
4951
<key>NSMainNibFile</key>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
InfoPlist.strings
3+
GitUp
4+
5+
Created by Dmitry Lobanov on 25/08/2019.
6+
7+
*/
8+
9+
"NSAppleEventsUsageDescription" = "Please give access to Terminal via Apple Script.";

GitUp/GitUp.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
0AE7F5F12312C1B000B06050 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0AE7F5ED2312C1B000B06050 /* InfoPlist.strings */; };
1011
165C32B61B95739700D2F894 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 165C32B51B95739700D2F894 /* QuartzCore.framework */; };
1112
31CD50E3203E2E2800360B3A /* ToolbarItemWrapperView.m in Sources */ = {isa = PBXBuildFile; fileRef = 31CD50E2203E2E2800360B3A /* ToolbarItemWrapperView.m */; };
1213
E212A6DE1B92100E00F62B18 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E212A6DD1B92100E00F62B18 /* libiconv.dylib */; };
@@ -106,6 +107,7 @@
106107
/* End PBXCopyFilesBuildPhase section */
107108

108109
/* Begin PBXFileReference section */
110+
0AE7F5EE2312C1B000B06050 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
109111
165C32B51B95739700D2F894 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
110112
31CD50E1203E2E2800360B3A /* ToolbarItemWrapperView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ToolbarItemWrapperView.h; sourceTree = "<group>"; };
111113
31CD50E2203E2E2800360B3A /* ToolbarItemWrapperView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ToolbarItemWrapperView.m; sourceTree = "<group>"; };
@@ -267,6 +269,7 @@
267269
E2BDA0671AD47A2F00E69729 /* Help.plist */,
268270
E2C338AF19F8562F00063D95 /* Info.plist */,
269271
E2A5BE6E1A814970008DD47F /* Localizable.strings */,
272+
0AE7F5ED2312C1B000B06050 /* InfoPlist.strings */,
270273
E2C338B319F8562F00063D95 /* main.m */,
271274
E2C338BD19F8562F00063D95 /* MainMenu.xib */,
272275
E2C5672B1A6D98BC00ECFE07 /* WindowController.h */,
@@ -400,6 +403,7 @@
400403
buildActionMask = 2147483647;
401404
files = (
402405
E25EBCEB1AA3F8B700D3AF44 /* Application.xcassets in Resources */,
406+
0AE7F5F12312C1B000B06050 /* InfoPlist.strings in Resources */,
403407
E2A5BE701A814970008DD47F /* Localizable.strings in Resources */,
404408
E2C338BA19F8562F00063D95 /* Document.xib in Resources */,
405409
E2C338BF19F8562F00063D95 /* MainMenu.xib in Resources */,
@@ -448,6 +452,14 @@
448452
/* End PBXTargetDependency section */
449453

450454
/* Begin PBXVariantGroup section */
455+
0AE7F5ED2312C1B000B06050 /* InfoPlist.strings */ = {
456+
isa = PBXVariantGroup;
457+
children = (
458+
0AE7F5EE2312C1B000B06050 /* en */,
459+
);
460+
name = InfoPlist.strings;
461+
sourceTree = "<group>";
462+
};
451463
E2A5BE6E1A814970008DD47F /* Localizable.strings */ = {
452464
isa = PBXVariantGroup;
453465
children = (

0 commit comments

Comments
 (0)