Documentation
¶
Overview ¶
Package execguard decides whether a detector may safely launch a third-party binary on this machine.
On macOS, executing a quarantined binary (com.apple.quarantine xattr, set by browser downloads and Homebrew cask installs) makes Gatekeeper assess it; when the binary or a native library it loads is not notarized, the OS shows a "could not verify … free of malware / Move to Bin" dialog in the logged-in user's session — a scary popup for something the user never ran themselves. SafeToExec answers, without any UI side effects, whether that would happen, so version probes can skip the exec (reporting "unknown") instead of triggering it. This generalizes the existing IsAppleCLTStub guard (which prevents the analogous Command Line Tools install prompt).
On Linux the cause differs and the effect is the same: a packaged Electron app does not implement --version (only the unpackaged `electron` binary's default app does), so the flag is ignored and its window opens on the user's desktop. Reported by an Ubuntu 22.04 customer via LM Studio.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SafeToExec ¶
SafeToExec reports whether launching binaryPath is safe from a GUI-popup perspective, and when it is not, why. Windows always returns true.
The reason is returned rather than left to callers to describe: they log it, and the cause is platform-specific, so a hardcoded message goes stale the moment a platform is added. It is "" when safe.
On macOS it resolves symlinks, then checks the binary and its containing directory for the com.apple.quarantine attribute (cask installs quarantine the whole install tree, so the parent dir catches partially-cleared installs). Unquarantined binaries are safe: Gatekeeper only assesses quarantined files. For quarantined ones, `spctl --assess --type execute` gives Gatekeeper's verdict silently — accepted means executing shows no popup; rejected (or any spctl failure, conservatively) means skip.
Both probes execute only Apple-provided utilities (/usr/bin/xattr, /usr/sbin/spctl), which carry none of the third-party-binary risk this package exists to avoid.
On Linux it answers whether the binary is an Electron app's GUI entry point, purely from stats.
Types ¶
This section is empty.