portalrunner

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 27 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 portalrunner validates protected ephemeral portal-runner definitions and owns their host-side temporary state.

Index

Constants

View Source
const (

	// HostedCellRemoteDesktop exercises portal-backed pointer and keyboard
	// input in a disposable desktop guest.
	HostedCellRemoteDesktop = "remote-desktop"
	// HostedCellScreenCast exercises persistent portal-backed capture in a
	// disposable desktop guest.
	HostedCellScreenCast = "screencast"
	// HostedCellDisplayBounds exercises read-only public display geometry
	// without opening a portal session or exposing X11 to the test process.
	HostedCellDisplayBounds = "display-bounds"

	// HostedTopologySingle preserves the established one-output portal run.
	HostedTopologySingle = "single-output"
	// HostedTopologyMulti enables the manifest-bound two-output experiment.
	HostedTopologyMulti = "multi-output"
)
View Source
const (
	// ManifestSchemaVersion identifies the protected runner definition format.
	ManifestSchemaVersion = "1"
	// HostedGuestEnvKey gates commands that may reconfigure the disposable
	// hosted guest desktop.
	HostedGuestEnvKey = "ROBOTGO_HOSTED_GUEST"
	// HostedExpectedOutputsEnvKey carries the encoded logical topology for
	// consent-free hosted display-bounds evidence.
	HostedExpectedOutputsEnvKey = "ROBOTGO_HOSTED_EXPECTED_OUTPUTS"
	// HostedBoundsVariantEnvKey identifies which public output implementation
	// the hosted bounds contract is exercising.
	HostedBoundsVariantEnvKey = "ROBOTGO_HOSTED_BOUNDS_VARIANT"
	// HostedBoundsVariantNativeCGO identifies the native-CGO Wayland client.
	HostedBoundsVariantNativeCGO = "native-cgo"
	// HostedBoundsVariantPureGo identifies the Pure-Go Wayland client.
	HostedBoundsVariantPureGo = "pure-go"
	// PortalMultiOutputEnvKey enables the hosted multi-output portal contract.
	PortalMultiOutputEnvKey = "ROBOTGO_PORTAL_MULTI_OUTPUT"
	// PortalExpectedOutputsEnvKey carries the encoded hosted output topology.
	PortalExpectedOutputsEnvKey = "ROBOTGO_PORTAL_EXPECTED_OUTPUTS"
)

Variables

This section is empty.

Functions

func BuildImage

func BuildImage(
	ctx context.Context,
	options ImageBuildOptions,
) (imagePath string, returnError error)

BuildImage creates or reuses the image identified by the exact manifest digest. It returns a path under the external private state root.

func CleanupAbandonedRuns

func CleanupAbandonedRuns(ctx context.Context, stateRoot string) error

CleanupAbandonedRuns stops verified QEMU processes and removes every sentinel-owned transient run under a validated state root. Persistent images and unrelated entries are never removed.

func CleanupRun

func CleanupRun(stateRoot, runDirectory string) error

CleanupRun removes only a sentinel-owned direct child of the validated state root. Symlinks and unrelated paths fail closed.

func ConfigureHostedDisplay

func ConfigureHostedDisplay(
	ctx context.Context,
	manifest Manifest,
	output io.Writer,
) error

ConfigureHostedDisplay applies and verifies the manifest-bound topology inside a disposable hosted guest. Callers must independently ensure this is never invoked against a developer desktop.

func CreateRun

func CreateRun(stateRoot string) (string, error)

CreateRun creates one private direct child owned by the runner supervisor.

func HostedDisplayFailureStage

func HostedDisplayFailureStage(err error) string

HostedDisplayFailureStage returns only an allowlisted, privacy-safe stage name for a topology failure. It never exposes connector or mode identifiers.

func HostedStreamEvidenceFailureStage

func HostedStreamEvidenceFailureStage(err error) string

HostedStreamEvidenceFailureStage returns a bounded, privacy-safe validation category without exposing transient portal identifiers.

func PrepareStateRoot

func PrepareStateRoot(path, repositoryRoot string) error

PrepareStateRoot creates or validates private runner storage outside the repository. Images may persist there; per-job overlays are separate runs.

func ProbeImage

func ProbeImage(
	ctx context.Context,
	options ImageProbeOptions,
) (returnError error)

ProbeImage proves that the pinned image starts the required local GNOME portal session and can reach an allowlisted HTTPS endpoint only via proxy.

func RunHosted

func RunHosted(
	ctx context.Context,
	options HostedRuntimeOptions,
) (returnError error)

RunHosted transfers the exact clean commit into a disposable guest and runs one integration cell. Portal cells drive desktop consent independently through QMP; read-only cells do not create a portal session. The runner does not register a GitHub Actions runner or consume tokens.

func RunProtectedGNOME

func RunProtectedGNOME(
	ctx context.Context,
	options ProtectedRuntimeOptions,
) (returnError error)

RunProtectedGNOME boots one visible disposable GNOME VM, binds it to one approved GitHub workflow attempt, and destroys the VM after at most one job.

func ValidateHostedStreamEvidence

func ValidateHostedStreamEvidence(
	display HostedDisplay,
	screenCastVersion uint32,
	streams []HostedStreamEvidence,
) error

ValidateHostedStreamEvidence validates the mandatory stream identity and any optional topology metadata exposed by the negotiated ScreenCast interface without returning transient identifiers in errors.

func WriteHostedDisplayFailureMarker

func WriteHostedDisplayFailureMarker(output io.Writer, err error) error

WriteHostedDisplayFailureMarker emits only the allowlisted stage marker used by the independent host controller.

Types

type Artifact

type Artifact struct {
	Version string `json:"version"`
	URL     string `json:"url"`
	SHA256  string `json:"sha256"`
}

Artifact identifies immutable downloaded image content.

type CONNECTProxy

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

CONNECTProxy restricts a guest to TLS tunnels for manifest-allowlisted dependency hosts. It never parses or retains tunneled content.

func NewCONNECTProxy

func NewCONNECTProxy(network NetworkConfig) (*CONNECTProxy, error)

NewCONNECTProxy constructs a bounded allowlist proxy.

func (*CONNECTProxy) Serve

func (proxy *CONNECTProxy) Serve(ctx context.Context, listener net.Listener) error

Serve handles proxy traffic until context cancellation or a listener error.

func (*CONNECTProxy) ServeHTTP

func (proxy *CONNECTProxy) ServeHTTP(response http.ResponseWriter, request *http.Request)

ServeHTTP accepts only allowlisted HTTPS CONNECT requests.

type CommandExecutor

type CommandExecutor interface {
	Run(
		ctx context.Context,
		name string,
		args []string,
		stdin io.Reader,
		output io.Writer,
	) error
}

CommandExecutor runs one host-side provisioning command without exposing command arguments in returned errors.

type HostedDisplay

type HostedDisplay struct {
	Outputs []HostedOutput `json:"outputs"`
}

HostedDisplay defines the exact logical monitor topology used by explicit multi-output runs. Outputs are ordered by virtual scanout; the first output is the primary display used for consent interaction.

func ParseHostedDisplay

func ParseHostedDisplay(encoded string) (HostedDisplay, error)

ParseHostedDisplay decodes only the canonical representation emitted by Encode and re-applies every topology safety bound.

func (HostedDisplay) Encode

func (display HostedDisplay) Encode() (string, error)

Encode returns the canonical, non-sensitive environment representation of the exact hosted logical topology.

func (HostedDisplay) Validate

func (display HostedDisplay) Validate() error

Validate rejects ambiguous, overlapping, or unbounded hosted topologies.

type HostedOutput

type HostedOutput struct {
	Width  int `json:"width"`
	Height int `json:"height"`
	X      int `json:"x"`
	Y      int `json:"y"`
}

HostedOutput is one logical monitor rectangle in compositor coordinates.

type HostedRuntimeOptions

type HostedRuntimeOptions struct {
	ManifestPath   string
	RepositoryRoot string
	StateRoot      string
	GuestFiles     string
	SSHPort        int
	Commit         string
	Cell           string
	Topology       string
	Output         io.Writer
	Commands       CommandExecutor
}

HostedRuntimeOptions identifies one credential-free integration test in a disposable desktop guest running inside a GitHub-hosted Linux runner.

type HostedStreamEvidence

type HostedStreamEvidence struct {
	NodeID         uint32
	ID             string
	MappingID      string
	PipeWireSerial uint64
	Monitor        bool
	HasPosition    bool
	HasSize        bool
	X              int
	Y              int
	Width          int
	Height         int
}

HostedStreamEvidence contains only the transient metadata required to prove one selected monitor stream. Callers must not log or persist the values.

type ImageBuildOptions

type ImageBuildOptions struct {
	ManifestPath   string
	RepositoryRoot string
	StateRoot      string
	GuestFiles     string
	SSHPort        int
	Output         io.Writer
	HTTPClient     *http.Client
	Commands       CommandExecutor
}

ImageBuildOptions defines one immutable portal-runner image build.

type ImageProbeOptions

type ImageProbeOptions struct {
	ManifestPath   string
	RepositoryRoot string
	StateRoot      string
	GuestFiles     string
	SSHPort        int
	Output         io.Writer
	Commands       CommandExecutor
}

ImageProbeOptions defines a private non-runner guest boot.

type Manifest

type Manifest struct {
	SchemaVersion string        `json:"schema_version"`
	Lane          string        `json:"lane"`
	Repository    string        `json:"repository"`
	Labels        []string      `json:"labels"`
	BaseImage     Artifact      `json:"base_image"`
	APTSnapshot   string        `json:"apt_snapshot"`
	Go            Artifact      `json:"go"`
	ActionsRunner Artifact      `json:"actions_runner"`
	VM            VMConfig      `json:"vm"`
	HostedDisplay HostedDisplay `json:"hosted_display"`
	Packages      []string      `json:"packages"`
	Network       NetworkConfig `json:"network"`
}

Manifest is the complete non-secret definition of one protected runner image and its runtime boundary.

func LoadManifest

func LoadManifest(path string) (Manifest, error)

LoadManifest decodes and validates a bounded manifest without accepting unknown fields or trailing JSON values.

func (Manifest) MaximumLifetime

func (manifest Manifest) MaximumLifetime() time.Duration

MaximumLifetime returns the validated guest lifetime.

func (Manifest) ProxyAddress

func (manifest Manifest) ProxyAddress() string

ProxyAddress returns the fixed guest-visible proxy endpoint.

func (Manifest) Validate

func (manifest Manifest) Validate() error

Validate verifies the immutable image, guest, and egress contract.

type NetworkConfig

type NetworkConfig struct {
	ProxyPort    int      `json:"proxy_port"`
	AllowedHosts []string `json:"allowed_hosts"`
}

NetworkConfig is the sole guest egress path during untrusted job execution.

func (NetworkConfig) HostAllowed

func (network NetworkConfig) HostAllowed(value string) bool

HostAllowed reports whether a CONNECT destination is covered by the exact or wildcard-suffix egress set. IP literals and port-bearing hosts are denied.

type ProtectedRunIdentity

type ProtectedRunIdentity struct {
	Repository string
	Commit     string
	RunID      string
	RunAttempt int
	Cell       string
}

ProtectedRunIdentity binds one disposable runner to one approved workflow attempt and exact repository commit.

type ProtectedRuntimeOptions

type ProtectedRuntimeOptions struct {
	ManifestPath   string
	RepositoryRoot string
	StateRoot      string
	GuestFiles     string
	SSHPort        int
	Identity       ProtectedRunIdentity
	OperatorInput  io.Reader
	Output         io.Writer
	Commands       CommandExecutor
	// contains filtered or unexported fields
}

ProtectedRuntimeOptions identifies one operator-approved disposable runner invocation. OperatorInput must provide the exact line READY only after the private GNOME console is visible and controlled by the operator.

type RedactingWriter

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

RedactingWriter removes configured non-empty secrets from a stream, including values split across adjacent Write calls.

func NewRedactingWriter

func NewRedactingWriter(destination io.Writer, secrets ...[]byte) (*RedactingWriter, error)

NewRedactingWriter creates a streaming redactor. Secret bytes are copied so callers may clear their source buffers immediately.

func (*RedactingWriter) Flush

func (writer *RedactingWriter) Flush() error

Flush emits the final buffered suffix exactly once.

func (*RedactingWriter) Write

func (writer *RedactingWriter) Write(data []byte) (int, error)

Write buffers only the suffix needed to recognize a secret split across calls. It reports the caller's full input length on successful emission.

type StateLock

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

StateLock prevents concurrent image mutation, probing, and protected runner execution within one private state root.

func AcquireStateLock

func AcquireStateLock(stateRoot string) (*StateLock, error)

AcquireStateLock obtains a non-blocking exclusive lock without following a replacement symlink.

func (*StateLock) Close

func (lock *StateLock) Close() error

Close releases the state lock.

type VMConfig

type VMConfig struct {
	CPUs            int    `json:"cpus"`
	MemoryMiB       int    `json:"memory_mib"`
	DiskGiB         int    `json:"disk_gib"`
	KernelRelease   string `json:"kernel_release"`
	MaximumLifetime string `json:"maximum_lifetime"`
}

VMConfig contains bounded disposable-guest resources.

Jump to

Keyboard shortcuts

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