deno

package
v0.0.0-...-d45155d Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const StdStreamLimit int64 = 1 * 1024 * 1024

StdStreamLimit is 1MiB.

Variables

View Source
var ErrAllHost = fmt.Errorf("network permission without host is disallowed")

Functions

func DisallowGlobalUnicast

func DisallowGlobalUnicast(ip net.IP) (bool, error)

func DisallowInterfaceLocalMulticast

func DisallowInterfaceLocalMulticast(ip net.IP) (bool, error)

func DisallowLinkLocalMulticast

func DisallowLinkLocalMulticast(ip net.IP) (bool, error)

func DisallowLinkLocalUnicast

func DisallowLinkLocalUnicast(ip net.IP) (bool, error)

func DisallowLoopback

func DisallowLoopback(ip net.IP) (bool, error)

func DisallowMulticast

func DisallowMulticast(ip net.IP) (bool, error)

func DisallowPrivate

func DisallowPrivate(ip net.IP) (bool, error)

func DisallowUnspecified

func DisallowUnspecified(ip net.IP) (bool, error)

func ScanStderr

func ScanStderr(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanStderr is the extended version of ScanLines. It additionally treats the deno permission prompt as a line.

Types

type CheckFileError

type CheckFileError struct {
	Inner  error
	Stderr string
}

func (*CheckFileError) Error

func (e *CheckFileError) Error() string

func (*CheckFileError) Unwrap

func (e *CheckFileError) Unwrap() error

type CheckFileOptions

type CheckFileOptions struct {
	// TargetScript is the filename of the target script.
	TargetScript string
}

type CheckSnippetOptions

type CheckSnippetOptions struct {
	// TargetScript is the content of the target script.
	TargetScript string
}

type Checker

type Checker struct{}

func (*Checker) CheckFile

func (c *Checker) CheckFile(ctx context.Context, opts CheckFileOptions) error

func (*Checker) CheckSnippet

func (c *Checker) CheckSnippet(ctx context.Context, opts CheckSnippetOptions) error

type ErrorGlobalUnicast

type ErrorGlobalUnicast struct {
	IP net.IP
}

func (*ErrorGlobalUnicast) Error

func (e *ErrorGlobalUnicast) Error() string

type ErrorInterfaceLocalMulticast

type ErrorInterfaceLocalMulticast struct {
	IP net.IP
}

func (*ErrorInterfaceLocalMulticast) Error

type ErrorInvalidIP

type ErrorInvalidIP struct {
	Value string
}

func (*ErrorInvalidIP) Error

func (e *ErrorInvalidIP) Error() string

type ErrorLinkLocalMulticast

type ErrorLinkLocalMulticast struct {
	IP net.IP
}

func (*ErrorLinkLocalMulticast) Error

func (e *ErrorLinkLocalMulticast) Error() string

type ErrorLinkLocalUnicast

type ErrorLinkLocalUnicast struct {
	IP net.IP
}

func (*ErrorLinkLocalUnicast) Error

func (e *ErrorLinkLocalUnicast) Error() string

type ErrorLoopback

type ErrorLoopback struct {
	IP net.IP
}

func (*ErrorLoopback) Error

func (e *ErrorLoopback) Error() string

type ErrorMulticast

type ErrorMulticast struct {
	IP net.IP
}

func (*ErrorMulticast) Error

func (e *ErrorMulticast) Error() string

type ErrorNameUnmatched

type ErrorNameUnmatched struct {
	Expected PermissionName
	Actual   PermissionName
}

func (*ErrorNameUnmatched) Error

func (e *ErrorNameUnmatched) Error() string

type ErrorNoIP

type ErrorNoIP struct {
	Host string
}

func (*ErrorNoIP) Error

func (e *ErrorNoIP) Error() string

type ErrorPrivate

type ErrorPrivate struct {
	IP net.IP
}

func (*ErrorPrivate) Error

func (e *ErrorPrivate) Error() string

type ErrorUnspecified

type ErrorUnspecified struct {
	IP net.IP
}

func (*ErrorUnspecified) Error

func (e *ErrorUnspecified) Error() string

type HostPort

type HostPort struct {
	Host string
	IPv4 net.IP
	IPv6 net.IP
	Port string
}

func ParseHostPort

func ParseHostPort(s string) (*HostPort, error)

func (HostPort) MarshalText

func (p HostPort) MarshalText() ([]byte, error)

func (*HostPort) String

func (p *HostPort) String() string

func (*HostPort) UnmarshalText

func (p *HostPort) UnmarshalText(text []byte) error

type IPPolicy

type IPPolicy func(ip net.IP) (bool, error)

type IPPolicyPermissioner

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

func DisallowIPPolicy

func DisallowIPPolicy(policies ...IPPolicy) IPPolicyPermissioner

func (IPPolicyPermissioner) RequestPermission

func (p IPPolicyPermissioner) RequestPermission(ctx context.Context, pd PermissionDescriptor) (bool, error)

type PermissionDescriptor

type PermissionDescriptor struct {
	Name PermissionName `json:"name"`
	// run
	Command string `json:"command,omitempty"`
	// read, write, ffi
	Path string `json:"path,omitempty"`
	// net
	Host *HostPort `json:"host,omitempty"`
	// env
	Variable string `json:"variable,omitempty"`
	// sys
	Kind SysKind `json:"kind,omitempty"`
}

func LineToPermissionDescriptor

func LineToPermissionDescriptor(line string) (*PermissionDescriptor, bool)

func ParsePermissionDescriptor

func ParsePermissionDescriptor(name string, target string) (*PermissionDescriptor, bool)

type PermissionName

type PermissionName string
const (
	PermissionNameRun    PermissionName = "run"
	PermissionNameRead   PermissionName = "read"
	PermissionNameWrite  PermissionName = "write"
	PermissionNameNet    PermissionName = "net"
	PermissionNameEnv    PermissionName = "env"
	PermissionNameSys    PermissionName = "sys"
	PermissionNameFfi    PermissionName = "ffi"
	PermissionNameHrtime PermissionName = "hrtime"
)

type Permissioner

type Permissioner interface {
	RequestPermission(ctx context.Context, pd PermissionDescriptor) (bool, error)
}

type RunFileError

type RunFileError struct {
	Inner  error
	Stdout StdStream
	Stderr StdStream
}

func (*RunFileError) Error

func (e *RunFileError) Error() string

func (*RunFileError) Unwrap

func (e *RunFileError) Unwrap() error

type RunFileOptions

type RunFileOptions struct {
	// TargetScript is the filename of the target script.
	TargetScript string
	// Input is the filename of the input.
	Input string
	// Output is the filename of the output.
	Output string
}

type RunFileResult

type RunFileResult struct {
	Stdout StdStream
	Stderr StdStream
}

func (*RunFileResult) Wrap

func (r *RunFileResult) Wrap(err error) error

type RunGoValueOptions

type RunGoValueOptions struct {
	// TargetScript is the content of the target script.
	TargetScript string
	// Input is the input.
	Input interface{}
}

type RunGoValueResult

type RunGoValueResult struct {
	Output interface{}
	Stdout StdStream
	Stderr StdStream
}

type Runner

type Runner struct {
	// RunnerScript is the runner script that will import the target script
	// and execute the default function.
	RunnerScript string
	// Permissioner manages the permissions of the target script.
	Permissioner Permissioner
}

func (*Runner) RunFile

func (r *Runner) RunFile(ctx context.Context, opts RunFileOptions) (*RunFileResult, error)

func (*Runner) RunGoValue

func (r *Runner) RunGoValue(ctx context.Context, opts RunGoValueOptions) (*RunGoValueResult, error)

type StdStream

type StdStream = *ioutil.LimitedWriter[*bytes.Buffer]

type SysKind

type SysKind string
const (
	SysKindAll               SysKind = ""
	SysKindLoadavg           SysKind = "loadavg"
	SysKindHostname          SysKind = "hostname"
	SysKindSystemMemoryInfo  SysKind = "systemMemoryInfo"
	SysKindNetworkInterfaces SysKind = "networkInterfaces"
	SysKindosRelease         SysKind = "osRelease"
	//nolint:revive
	SysKindosUid SysKind = "uid"
	//nolint:revive
	SysKindosGid SysKind = "gid"
)

func ParseSysKind

func ParseSysKind(kind string) (SysKind, bool)

Jump to

Keyboard shortcuts

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