macOS sandbox profiles used to be able to include a trace
command that would write all the denied operations to a sandbox profile, allowing a profile to be iterativley built up. Apple removed that functionality for reasons explained below.
trace.sh
examines the kernel log for the denied operations and creates the relevant allow rules in a sandbox profile, just like the sandbox profile trace
command used to.
shrink.sh
tries to reduce a sandbox profile to the minimum lines necessary.
It's very rough and ready at the moment (check the sed regex'es in the script to see what I mean) and needs more testing with a wider set of use cases.