composebundle

package
v0.207.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 17 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 composebundle carries a HyperFrames project between machines: Pack turns a project directory into a gzip-compressed tar, Extract unpacks one into a fresh directory, and Confine checks that the project only refers to files inside itself (ADR 0071).

A project is trusted code: HyperFrames' Chrome runs without a sandbox and executes the project's JavaScript. The fleet's project door (fleetnode compose-project) accepts one only from a holder of the fleet token, and these three functions are the rest of its defence:

  • Extract writes regular files and directories only (no symlink, hard link, device or FIFO), never outside the target (no absolute path, drive letter, UNC path, `..`, backslash, NUL or colon in a name), and within caps on the entries (directories included), the files, each file and the total, counted on the bytes actually written, not on the headers, with the whole decompressed stream bounded too.
  • Confine (confine.go) reads every reference the project's HTML, SVG and CSS make, and those of any file a composition attribute names whatever its extension (src, href, poster, srcset, data, xlink:href, data-composition-src/-file, CSS url(), @import and image-set strings, in a raw-text scan that does not depend on parsing HTML as the compiler's parser does), and refuses one that points outside the project: a root-relative, absolute, UNC or protocol-relative path, a relative path that climbs above the project root from its file or from the root (where HyperFrames' compiler resolves one that does not start with "../"), a file: or other non-web URL, or an http(s) URL to a host that is not public (loopback in any legacy numeric form, private, the shared 100.64/10 range the tailnet uses, link-local, a .ts.net, .local or .internal name, a name with no dot, or a non-ASCII name). HyperFrames' compiler copies an asset referenced outside the project into its output and reads a composition file by any path; those are how a project could read a file off the render node, and Confine is what closes them. JavaScript is not parsed: at render time the page can reach only the project and its compiled copy (HyperFrames' file server confines every path to them).

Index

Constants

View Source
const (
	DefaultMaxFiles     = 4096
	DefaultMaxFileBytes = 256 << 20
	DefaultMaxTotal     = 512 << 20
)

Variables

View Source
var ErrIO = errors.New("i/o")

ErrIO marks an Extract failure that is the target machine's own (a directory it could not create, a write that failed, a disk that filled), never the bundle's: a node answers it as its own failure, not as a refused bundle.

Functions

func Confine

func Confine(dir, entry string) error

Confine checks every reference the project's HTML, SVG and CSS make, and those of every file a composition attribute names whatever its extension, and returns one error listing each that points outside the project (file:line and why). entry is the composition the render starts from; it must be a regular file inside the project.

func Extract

func Extract(bundle []byte, dir string, lim Limits) error

Extract unpacks a bundle into dir, which must exist and be empty.

func Pack

func Pack(dir string, lim Limits) ([]byte, error)

Pack writes the project under dir as a gzip-compressed tar: regular files only, with forward-slash names relative to dir, in sorted order. Symlinks are refused rather than followed or skipped, so what is sent is exactly what the sender sees.

func PackHTML

func PackHTML(html string) ([]byte, error)

PackHTML is the bundle for a single-file composition: one index.html.

Types

type Limits

type Limits struct {
	MaxFiles     int   // files in the bundle
	MaxEntries   int   // entries of any kind, directories included (default: twice MaxFiles)
	MaxFileBytes int64 // one file, uncompressed
	MaxTotal     int64 // all files, uncompressed
}

Limits bound a bundle. The zero value means the defaults below.

Jump to

Keyboard shortcuts

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