Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type AppConfig struct {
IsLeakless bool `mapstructure:"leakless"`
BlockResources string `mapstructure:"block_resources"`
BlockTrackers bool `mapstructure:"block_trackers"`
NoSandbox bool `mapstructure:"no_sandbox"`
DebugEndpoints bool `mapstructure:"debug_endpoints"`
LogFormat string `mapstructure:"log_format"`
MaxProcesses int `mapstructure:"max_processes"`
Expand Down Expand Up @@ -133,6 +134,7 @@ var flagToConfigKey = map[string]string{
"cb_recovery": "circuit_breaker.recovery_seconds",
"cb_successes": "circuit_breaker.successes",
"log_format": "app.log_format",
"no-sandbox": "app.no_sandbox",
}

var RootCmd = &cobra.Command{
Expand Down Expand Up @@ -186,6 +188,7 @@ func sanitizedConfigForLog(cfg Config) map[string]interface{} {
"leakless": cfg.App.IsLeakless,
"block_resources": cfg.App.BlockResources,
"block_trackers": cfg.App.BlockTrackers,
"no_sandbox": cfg.App.NoSandbox,
"debug_endpoints": cfg.App.DebugEndpoints,
"log_format": cfg.App.LogFormat,
"max_processes": cfg.App.MaxProcesses,
Expand Down Expand Up @@ -407,6 +410,7 @@ func setConfigDefaults(v *viper.Viper) {
v.SetDefault("app.leakless", false)
v.SetDefault("app.block_resources", "")
v.SetDefault("app.block_trackers", false)
v.SetDefault("app.no_sandbox", false)
v.SetDefault("app.debug_endpoints", false)
v.SetDefault("app.max_processes", 4)
v.SetDefault("app.idle_ttl", "10m")
Expand Down Expand Up @@ -468,4 +472,5 @@ func init() {
RootCmd.PersistentFlags().IntVar(&config.CircuitBreaker.RecoverySeconds, "cb_recovery", 60, "Seconds before retrying an engine with open circuit")
RootCmd.PersistentFlags().IntVar(&config.CircuitBreaker.Successes, "cb_successes", 2, "Consecutive successful half-open checks needed to close circuit")
RootCmd.PersistentFlags().StringVar(&config.App.LogFormat, "log_format", "", "Log format: json or text (default: json in production, text in debug)")
RootCmd.PersistentFlags().BoolVar(&config.App.NoSandbox, "no-sandbox", false, "Launch browser with --no-sandbox (for environments where the sandbox SUID helper is unavailable)")
}
2 changes: 2 additions & 0 deletions cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ func newCLIExtractBrowser(cfg extractpkg.Config, proxyURL string, captchaSolverE
BrowserPath: config.App.BrowserPath,
ProxyURL: proxyURL,
Insecure: config.Server.Insecure,
NoSandbox: config.App.NoSandbox,
BlockResourceTypes: blockedResourceTypes,
BlockTrackers: config.App.BlockTrackers,
}
Expand Down Expand Up @@ -363,6 +364,7 @@ func searchBrowser(ctx context.Context, spec engineSpec, query core.Query, brows
BrowserPath: config.App.BrowserPath,
ProxyURL: browserProxyURL,
Insecure: config.Server.Insecure,
NoSandbox: config.App.NoSandbox,
BlockResourceTypes: blockedResourceTypes,
BlockTrackers: config.App.BlockTrackers,
}
Expand Down
1 change: 1 addition & 0 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func buildFingerprintBrowserOptions() core.BrowserOpts {
Timeout: time.Second * time.Duration(config.App.Timeout),
BrowserPath: config.App.BrowserPath,
Insecure: config.Server.Insecure,
NoSandbox: config.App.NoSandbox,
BlockResourceTypes: blockedResourceTypes,
BlockTrackers: config.App.BlockTrackers,
}
Expand Down
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ app:
leave_head: false # Keep tabs open after request
block_resources: "image,font,css,media" # Block heavy subresources in browser mode
block_trackers: true # Block known tracker domains
no_sandbox: false # Launch browser with --no-sandbox (use when the sandbox SUID helper is unavailable, e.g. nix on non-NixOS)
max_processes: 6 # Concurrent Chrome processes
idle_ttl: 5m # close a Chrome that has not served traffic for this long

Expand Down
7 changes: 7 additions & 0 deletions core/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ type BrowserOpts struct {
ProxyLaneStore *LaneStore
// Insecure allows invalid TLS certificates for browser requests.
Insecure bool
// NoSandbox launches Chromium with --no-sandbox. Needed when the sandbox
// helper binary cannot get the SUID bit (e.g. /nix/store is read-only).
NoSandbox bool
// UserAgent optionally overrides browser-reported user agent during emulation.
UserAgent string
// BlockResourceTypes are blocked during page navigation when non-empty.
Expand Down Expand Up @@ -293,6 +296,9 @@ func NewBrowser(opts BrowserOpts) (*Browser, error) {
} else {
l = l.Headless(false)
}
if opts.NoSandbox {
l = l.NoSandbox(true)
}
if path != "" {
logrus.WithField("browser_path", path).Debug("Using browser binary")
l = l.Bin(path)
Expand Down Expand Up @@ -355,6 +361,7 @@ func browserOptsLogFields(opts BrowserOpts) logrus.Fields {
"browser_path_configured": strings.TrimSpace(opts.BrowserPath) != "",
"proxy": maskedProxyLogValue(opts.ProxyURL),
"insecure": opts.Insecure,
"no_sandbox": opts.NoSandbox,
"user_agent_override": strings.TrimSpace(opts.UserAgent) != "",
"block_resource_types": len(opts.BlockResourceTypes),
"block_trackers": opts.BlockTrackers,
Expand Down