execguard

package
v1.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func SafeToExec(ctx context.Context, exec executor.Executor, binaryPath string) (bool, string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL