Skip to main content

A capability is one thing a plugin may do, written as a stable string such as launch.args, cdp:Network or page.script:example.com. A plugin declares the ones it needs in its metadata; a PluginSet grants them and checks them against what the host supports. Items are in seleniumbase_rs_plugin, defined in capability.rs, host.rs and switch_policy.rs of crates/seleniumbase-rs-plugin/src/.

Warning

For a native Rust plugin, capabilities are a declared contract, not a sandbox: the plugin can still call std directly. This version checks the required capabilities when the set is checked, and each change before_launch makes; the request guard refuses Fetch.* and merges Network.setBlockedURLs. It does not compare a plugin’s send, evaluate, add_init_script or packages with what it declared (see Limits). Only WebAssembly plugins are sandboxed.

Capability#

enum non_exhaustive seleniumbase_rs_plugin::Capability

One thing a plugin may do. Every variant has a string form (Display and FromStr), a risk, and an enforcement. A CapabilitySet keeps them sorted in the order of the variants above.

VariantStringRiskWASMNative
LaunchArgs: add browser switches (the refused list applies)launch.argsLowyesenforced
LaunchPrefs: set browser preferenceslaunch.prefsMediumyesenforced
LaunchHeadless: change headless modelaunch.headlessMediumyesenforced
LaunchNetwork: host rules, WebRTC policy, QUIClaunch.networkHighyesenforced
LaunchProxy: set the proxylaunch.proxyHighyesenforced
LaunchExtensions: load extensionslaunch.extensionsHighnoenforced
LaunchProfile: use the profile folderlaunch.profileMediumnoenforced
PageScript(HostScope::Hosts(..)): scripts on these hostspage.script:a.com,b.comLowyesenforced
PageScript(HostScope::Everywhere): scripts on every sitepage.script:*Highyesenforced
PageEvaluate: evaluate JavaScript in pagespage.evaluateMediumyesenforced
PageNavigate: navigate pagespage.navigateMediumyesenforced
Cdp(domain): use one DevTools domaincdp:NetworkMedium; Critical for Target and Browseryes, unless Criticalenforced
NetObserve: observe requests and responsesnet.observeLowyesenforced
NetSensitive: see cookies and authorization headersnet.sensitiveHighyesenforced
NetBodies: read response bodiesnet.bodiesHighyesenforced
NetIntercept: intercept and change requestsnet.interceptMediumyesenforced
NetFulfill: answer requests without the networknet.fulfillHighyesenforced
CookiesReadcookies.readHighyesenforced
CookiesWritecookies.writeHighyesenforced
StorageClearstorage.clearMediumyesenforced
Contexts: create browser contextscontextsMediumyesenforced
TestHooks: hook test start and endtest.hooksLowyesenforced
Task: run as a tasktaskMediumyesenforced
ArtifactsWrite: write files to the run’s outputartifacts.writeMediumyesenforced
HostNet(NetScope::Loopback)host.net:loopbackHighnodeclared only
HostNet(NetScope::Any)host.net:anyHighnodeclared only
HostFsRead(scope): read host fileshost.fs.read:temp, host.fs.read:run-output, host.fs.read:/a,/bHighnodeclared only
HostFsWrite(scope): write host fileshost.fs.write:temp, …Highnodeclared only
HostProcess: start host processeshost.processCriticalnodeclared only
Clock: read the clockclockLowyesenforced
Random: use randomnessrandomLowyesenforced
State { persist: false }: keep state for the runstateLowyesenforced
State { persist: true }: keep state across runsstate:persistLowyesenforced
Raw(RawKind::Cdp): any DevTools commandraw:cdpCriticalnoenforced
Raw(RawKind::Switches): any switch not refused for everyoneraw:switchesCriticalnoenforced

“WASM” is wasm_grantable(); “Native” is enforcement(false).

Capability::risk#

fn
returnRisk#

How dangerous the capability is, as in the table above.

PluginSet::with and Registry::plugin_set never grant a Critical capability; PluginSet::with_trusted must name each one.

Capability::wasm_grantable#

fn
returnbool#

Whether a WASM module or manifest may be granted it: not when it is Critical, nor for host.process, host.fs.read, host.fs.write, host.net, launch.extensions and launch.profile.

Capability::enforcement#

fn
wasmboolrequired#

Whether the plugin is a WASM module (true) or native Rust (false).

returnEnforcement#

DeclaredOnly for host.net, host.fs.read, host.fs.write and host.process on a native plugin; Enforced otherwise.

PluginSet::audit and sbrs plugin info report enforcement(false).

Capability::covers#

fn
wanted&Capabilityrequired#

The capability a plugin needs.

returnbool#

Whether holding self allows wanted.

Equal capabilities cover each other. Beyond that:

HoldingCovers
page.script:*every page.script
page.script:HOSTSpage.script of a subset of those hosts
host.net:anyhost.net:loopback too
raw:cdpevery cdp:DOMAIN
host.fs.read or host.fs.write of declared pathsthe same with a subset of the paths

raw:cdp does not cover raw:switches, and temp or run-output cover only themselves.

Display and FromStr#

impl impl fmt::Display for Capability, impl FromStr for Capability

The string forms in the table round-trip: text.parse::<Capability>()?.to_string() == text. The grammar is HEAD or HEAD:ARG, split at the first ::

  • page.script:* is every site; page.script:a.com,b.com is a host list (empty entries are dropped); page.script: alone is refused.
  • cdp:DOMAIN needs a domain; the domain is kept as written.
  • host.fs.read:SCOPE and host.fs.write:SCOPE take temp, run-output, or comma-separated paths.
  • host.net: takes loopback or any; state: takes persist; raw: takes cdp or switches.
  • Any other text is ParseCapabilityError.

ParseCapabilityError#

struct seleniumbase_rs_plugin::ParseCapabilityError

0String#

The text that does not parse.

CapabilitySet#

struct seleniumbase_rs_plugin::CapabilitySet

A set of capabilities, sorted and without repeats: the capabilities and optional of Metadata, and the grants of a plugin in a set. Build one with collect(), new and insert, or legacy.

CapabilitySet::new#

fn
returnCapabilitySet#

The empty set.

CapabilitySet::legacy#

fn
returnCapabilitySet#

What a plugin that declares nothing is treated as having: launch.args, launch.prefs, launch.headless, launch.proxy, launch.extensions, page.script:*, page.evaluate and raw:cdp.

CapabilitySet::insert#

fn
capabilityCapabilityrequired#

The capability to add; a repeat changes nothing.

CapabilitySet::covers#

fn
wanted&Capabilityrequired#

The capability a plugin needs.

returnbool#

Whether some member covers it (Capability::covers).

CapabilitySet::iter#

fn
returnimpl Iterator<Item = &Capability>#

The members, in order.

CapabilitySet::is_empty#

fn
returnbool#

Whether the set is empty.

CapabilitySet::union#

fn
other&CapabilitySetrequired#

The other set.

returnCapabilitySet#

The members of both.

CapabilitySet::without_critical#

fn
returnCapabilitySet#

The members that are not Risk::Critical: the default grants are capabilities.union(&optional).without_critical().

HostScope#

enum seleniumbase_rs_plugin::HostScope

Which sites a page script may run on: the scope of Capability::PageScript.

HostScopeenum#

NetScope#

enum seleniumbase_rs_plugin::NetScope

Which network peers a plugin may talk to from the host: the scope of Capability::HostNet.

NetScopeenum#

PathScope#

enum seleniumbase_rs_plugin::PathScope

Which files a plugin may use: the scope of Capability::HostFsRead and HostFsWrite.

PathScopeenum#

RawKind#

enum seleniumbase_rs_plugin::RawKind

The kind of raw access a plugin has: the scope of Capability::Raw. Both are Critical.

RawKindenum#

Risk#

enum seleniumbase_rs_plugin::Risk

How dangerous a capability is. Ordered from Low to Critical.

Riskenum#

Enforcement#

enum seleniumbase_rs_plugin::Enforcement

Whether the host stops a plugin that goes beyond a capability, as Capability::enforcement classifies it.

Enforcementenum#

HostInfo#

struct seleniumbase_rs_plugin::HostInfo

What the host that runs a set supports, passed to PluginSet::check_with so the set can refuse a plugin whose required capabilities the host cannot provide (PluginError::Unsupported).

Capabilitiescdp()webdriver(Chromium)webdriver(Firefox or Safari)embedded()
page.script, page.evaluate, test.hooks, clock, randomyesyesyesyes
cdp:*, raw:*yesyesnono
net.*, contextsyesnonono
Every other capability (launch.*, page.navigate, cookies.*, storage.clear, task, artifacts.write, host.*, state)yesyesyesno

HostInfo::cdp#

fn const
returnHostInfo#

The pure CDP engine, which supports everything. PluginSet::check uses it.

HostInfo::webdriver#

fn
familyBrowserFamilyrequired#

The browser’s family.

returnHostInfo#

HostKind::WebDriverChromium for Chromium, HostKind::WebDriverOther for any other family.

HostInfo::embedded#

fn const
returnHostInfo#

A Tauri webview. The WebDriver engine re-checks a set against it when the server answers browserName: tauri.

HostInfo::kind#

fn const
returnHostKind#

The kind of host.

HostInfo::name#

fn const
return&'static str#

A short name for messages: the CDP engine, WebDriver with Chromium, WebDriver with Firefox or Safari, an embedded webview.

HostInfo::supports#

fn
capability&Capabilityrequired#

A capability a plugin requires.

returnbool#

Whether the host can provide it, as in the table under HostInfo.

HostKind#

enum non_exhaustive seleniumbase_rs_plugin::HostKind

HostKindenum#

switch_policy#

mod seleniumbase_rs_plugin::switch_policy

The one list of browser switches that no plugin may add, and of the features no plugin may turn on or off. PluginSet::before_launch applies it to every plugin, legacy ones included, unless the plugin holds raw:switches. seleniumbase-rs has a test (tests/plugin_switch_policy.rs) that fails when a switch its own stealth layer forbids is missing from REFUSED_SWITCHES.

REFUSED_SWITCHES#

const seleniumbase_rs_plugin::switch_policy::REFUSED_SWITCHES

Switch names (no dashes, lower case) refused for every plugin:

KindSwitches
Process launchersrenderer-cmd-prefix, utility-cmd-prefix, zygote-cmd-prefix, gpu-launcher, ppapi-plugin-launcher, plugin-launcher, browser-subprocess-path, nacl-gdb, nacl-gdb-script
Sandbox and securityno-sandbox, disable-setuid-sandbox, disable-gpu-sandbox, no-zygote, disable-web-security, ignore-certificate-errors, ignore-certificate-errors-spki-list, disable-site-isolation-trials, allow-file-access-from-files, unsafely-treat-insecure-origin-as-secure, allow-running-insecure-content, single-process, js-flags
Network (use the LaunchSettings fields)proxy-server, proxy-pac-url, host-resolver-rules, host-rules
Remote debuggingremote-debugging-port, remote-debugging-address, remote-debugging-pipe, remote-allow-origins
Extensions and profileload-extension, load-component-extension, disable-extensions-except, user-data-dir
Logs and dumpslog-net-log, net-log-capture-mode, enable-logging, log-file, disk-cache-dir, crash-dumps-dir

REFUSED_FEATURES#

const seleniumbase_rs_plugin::switch_policy::REFUSED_FEATURES

Feature names (lower case) that may not be disabled or enabled, through --disable-features=, --enable-features=, or the disable_features and enable_features fields of LaunchSettings.

switch_name#

fn seleniumbase_rs_plugin::switch_policy::switch_name

arg&strrequired#

A command-line argument.

returnOption<String>#

The switch name of arg: surrounding spaces, the leading -- or - and any =value removed, in lower case. None when arg is not a switch.

refusal#

fn seleniumbase_rs_plugin::switch_policy::refusal

arg&strrequired#

A command-line argument a plugin adds.

returnOption<String>#

Why arg is refused, or None when it is allowed: the switch `--NAME` is refused for every plugin, or, for a --disable-features= or --enable-features= list naming a refused feature, the feature `NAME` may not be changed by a plugin. Every spelling counts: -name, upper case, surrounding spaces.

feature_refused#

fn seleniumbase_rs_plugin::switch_policy::feature_refused

feature&strrequired#

A feature name, as in --disable-features=; anything after a : is ignored.

returnbool#

Whether the feature is in REFUSED_FEATURES, compared in lower case.