QueryContext lets you check what operations would be permitted by a capability set without actually applying the sandbox. This is useful for validation, testing, and building permission-checking UIs.
Constructor
CapabilitySet
required
The capability set to query against.
The context captures a snapshot of the capabilities at creation time. Changes to the original
CapabilitySet after creating the context are not reflected.Methods
query_path
str
required
Path to check.
AccessMode
required
Requested access mode.
Allowed Result
When the operation would be permitted:Denied Results
When the operation would be blocked: Path not granted:Example
query_network
Allowed Result
Denied Result
Example
Use Cases
Configuration Validation
Validate a capability configuration before deployment:Permission Checking UI
Build an interactive permission checker:Testing Capability Sets
Write tests for your sandbox configuration:Related
- CapabilitySet - Build the capability set to query
- AccessMode - Access modes for queries