{"id":3482,"date":"2018-08-25T10:19:18","date_gmt":"2018-08-25T15:19:18","guid":{"rendered":"https:\/\/dev.iachieved.it\/iachievedit\/?p=3482"},"modified":"2018-08-25T10:19:18","modified_gmt":"2018-08-25T15:19:18","slug":"not-authorized-to-send-apple-events-to-system-events","status":"publish","type":"post","link":"https:\/\/dev.iachieved.it\/iachievedit\/not-authorized-to-send-apple-events-to-system-events\/","title":{"rendered":"Not authorized to send Apple events to System Events"},"content":{"rendered":"<p>As <a href=\"https:\/\/www.felix-schwarz.org\/blog\/2018\/06\/apple-event-sandboxing-in-macos-mojave\">others have written about<\/a>, Apple appears to be making a hash out of the ability to automate tasks on macOS 10.14 (Mojave).  I get it.  In the age of hyper-connectivity there is a continuous assault on our computing environments by bad actors looking to extort some cash or otherwise ruin our day.  <i>Something<\/i> needs to safeguard our systems against random scripts aiming to misbehave.  Enter Mojave&#8217;s enhanced privacy protection controls and event sandboxing.<\/p>\n<p>With earlier versions of Mojave the new event sandboxing mechanism was considerably flaky.  In some versions (notably Beta 4), you&#8217;d intermittently be presented with <code>Not authorized to send Apple events to System Events<\/code> when attempting to execute AppleScript applications.  As of Mojave Beta 8 (18A371a) I have found that the authorization functionality is at least consistent in prompting you for permission.<\/p>\n<p>As a test, open a <code>Terminal<\/code> window and enter the following:<\/p>\n<p>[code lang=text]<br \/>\nosascript -e &#039;tell application &quot;Finder&quot;&#039; -e &#039;set _b to bounds of window of desktop&#039; -e &#039;end tell&#039;<br \/>\n[\/code]<\/p>\n<p>You will get different results depending upon your current automation privacy settings.  <i>If<\/i> you&#8217;ve never given permission to <code>Terminal<\/code> to send events to <code>Finder<\/code> you&#8217;ll see an authorization dialog like this:<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/terminal_permission.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/terminal_permission.png\" alt=\"\" width=\"838\" height=\"310\" class=\"aligncenter size-full wp-image-3486\" srcset=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/terminal_permission.png 838w, https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/terminal_permission-300x111.png 300w, https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/terminal_permission-768x284.png 768w\" sizes=\"(max-width: 838px) 100vw, 838px\" \/><\/a><\/p>\n<p><i>If<\/i> you&#8217;ve already given permission (as shown in the example Privacy panel below), the AppleScript <code>tell<\/code> will succeed and you&#8217;ll see something like <code>-2560, 0, 1920, 1440<\/code> (the bounds coordinates).<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/privacypanel.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/privacypanel.png\" alt=\"\" width=\"1200\" height=\"705\" class=\"aligncenter size-full wp-image-3488\" srcset=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/privacypanel.png 1200w, https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/privacypanel-300x176.png 300w, https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/privacypanel-768x451.png 768w, https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2018\/08\/privacypanel-1024x602.png 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<p>But wait, there&#8217;s more!  <i>If<\/i> you had previously given permission, and then revoked it by unchecking the permission in the Privacy panel, you&#8217;ll get <code>execution error: Not authorized to send Apple events to Finder. (-1743)<\/code>.<\/p>\n<h2>Automation Implications<\/h2>\n<p>A lot of folks (myself included) write AppleScript applications that perform some set of tasks.  That is sort of the whole point of automation.  Again, I get it.  If my machine is compromised with a rogue application or script, it could do some serious damage.  But that will always be the case.<\/p>\n<p>Now I can imagine how this will be resolved, and it&#8217;s going to include me forking over some money to get a verified publisher certificate.  My certificate will be signed by Apple, and that signing certificate will be trusted by the OS <i>a priori<\/i>, and I&#8217;ll have to sign my scripts somehow, and so on.  That&#8217;s the only way I can see this panning out, unless the plan is to literally break the automation capabilities with AppleScript.  If you envision a different solution, please leave a comment!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As others have written about, Apple appears to be making a hash out of the ability to automate tasks on macOS 10.14 (Mojave). I get it. In the age of hyper-connectivity there is a continuous assault on our computing environments by bad actors looking to extort some cash or otherwise ruin our day. Something needs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3318,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,21],"tags":[],"class_list":["post-3482","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apple","category-devops"],"_links":{"self":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3482"}],"collection":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/comments?post=3482"}],"version-history":[{"count":7,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3482\/revisions"}],"predecessor-version":[{"id":3492,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3482\/revisions\/3492"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media\/3318"}],"wp:attachment":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media?parent=3482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/categories?post=3482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/tags?post=3482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}