I manage AppleScripts for around 40 users. We just changed a lot of environment parameters and I have trouble with Apple Security. I am confused about what is happening here.
We were using Mojave and using MySQL for communicate with databases. Also Satimage and XMLLib in addition to our own Script Libraries.
Everything rewritten to use JSON Helper, curl/PHP and MariaDB. RegExAndStuff replaced Satimage. Tiny XML-files handled with System Events XML, and larger XML-stuff with AppleScriptObjC. Pashua for dialogs. Homebrew for PHP, Python, MariaDB, ImageMagick etc… We then moved to Monterey.
So many things have changed.
No such problems on Mojave, but under Monterey some scripts fails on some macs. Randomly, or sometimes nearly always. A script that has run fine every day for weeks may suddenly start to fail. On one or two of my users. But running just fine for others. Fail, as in just choked – without any dialog.
I am quite sure the problem is related to Apple TCC Security. Running the scripts from Script Debugger always works, but they may (or may not) fail silently when run either as Script Applications or as script files from ie InDesigns Script Panel.
Strange thing is that if I try many times, they will sometimes execute just fine. Say if I run a script 10 times in a row it may execute on 3rd, 5th and 9th attempt. On the rest it is stopped by Apple Security:
Example log when it is stopped by TCC:
2022-10-10 10:07:08.339026+0200 0x1e15159 Error 0x1688bed 19803 0 tccd: [com.apple.TCC:access] Prompting policy for hardened runtime; service: kTCCServiceAppleEvents requires entitlement com.apple.security.automation.apple-events but it is missing for accessing={<TCCDProcess: identifier=com.vidblishen.jsonhelper, pid=35329, auid=502, euid=502, binary_path=/Applications/JSON Helper.app/Contents/MacOS/JSON Helper>}, requesting={<TCCDProcess: identifier=com.vidblishen.jsonhelper, pid=35329, auid=502, euid=502, binary_path=/Applications/JSON Helper.app/Contents/MacOS/JSON Helper>},
But it does only happen randomly to some scripts, on only some Macs (and other scripts using JSON helper runs just fine on the same Mac). It is difficult to debug as it will always run from Script Debugger.
If this is “security” why is it so random? How can I bless JSON helper to be always allowed to run?
I have tried to give JSON Helper “Full Disk Access” in the security pane, but no avail. It has no quarrentine xattr. Tried version 1.11 and 1.2.
I have tried to reset the TCC database for AE, “tccutil reset AppleEvents”
and also a total reset; tccutil “reset SystemPolicyAllFiles”
This seems to work some of the time on some Macs, but is no silver bullet. It is also highly annoying for users as every prompt is reset. (Hello Windows Vista!)
My scripts and own libraries are all code signed, but not notarized.
I have not code signed RegExAndStuff (should I?)
I have around 50 different scripts, with some executed 100s of times each day. I guess they run just fine about 95% of the time. But then suddenly, for some random user one of them starts to fail often.
Anyone else seeing this? Any suggestions on what I can do?