sandbox

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sandbox provides isolated execution environment for protocol decoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy struct {
	MaxMemoryMB    int           `json:"max_memory_mb"`
	MaxCPUTime     time.Duration `json:"max_cpu_time"`
	MaxDecodeDepth int           `json:"max_decode_depth"`
	MaxOutputSize  int           `json:"max_output_size"`
	MaxNestLevel   int           `json:"max_nest_level"`
}

Policy defines sandbox security constraints.

func DefaultPolicy

func DefaultPolicy() *Policy

DefaultPolicy returns a default sandbox policy.

type Result

type Result struct {
	Success   bool           `json:"success"`
	Data      map[string]any `json:"data,omitempty"`
	BytesRead int            `json:"bytes_read,omitempty"`
	Error     string         `json:"error,omitempty"`
	Duration  time.Duration  `json:"duration"`
	MemUsed   uint64         `json:"mem_used_bytes"`
}

Result holds the sandbox execution result.

type Sandbox

type Sandbox struct {
	// contains filtered or unexported fields
}

Sandbox provides isolated protocol decoding.

func NewSandbox

func NewSandbox(lib *protocol.Library, policy *Policy) *Sandbox

NewSandbox creates a new sandbox with the given policy.

func (*Sandbox) Decode

func (s *Sandbox) Decode(protoName string, data []byte) *Result

Decode decodes data in the sandbox with resource limits.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL