Skip to main content
The CapabilitySet class is the primary way to define what resources your sandboxed process can access. It provides methods for granting filesystem access, blocking network access, and managing command execution.

Constructor

Creates an empty capability set. By default, no filesystem paths are accessible and network access is allowed.

Methods

allowPath

Grant access to a directory and all its contents.
string
required
Absolute path to the directory. Must exist and be a directory.
AccessMode
required
Access level to grant: Read, Write, or ReadWrite.
Throws an error if the path does not exist or is not a directory.

allowFile

Grant access to a single file.
string
required
Absolute path to the file. Must exist and be a regular file.
AccessMode
required
Access level to grant: Read, Write, or ReadWrite.
Throws an error if the path does not exist or is not a file.

blockNetwork

Block all outbound network access. Once blocked, the process cannot make any network connections.

allowCommand

Add a command to the allow list. Commands on the allow list can be executed even if they would otherwise be blocked.
string
required
The command name to allow (e.g., "git", "npm").

blockCommand

Add a command to the block list. Blocked commands cannot be executed.
string
required
The command name to block (e.g., "curl", "wget").

platformRule

Add a raw platform-specific sandbox rule.
string
required
On macOS, this is a Seatbelt S-expression. Ignored on Linux.
Throws an error if the rule is malformed or attempts to grant dangerous access.

deduplicate

Remove duplicate filesystem capabilities, keeping the highest access level for each path.

pathCovered

Check if a path is covered by an existing directory capability.
string
required
The path to check.
boolean
true if the path would be accessible, false otherwise.

fsCapabilities

Get a list of all filesystem capabilities in this set.
FsCapabilityInfo[]
Array of capability objects with the following properties:
  • original: The path as originally specified
  • resolved: The canonicalized absolute path
  • access: Access mode string ("read", "write", or "read+write")
  • isFile: true if this is a file capability, false for directories
  • source: How the capability was added

summary

Get a human-readable summary of all capabilities.
string
Multi-line string describing all filesystem and network capabilities.

Properties

isNetworkBlocked

Returns true if network access has been blocked.

Example: Web Server Sandbox