jsonnetsecure

package
v0.0.0-...-398cf1c Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProcessPoolClosed = errors.New("jsonnetsecure: process pool closed")
)

Functions

func JsonnetTestBinary

func JsonnetTestBinary(t testing.TB) string

func NewJsonnetCmd

func NewJsonnetCmd() *cobra.Command

Types

type DefaultProvider

type DefaultProvider struct {
	Subcommand string
	Pool       Pool
}

DefaultProvider provides a secure VM by calling the currently running the current binary with the provided subcommand.

func (*DefaultProvider) JsonnetVM

func (p *DefaultProvider) JsonnetVM(ctx context.Context) (VM, error)

type ErrorImporter

type ErrorImporter struct{}

ErrorImporter errors when calling "import".

func (*ErrorImporter) Import

func (importer *ErrorImporter) Import(importedFrom, importedPath string) (contents jsonnet.Contents, foundAt string, err error)

Import fetches data from a map entry. All paths are treated as absolute keys.

type Option

type Option func(o *vmOptions)

func WithJsonnetBinary

func WithJsonnetBinary(jsonnetBinaryPath string) Option

func WithProcessArgs

func WithProcessArgs(args ...string) Option

func WithProcessIsolatedVM

func WithProcessIsolatedVM(ctx context.Context) Option

func WithProcessPool

func WithProcessPool(p Pool) Option

type Pool

type Pool interface {
	Close()
	// contains filtered or unexported methods
}

func NewProcessPool

func NewProcessPool(size int) Pool

type ProcessVM

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

func (*ProcessVM) EvaluateAnonymousSnippet

func (p *ProcessVM) EvaluateAnonymousSnippet(filename string, snippet string) (_ string, err error)

func (*ProcessVM) ExtCode

func (p *ProcessVM) ExtCode(key string, val string)

func (*ProcessVM) ExtVar

func (p *ProcessVM) ExtVar(key string, val string)

func (*ProcessVM) TLACode

func (p *ProcessVM) TLACode(key string, val string)

func (*ProcessVM) TLAVar

func (p *ProcessVM) TLAVar(key string, val string)

type TestProvider

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

TestProvider provides a secure VM by running go build on github. com/ory/x/jsonnetsecure/cmd.

func NewTestProvider

func NewTestProvider(t testing.TB) *TestProvider

func (*TestProvider) JsonnetVM

func (p *TestProvider) JsonnetVM(ctx context.Context) (VM, error)

type VM

type VM interface {
	EvaluateAnonymousSnippet(filename string, snippet string) (json string, formattedErr error)
	ExtCode(key string, val string)
	ExtVar(key string, val string)
	TLACode(key string, val string)
	TLAVar(key string, val string)
}

func MakeSecureVM

func MakeSecureVM(opts ...Option) VM

func NewProcessPoolVM

func NewProcessPoolVM(opts *vmOptions) VM

func NewProcessVM

func NewProcessVM(opts *vmOptions) VM

type VMProvider

type VMProvider interface {
	// JsonnetVM creates a new secure process-isolated Jsonnet VM whose
	// execution is bound to the provided context, i.e.,
	// cancelling the context will terminate the VM process.
	JsonnetVM(context.Context) (VM, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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