Documentation
¶
Index ¶
- Variables
- func Close(executionId string)
- func FailWithReason(page *rod.Page, e *proto.FetchRequestPaused) error
- func GetLfaAllowed(options *types.Options) bool
- func GetNetworkPolicy(ctx context.Context) *networkpolicy.NetworkPolicy
- func GlobalGuardBytesBufferAlloc() error
- func GlobalRestoreBytesBufferAlloc()
- func GuardThreadsOrDefault(current int) int
- func HasExecutionContext(ctx context.Context) bool
- func Init(options *types.Options) error
- func InitHeadless(options *types.Options)
- func IsHostAllowed(executionId string, targetUrl string) bool
- func IsLfaAllowed(options *types.Options) bool
- func IsLowOnMemory() bool
- func IsRestrictLocalNetworkAccess(options *types.Options) bool
- func NewJSRuntime() *goja.Runtime
- func NormalizePath(options *types.Options, filePath string) (string, error)
- func NormalizePathWithExecutionId(executionId string, filePath string) (string, error)
- func SetLfaAllowed(options *types.Options)
- func ShouldInit(id string) bool
- func StartActiveMemGuardian(ctx context.Context)
- func StopActiveMemGuardian()
- func ValidateNFailRequest(options *types.Options, page *rod.Page, e *proto.FetchRequestPaused) error
- func WithAutoExecutionContext(ctx context.Context) context.Context
- func WithExecutionID(ctx context.Context, executionContext *ExecutionContext) context.Context
- type ContextKey
- type Dialers
- type ExecutionContext
Constants ¶
This section is empty.
Variables ¶
var ( ErrURLDenied = errkit.New("headless: url dropped by rule") ErrHostDenied = errorTemplate{/* contains filtered or unexported fields */} )
var ( MaxThreadsOnLowMemory = env.GetEnvOrDefault("MEMGUARDIAN_THREADS", 0) MaxBytesBufferAllocOnLowMemory = env.GetEnvOrDefault("MEMGUARDIAN_ALLOC", 0) )
var ( // LfaAllowed means local file access is allowed LfaAllowed *mapsutil.SyncLockMap[string, bool] )
var Memoizer *memoize.Memoizer
Functions ¶
func FailWithReason ¶
func FailWithReason(page *rod.Page, e *proto.FetchRequestPaused) error
FailWithReason fails request with AccessDenied reason
func GetLfaAllowed ¶ added in v3.4.8
func GetNetworkPolicy ¶ added in v3.4.8
func GetNetworkPolicy(ctx context.Context) *networkpolicy.NetworkPolicy
func GlobalGuardBytesBufferAlloc ¶ added in v3.2.1
func GlobalGuardBytesBufferAlloc() error
Global setting
func GlobalRestoreBytesBufferAlloc ¶ added in v3.2.1
func GlobalRestoreBytesBufferAlloc()
Global setting
func GuardThreadsOrDefault ¶ added in v3.2.1
GuardThreads on caller
func HasExecutionContext ¶ added in v3.4.8
HasExecutionID checks if the context has an execution ID
func InitHeadless ¶
InitHeadless initializes headless protocol state
func IsHostAllowed ¶
IsHostAllowed checks if the host is allowed by network policy
func IsLfaAllowed ¶ added in v3.4.8
IsLfaAllowed returns whether local file access is allowed
func IsLowOnMemory ¶ added in v3.2.1
func IsLowOnMemory() bool
func IsRestrictLocalNetworkAccess ¶ added in v3.4.8
func NewJSRuntime ¶
NewJSRuntime returns a new javascript runtime with defaults set i.e sourcemap parsing is disabled by default
func NormalizePath ¶
Normalizepath normalizes path and returns absolute path it returns error if path is not allowed this respects the sandbox rules and only loads files from allowed directories
func NormalizePathWithExecutionId ¶ added in v3.4.8
func SetLfaAllowed ¶ added in v3.4.8
func ShouldInit ¶ added in v3.2.9
func StartActiveMemGuardian ¶ added in v3.2.1
func StopActiveMemGuardian ¶ added in v3.2.1
func StopActiveMemGuardian()
func ValidateNFailRequest ¶
func ValidateNFailRequest(options *types.Options, page *rod.Page, e *proto.FetchRequestPaused) error
ValidateNFailRequest validates and fails request if the request does not respect the rules, it will be canceled with reason
func WithAutoExecutionContext ¶ added in v3.4.8
WithAutoExecutionContext creates a new context with an automatically generated execution ID If the input context already has an execution ID, it will be preserved
func WithExecutionID ¶ added in v3.4.8
func WithExecutionID(ctx context.Context, executionContext *ExecutionContext) context.Context
WithExecutionID adds an execution ID to the context
Types ¶
type Dialers ¶ added in v3.4.8
type Dialers struct {
Fastdialer *fastdialer.Dialer
RawHTTPClient *rawhttp.Client
DefaultHTTPClient *retryablehttp.Client
HTTPClientPool *mapsutil.SyncLockMap[string, *retryablehttp.Client]
NetworkPolicy *networkpolicy.NetworkPolicy
LocalFileAccessAllowed bool
RestrictLocalNetworkAccess bool
sync.Mutex
}
func GetDialers ¶ added in v3.4.8
func GetDialersWithId ¶ added in v3.4.8
type ExecutionContext ¶ added in v3.4.8
type ExecutionContext struct {
ExecutionID string
}
func GetExecutionContext ¶ added in v3.4.8
func GetExecutionContext(ctx context.Context) *ExecutionContext
GetExecutionID retrieves the execution ID from the context Returns empty string if no execution ID is set