isolate

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package isolate runs spec parsing in a child process (SPEC §5.3, T2).

libopenapi parses on goroutines it starts itself, and a panic on one of them cannot be recovered: in-process, one hostile spec would crash plugit (pb33f/libopenapi#705). The parent re-executes the plugit binary with ChildArg, sends the spec on stdin and reads the manifest from stdout. A crash, malformed output, oversized output or a timeout in the child becomes an ordinary error in the parent.

The child gets an almost empty environment, so secrets held in the parent's env vars never reach the code that handles untrusted input.

Index

Constants

View Source
const (
	DefaultTimeout   = 30 * time.Second
	DefaultMaxOutput = 256 << 20
)

Defaults applied when the corresponding Runner field is zero.

View Source
const ChildArg = "__parse"

ChildArg is the hidden first argument that turns plugit into a parse child.

Variables

View Source
var (
	ErrParserCrashed = errors.New("spec parser crashed")
	ErrParseTimeout  = errors.New("spec parser timed out")
)

Sentinel errors callers can match with errors.Is.

Functions

func ChildMain

func ChildMain(stdin io.Reader, stdout io.Writer) int

ChildMain is the child side: it reads one request from stdin, parses it and writes one response to stdout. It returns the process exit code.

func Parse

func Parse(ctx context.Context, data []byte, opts openapi.Options) (*model.Manifest, error)

Parse is openapi.Parse in a child process. opts.Logger is not used.

Types

type Runner

type Runner struct {
	Exe       string
	Args      []string
	Env       []string
	Timeout   time.Duration
	MaxOutput int64
}

Runner starts parse children.

func NewRunner

func NewRunner() (*Runner, error)

NewRunner returns a Runner that re-executes the current binary.

func (*Runner) Parse

func (r *Runner) Parse(ctx context.Context, data []byte, opts openapi.Options) (*model.Manifest, error)

Parse runs one parse child.

Jump to

Keyboard shortcuts

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